diff --git a/smash/web/redcap_connector.py b/smash/web/redcap_connector.py index 01016a06f911db2dd5547562818cae7a8a972a91..bca70fc0951a5894d2557f83a03f271eb216ce85 100644 --- a/smash/web/redcap_connector.py +++ b/smash/web/redcap_connector.py @@ -51,6 +51,14 @@ class RedcapSubject(object): self.languages.append(language) +def different_string(string1, string2): + if string1 is None: + string1 = "" + if string2 is None: + string2 = "" + return string1.strip() != string2.strip() + + class RedcapConnector(object): def __init__(self): self.token = None @@ -184,7 +192,7 @@ class RedcapConnector(object): if subject.dead != red_cap_subject.dead: field = InconsistentField.create("dead", str(subject.dead), str(red_cap_subject.dead)) fields.append(field) - if subject.mpower_id != red_cap_subject.mpower_id: + if different_string(subject.mpower_id, red_cap_subject.mpower_id): field = InconsistentField.create("mpower id", subject.mpower_id, red_cap_subject.mpower_id) fields.append(field) missing_language = False diff --git a/smash/web/static/flags/BG.png b/smash/web/static/flags/BG.png new file mode 100644 index 0000000000000000000000000000000000000000..3aac5b6998be6df037bc401965244cfb68402df0 Binary files /dev/null and b/smash/web/static/flags/BG.png differ diff --git a/smash/web/static/flags/CN.png b/smash/web/static/flags/CN.png new file mode 100644 index 0000000000000000000000000000000000000000..09036286ef8983b280a43503d56b0bc542c5527c Binary files /dev/null and b/smash/web/static/flags/CN.png differ diff --git a/smash/web/static/flags/EE.png b/smash/web/static/flags/EE.png new file mode 100644 index 0000000000000000000000000000000000000000..f74eb1619b32edbaaaf6e004a2970c6c1b5f8cc5 Binary files /dev/null and b/smash/web/static/flags/EE.png differ diff --git a/smash/web/static/flags/IN.png b/smash/web/static/flags/IN.png new file mode 100644 index 0000000000000000000000000000000000000000..66489f8c21ce885abcc822fdd33cefc5c0bae6a0 Binary files /dev/null and b/smash/web/static/flags/IN.png differ diff --git a/smash/web/static/flags/IR.png b/smash/web/static/flags/IR.png new file mode 100644 index 0000000000000000000000000000000000000000..8bbf81b75db6d02f89de92cc35d82add0adb17af Binary files /dev/null and b/smash/web/static/flags/IR.png differ diff --git a/smash/web/static/flags/readme.txt b/smash/web/static/flags/readme.txt index 250b9059378155743fcc5cf128cf144468975ae4..50b5ab63341b2ebb540225d91642c48d441e99ff 100644 --- a/smash/web/static/flags/readme.txt +++ b/smash/web/static/flags/readme.txt @@ -1,3 +1,3 @@ Icons come from an open source project: https://github.com/googlei18n/region-flags -To add another ones, pick them from png folder, and resize to 300x180 to mantain consistency. +To add another ones, pick them from png folder, and resize to 300x180 to maintain consistency. Then, add them in administrative panel. diff --git a/smash/web/tests/test_RedcapConnector.py b/smash/web/tests/test_RedcapConnector.py index 23b1cd9f68c03c69b79cdd5c44a1facca74e567a..e7d0159608d156c9058c57e11a62d8a2888aab3f 100644 --- a/smash/web/tests/test_RedcapConnector.py +++ b/smash/web/tests/test_RedcapConnector.py @@ -9,7 +9,7 @@ from web.models import ConfigurationItem, Language from web.models.constants import REDCAP_TOKEN_CONFIGURATION_TYPE, REDCAP_BASE_URL_CONFIGURATION_TYPE from web.models.inconsistent_subject import InconsistentSubject from web.models.missing_subject import MissingSubject -from web.redcap_connector import RedcapConnector, RedcapSubject +from web.redcap_connector import RedcapConnector, RedcapSubject, different_string from web.views.notifications import get_today_midnight_date logger = logging.getLogger(__name__) @@ -125,6 +125,18 @@ class TestRedcapConnector(TestCase): self.check_single_inconsistency(redcap_subject, subject) + def test_create_inconsistent_data_for_mpower_id_with_whitespace(self): + self.prepare_test_redcap_connection() + subject = create_subject() + subject.mpower_id = "105" + + redcap_subject = self.create_redcap_subject_from_smash_subject(subject) + subject.mpower_id = " 105 " + + redcap_connection = RedcapConnector() + result = redcap_connection.create_inconsistency_subject(redcap_subject, subject, "") + self.assertIsNone(result) + @staticmethod def create_redcap_subject_from_smash_subject(subject): redcap_subject = RedcapSubject() @@ -212,3 +224,10 @@ class TestRedcapConnector(TestCase): redcap_connection = RedcapConnector() redcap_connection.refresh_inconsistent() self.assertTrue(InconsistentSubject.objects.count() > 0) + + def test_different_string(self): + self.assertFalse(different_string(None, None)) + self.assertFalse(different_string(None, "")) + self.assertFalse(different_string("", None)) + self.assertFalse(different_string(" abc", "abc ")) + self.assertTrue(different_string("y", "x"))