diff --git a/smash/web/admin.py b/smash/web/admin.py index 303aa56d09cf241230750c164e8abb6424dedea9..91037bb878f4658e2f3142ee72a6b1878ddff938 100644 --- a/smash/web/admin.py +++ b/smash/web/admin.py @@ -1,7 +1,7 @@ from django.contrib import admin -from models import StudySubject, Item, Room, AppointmentType, Language, Location, Worker, FlyingTeam, Availability, Holiday, \ - Visit, Appointment +from models import StudySubject, Item, Room, AppointmentType, Language, Location, Worker, FlyingTeam, Availability, \ + Holiday, Visit, Appointment class LanguageAdmin(admin.ModelAdmin): diff --git a/smash/web/api_views/appointment.py b/smash/web/api_views/appointment.py index 14a96d62d4423f0343255cc896301db479169dc1..331c331c50b6cecc4f17070235448222c07d7dda 100644 --- a/smash/web/api_views/appointment.py +++ b/smash/web/api_views/appointment.py @@ -91,7 +91,9 @@ def serialize_appointment(appointment): subject_string = study_subject.subject.last_name + " " + study_subject.subject.first_name nd_number = study_subject.nd_number screening_number = study_subject.screening_number - phone_numbers = ", ".join(filter(None, [study_subject.subject.phone_number, study_subject.subject.phone_number_2, study_subject.subject.phone_number_3])) + phone_numbers = ", ".join(filter(None, + [study_subject.subject.phone_number, study_subject.subject.phone_number_2, + study_subject.subject.phone_number_3])) appointment_types = ", ".join([unicode(type) for type in appointment.appointment_types.all()]) else: title = appointment.comment diff --git a/smash/web/api_views/daily_planning.py b/smash/web/api_views/daily_planning.py index bd739c5c5569aabffc3ed9b05c9164e3cd9d5c07..cca2057d53c58f1e41114d90968e1026ac759a51 100644 --- a/smash/web/api_views/daily_planning.py +++ b/smash/web/api_views/daily_planning.py @@ -73,15 +73,13 @@ def remove_holidays(availability, worker, date): holidays_ending_today = Holiday.objects.filter(person=worker, datetime_end__lte=today_end, datetime_end__gte=today_start) result = [] - timestamps = [] - timestamps.append({ + timestamps = [{ "time": availability.available_from, "type": "start" - }) - timestamps.append({ + }, { "time": availability.available_till, "type": "stop" - }) + }] direction = -holidays_starting_before.count() diff --git a/smash/web/forms/forms.py b/smash/web/forms/forms.py index 76b196785782e284bc84f33cb71cf26669600908..b33eb52d2f19cde653eb450aa2732a97e241aba6 100644 --- a/smash/web/forms/forms.py +++ b/smash/web/forms/forms.py @@ -349,7 +349,7 @@ class AvailabilityEditForm(ModelForm): worker = Worker.objects.get(id=self.cleaned_data["person"].id) availabilities = worker.availability_set.all() for availability in availabilities: - if availability.id <> self.availability_id: + if availability.id != self.availability_id: validate_availability_conflict(self, self.cleaned_data, availability) @@ -358,9 +358,9 @@ def validate_availability_conflict(self, cleaned_data, availability): end_hour = self.cleaned_data.get("available_till", None) if availability.day_number == self.cleaned_data.get("day_number", None) and \ ((start_hour <= availability.available_from < end_hour) or - (start_hour < availability.available_till <= end_hour) or - (availability.available_from <= start_hour < availability.available_till) or - (availability.available_from < end_hour <= availability.available_till)): + (start_hour < availability.available_till <= end_hour) or + (availability.available_from <= start_hour < availability.available_till) or + (availability.available_from < end_hour <= availability.available_till)): error = "User has defined availability for this day that overlaps: " + availability.available_from.strftime( DATE_FORMAT_TIME) + ", " + availability.available_till.strftime(DATE_FORMAT_TIME) self.add_error('day_number', error) diff --git a/smash/web/forms/study_subject_forms.py b/smash/web/forms/study_subject_forms.py index 22eba79ce66557e8c53ac5cff063e28fcf3456c2..a8743d146d029b0a26d25c66c1c472ed30fd6974 100644 --- a/smash/web/forms/study_subject_forms.py +++ b/smash/web/forms/study_subject_forms.py @@ -131,7 +131,7 @@ def get_study_from_args(kwargs): def prepare_field(fields, visible_columns, field_name, required=False): - if not getattr(visible_columns, field_name) and field_name in fields: + if not getattr(visible_columns, field_name) and field_name in fields: del fields[field_name] elif required: fields[field_name].required = True diff --git a/smash/web/redcap_connector.py b/smash/web/redcap_connector.py index 8a2828583aee2e92ff795c73ae3182fc505d5e9b..ff09df743be6cd71ce5826ed375330df967e4df6 100644 --- a/smash/web/redcap_connector.py +++ b/smash/web/redcap_connector.py @@ -21,14 +21,18 @@ RED_CAP_LANGUAGE_2_FIELD = 'dm_language_2' RED_CAP_LANGUAGE_1_FIELD = 'dm_language_1' +# noinspection SpellCheckingInspection RED_CAP_MPOWER_ID_FIELD = 'dm_mpowerid' RED_CAP_DEAD_FIELD = 'dm_death' +# noinspection SpellCheckingInspection RED_CAP_SEX_FIELD = 'cdisc_dm_sex' +# noinspection SpellCheckingInspection RED_CAP_DATE_BORN_FIELD = 'cdisc_dm_brthdtc' +# noinspection SpellCheckingInspection RED_CAP_ND_NUMBER_FIELD = 'cdisc_dm_usubjd' logger = logging.getLogger(__name__) diff --git a/smash/web/tests/api_views/test_daily_planning.py b/smash/web/tests/api_views/test_daily_planning.py index abaea166149c9dbf02967115040209f5fcaa9cb8..0d48c8d15ed527d6704f168a77cdd0b47f94dfad 100644 --- a/smash/web/tests/api_views/test_daily_planning.py +++ b/smash/web/tests/api_views/test_daily_planning.py @@ -10,8 +10,8 @@ from django.urls import reverse from web.api_views.daily_planning import get_workers_for_daily_planning, get_generic_appointment_events from web.models import Worker, Availability, Holiday, AppointmentTypeLink from web.models.constants import TUESDAY_AS_DAY_OF_WEEK -from web.tests.functions import create_worker, create_study_subject, create_appointment, create_flying_team, create_visit, \ - create_appointment_type, get_test_location +from web.tests.functions import create_worker, create_study_subject, create_appointment, create_flying_team, \ + create_visit, create_appointment_type, get_test_location class TestApi(TestCase): diff --git a/smash/web/tests/functions.py b/smash/web/tests/functions.py index 29dc7123e64fbb76cd8d6d4dd454be27ba029b53..6994935f76045a59b011f429d58b408386c7152d 100644 --- a/smash/web/tests/functions.py +++ b/smash/web/tests/functions.py @@ -3,8 +3,8 @@ import os from django.contrib.auth.models import User -from web.models import Location, AppointmentType, StudySubject, Worker, Visit, Appointment, ConfigurationItem, Language, \ - ContactAttempt, FlyingTeam, Availability, Subject, Study, StudyColumns +from web.models import Location, AppointmentType, StudySubject, Worker, Visit, Appointment, ConfigurationItem, \ + Language, ContactAttempt, FlyingTeam, Availability, Subject, Study, StudyColumns from web.models.constants import REDCAP_TOKEN_CONFIGURATION_TYPE, REDCAP_BASE_URL_CONFIGURATION_TYPE, \ SEX_CHOICES_MALE, SUBJECT_TYPE_CHOICES_CONTROL, CONTACT_TYPES_PHONE, \ MONDAY_AS_DAY_OF_WEEK, COUNTRY_AFGHANISTAN_ID