diff --git a/apps/wei/models.py b/apps/wei/models.py index 7ab56f57..6b7272b4 100644 --- a/apps/wei/models.py +++ b/apps/wei/models.py @@ -7,6 +7,7 @@ from datetime import date from django.conf import settings from django.contrib.auth.models import User from django.db import models +from django.db.models import Q from django.utils.translation import gettext_lazy as _ from phonenumber_field.modelfields import PhoneNumberField from member.models import Club, Membership @@ -98,6 +99,13 @@ class Bus(models.Model): """ self.information_json = json.dumps(information, indent=2) + @property + def suggested_first_year(self): + registrations = WEIRegistration.objects.filter(Q(membership__isnull=True) | Q(membership__bus__isnull=True), + first_year=True, wei=self.wei) + registrations = [r for r in registrations if 'selected_bus_pk' in r.information] + return sum(1 for r in registrations if r.information['selected_bus_pk'] == self.pk) + def __str__(self): return self.name diff --git a/apps/wei/templates/wei/attribute_bus_1A.html b/apps/wei/templates/wei/attribute_bus_1A.html index 32cc27dd..3305981b 100644 --- a/apps/wei/templates/wei/attribute_bus_1A.html +++ b/apps/wei/templates/wei/attribute_bus_1A.html @@ -50,7 +50,7 @@ {% for bus, score in survey.ordered_buses %} {% endfor %}