diff --git a/smash/web/forms.py b/smash/web/forms.py index 663f68869f6d81e87e02507d16b2f308474919bf..2522e94b9b48a244f7c10b8a9d9471c481e715a5 100644 --- a/smash/web/forms.py +++ b/smash/web/forms.py @@ -135,6 +135,8 @@ class VisitDetailForm(ModelForm): widget=forms.DateInput(DATEPICKER_DATE_ATTRS, "%Y-%m-%d") ) + post_mail_sent = forms.RadioSelect() + class Meta: model = Visit exclude = ['is_finished'] diff --git a/smash/web/models.py b/smash/web/models.py index 3567021a5adba3c071f3361dc9c76aa3da27c4aa..18f2f5aea3436d4034431d0e2016e96a4c7e19d5 100644 --- a/smash/web/models.py +++ b/smash/web/models.py @@ -479,7 +479,11 @@ class Visit(models.Model): verbose_name='Has ended', default=False ) - + BOOL_CHOICES = ((True, 'Yes'), (False, 'No')) + post_mail_sent = models.BooleanField(choices=BOOL_CHOICES, + verbose_name='Post mail sent', + default=False + ) appointment_types = models.ManyToManyField(AppointmentType, verbose_name='Requested appointments', blank=True, diff --git a/smash/web/views.py b/smash/web/views.py index f86045232d1fe15512965d84493e010f7308d156..7d0707ee4a86c2c6c557a31f14162b84e084fbf7 100644 --- a/smash/web/views.py +++ b/smash/web/views.py @@ -185,6 +185,14 @@ def get_approaching_visits_without_appointments_count(user): type = 'web.views.approaching_visits_without_appointments') return notification +def get_approaching_visits_for_mail_contact_count(user): + notification = NotificationCount( + title = "post mail for approaching visits", + count = get_approaching_visits_for_mail_contact(user).count(), + style = "fa fa-users text-aqua", + type = 'web.views.approaching_visits_for_mail_contact') + return notification + def get_approaching_visits_without_appointments(user): today = get_today_midnight_date() today_plus_two_months =today+datetime.timedelta(days=62) @@ -195,6 +203,18 @@ def get_approaching_visits_without_appointments(user): subject__default_location__in = get_filter_locations(user), my_count=0) +def get_approaching_visits_for_mail_contact(user): + today = get_today_midnight_date() + today_plus_three_months =today+datetime.timedelta(days=91) + today_plus_six_months =today+datetime.timedelta(days=183) + return Visit.objects.annotate(my_count=Count(Case(When(appointment__status=Appointment.APPOINTMENT_STATUS_SCHEDULED, then=1)))).filter( + datetime_begin__gt = today_plus_three_months, + datetime_begin__lt = today_plus_six_months, + is_finished = False, + post_mail_sent = False, + subject__default_location__in = get_filter_locations(user), + my_count=0) + def get_unfinished_appointments_count(user): return NotificationCount( title = "unfinished appointments ",