diff --git a/streetup/home/admin.py b/streetup/home/admin.py index 9a58644..41d92c9 100644 --- a/streetup/home/admin.py +++ b/streetup/home/admin.py @@ -1,15 +1,7 @@ from django.contrib import admin from django.utils.html import format_html from django.utils.safestring import mark_safe -from .models import HomeWidget, HomeWidgetConditionGroup, HomeWidgetCondition, TeambuildingVote - - -@admin.register(TeambuildingVote) -class TeambuildingVoteAdmin(admin.ModelAdmin): - list_display = ("id", "voter_name", "vote_gael", "vote_charly", "vote_tequila", "vote_vivien", "created_at") - list_filter = ("created_at",) - search_fields = ("voter_name",) - +from .models import HomeWidget, HomeWidgetConditionGroup, HomeWidgetCondition class HomeWidgetConditionInline(admin.TabularInline): diff --git a/streetup/home/locale/en/LC_MESSAGES/django.po b/streetup/home/locale/en/LC_MESSAGES/django.po index dc84f57..c3b51b2 100644 --- a/streetup/home/locale/en/LC_MESSAGES/django.po +++ b/streetup/home/locale/en/LC_MESSAGES/django.po @@ -225,34 +225,6 @@ msgstr "Condition" msgid "Conditions" msgstr "Terms" -#: home/models.py:341 -msgid "Nom (optionnel)" -msgstr "optional" - -#: home/models.py:342 -msgid "La journée 'Gaël Non Di Dju'" -msgstr "The 'Gaël Non Di Dju' day" - -#: home/models.py:343 -msgid "La journée 'La cité de Charly'" -msgstr "'The city of Charly' day" - -#: home/models.py:344 -msgid "La journée 'Tequila Cadena'" -msgstr "Tequila Cadena Day" - -#: home/models.py:345 -msgid "La journée 'Vivien de La Grande Propreté'" -msgstr "The 'Vivien de La Grande Propreté' day" - -#: home/models.py:352 -msgid "Vote Teambuilding" -msgstr "Teambuilding voting" - -#: home/models.py:353 -msgid "Votes Teambuilding" -msgstr "Teambuilding Votes" - #: home/templates/home/_add_repair_intervention_modal.html:9 msgid "Nouvelle intervention de réparation" msgstr "New repair intervention" diff --git a/streetup/home/locale/fr/LC_MESSAGES/django.po b/streetup/home/locale/fr/LC_MESSAGES/django.po index 48eb291..4f9edf3 100644 --- a/streetup/home/locale/fr/LC_MESSAGES/django.po +++ b/streetup/home/locale/fr/LC_MESSAGES/django.po @@ -230,34 +230,6 @@ msgstr "État" msgid "Conditions" msgstr "Conditions" -#: home/models.py:341 -msgid "Nom (optionnel)" -msgstr "Nom (optionnel)" - -#: home/models.py:342 -msgid "La journée 'Gaël Non Di Dju'" -msgstr "La journée 'Gaël Non Di Dju'" - -#: home/models.py:343 -msgid "La journée 'La cité de Charly'" -msgstr "La journée 'La cité de Charly'" - -#: home/models.py:344 -msgid "La journée 'Tequila Cadena'" -msgstr "La journée 'Tequila Cadena'" - -#: home/models.py:345 -msgid "La journée 'Vivien de La Grande Propreté'" -msgstr "La journée 'Vivien de La Grande Propreté'" - -#: home/models.py:352 -msgid "Vote Teambuilding" -msgstr "Vote Teambuilding" - -#: home/models.py:353 -msgid "Votes Teambuilding" -msgstr "Votes Teambuilding" - #: home/templates/home/_add_repair_intervention_modal.html:9 msgid "Nouvelle intervention de réparation" msgstr "Nouvelle intervention de réparation" diff --git a/streetup/home/locale/nl/LC_MESSAGES/django.po b/streetup/home/locale/nl/LC_MESSAGES/django.po index 568bac9..af1c261 100644 --- a/streetup/home/locale/nl/LC_MESSAGES/django.po +++ b/streetup/home/locale/nl/LC_MESSAGES/django.po @@ -225,34 +225,6 @@ msgstr "Staat" msgid "Conditions" msgstr "Voorwaarden" -#: home/models.py:341 -msgid "Nom (optionnel)" -msgstr "optioneel" - -#: home/models.py:342 -msgid "La journée 'Gaël Non Di Dju'" -msgstr "De 'Gaël Non Di Dju'-dag" - -#: home/models.py:343 -msgid "La journée 'La cité de Charly'" -msgstr "Dag 'De stad van Charly'" - -#: home/models.py:344 -msgid "La journée 'Tequila Cadena'" -msgstr "Tequila Cadena-dag" - -#: home/models.py:345 -msgid "La journée 'Vivien de La Grande Propreté'" -msgstr "De dag van 'Vivien de La Grande Propreté'" - -#: home/models.py:352 -msgid "Vote Teambuilding" -msgstr "Stemmen voor teambuilding" - -#: home/models.py:353 -msgid "Votes Teambuilding" -msgstr "Stemmen voor teambuilding" - #: home/templates/home/_add_repair_intervention_modal.html:9 msgid "Nouvelle intervention de réparation" msgstr "Nieuwe reparatie-interventie" diff --git a/streetup/home/migrations/0002_delete_teambuildingvote.py b/streetup/home/migrations/0002_delete_teambuildingvote.py new file mode 100644 index 0000000..0082976 --- /dev/null +++ b/streetup/home/migrations/0002_delete_teambuildingvote.py @@ -0,0 +1,16 @@ +# Generated by Django 6.0.7 on 2026-08-12 15:40 + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('home', '0001_initial'), + ] + + operations = [ + migrations.DeleteModel( + name='TeambuildingVote', + ), + ] diff --git a/streetup/home/models.py b/streetup/home/models.py index 1fc977f..0e490d8 100644 --- a/streetup/home/models.py +++ b/streetup/home/models.py @@ -335,21 +335,3 @@ class HomeWidgetCondition(models.Model): if self.is_negated: return not res return res - - -class TeambuildingVote(models.Model): - voter_name = models.CharField(max_length=100, blank=True, null=True, verbose_name=_("Nom (optionnel)")) - vote_gael = models.IntegerField(default=0, verbose_name=_("La journée 'Gaël Non Di Dju'")) - vote_charly = models.IntegerField(default=0, verbose_name=_("La journée 'La cité de Charly'")) - vote_tequila = models.IntegerField(default=0, verbose_name=_("La journée 'Tequila Cadena'")) - vote_vivien = models.IntegerField(default=0, verbose_name=_("La journée 'Vivien de La Grande Propreté'")) - created_at = models.DateTimeField(auto_now_add=True) - - def __str__(self): - return f"Vote #{self.id} - {self.voter_name or 'Anonyme'}" - - class Meta: - verbose_name = _("Vote Teambuilding") - verbose_name_plural = _("Votes Teambuilding") - - diff --git a/streetup/home/templates/home/flexi_teambuilding.html b/streetup/home/templates/home/flexi_teambuilding.html deleted file mode 100644 index 3eb4b78..0000000 --- a/streetup/home/templates/home/flexi_teambuilding.html +++ /dev/null @@ -1,594 +0,0 @@ -{% load static %} - - - - - - Flexi Teambuilding - Vote - - - - - - - - - - - - - - - - -
- -
-
FTB
-

