Skip to content
Snippets Groups Projects
Commit 5e4b4de6 authored by Piotr Gawron's avatar Piotr Gawron
Browse files

PEP issues

parent 39ac1d9c
No related branches found
No related tags found
1 merge request!101Resolve "list of subjects should contain columns dependent on the study"
Pipeline #
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):
......
......@@ -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
......
......@@ -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()
......
......@@ -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)
......
......@@ -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
......
......@@ -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__)
......
......@@ -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):
......
......@@ -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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment