diff --git a/smash/web/redcap_connector.py b/smash/web/redcap_connector.py index 602bf2a12dd6d89dee33bf0caed0666b0f704e7a..ae5a615b2945b7850b4514830a1d2c572bf83ebc 100644 --- a/smash/web/redcap_connector.py +++ b/smash/web/redcap_connector.py @@ -53,11 +53,19 @@ class RedcapVisit(object): def different_string(string1, string2): - if string1 is None: - string1 = "" - if string2 is None: - string2 = "" - return string1.strip() != string2.strip() + if type(string1) == bytes: + s1 = string1.decode('utf8') + else: + s1 = string1 + if type(string2) == bytes: + s2 = string1.decode('utf8') + else: + s2 = string2 + if s1 is None: + s1 = "" + if s2 is None: + s2 = "" + return s1.strip() != s2.strip() def date_equals(date1, date2): diff --git a/smash/web/tests/functions.py b/smash/web/tests/functions.py index f283c978566d37d192a95de77b2bfd1ae050c917..459c24795a58388dad0109485e8220db8e1e85fd 100644 --- a/smash/web/tests/functions.py +++ b/smash/web/tests/functions.py @@ -3,6 +3,7 @@ import logging import os from django.contrib.auth.models import User +from django.utils.timezone import make_aware from web.models import Location, AppointmentType, StudySubject, Worker, Visit, Appointment, ConfigurationItem, \ Language, ContactAttempt, FlyingTeam, Availability, Subject, Study, StudyColumns, StudyNotificationParameters, \ @@ -318,7 +319,7 @@ def create_appointment(visit=None, when=None, length=30): length=length, location=get_test_location(), status=Appointment.APPOINTMENT_STATUS_SCHEDULED, - datetime_when=when) + datetime_when=make_aware(when)) def create_appointment_without_visit(when=None, length=30): @@ -326,7 +327,7 @@ def create_appointment_without_visit(when=None, length=30): length=length, location=get_test_location(), status=Appointment.APPOINTMENT_STATUS_SCHEDULED, - datetime_when=when) + datetime_when=make_aware(when)) def create_configuration_item(): diff --git a/smash/web/utils.py b/smash/web/utils.py index eed9dbf7c8e8d9cff72e812877fc892306b8217d..3bc35e318faa5d4aa6e7e578006a8713660fd674 100644 --- a/smash/web/utils.py +++ b/smash/web/utils.py @@ -3,6 +3,8 @@ from django.utils import timezone import datetime from datetime import timedelta +from django.utils.timezone import make_aware + from web.algorithm import VerhoeffAlgorithm, LuhnAlgorithm def is_valid_social_security_number(number): @@ -23,7 +25,7 @@ def get_today_midnight_date(): today = timezone.now() today_midnight = datetime.datetime( today.year, today.month, today.day, tzinfo=today.tzinfo) - return today_midnight + return make_aware(today_midnight) def get_weekdays_in_period(fromdate, todate):