Flexi Teambuilding

-

Exprimez votre avis sur les 4 propositions de journée pour le prochain Teambuilding !

-
- Vote : de 0 à 3 étoiles -
-
- - -
- {% csrf_token %} - - -
- - -
-
-
01
-
-

La journée "Gaël Non Di Dju"

-
    -
  • RDV à Tour & Taxi à 10h pour un padel
  • -
  • Repas convivial dans les alentours
  • -
  • BattleKart de folie
  • -
  • Debrief autour d'un bon cocktail ou à la brasserie de la Senne
  • -
-
-
- - Budget : ~150 € / pers. - -
- - -
-
- Votre évaluation - -
-
- - - -
- -
Pas encore voté
-
-
-
- - -
-
-
02
-
-

La journée "La cité de Charly"

-
    -
  • RDV vers 10h30 à la station Demey
  • -
  • Petit dèj et balade dans les superbes cités jardin de Watermael-Boitsfort
  • -
  • En souvenir de notre jeunesse, on prend le bus (dingue !!!)
  • -
  • Repas convivial aux alentours du cimetière d'Ixelles, au feeling du jour
  • -
  • Escape game palpitant à Ixelles
  • -
  • Debriefing dans un rade local, ou évaluation des améliorations de la DGI sur base de la place Flagey
  • -
