Skip to content
This repository has been archived by the owner on Mar 8, 2021. It is now read-only.

Django upgrade #263

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ version: 2
jobs:
build:
docker:
- image: circleci/python:2.7.15-jessie-browsers
- image: circleci/python:3.7.7-buster-browsers
steps:
- checkout
- run: mkdir test-reports
Expand Down
2 changes: 1 addition & 1 deletion api/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from pttrack import models
from workup import models as workupModels
from simple_history.models import HistoricalRecords
# from django.core.urlresolvers import reverse
# from django.urls import reverse


class UrlReverser(object):
Expand Down
10 changes: 5 additions & 5 deletions api/test.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from __future__ import unicode_literals
import datetime

from django.core.urlresolvers import reverse
from django.urls import reverse
from django.utils.timezone import now
from rest_framework.test import APITestCase
from rest_framework import status
Expand Down Expand Up @@ -45,7 +45,7 @@ def setUp(self):
state='BA',
zip_code='63108',
pcp_preferred_zip='63018',
date_of_birth=datetime.date(1990, 0o1, 0o1),
date_of_birth=datetime.date(1990, 1, 1),
patient_comfortable_with_english=False,
preferred_contact_method=models.ContactMethod.objects.first(),
)
Expand All @@ -61,7 +61,7 @@ def setUp(self):
state='BA',
zip_code='63108',
pcp_preferred_zip='63018',
date_of_birth=datetime.date(1990, 0o1, 0o1),
date_of_birth=datetime.date(1990, 1, 1),
patient_comfortable_with_english=False,
preferred_contact_method=models.ContactMethod.objects.first(),
)
Expand All @@ -77,7 +77,7 @@ def setUp(self):
state='BA',
zip_code='63108',
pcp_preferred_zip='63018',
date_of_birth=datetime.date(1990, 0o1, 0o1),
date_of_birth=datetime.date(1990, 1, 1),
patient_comfortable_with_english=False,
preferred_contact_method=models.ContactMethod.objects.first(),
)
Expand Down Expand Up @@ -326,7 +326,7 @@ def test_api_list_patients_with_pending_action_item_and_referral(self):
FollowupRequest.objects.filter(
patient=response.data[1]['pk']).first().due_date)

# Add one more AI whose due date is even farther away than the
# Add one more AI whose due date is even farther away than the
# referral followup request
pt5_ai = models.ActionItem.objects.create(
due_date=now().date() + datetime.timedelta(days=1),
Expand Down
6 changes: 2 additions & 4 deletions api/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,9 @@
# pylint: disable=I0011

unwrapped_urlpatterns = [ # pylint: disable=invalid-name
url(r'^pt_list/$',
views.PtList.as_view(),
name='pt_list_api'),
url(r'pt_list/', views.PtList.as_view(), name='pt_list_api'),
]

wrap_config = {}
urlpatterns = [wrap_url(url, **wrap_config) for url in unwrapped_urlpatterns]
urlpatterns = [wrap_url(u, **wrap_config) for u in unwrapped_urlpatterns]
urlpatterns = format_suffix_patterns(urlpatterns)
6 changes: 3 additions & 3 deletions appointment/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

from crispy_forms.helper import FormHelper
from crispy_forms.layout import Submit
from bootstrap3_datetime.widgets import DateTimePicker

from .models import Appointment

Expand All @@ -17,8 +16,9 @@ class Meta(object):
'patient']

widgets = {
'clindate': DateTimePicker(options={"format": "YYYY-MM-DD"}),
'clintime': TimeInput(format='%H:%M')}
# 'clindate': DateTimePicker(options={"format": "YYYY-MM-DD"}),
'clintime': TimeInput(format='%H:%M')
}

def __init__(self, *args, **kwargs):
super(AppointmentForm, self).__init__(*args, **kwargs)
Expand Down
59 changes: 30 additions & 29 deletions appointment/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -1,52 +1,33 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.9 on 2018-08-17 03:20
from __future__ import unicode_literals
# Generated by Django 2.2.12 on 2020-05-05 15:32

import datetime
import appointment.models
from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion
from django.utils.timezone import utc
import simple_history.models


class Migration(migrations.Migration):

initial = True

