diff --git a/smash/web/api_views/appointment.py b/smash/web/api_views/appointment.py index 28a521b378a99371025414b1cdbdba1f56de573c..8945d166e824ceb7e8bf40396273b77194ac04c3 100644 --- a/smash/web/api_views/appointment.py +++ b/smash/web/api_views/appointment.py @@ -94,7 +94,6 @@ def serialize_appointment(appointment): time = "" if appointment.datetime_when is not None: time = appointment.datetime_when.strftime('%Y-%m-%d %H:%M') - # time = appointment.datetime_when.strftime('%Y-%m-%d %H:%M:%S.%f %Z%z') until = "" if appointment.datetime_when is not None: until = appointment.datetime_until().strftime('%Y-%m-%d %H:%M') diff --git a/smash/web/api_views/subject.py b/smash/web/api_views/subject.py index abdd81b424eeae69231dd0b0b2a45bf3236e440b..8f0161dd65b4aba72e97662896659431a4e0029a 100644 --- a/smash/web/api_views/subject.py +++ b/smash/web/api_views/subject.py @@ -10,25 +10,25 @@ from web.views.subject import SUBJECT_LIST_GENERIC, SUBJECT_LIST_NO_VISIT, SUBJE @login_required def cities(request): - X = Subject.objects.filter(city__isnull=False).values_list('city').distinct() + subjects = Subject.objects.filter(city__isnull=False).values_list('city').distinct() return JsonResponse({ - "cities": [x[0] for x in X] + "cities": [x[0] for x in subjects] }) @login_required def countries(request): - X = Subject.objects.filter(country__isnull=False).values_list('country').distinct() + subjects = Subject.objects.filter(country__isnull=False).values_list('country').distinct() return JsonResponse({ - "countries": [x[0] for x in X] + "countries": [x[0] for x in subjects] }) @login_required def referrals(request): - X = Subject.objects.filter(referral__isnull=False).values_list('referral').distinct() + subjects = Subject.objects.filter(referral__isnull=False).values_list('referral').distinct() return JsonResponse({ - "referrals": [x[0] for x in X] + "referrals": [x[0] for x in subjects] }) diff --git a/smash/web/api_views/worker.py b/smash/web/api_views/worker.py index 2b4aeaf1f31f7b83e0af569d4951b00fcc3f8be3..803435cb6588a5e4d1baff598a9f7d75493d5093 100644 --- a/smash/web/api_views/worker.py +++ b/smash/web/api_views/worker.py @@ -7,17 +7,17 @@ from ..views.notifications import get_filter_locations @login_required def specializations(request): - X = Worker.objects.filter(specialization__isnull=False).values_list('specialization').distinct() + workers = Worker.objects.filter(specialization__isnull=False).values_list('specialization').distinct() return JsonResponse({ - "specializations": [x[0] for x in X] + "specializations": [x[0] for x in workers] }) @login_required def units(request): - X = Worker.objects.filter(unit__isnull=False).values_list('unit').distinct() + workers = Worker.objects.filter(unit__isnull=False).values_list('unit').distinct() return JsonResponse({ - "units": [x[0] for x in X] + "units": [x[0] for x in workers] }) diff --git a/smash/web/models/availability.py b/smash/web/models/availability.py index a375ce11e93a03fb5b7616a99afb133219cff033..46a98ac1fba3ea81c8795214769eb940dd8bc15a 100644 --- a/smash/web/models/availability.py +++ b/smash/web/models/availability.py @@ -1,7 +1,5 @@ # coding=utf-8 -import datetime - from django.db import models from constants import WEEKDAY_CHOICES diff --git a/smash/web/models/mail_template.py b/smash/web/models/mail_template.py index 62d4491d1e22e0e1d0f6e549a13d245614ee8213..a5dabfbcfc323ca18a2caf8d39c36e45a83d8991 100644 --- a/smash/web/models/mail_template.py +++ b/smash/web/models/mail_template.py @@ -6,8 +6,8 @@ from contextlib import contextmanager from django.db import models -from .constants import MAIL_TEMPLATE_CONTEXT_CHOICES, MAIL_TEMPLATE_CONTEXT_APPOINTMENT, MAIL_TEMPLATE_CONTEXT_SUBJECT, \ - MAIL_TEMPLATE_CONTEXT_VISIT +from .constants import MAIL_TEMPLATE_CONTEXT_CHOICES, MAIL_TEMPLATE_CONTEXT_APPOINTMENT, \ + MAIL_TEMPLATE_CONTEXT_SUBJECT, MAIL_TEMPLATE_CONTEXT_VISIT from ..docx_helper import process_file from ..models import Appointment, Visit, Subject, Worker diff --git a/smash/web/templates/configuration/index.html b/smash/web/templates/configuration/index.html index 0b89158255f34e2027b3a624b14db6fb052333f6..7330cbc831b41c140a70a67eeeeb3aa1354305fc 100644 --- a/smash/web/templates/configuration/index.html +++ b/smash/web/templates/configuration/index.html @@ -64,7 +64,7 @@ success: function (response) { var message; var classString; - if (response.status == "ok") { + if (response.status === "ok") { message = "Element modified successfully"; classString = "alert alert-success" } else { diff --git a/smash/web/templates/subjects/add.html b/smash/web/templates/subjects/add.html index b3b490c6ce106a9797280c03ec61cc73521ef93f..0d22f5b169dc21f552d35d91a80075be3d141187 100644 --- a/smash/web/templates/subjects/add.html +++ b/smash/web/templates/subjects/add.html @@ -79,7 +79,7 @@ <script src="{% static 'AdminLTE/plugins/awesomplete/awesomplete.min.js' %}"></script> <script> $(document).ready(function () { - // If ever to debug and thinking why it doesn't work => look if theres 'null' in data from API + // If ever to debug and thinking why it doesn't work => look if there is 'null' in data from API $.get("{% url 'web.api.cities' %}", function (data) { new Awesomplete(document.querySelector("#id_city")).list = data.cities; }); diff --git a/smash/web/templates/subjects/edit.html b/smash/web/templates/subjects/edit.html index e2cb7121d332a7032a8ce1d0f19cb6e5e4ca079b..f1dbc493d27a2022d4981fbc3ae747f01b02f04a 100644 --- a/smash/web/templates/subjects/edit.html +++ b/smash/web/templates/subjects/edit.html @@ -158,7 +158,7 @@ <div class="modal-header"> <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button> - <h4 class="modal-title">Are you sure that you want to perfom this operation?</h4> + <h4 class="modal-title">Are you sure that you want to perform this operation?</h4> </div> <div class="modal-body"> <p>Screening number shouldn't change.</p> diff --git a/smash/web/tests/functions.py b/smash/web/tests/functions.py index 24cd16c2bff10bebb7076afc7b14c00c05354fd7..a492a1e69c4b9ae8f0493165f3c6132e031e3bd6 100644 --- a/smash/web/tests/functions.py +++ b/smash/web/tests/functions.py @@ -35,14 +35,14 @@ def create_appointment_type(): ) -def create_subject(id=1): +def create_subject(subject_id=1): return Subject.objects.create( first_name="Piotr", last_name="Gawron", default_location=get_test_location(), sex=SEX_CHOICES_MALE, type=SUBJECT_TYPE_CHOICES_CONTROL, - screening_number="piotr's number" + str(id), + screening_number="piotr's number" + str(subject_id), country="france" ) diff --git a/smash/web/tests/test_AvailabilityAddForm.py b/smash/web/tests/test_AvailabilityAddForm.py index 2f6b9b3568efaa9fffb8e2f910b3b9fd649f8a8b..85987100244f414824869bec471a1e3d4aca0143 100644 --- a/smash/web/tests/test_AvailabilityAddForm.py +++ b/smash/web/tests/test_AvailabilityAddForm.py @@ -9,7 +9,6 @@ from web.models import Worker class AvailabilityAddFormTests(TestCase): def setUp(self): - location = get_test_location() self.user = create_user() worker = Worker.get_by_user(self.user) diff --git a/smash/web/tests/test_AvailabilityEditForm.py b/smash/web/tests/test_AvailabilityEditForm.py index 3f3a3c854bb60d8faa4072d24eaef7450660f6ec..9d2d3bd1106c50f5626e3ebaeca788ba94ce6232 100644 --- a/smash/web/tests/test_AvailabilityEditForm.py +++ b/smash/web/tests/test_AvailabilityEditForm.py @@ -9,7 +9,6 @@ from web.models import Worker class AvailabilityEditFormTests(TestCase): def setUp(self): - location = get_test_location() self.user = create_user() worker = Worker.get_by_user(self.user) diff --git a/smash/web/tests/test_api_appointment_type.py b/smash/web/tests/test_api_appointment_type.py index 24b06c1feda1ac4e0f6b20237fcd38147f00b529..ea1610b7a58a5a6b3472513210a7c175631ab959 100644 --- a/smash/web/tests/test_api_appointment_type.py +++ b/smash/web/tests/test_api_appointment_type.py @@ -33,8 +33,8 @@ class TestApi(TestCase): appointment_types = json.loads(response.content)['appointment_types'] found = False - for type in appointment_types: - if type['type'] == type_name: + for appointment_type in appointment_types: + if appointment_type['type'] == type_name: found = True self.assertTrue(found) diff --git a/smash/web/tests/test_api_configuration_item.py b/smash/web/tests/test_api_configuration_item.py index 78ef0d1674706159f8faca41fd658ba441a65ef6..102e3a5b6d2451e3d9238400affa0034171526a7 100644 --- a/smash/web/tests/test_api_configuration_item.py +++ b/smash/web/tests/test_api_configuration_item.py @@ -6,9 +6,7 @@ from django.urls import reverse from web.models import ConfigurationItem from web.tests.functions import create_configuration_item from . import LoggedInTestCase -from web.models.constants import CANCELLED_APPOINTMENT_COLOR_CONFIGURATION_TYPE, \ - NO_SHOW_APPOINTMENT_COLOR_CONFIGURATION_TYPE, KIT_EMAIL_HOUR_CONFIGURATION_TYPE, \ - KIT_EMAIL_DAY_OF_WEEK_CONFIGURATION_TYPE +from web.models.constants import CANCELLED_APPOINTMENT_COLOR_CONFIGURATION_TYPE class TestConfigurationItemApi(LoggedInTestCase): diff --git a/smash/web/tests/test_api_subject.py b/smash/web/tests/test_api_subject.py index 9a947b410031fe06d9fd96e3ed113f7b8647d8f2..8fbce03c8fd979bb726f96d305fd8e4fd4f57f9e 100644 --- a/smash/web/tests/test_api_subject.py +++ b/smash/web/tests/test_api_subject.py @@ -280,12 +280,12 @@ class TestApi(TestCase): def test_subjects_filter_unknown(self): subject = self.subject - self.check_subject_filtered([["some_unknown", "zxczxc"]], [subject]) + self.check_subject_filtered([["some_unknown", "unknown data"]], [subject]) self.check_subject_filtered([["", ""]], [subject]) def test_serialize_subject(self): subject = self.subject subject.dead = True - subject_json = serialize_subject(subject); - self.assertEqual("YES", subject_json["dead"]); + subject_json = serialize_subject(subject) + self.assertEqual("YES", subject_json["dead"]) diff --git a/smash/web/tests/test_api_worker.py b/smash/web/tests/test_api_worker.py index f3f353d3b4fbd2a45dd4703545dc8269b5f2c617..1b93de263fb7a6c3360c2a7d33b7d5e7e9333e5e 100644 --- a/smash/web/tests/test_api_worker.py +++ b/smash/web/tests/test_api_worker.py @@ -6,7 +6,7 @@ from django.test import Client from django.test import TestCase from django.urls import reverse -from web.tests.functions import create_subject, create_worker +from web.tests.functions import create_worker class TestApi(TestCase): diff --git a/smash/web/tests/test_process_file.py b/smash/web/tests/test_process_file.py index f46bcac4266a002dcd993cf59d73cb0fb78c82c8..d7ef2bb4270ce3e6f845d01b0bc916f2b17be670 100644 --- a/smash/web/tests/test_process_file.py +++ b/smash/web/tests/test_process_file.py @@ -21,8 +21,8 @@ class TestDocxProcessor(TestCase): changes = { "##SIR##": "Mr", "##NAME##": "Jan", - "##SURNAME##": "Weglarz", - "##ADDRESS1##": "Piotrowo 23", + "##SURNAME##": "Gawron", + "##ADDRESS1##": "Rock'n'roll 23", "##ADDRESS2##": "61-234, Poznan", "##COUNTRY##": "POLAND", "##CONTENT##": "1", diff --git a/smash/web/tests/test_view_appointments.py b/smash/web/tests/test_view_appointments.py index b29533c218f459fe6362280e8bfa643fa9be41a3..e32a1b54a167a1aeaf9eb19da20b4a8484d91b88 100644 --- a/smash/web/tests/test_view_appointments.py +++ b/smash/web/tests/test_view_appointments.py @@ -94,4 +94,4 @@ class AppointmentsViewTests(LoggedInTestCase): self.assertEqual(response.status_code, 302) updated_subject = Subject.objects.get(id=subject.id) - self.assertTrue(updated_subject.information_sent) \ No newline at end of file + self.assertTrue(updated_subject.information_sent) diff --git a/smash/web/tests/test_view_configuration.py b/smash/web/tests/test_view_configuration.py index 4408228562166b9b96553fb6e293d43a965d5e13..4b9bbccdc61c23d13edd9b6e2906314a5c995573 100644 --- a/smash/web/tests/test_view_configuration.py +++ b/smash/web/tests/test_view_configuration.py @@ -2,10 +2,6 @@ import datetime from django.urls import reverse -from functions import create_subject, create_visit, create_appointment, create_appointment_type -from web.forms import VisitDetailForm, VisitAddForm -from web.models import Visit -from web.views.notifications import get_today_midnight_date from . import LoggedInTestCase diff --git a/smash/web/tests/test_view_contact_attempt.py b/smash/web/tests/test_view_contact_attempt.py index 872bfa8fd631f411c53b60c65c26d2982c1b6480..760119e7466f20d39f8ef815805384927fffa229 100644 --- a/smash/web/tests/test_view_contact_attempt.py +++ b/smash/web/tests/test_view_contact_attempt.py @@ -26,7 +26,7 @@ class ContactAttemptViewTests(LoggedInWithWorkerTestCase): form_data = {'datetime_when': now, 'worker': self.worker.id, 'type': contact_type, 'comment': comment} response = self.client.post( reverse('web.views.contact_add', kwargs={'subject_id': subject.id}), data=form_data) - # check correct redirection to suject edit page + # check correct redirection to subject edit page self.assertRedirects(response, reverse('web.views.subject_edit', kwargs={'id': subject.id})) contact_attempts = ContactAttempt.objects.filter(subject=subject).all() self.assertEqual(1, len(contact_attempts)) diff --git a/smash/web/tests/test_view_functions.py b/smash/web/tests/test_view_functions.py index db206b6b31194cdfbe5a955e6973d872a0edf87f..7df3e0a0a13ae7b9fcb0d1dfd87c09cac5060f89 100644 --- a/smash/web/tests/test_view_functions.py +++ b/smash/web/tests/test_view_functions.py @@ -6,7 +6,7 @@ from web.views.notifications import get_filter_locations class ViewFunctionsTests(TestCase): def setUp(self): - create_location("tescik") + create_location("testLocation") return def test_locations_for_user(self): diff --git a/smash/web/tests/test_view_kit_request.py b/smash/web/tests/test_view_kit_request.py index 4a061d4a9c4d5ec17ae6eff7bba66656766fe59a..00967ccd05c7072169f177071669ee3cf59ae772 100644 --- a/smash/web/tests/test_view_kit_request.py +++ b/smash/web/tests/test_view_kit_request.py @@ -74,7 +74,7 @@ class ViewFunctionsTests(LoggedInTestCase): appointment_type.required_equipment.add(item) appointment_type.save() - visit = create_visit(); + visit = create_visit() appointment1 = create_appointment(visit) appointment1.datetime_when = get_today_midnight_date() + datetime.timedelta(days=3) diff --git a/smash/web/tests/test_view_notifications.py b/smash/web/tests/test_view_notifications.py index 1467a1699f5eb433ab9ca58fa7f7411b6644596e..9c79dd8cbdac2dbdbfbd6e8608d659e65ddbfcd8 100644 --- a/smash/web/tests/test_view_notifications.py +++ b/smash/web/tests/test_view_notifications.py @@ -428,7 +428,7 @@ class NotificationViewTests(LoggedInTestCase): def test_get_filter_locations_for_invalid_user_2(self): try: - locations = get_filter_locations("invalid class") + get_filter_locations("invalid class") self.fail("Exception expected") except TypeError: pass diff --git a/smash/web/tests/test_view_subjects.py b/smash/web/tests/test_view_subjects.py index 92444e1b6f7a388518429a2438ba558008b4419d..2983777c9b445e22b9bcaf90c4ecb6eada6c54da 100644 --- a/smash/web/tests/test_view_subjects.py +++ b/smash/web/tests/test_view_subjects.py @@ -82,7 +82,8 @@ class SubjectsViewTests(TestCase): subject = Subject.objects.all()[0] self.assertEqual("L-001", subject.screening_number, - "prefix should start by L as default location prefix is not defined and subject type is control") + "prefix should start by L" + + " as default location prefix is not defined and subject type is control") def test_subjects_add_patient(self): @@ -105,7 +106,8 @@ class SubjectsViewTests(TestCase): subject = Subject.objects.all()[0] self.assertEqual("P-001", subject.screening_number, - "prefix should start by P as default location prefix is not defined and subject type is patient") + "prefix should start by P" + + " as default location prefix is not defined and subject type is patient") def test_subjects_add_with_prefixed_location(self): diff --git a/smash/web/views/doctor.py b/smash/web/views/doctor.py index dca2692f13606e93c2368e7390847b671616af00..12e4cace3cccecca92b53f2ac13ce6d468eed054 100644 --- a/smash/web/views/doctor.py +++ b/smash/web/views/doctor.py @@ -37,8 +37,8 @@ def doctor_edit(request, doctor_id): return redirect('web.views.doctors') else: form = WorkerEditForm(instance=the_doctor) - availabilities = Availability.objects.filter(person=doctor_id).order_by('day_number', 'available_from'); - holidays = Holiday.objects.filter(person=doctor_id).order_by('-datetime_start'); + availabilities = Availability.objects.filter(person=doctor_id).order_by('day_number', 'available_from') + holidays = Holiday.objects.filter(person=doctor_id).order_by('-datetime_start') return wrap_response(request, 'doctors/edit.html', { 'form': form, diff --git a/smash/web/views/export.py b/smash/web/views/export.py index d76a0465623321b07215b6cdd2345591bb16a988..6f98432d6a056091e83a53173d503d0692290f66 100644 --- a/smash/web/views/export.py +++ b/smash/web/views/export.py @@ -49,7 +49,9 @@ def write_subjects_to_csv(writer): def write_appointments_to_csv(writer): appointments_fields = [] for field in Appointment._meta.fields: - if field.name != "visit" and field.name != "id" and field.name != "worker_assigned" and field.name != "appointment_types" and field.name != "room" and field.name != "flying_team": + if field.name != "visit" and field.name != "id" and \ + field.name != "worker_assigned" and field.name != "appointment_types" and \ + field.name != "room" and field.name != "flying_team": appointments_fields.append(field) field_names = ['ND number', 'Family name', 'Name', 'Visit'] diff --git a/smash/web/views/kit.py b/smash/web/views/kit.py index 8c33bbdaf48a3e04af7ae6b3e00c0e0cb7099534..4955103d7f6293290e8a2b1fa182e1f82bf672d2 100644 --- a/smash/web/views/kit.py +++ b/smash/web/views/kit.py @@ -129,8 +129,8 @@ def kit_requests_send_mail(request, start_date, end_date=None): class KitRequestEmailSendJob(CronJobBase): - RUN_EVERY_MINS = 1 - schedule = Schedule(run_every_mins=RUN_EVERY_MINS) + RUN_EVERY_MINUTES = 1 + schedule = Schedule(run_every_mins=RUN_EVERY_MINUTES) code = 'web.kit_request_weekly_email' # a unique code def do(self): @@ -148,8 +148,8 @@ class KitRequestEmailSendJob(CronJobBase): if jobs.count() == 0: if pytz.utc.localize(datetime.datetime.utcnow()) > date: if self.match_day_of_week(): - data = get_kit_requests(Worker.objects.create()); - send_mail(data); + data = get_kit_requests(Worker.objects.create()) + send_mail(data) return "mail sent" else: return "day of week doesn't match" @@ -160,7 +160,7 @@ class KitRequestEmailSendJob(CronJobBase): def match_day_of_week(self): user_day_of_week = ConfigurationItem.objects.get(type=KIT_EMAIL_DAY_OF_WEEK_CONFIGURATION_TYPE).value - language = Language.objects.get(name="English"); + language = Language.objects.get(name="English") locale_name = language.locale if platform.system() == 'Windows': locale_name = language.windows_locale_name @@ -171,6 +171,6 @@ class KitRequestEmailSendJob(CronJobBase): traceback.print_exc(file=sys.stdout) user_day_of_week_int = int(time.strptime(user_day_of_week, '%A').tm_wday) + 1 - current_day_of_week_int = int(datetime.datetime.now().strftime("%w")); + current_day_of_week_int = int(datetime.datetime.now().strftime("%w")) return user_day_of_week_int == current_day_of_week_int diff --git a/smash/web/views/notifications.py b/smash/web/views/notifications.py index 0f7d4e666a919281fd4845c2f5bc704eb38bf519..0d47a354c00a01796a5a656f2543a5cdf715ddf7 100644 --- a/smash/web/views/notifications.py +++ b/smash/web/views/notifications.py @@ -241,4 +241,4 @@ def get_filter_locations(user): def get_today_midnight_date(): today = datetime.datetime.now() today_midnight = datetime.datetime(today.year, today.month, today.day) - return today_midnight \ No newline at end of file + return today_midnight