mirror of
				https://gitlab.crans.org/bde/nk20
				synced 2025-11-04 01:12:08 +01:00 
			
		
		
		
	Compare commits
	
		
			4 Commits
		
	
	
		
			b92e6e4e10
			...
			survey_wei
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 
						 | 
					c1a353963a | ||
| 
						 | 
					178ce2b579 | ||
| 
						 | 
					185a2cabf2 | ||
| 
						 | 
					7552e55c8d | 
@@ -55,7 +55,7 @@ buses_descr = [
 | 
			
		||||
        pour les plus calmes, vous trouverez au bus Aspique-Kyottes les 2A+ qui vous feront kiffer votre WEI.""",
 | 
			
		||||
    ],
 | 
			
		||||
    [
 | 
			
		||||
        "Zanzo[Bus] 🤩👽🐔", "#FFFF", 3,
 | 
			
		||||
        "Zanzo[Bus] 🤯🚸🐒", "#FFFF", 3,
 | 
			
		||||
        """Dans un entre-trois bien senti entre zinzinerie, enfance et vieillerie, le Zanzo[BUS] est un concentré de fun mêlé à
 | 
			
		||||
        de la dinguerie à gogo. N'hésitez plus et rejoignez-nous pour un WEI toujours plus déjanté !""",
 | 
			
		||||
    ],
 | 
			
		||||
@@ -276,13 +276,27 @@ class WEISurveyAlgorithm2024(WEISurveyAlgorithm):
 | 
			
		||||
        surveys = list(self.get_survey_class()(r) for r in self.get_registrations())  # All surveys
 | 
			
		||||
        surveys = [s for s in surveys if s.is_complete()]  # Don't consider invalid surveys
 | 
			
		||||
        # Don't manage hardcoded people
 | 
			
		||||
        surveys = [s for s in surveys if not hasattr(s.information, 'hardcoded') or not s.information.hardcoded]
 | 
			
		||||
        # surveys = [s for s in surveys if s.bus_id != None]
 | 
			
		||||
        # surveys = [s for s in surveys if not hasattr(s.information, 'hardcoded') or not s.information.hardcoded]
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        # surveys = [s for s in surveys if s.registration.user_id in free_users]
 | 
			
		||||
 | 
			
		||||
        # hardcoded_first_year_mb = WEIMembership.objects.filter(bus != None,registration__first_year=True)
 | 
			
		||||
        # hardcoded_first_year = hardcoded_first_year_mb.values_list('user__id', 'bus__id')
 | 
			
		||||
 | 
			
		||||
        hardcoded_first_year_mb = WEIMembership.objects.filter(registration__first_year=True)
 | 
			
		||||
        hardcoded_first_year = {mb.user.id if mb.bus else None: mb.bus.id if mb.bus else None for mb in hardcoded_first_year_mb}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        # Reset previous algorithm run
 | 
			
		||||
        for survey in surveys:
 | 
			
		||||
            survey.free()
 | 
			
		||||
            if survey.registration.user_id in hardcoded_first_year.keys():
 | 
			
		||||
                survey.select_bus(hardcoded_first_year[s.registration.user_id])
 | 
			
		||||
            survey.save()
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        non_men = [s for s in surveys if s.registration.gender != 'male']
 | 
			
		||||
        men = [s for s in surveys if s.registration.gender == 'male']
 | 
			
		||||
 | 
			
		||||
@@ -291,9 +305,7 @@ class WEISurveyAlgorithm2024(WEISurveyAlgorithm):
 | 
			
		||||
        non_men_total = registrations.filter(~Q(gender='male')).count()
 | 
			
		||||
        for bus in self.get_buses():
 | 
			
		||||
            free_seats = bus.size - WEIMembership.objects.filter(bus=bus, registration__first_year=False).count()
 | 
			
		||||
            # Remove hardcoded people
 | 
			
		||||
            free_seats -= WEIMembership.objects.filter(bus=bus, registration__first_year=True,
 | 
			
		||||
                                                       registration__information_json__icontains="hardcoded").count()
 | 
			
		||||
            free_seats -= sum(1 for s in non_men if s.information.selected_bus_pk == bus.pk)
 | 
			
		||||
            quotas[bus] = 4 + int(non_men_total / registrations.count() * free_seats)
 | 
			
		||||
 | 
			
		||||
        tqdm_obj = None
 | 
			
		||||