-
-
- - Budget : ~100 € / pers. - -
- - -
-
- Votre évaluation - -
-
- - - -
- -
Pas encore voté
-
-
-
- - -
-
-
03
-
-

La journée "Tequila Cadena"

-
    -
  • 10h30 : Tequila en attendant la retardataire, puis 10h40 : Tequila pour bien débuter la journée
  • -
  • 10h45 : Exercices fun de théâtre et d'improvisation
  • -
  • Tequila pour l'apéro, suivi d'un repas chaleureux
  • -
  • Tequila pour le digestif
  • -
  • Voyage dans le temps en visitant quelques authentiques estaminets
  • -
  • Tequila finale pour se dire au revoir
  • -
-
-
- - Budget : ~75 € / pers. - -
- - -
-
- Votre évaluation - -
-
- - - -
- -
Pas encore voté
-
-
-
- - -
-
-
04
-
-

La journée "Vivien de La Grande Propreté"

-
    -
  • 10h00 : RDV chez Bruxelles Propreté pour une présentation historique sur cette administration soeur
  • -
  • 10h45 : Présentation instructive sur les statuts juridiques de Bruxelles Propreté
  • -
  • 12h00 : Sandwich du jour offert
  • -
  • Accompagnement en immersion totale d'une équipe de collecte de sacs (avec tour en camion et siège passager !)
  • -
  • Inspection approfondie de sacs d'ordure pour identifier le non-respect du tri
  • -
  • Délicieux jus de pomme bio pour clôturer cette formidable journée
  • -
-
-
- - Budget minimal - -
- - -
-
- Votre évaluation - -
-
- - - -
- -
Pas encore voté
-
-
-
- -
- - -
-
-
-

Prêt à soumettre ?

-

- Vous pouvez indiquer votre nom ci-contre pour que l'organisateur sache qui a voté (facultatif). Le vote est anonyme par défaut. -

-
-
-
- - -
-
-
- - -
- -
-
- - - - - - diff --git a/streetup/home/templates/home/flexi_teambuilding_results.html b/streetup/home/templates/home/flexi_teambuilding_results.html deleted file mode 100644 index ee3cb00..0000000 --- a/streetup/home/templates/home/flexi_teambuilding_results.html +++ /dev/null @@ -1,430 +0,0 @@ -{% load static %} - - - - - - Flexi Teambuilding - Résultats - - - - - - - - - - - - - - - - -
- - {% if success %} -
- -
-
Votre vote a bien été enregistré !
-

Merci pour votre participation active au teambuilding.

-
-
- {% endif %} - - -
-
FTB
-

Résultats des Votes

-

Visualisation en temps réel des avis exprimés sur le Flexi Teambuilding

- -
-
-
{{ total_votes }}
-
- Participation{{ total_votes|pluralize }} -
-
-
-
- - -
-

- Moyennes des évaluations -

- - {% if total_votes > 0 %} - -
-
1) La journée "Gaël Non Di Dju"
-
-
- - {{ avg_gael }} ★ -
-
{{ pct_gael }}% d'approbation
-
-
-
-
-
- - -
-
2) La journée "La cité de Charly"
-
-
- {{ avg_charly }} ★ -
-
{{ pct_charly }}% d'approbation
-
-
-
-
-
- - -
-
3) La journée "Tequila Cadena"
-
-
- {{ avg_tequila }} ★ -
-
{{ pct_tequila }}% d'approbation
-
-
-
-
-
- - -
-
4) La journée "Vivien de La Grande Propreté"
-
-
- {{ avg_vivien }} ★ -
-
{{ pct_vivien }}% d'approbation
-
-
-
-
-
- {% else %} -
- -