dependencies = [
('pttrack', '0005_simplehistory_add_change_reason'),
('pttrack', '0001_initial'),
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
]

operations = [
migrations.CreateModel(
name='Appointment',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('written_datetime', models.DateTimeField(auto_now_add=True)),
('last_modified', models.DateTimeField(auto_now=True)),
('clindate', models.DateField(verbose_name=b'Appointment Date')),
('clintime', models.TimeField(default=datetime.datetime(2018, 8, 17, 9, 0, tzinfo=utc), verbose_name=b'Time of Appointment')),
('appointment_type', models.CharField(choices=[(b'PSYCH_NIGHT', b'Psych Night'), (b'ACUTE_FOLLOWUP', b'Acute Followup'), (b'CHRONIC_CARE', b'Chronic Care')], default=b'CHRONIC_CARE', max_length=15, verbose_name=b'Appointment Type')),
('comment', models.TextField(help_text=b'What should happen at this appointment?')),
('author', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='pttrack.Provider')),
('author_type', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='pttrack.ProviderType')),
('patient', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='pttrack.Patient')),
],
options={
'abstract': False,
},
),
migrations.CreateModel(
name='HistoricalAppointment',
fields=[
('id', models.IntegerField(auto_created=True, blank=True, db_index=True, verbose_name='ID')),
('written_datetime', models.DateTimeField(blank=True, editable=False)),
('last_modified', models.DateTimeField(blank=True, editable=False)),
('clindate', models.DateField(verbose_name=b'Appointment Date')),
('clintime', models.TimeField(default=datetime.datetime(2018, 8, 17, 9, 0, tzinfo=utc), verbose_name=b'Time of Appointment')),
('appointment_type', models.CharField(choices=[(b'PSYCH_NIGHT', b'Psych Night'), (b'ACUTE_FOLLOWUP', b'Acute Followup'), (b'CHRONIC_CARE', b'Chronic Care')], default=b'CHRONIC_CARE', max_length=15, verbose_name=b'Appointment Type')),
('comment', models.TextField(help_text=b'What should happen at this appointment?')),
('clindate', models.DateField(verbose_name='Appointment Date')),
('clintime', models.TimeField(default=appointment.models.generate_default_appointment_time, verbose_name='Time of Appointment')),
('appointment_type', models.CharField(choices=[('PSYCH_NIGHT', 'Psych Night'), ('ACUTE_FOLLOWUP', 'Acute Followup'), ('CHRONIC_CARE', 'Chronic Care'), ('VACCINE', 'Vaccine Followup')], default='CHRONIC_CARE', max_length=15, verbose_name='Appointment Type')),
('comment', models.TextField(help_text='What should happen at this appointment?')),
('pt_showed', models.NullBooleanField(help_text='Did the patient come to this appointment?', verbose_name='Patient Showed')),
('history_id', models.AutoField(primary_key=True, serialize=False)),
('history_date', models.DateTimeField()),
('history_change_reason', models.CharField(max_length=100, null=True)),
Expand All @@ -57,9 +38,29 @@ class Migration(migrations.Migration):
('patient', models.ForeignKey(blank=True, db_constraint=False, null=True, on_delete=django.db.models.deletion.DO_NOTHING, related_name='+', to='pttrack.Patient')),
],
options={
'verbose_name': 'historical appointment',
'ordering': ('-history_date', '-history_id'),
'get_latest_by': 'history_date',
'verbose_name': 'historical appointment',
},
bases=(simple_history.models.HistoricalChanges, models.Model),
),
migrations.CreateModel(
name='Appointment',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('written_datetime', models.DateTimeField(auto_now_add=True)),
('last_modified', models.DateTimeField(auto_now=True)),
('clindate', models.DateField(verbose_name='Appointment Date')),
('clintime', models.TimeField(default=appointment.models.generate_default_appointment_time, verbose_name='Time of Appointment')),
('appointment_type', models.CharField(choices=[('PSYCH_NIGHT', 'Psych Night'), ('ACUTE_FOLLOWUP', 'Acute Followup'), ('CHRONIC_CARE', 'Chronic Care'), ('VACCINE', 'Vaccine Followup')], default='CHRONIC_CARE', max_length=15, verbose_name='Appointment Type')),
('comment', models.TextField(help_text='What should happen at this appointment?')),
('pt_showed', models.NullBooleanField(help_text='Did the patient come to this appointment?', verbose_name='Patient Showed')),
('author', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='pttrack.Provider')),
('author_type', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='pttrack.ProviderType')),
('patient', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='pttrack.Patient')),
],
options={
'ordering': ['-clindate', '-clintime'],
},
),
]
37 changes: 0 additions & 37 deletions appointment/migrations/0002_vaccineappointment_20181031_1852.py