@@ -308,9 +320,6 @@ class WEISurveyAlgorithm2024(WEISurveyAlgorithm):
 | 
			
		||||
        for bus in self.get_buses():
 | 
			
		||||
            free_seats = bus.size - WEIMembership.objects.filter(bus=bus, registration__first_year=False).count()
 | 
			
		||||
            free_seats -= sum(1 for s in non_men if s.information.selected_bus_pk == bus.pk)
 | 
			
		||||
            # Remove hardcoded people
 | 
			
		||||
            free_seats -= WEIMembership.objects.filter(bus=bus, registration__first_year=True,
 | 
			
		||||
                                                       registration__information_json__icontains="hardcoded").count()
 | 
			
		||||
            quotas[bus] = free_seats
 | 
			
		||||
 | 
			
		||||
        if display_tqdm:
 | 
			
		||||
 
 | 
			
		||||
@@ -0,0 +1,17 @@
 | 
			
		||||
# Generated by Django 4.2.15 on 2024-08-29 20:15
 | 
			
		||||
 | 
			
		||||
from django.db import migrations
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class Migration(migrations.Migration):
 | 
			
		||||
 | 
			
		||||
    dependencies = [
 | 
			
		||||
        ('wei', '0009_weiregistration_specific_diet'),
 | 
			
		||||
    ]
 | 
			
		||||
 | 
			
		||||
    operations = [
 | 
			
		||||
        migrations.RemoveField(
 | 
			
		||||
            model_name='weiregistration',
 | 
			
		||||
            name='specific_diet',
 | 
			
		||||
        ),
 | 
			
		||||
    ]
 | 
			
		||||
@@ -232,12 +232,6 @@ class WEIRegistration(models.Model):
 | 
			
		||||
        verbose_name=_("health issues"),
 | 
			
		||||
    )
 | 
			
		||||
 | 
			
		||||
    specific_diet = models.TextField(
 | 
			
		||||
        blank=True,
 | 
			
		||||
        default="",
 | 
			
		||||
        verbose_name=_("specific diet"),
 | 
			
		||||
    )
 | 
			
		||||
 | 
			
		||||
    emergency_contact_name = models.CharField(
 | 
			
		||||
        max_length=255,
 | 
			
		||||
        verbose_name=_("emergency contact name"),
 | 
			
		||||
 
 | 
			
		||||
@@ -25,12 +25,9 @@
 | 
			
		||||
                <dt class="col-xl-6">{% trans 'department'|capfirst %}</dt>
 | 
			
		||||
                <dd class="col-xl-6">{{ object.user.profile.get_department_display }}</dd>
 | 
			
		||||
 | 
			
		||||
                <dt class="col-xl-6">{% trans 'health issues'|capfirst %}</dt>
 | 
			
		||||
                <dt class="col-xl-6">{% trans 'health issues or specific diet'|capfirst %}</dt>
 | 
			
		||||
                <dd class="col-xl-6">{{ object.health_issues|default:"—" }}</dd>
 | 
			
		||||
 | 
			
		||||
                <dt class="col-xl-6">{% trans 'specific diet'|capfirst %}</dt>
 | 
			
		||||
                <dd class="col-xl-6">{{ object.specific_diet|default:"—" }}</dd>
 | 
			
		||||
 | 
			
		||||
                <dt class="col-xl-6">{% trans 'suggested bus'|capfirst %}</dt>
 | 
			
		||||
                <dd class="col-xl-6">{{ survey.information.selected_bus_name }}</dd>
 | 
			
		||||
            </dl>
 | 
			
		||||
 
 | 
			
		||||
@@ -64,12 +64,9 @@ SPDX-License-Identifier: GPL-3.0-or-later
 | 
			
		||||
                <dt class="col-xl-6">{% trans 'birth date'|capfirst %}</dt>
 | 
			
		||||
                <dd class="col-xl-6">{{ registration.birth_date }}</dd>
 | 
			
		||||
 | 
			
		||||
                <dt class="col-xl-6">{% trans 'health issues'|capfirst %}</dt>
 | 
			
		||||
                <dt class="col-xl-6">{% trans 'health issues or specific diet'|capfirst %}</dt>
 | 
			
		||||
                <dd class="col-xl-6">{{ registration.health_issues }}</dd>
 | 
			
		||||
 | 
			
		||||
                <dt class="col-xl-6">{% trans 'specific diet'|capfirst %}</dt>
 | 
			
		||||
                <dd class="col-xl-6">{{ registration.specific_diet }}</dd>
 | 
			
		||||
 | 
			
		||||
                <dt class="col-xl-6">{% trans 'emergency contact name'|capfirst %}</dt>
 | 
			
		||||
                <dd class="col-xl-6">{{ registration.emergency_contact_name }}</dd>
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user