Aucun vote n'a encore été enregistré.

-

Soyez le premier à donner votre avis !

-
- {% endif %} -
- - - {% if total_votes > 0 %} -
-

- Votants récents -

-
- {% for vote in votes %} -
-
- - {{ vote.voter_name|default:"Votant Anonyme" }} - - Voté le {{ vote.created_at|date:"d/m/Y à H:i" }} -
-
- {% endfor %} -
-
- {% endif %} - - -
- - Retour au formulaire de vote - -
-
- - - - - - diff --git a/streetup/home/tests.py b/streetup/home/tests.py index adffa02..f857255 100644 --- a/streetup/home/tests.py +++ b/streetup/home/tests.py @@ -4,7 +4,7 @@ from datetime import date from common.models import Role, Thematic, UserConfig, UserThematics from contracts.models import Company, CompanyTeam, Contract -from home.models import HomeWidget, HomeWidgetConditionGroup, HomeWidgetCondition, TeambuildingVote +from home.models import HomeWidget, HomeWidgetConditionGroup, HomeWidgetCondition class HomeWidgetConditionTests(TestCase): @@ -187,67 +187,6 @@ class HomeWidgetConditionTests(TestCase): self.assertEqual(self.group.get_summary(), "not(role=admin)") -class TeambuildingVoteViewsTests(TestCase): - def test_flexi_teambuilding_get(self): - # Page should be publicly accessible without logging in - response = self.client.get("/flexi-teambuilding/") - self.assertEqual(response.status_code, 200) - self.assertTemplateUsed(response, "home/flexi_teambuilding.html") - - def test_flexi_teambuilding_post(self): - # Submit a vote (publicly accessible) - response = self.client.post("/flexi-teambuilding/", { - "voter_name": "Jean-Luc", - "vote_gael": "3", - "vote_charly": "2", - "vote_tequila": "1", - "vote_vivien": "0" - }) - # Should redirect to results page with success query param - self.assertRedirects(response, "/flexi-teambuilding/results/?success=1") - - # Verify the database entry - self.assertEqual(TeambuildingVote.objects.count(), 1) - vote = TeambuildingVote.objects.first() - self.assertEqual(vote.voter_name, "Jean-Luc") - self.assertEqual(vote.vote_gael, 3) - self.assertEqual(vote.vote_charly, 2) - self.assertEqual(vote.vote_tequila, 1) - self.assertEqual(vote.vote_vivien, 0) - - def test_flexi_teambuilding_results_calculation(self): - # Create dummy votes - TeambuildingVote.objects.create( - voter_name="Alice", - vote_gael=3, - vote_charly=2, - vote_tequila=1, - vote_vivien=0 - ) - TeambuildingVote.objects.create( - voter_name="Bob", - vote_gael=1, - vote_charly=2, - vote_tequila=3, - vote_vivien=3 - ) - - # Access results page (publicly accessible) - response = self.client.get("/flexi-teambuilding/results/") - self.assertEqual(response.status_code, 200) - self.assertTemplateUsed(response, "home/flexi_teambuilding_results.html") - - # Check context averages - self.assertEqual(response.context["total_votes"], 2) - self.assertEqual(response.context["avg_gael"], 2.0) - self.assertEqual(response.context["avg_charly"], 2.0) - self.assertEqual(response.context["avg_tequila"], 2.0) - self.assertEqual(response.context["avg_vivien"], 1.5) - - self.assertEqual(response.context["pct_gael"], 66.7) - self.assertEqual(response.context["pct_charly"], 66.7) - self.assertEqual(response.context["pct_tequila"], 66.7) - self.assertEqual(response.context["pct_vivien"], 50.0) class HomeIndexViewTests(TestCase): diff --git a/streetup/home/urls.py b/streetup/home/urls.py index 5a31950..277d347 100644 --- a/streetup/home/urls.py +++ b/streetup/home/urls.py @@ -7,6 +7,4 @@ urlpatterns = [ path("", views.index, name="index"), path("privacy/", views.privacy, name="privacy"), path("api/incident-count/", views.incident_count_api, name="incident_count_api"), - path("flexi-teambuilding/", views.flexi_teambuilding, name="flexi_teambuilding"), - path("flexi-teambuilding/results/", views.flexi_teambuilding_results, name="flexi_teambuilding_results"), ] \ No newline at end of file diff --git a/streetup/home/views.py b/streetup/home/views.py index 6556839..d69bdc7 100644 --- a/streetup/home/views.py +++ b/streetup/home/views.py @@ -27,7 +27,7 @@ from interventions.models import Intervention, InterventionTimeLine, STATUS_ORDE from common.models import UserConfig, UserThematics, UserContractAccess from contracts.models import CompanyMember, Contract from contracts.permissions import get_allowed_contracts_for_user -from home.models import HomeWidget, TeambuildingVote +from home.models import HomeWidget from observations.models import Observation from stock.models import PreparationOrder, ProductionOrder, StockAlert, PurchaseOrderItem, StockMovement, StockMovementBatch, PurchaseOrder @@ -843,68 +843,4 @@ def incident_count_api(request): } for obs in qs[:5] ] - return JsonResponse({'count': qs.count(), 'incidents': incidents}) - - -@login_not_required -def flexi_teambuilding(request): - if request.method == "POST": - voter_name = request.POST.get("voter_name", "").strip() or None - vote_gael = int(request.POST.get("vote_gael", 0)) - vote_charly = int(request.POST.get("vote_charly", 0)) - vote_tequila = int(request.POST.get("vote_tequila", 0)) - vote_vivien = int(request.POST.get("vote_vivien", 0)) - - # Validate rating values - vote_gael = max(0, min(3, vote_gael)) - vote_charly = max(0, min(3, vote_charly)) - vote_tequila = max(0, min(3, vote_tequila)) - vote_vivien = max(0, min(3, vote_vivien)) - - TeambuildingVote.objects.create( - voter_name=voter_name, - vote_gael=vote_gael, - vote_charly=vote_charly, - vote_tequila=vote_tequila, - vote_vivien=vote_vivien - ) - return redirect(reverse("home:flexi_teambuilding_results") + "?success=1") - - return render(request, "home/flexi_teambuilding.html") - - -@login_not_required -def flexi_teambuilding_results(request): - from django.db.models import Avg - - votes = TeambuildingVote.objects.all().order_by("-created_at") - total_votes = votes.count() - - averages = votes.aggregate( - avg_gael=Avg("vote_gael"), - avg_charly=Avg("vote_charly"), - avg_tequila=Avg("vote_tequila"), - avg_vivien=Avg("vote_vivien") - ) - - avg_gael = round(averages["avg_gael"] or 0, 2) - avg_charly = round(averages["avg_charly"] or 0, 2) - avg_tequila = round(averages["avg_tequila"] or 0, 2) - avg_vivien = round(averages["avg_vivien"] or 0, 2) - - success = request.GET.get("success") == "1" - - context = { - "votes": votes, - "total_votes": total_votes, - "avg_gael": avg_gael, - "avg_charly": avg_charly, - "avg_tequila": avg_tequila, - "avg_vivien": avg_vivien, - "pct_gael": round((avg_gael / 3) * 100, 1) if avg_gael else 0, - "pct_charly": round((avg_charly / 3) * 100, 1) if avg_charly else 0, - "pct_tequila": round((avg_tequila / 3) * 100, 1) if avg_tequila else 0, - "pct_vivien": round((avg_vivien / 3) * 100, 1) if avg_vivien else 0, - "success": success - } - return render(request, "home/flexi_teambuilding_results.html", context) \ No newline at end of file + return JsonResponse({'count': qs.count(), 'incidents': incidents}) \ No newline at end of file