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

Merge branch 'fix/378_for_real' into 'master'

fixes #436 while keeping the constants that are relied on by many parts of the...

See merge request NCER-PD/scheduling-system!349
parents cc595ef6 352d1a90
No related branches found
No related tags found
1 merge request!349fixes #436 while keeping the constants that are relied on by many parts of the...
Pipeline #46459 passed
smasch (1.1.0~alpha.0-1) unstable; urgency=low
* improvement: put current date in the mail template tag examples (#436)
* improvement: remove sorting from columns that do not require sorting in
mail template menu and languages menu (#436)
* improvement: added explanatory tooltip for the column `order` in language
......
......@@ -13,15 +13,12 @@ from ..models import Appointment, Visit, StudySubject, Worker, Voucher
DATE_FORMAT_FULL = "%A %d %B %Y"
DATETIME_FORMAT = "%A %d %B %Y, %H:%m"
DATETIME_FORMAT = "%A %d %B %Y, %H:%M"
DATE_FORMAT_SHORT = "%d.%m.%Y"
DATE_FORMAT_TIME = "%H:%M"
now = datetime.datetime.now()
def date_format_encoding():
return locale.getlocale(locale.LC_TIME)[1] or locale.getpreferredencoding()
......@@ -40,7 +37,7 @@ def get_formatted_time(time_format):
# Was:
# return now.strftime(time_format).decode(date_format_encoding())
# Is:
return now.strftime(time_format) # /-->
return datetime.datetime.now().strftime(time_format) # /-->
def date_to_str(date, date_format):
......@@ -53,119 +50,124 @@ def date_to_str(date, date_format):
else:
return ""
class MailTemplate(models.Model):
MAILS_TEMPLATE_GENERIC_TAGS = [
("##DATE_FULL##", "Current date when the mail will be generated (long format)",
get_formatted_time(DATE_FORMAT_FULL)),
("##DATE_SHORT##", "Current date when the mail will be generated (short format)",
now.strftime(DATE_FORMAT_SHORT)),
("##WORKER##", "The full name of the currently logged in user", ""),
("##WORKER_EMAIL##", "Email address of the currently logged in user", "")
]
MAILS_TEMPLATE_SUBJECT_TAGS = [
("##S_FULL_NAME##", "Subject's full name", "first_name last_name"),
("##S_FIRST_NAME##", "Subject's first name", ""),
("##S_LAST_NAME##", "Subject's last name", ""),
("##S_ADDRESS##", "Subject's address", "street name and number"),
("##S_CITY##", "Subject's city of residence", ""),
("##S_POST_CODE##", "Subject's post code of residence", ""),
("##S_COUNTRY##", "Subject's country of residence", ""),
("##S_SEX##", "Subject's gender", "Male/Female"),
("##S_TYPE##", "Subject's type", "CONTROL/PATIENT"),
("##S_DATE_BORN##", "Subject's date of birth", get_formatted_time(DATE_FORMAT_SHORT)),
("##S_EMAIL##", "Subject's email address", ""),
("##S_PHONE_NUMBER##", "Subject's phone number", ""),
("##S_PHONE_NUMBER_2##", "Subject's second phone number", ""),
("##S_PHONE_NUMBER_3##", "Subject's third phone number", ""),
("##S_MAIL_LANGUAGE##", "Subject's preferred language for written communication", ""),
("##S_KNOWN_LANGUAGES##", "List of languages known by the subject", "comma separated"),
("##S_SCREENING_NUMBER##", "Subject's screening number", ""),
("##S_DIAGNOSIS##", "Subject's diagnosis", ""),
("##S_DIAGNOSIS_YEAR##", "Subject's year of diagnosis", ""),
("##S_MPOWER_ID##", "Subject's mPower identifier", ""),
("##S_ND_NUMBER##", "Subject's ND number", ""),
("##S_DATE_ADDED##", "Subject's date of creation", get_formatted_time(DATE_FORMAT_SHORT)),
("##S_VIRUS_1_SAMPLE_COLLECTION_DATE##", "Virus test collection date in visit 1",
get_formatted_time(DATE_FORMAT_SHORT)),
("##S_VIRUS_2_SAMPLE_COLLECTION_DATE##", "Virus test collection date in visit 2",
get_formatted_time(DATE_FORMAT_SHORT)),
("##S_VIRUS_3_SAMPLE_COLLECTION_DATE##", "Virus test collection date in visit 3",
get_formatted_time(DATE_FORMAT_SHORT)),
("##S_VIRUS_4_SAMPLE_COLLECTION_DATE##", "Virus test collection date in visit 4",
get_formatted_time(DATE_FORMAT_SHORT)),
("##S_VIRUS_5_SAMPLE_COLLECTION_DATE##", "Virus test collection date in visit 5",
get_formatted_time(DATE_FORMAT_SHORT)),
("##S_VIRUS_1_RESULT##", "Virus test results in visit 1", "Positive"),
("##S_VIRUS_2_RESULT##", "Virus test results in visit 2", "Negative"),
("##S_VIRUS_3_RESULT##", "Virus test results in visit 3", "Inconclusive"),
("##S_VIRUS_4_RESULT##", "Virus test results in visit 4", ""),
("##S_VIRUS_5_RESULT##", "Virus test results in visit 5", ""),
("##S_VIRUS_1_IGA_STATUS##", "IgA Status in visit 1", "Positive"),
("##S_VIRUS_2_IGA_STATUS##", "IgA Status in visit 2", "Negative"),
("##S_VIRUS_3_IGA_STATUS##", "IgA Status in visit 3", "Borderline"),
("##S_VIRUS_4_IGA_STATUS##", "IgA Status in visit 4", ""),
("##S_VIRUS_5_IGA_STATUS##", "IgA Status in visit 5", ""),
("##S_VIRUS_1_IGG_STATUS##", "IgG Status in visit 1", "Positive"),
("##S_VIRUS_2_IGG_STATUS##", "IgG Status in visit 2", "Negative"),
("##S_VIRUS_3_IGG_STATUS##", "IgG Status in visit 3", "Borderline"),
("##S_VIRUS_4_IGG_STATUS##", "IgG Status in visit 4", ""),
("##S_VIRUS_5_IGG_STATUS##", "IgG Status in visit 5", ""),
("##S_HEALTH_PARTNER_NAME##", "Name of the health partner", ""),
("##S_HEALTH_PARTNER_ADDRESS##", "Address of the health partner", ""),
("##S_HEALTH_PARTNER_ZIP_CODE##", "Zip code of the health partner", ""),
("##S_HEALTH_PARTNER_CITY##", "City of the health partner", ""),
]
MAILS_TEMPLATE_VISIT_TAGS = [
("##V_DATE_START_FULL##", "Visit's start date", get_formatted_time(DATETIME_FORMAT)),
("##V_DATE_START_SHORT##", "Visit's start date", get_formatted_time(DATE_FORMAT_SHORT)),
("##V_DATE_ENDS_FULL##", "Visit's end date", get_formatted_time(DATETIME_FORMAT)),
("##V_DATE_ENDS_SHORT##", "Visit's end date", get_formatted_time(DATE_FORMAT_SHORT)),
]
MAILS_TEMPLATE_APPOINTMENT_TAGS = [
("##A_DATE_FULL##", "Appointment's date and time", get_formatted_time(DATETIME_FORMAT)),
("##A_DATE_SHORT##", "Appointment's date", get_formatted_time(DATE_FORMAT_SHORT)),
("##A_TIME##", "Appointment's time", get_formatted_time(DATE_FORMAT_TIME)),
("##A_FLYING_TEAM##", "Appointment's flying team location", ""),
("##A_LOCATION##", "Appointment's location", "value can be 'Flying Team'"),
("##A_LOCATION_OR_FLYINGTEAM##", "Appointment's real location",
"if flying team then returns flying team exact location, otherwise returns location name"),
("##A_STATUS##", "Appointment's status", ""),
("##A_WORKER##", "Worker conducting the assessment", "first_name last_name"),
("##A_WORKER_PHONE##", "Phone number of the worker conducting the assessment", ""),
("##A_WORKER_EMAIL##", "Email address of the worker conducting the assessment", ""),
("##A_ROOM##", "Appointment's room", 'room_number address city'),
("##A_LENGTH##", "Appointment's duration", 'integer, value in minutes'),
("##A_TYPES##", "Appointment's types", "comma separated"),
]
MAILS_TEMPLATE_VOUCHER_TAGS = [
("##C_NUMBER##", "Number", ''),
("##C_PATIENT_NAME##", "Voucher Partner name", ''),
("##C_VOUCHER_TYPE##", "Voucher type", ''),
("##C_ISSUE_DATE_SHORT##", "Issue date", get_formatted_time(DATE_FORMAT_SHORT)),
("##C_EXPIRY_START_SHORT##", "Expiry date", get_formatted_time(DATE_FORMAT_SHORT)),
("##C_PARTNER_NAME##", "Voucher Partner name", ''),
("##C_PARTNER_ADDRESS##", "Voucher Partner address", ''),
("##C_PARTNER_CITY##", "Voucher Partner city", ''),
("##C_PARTNER_POSTAL_CODE##", "Voucher Partner postal code", ''),
("##C_PARTNER_COUNTRY##", "Voucher Partner country", ''),
("##C_PARTNER_PHONE##", "Voucher Partner phone", ''),
("##C_HOURS##", "Hours", ''),
]
@classmethod
def update_tags(cls):
"""This solves the problem of showing the tags with current times on the mail template
view while keeping the constant structure that is accessed in many parts of the code.
"""
cls.MAILS_TEMPLATE_GENERIC_TAGS = [
("##DATE_FULL##", "Current date when the mail will be generated (long format)",
get_formatted_time(DATE_FORMAT_FULL)),
("##DATE_SHORT##", "Current date when the mail will be generated (short format)",
get_formatted_time(DATE_FORMAT_SHORT)),
("##WORKER##", "The full name of the currently logged in user", ""),
("##WORKER_EMAIL##", "Email address of the currently logged in user", "")
]
cls.MAILS_TEMPLATE_SUBJECT_TAGS = [
("##S_FULL_NAME##", "Subject's full name", "first_name last_name"),
("##S_FIRST_NAME##", "Subject's first name", ""),
("##S_LAST_NAME##", "Subject's last name", ""),
("##S_ADDRESS##", "Subject's address", "street name and number"),
("##S_CITY##", "Subject's city of residence", ""),
("##S_POST_CODE##", "Subject's post code of residence", ""),
("##S_COUNTRY##", "Subject's country of residence", ""),
("##S_SEX##", "Subject's gender", "Male/Female"),
("##S_TYPE##", "Subject's type", "CONTROL/PATIENT"),
("##S_DATE_BORN##", "Subject's date of birth", get_formatted_time(DATE_FORMAT_SHORT)),
("##S_EMAIL##", "Subject's email address", ""),
("##S_PHONE_NUMBER##", "Subject's phone number", ""),
("##S_PHONE_NUMBER_2##", "Subject's second phone number", ""),
("##S_PHONE_NUMBER_3##", "Subject's third phone number", ""),
("##S_MAIL_LANGUAGE##", "Subject's preferred language for written communication", ""),
("##S_KNOWN_LANGUAGES##", "List of languages known by the subject", "comma separated"),
("##S_SCREENING_NUMBER##", "Subject's screening number", ""),
("##S_DIAGNOSIS##", "Subject's diagnosis", ""),
("##S_DIAGNOSIS_YEAR##", "Subject's year of diagnosis", ""),
("##S_MPOWER_ID##", "Subject's mPower identifier", ""),
("##S_ND_NUMBER##", "Subject's ND number", ""),
("##S_DATE_ADDED##", "Subject's date of creation", get_formatted_time(DATE_FORMAT_SHORT)),
("##S_VIRUS_1_SAMPLE_COLLECTION_DATE##", "Virus test collection date in visit 1",
get_formatted_time(DATE_FORMAT_SHORT)),
("##S_VIRUS_2_SAMPLE_COLLECTION_DATE##", "Virus test collection date in visit 2",
get_formatted_time(DATE_FORMAT_SHORT)),
("##S_VIRUS_3_SAMPLE_COLLECTION_DATE##", "Virus test collection date in visit 3",
get_formatted_time(DATE_FORMAT_SHORT)),
("##S_VIRUS_4_SAMPLE_COLLECTION_DATE##", "Virus test collection date in visit 4",
get_formatted_time(DATE_FORMAT_SHORT)),
("##S_VIRUS_5_SAMPLE_COLLECTION_DATE##", "Virus test collection date in visit 5",
get_formatted_time(DATE_FORMAT_SHORT)),
("##S_VIRUS_1_RESULT##", "Virus test results in visit 1", "Positive"),
("##S_VIRUS_2_RESULT##", "Virus test results in visit 2", "Negative"),
("##S_VIRUS_3_RESULT##", "Virus test results in visit 3", "Inconclusive"),
("##S_VIRUS_4_RESULT##", "Virus test results in visit 4", ""),
("##S_VIRUS_5_RESULT##", "Virus test results in visit 5", ""),
("##S_VIRUS_1_IGA_STATUS##", "IgA Status in visit 1", "Positive"),
("##S_VIRUS_2_IGA_STATUS##", "IgA Status in visit 2", "Negative"),
("##S_VIRUS_3_IGA_STATUS##", "IgA Status in visit 3", "Borderline"),
("##S_VIRUS_4_IGA_STATUS##", "IgA Status in visit 4", ""),
("##S_VIRUS_5_IGA_STATUS##", "IgA Status in visit 5", ""),
("##S_VIRUS_1_IGG_STATUS##", "IgG Status in visit 1", "Positive"),
("##S_VIRUS_2_IGG_STATUS##", "IgG Status in visit 2", "Negative"),
("##S_VIRUS_3_IGG_STATUS##", "IgG Status in visit 3", "Borderline"),
("##S_VIRUS_4_IGG_STATUS##", "IgG Status in visit 4", ""),
("##S_VIRUS_5_IGG_STATUS##", "IgG Status in visit 5", ""),
("##S_HEALTH_PARTNER_NAME##", "Name of the health partner", ""),
("##S_HEALTH_PARTNER_ADDRESS##", "Address of the health partner", ""),
("##S_HEALTH_PARTNER_ZIP_CODE##", "Zip code of the health partner", ""),
("##S_HEALTH_PARTNER_CITY##", "City of the health partner", ""),
]
cls.MAILS_TEMPLATE_VISIT_TAGS = [
("##V_DATE_START_FULL##", "Visit's start date", get_formatted_time(DATETIME_FORMAT)),
("##V_DATE_START_SHORT##", "Visit's start date", get_formatted_time(DATE_FORMAT_SHORT)),
("##V_DATE_ENDS_FULL##", "Visit's end date", get_formatted_time(DATETIME_FORMAT)),
("##V_DATE_ENDS_SHORT##", "Visit's end date", get_formatted_time(DATE_FORMAT_SHORT)),
]
cls.MAILS_TEMPLATE_APPOINTMENT_TAGS = [
("##A_DATE_FULL##", "Appointment's date and time", get_formatted_time(DATETIME_FORMAT)),
("##A_DATE_SHORT##", "Appointment's date", get_formatted_time(DATE_FORMAT_SHORT)),
("##A_TIME##", "Appointment's time", get_formatted_time(DATE_FORMAT_TIME)),
("##A_FLYING_TEAM##", "Appointment's flying team location", ""),
("##A_LOCATION##", "Appointment's location", "value can be 'Flying Team'"),
("##A_LOCATION_OR_FLYINGTEAM##", "Appointment's real location",
"if flying team then returns flying team exact location, otherwise returns location name"),
("##A_STATUS##", "Appointment's status", ""),
("##A_WORKER##", "Worker conducting the assessment", "first_name last_name"),
("##A_WORKER_PHONE##", "Phone number of the worker conducting the assessment", ""),
("##A_WORKER_EMAIL##", "Email address of the worker conducting the assessment", ""),
("##A_ROOM##", "Appointment's room", 'room_number address city'),
("##A_LENGTH##", "Appointment's duration", 'integer, value in minutes'),
("##A_TYPES##", "Appointment's types", "comma separated"),
]
cls.MAILS_TEMPLATE_VOUCHER_TAGS = [
("##C_NUMBER##", "Number", ''),
("##C_PATIENT_NAME##", "Voucher Partner name", ''),
("##C_VOUCHER_TYPE##", "Voucher type", ''),
("##C_ISSUE_DATE_SHORT##", "Issue date", get_formatted_time(DATE_FORMAT_SHORT)),
("##C_EXPIRY_START_SHORT##", "Expiry date", get_formatted_time(DATE_FORMAT_SHORT)),
("##C_PARTNER_NAME##", "Voucher Partner name", ''),
("##C_PARTNER_ADDRESS##", "Voucher Partner address", ''),
("##C_PARTNER_CITY##", "Voucher Partner city", ''),
("##C_PARTNER_POSTAL_CODE##", "Voucher Partner postal code", ''),
("##C_PARTNER_COUNTRY##", "Voucher Partner country", ''),
("##C_PARTNER_PHONE##", "Voucher Partner phone", ''),
("##C_HOURS##", "Hours", ''),
]
name = models.CharField(max_length=255)
context = models.CharField(max_length=1, choices=MAIL_TEMPLATE_CONTEXT_CHOICES)
......@@ -414,3 +416,6 @@ class MailTemplate(models.Model):
"##C_HOURS##": str(voucher.hours),
}
return {}
MailTemplate.update_tags()
......@@ -88,7 +88,7 @@
</div>
{% if field.errors %}
<span class="help-block">
<span class="help-block col-sm-12">
{{ field.errors }}
</span>
{% endif %}
......
......@@ -39,6 +39,7 @@ class MailTemplatesListView(ListView, WrappedView):
def get_context_data(self, *args, **kwargs):
context = super().get_context_data()
MailTemplate.update_tags()
context['explanations'] = {"generic": MailTemplate.MAILS_TEMPLATE_GENERIC_TAGS,
"subject": MailTemplate.MAILS_TEMPLATE_SUBJECT_TAGS,
"visit": MailTemplate.MAILS_TEMPLATE_VISIT_TAGS,
......
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