This file was deleted.

This file was deleted.

This file was deleted.

2 changes: 1 addition & 1 deletion appointment/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

from django.test import TestCase
from django.utils.timezone import now
from django.core.urlresolvers import reverse
from django.urls import reverse
from pttrack.models import Provider, ProviderType, Patient
from pttrack.test_views import log_in_provider, build_provider
from .test_forms import apt_dict
Expand Down
32 changes: 16 additions & 16 deletions appointment/urls.py
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
from __future__ import unicode_literals
from django.conf.urls import url
from django.urls import path
from pttrack.urls import wrap_url

from . import views

unwrapped_urlconf = [ # pylint: disable=invalid-name
url(r'^new$',
views.AppointmentCreate.as_view(),
name='appointment-new'),
url(r'^(?P<pk>[0-9]+)/update$',
views.AppointmentUpdate.as_view(),
name='appointment-update'),
url(r'^list$',
views.list_view,
name='appointment-list'),
url(r'^(?P<pk>[0-9]+)/noshow$',
views.mark_no_show,
name='appointment-mark-no-show'),
url(r'^(?P<pk>[0-9]+)/arrived$',
views.mark_arrived,
name='appointment-mark-arrived'),
path(r'new',
views.AppointmentCreate.as_view(),
name='appointment-new'),
path(r'<int:pk>/update',
views.AppointmentUpdate.as_view(),
name='appointment-update'),
path(r'list',
views.list_view,
name='appointment-list'),
path(r'<int:pk>/noshow',
views.mark_no_show,
name='appointment-mark-no-show'),
path(r'<int:pk>/arrived',
views.mark_arrived,
name='appointment-mark-arrived'),
]

wrap_config = {}
Expand Down
2 changes: 1 addition & 1 deletion appointment/views.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from __future__ import unicode_literals
import collections

from django.core.urlresolvers import reverse
from django.urls import reverse
from django.shortcuts import render, get_object_or_404, HttpResponseRedirect
from django.utils.timezone import now

Expand Down
10 changes: 4 additions & 6 deletions audit/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.9.1 on 2018-11-18 01:34
from __future__ import unicode_literals
# Generated by Django 2.2.12 on 2020-05-05 15:32

from django.conf import settings
from django.db import migrations, models
Expand All @@ -12,7 +10,7 @@ class Migration(migrations.Migration):
initial = True

dependencies = [
('pttrack', '0006_referral_additional_fields_20180826'),
('pttrack', '0001_initial'),
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
]

Expand All @@ -27,8 +25,8 @@ class Migration(migrations.Migration):
('referrer', models.URLField(blank=True, max_length=256, null=True)),
('status_code', models.PositiveSmallIntegerField()),
('timestamp', models.DateTimeField(auto_now_add=True)),
('role', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='pttrack.ProviderType')),
('user', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
('role', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.DO_NOTHING, to='pttrack.ProviderType')),
('user', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.DO_NOTHING, to=settings.AUTH_USER_MODEL)),
],
),
]
12 changes: 9 additions & 3 deletions audit/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,16 @@ class PageviewRecord(models.Model):
HTTP_METHODS = ['GET', 'POST', 'HEAD', 'PUT', 'PATCH', 'DELETE',
'CONNECT', 'OPTIONS', 'TRACE']

user = models.ForeignKey(User, blank=True, null=True)
user = models.ForeignKey(
User,
blank=True, null=True,
on_delete=models.DO_NOTHING
)
user_ip = models.GenericIPAddressField()
role = models.ForeignKey(core_models.ProviderType,
blank=True, null=True)
role = models.ForeignKey(
core_models.ProviderType,
on_delete=models.DO_NOTHING,
blank=True, null=True)

method = models.CharField(
max_length=max(len(v) for v in HTTP_METHODS),
Expand Down
Loading