Skip to content
Snippets Groups Projects

Virus visit column changes

Merged Carlos Vega requested to merge virus_visit_column_changes into master
2 unresolved threads
Files
3
+ 14
2
@@ -7,8 +7,10 @@ from django.utils.dates import MONTHS
from web.models import Appointment, AppointmentType, AppointmentTypeLink, \
Availability, ContactAttempt, FlyingTeam, Holiday, Item, \
StudySubject, Room, Worker, Visit, VoucherType, VoucherTypePrice
from web.models.constants import SUBJECT_TYPE_CHOICES
StudySubject, Room, Worker, Visit, VoucherType, VoucherTypePrice, ConfigurationItem
from web.models.constants import SUBJECT_TYPE_CHOICES, VISIT_SHOW_VISIT_NUMBER_FROM_ZERO
from distutils.util import strtobool
from web.templatetags.filters import display_visit_number
"""
Possible redundancy, but if need arises, contents of forms can be easily customized
@@ -127,6 +129,16 @@ class StatisticsForm(Form):
choices = [(-1, "all")]
choices.extend(SUBJECT_TYPE_CHOICES.items())
self.fields['subject_type'] = forms.ChoiceField(choices=choices, initial="-1")
visit_from_zero = ConfigurationItem.objects.get(type=VISIT_SHOW_VISIT_NUMBER_FROM_ZERO).value
#True values are y, yes, t, true, on and 1; false values are n, no, f, false, off and 0.
if strtobool(visit_from_zero):
new_choices = []
for value, label in visit_choices:
if int(value) > 0:
label = display_visit_number(label)
new_choices.append((value, label))
visit_choices = new_choices
self.fields['visit'] = forms.ChoiceField(choices=visit_choices, initial="-1")
Loading