Compare commits
114 Commits
f03c13a4b8
...
app_downlo
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e119e2295c | ||
|
|
37beb8f421 | ||
|
|
cae86bcd46 | ||
|
|
04001202f2 | ||
|
|
af36d1427a | ||
|
|
75a59e0a7a | ||
|
|
af39bf7068 | ||
|
|
4c40566513 | ||
|
|
7c45b59298 | ||
|
|
418268db27 | ||
|
|
73045586a3 | ||
|
|
22d668a75c | ||
|
|
5dfa12fad2 | ||
|
|
5af69f719d | ||
|
|
4f6b1d5b6c | ||
|
|
d4cb464169 | ||
|
|
27a1f36183 | ||
|
|
83c8b9a3d0 | ||
|
|
cb3b34f874 | ||
|
|
0962a3735e | ||
|
|
9907cfbd86 | ||
|
|
ad90887691 | ||
|
|
47d2476b51 | ||
|
|
5d8720cf46 | ||
|
|
8700144dea | ||
|
|
d17ab26f2f | ||
|
|
297f289d7e | ||
|
|
034ad9a4ce | ||
|
|
897d37f74d | ||
|
|
42fb0aa2d6 | ||
|
|
4bc43ec3cb | ||
|
|
00737da69f | ||
|
|
6eb192b823 | ||
|
|
0934b8fa34 | ||
|
|
bcd6444ff2 | ||
|
|
2a638e7b32 | ||
|
|
7633c9ab4b | ||
|
|
bb06206a9b | ||
|
|
55be3c9836 | ||
|
|
2ac19ab7be | ||
|
|
7d359dec13 | ||
|
|
1015a5dba1 | ||
|
|
8f9f650826 | ||
|
|
99a90867cc | ||
|
|
0d69695b00 | ||
|
|
92f6d11cb5 | ||
|
|
1fdb30d7d2 | ||
|
|
6975ed6df6 | ||
|
|
4da87872bd | ||
|
|
c25f6ca2c1 | ||
|
|
4d567cdcc7 | ||
|
|
61057b71ba | ||
|
|
80f28aa771 | ||
|
|
f13a44702a | ||
|
|
85b857976a | ||
|
|
0c259155a8 | ||
|
|
4a9b7c1312 | ||
|
|
74f9c53c18 | ||
|
|
b10b2fb3b6 | ||
|
|
4fa8ef4b56 | ||
|
|
68e5f280b4 | ||
|
|
251bb933da | ||
|
|
4fbbfd2365 | ||
|
|
0ac719b1f6 | ||
|
|
e55a6ae407 | ||
|
|
59a502d624 | ||
|
|
312ab6dac4 | ||
|
|
cf53b480db | ||
|
|
d1aa1edd09 | ||
|
|
d6f9a9c5b0 | ||
|
|
fc0071144e | ||
|
|
573f2d8a22 | ||
|
|
da30382f41 | ||
|
|
8e98d62b69 | ||
|
|
3b7f8b87c4 | ||
|
|
023fc1db84 | ||
|
|
d50bb2134a | ||
|
|
0992a8a7ee | ||
|
|
97597eb103 | ||
|
|
bfa5734d55 | ||
|
|
296d021d54 | ||
|
|
6e348b995b | ||
|
|
12477b33cb | ||
|
|
adc925e4b1 | ||
|
|
8c3ae338ea | ||
|
|
c66cc14576 | ||
|
|
db4d0dd83a | ||
|
|
2af671d61a | ||
|
|
4c3b714b56 | ||
|
|
1274315cde | ||
|
|
4975c1ab6f | ||
|
|
61999a31a5 | ||
|
|
b217f7ceec | ||
|
|
2755a5f7ab | ||
|
|
9ab4df94e6 | ||
|
|
edb6abfff5 | ||
|
|
ea8fcad8b5 | ||
|
|
03c1bb41b6 | ||
|
|
9e700fd3de | ||
|
|
67b936ae98 | ||
|
|
ac56700705 | ||
|
|
f64138605d | ||
|
|
40922843f8 | ||
|
|
57f43a8700 | ||
|
|
a72572ded6 | ||
|
|
e6839a1079 | ||
|
|
ab9abc8520 | ||
|
|
249b797d5a | ||
|
|
65dd42fc97 | ||
|
|
3ebadf34bc | ||
|
|
6f4fbecdd0 | ||
|
|
c7bd733911 | ||
|
|
f6ad6197de | ||
|
|
6c7d86185a |
@@ -32,7 +32,7 @@ class ActivityForm(forms.ModelForm):
|
|||||||
def clean_organizer(self):
|
def clean_organizer(self):
|
||||||
organizer = self.cleaned_data['organizer']
|
organizer = self.cleaned_data['organizer']
|
||||||
if not organizer.note.is_active:
|
if not organizer.note.is_active:
|
||||||
self.add_error('organiser', _('The note of this club is inactive.'))
|
self.add_error('organizer', _('The note of this club is inactive.'))
|
||||||
return organizer
|
return organizer
|
||||||
|
|
||||||
def clean_date_end(self):
|
def clean_date_end(self):
|
||||||
|
|||||||
@@ -37,6 +37,11 @@ SPDX-License-Identifier: GPL-3.0-or-later
|
|||||||
<div id="guests_table">
|
<div id="guests_table">
|
||||||
{% render_table guests %}
|
{% render_table guests %}
|
||||||
</div>
|
</div>
|
||||||
|
<div class="card-footer text-center">
|
||||||
|
<button class="btn btn-block btn-primary mb-3" onclick="window.location.href='?_export=1&table=guests'">
|
||||||
|
{% trans "Export to CSV" %}
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
{% extends "base.html" %}
|
{% extends "base_search.html" %}
|
||||||
{% comment %}
|
{% comment %}
|
||||||
SPDX-License-Identifier: GPL-3.0-or-later
|
SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
{% endcomment %}
|
{% endcomment %}
|
||||||
@@ -44,6 +44,8 @@ SPDX-License-Identifier: GPL-3.0-or-later
|
|||||||
<h3 class="card-header text-center">
|
<h3 class="card-header text-center">
|
||||||
{% trans "All activities" %}
|
{% trans "All activities" %}
|
||||||
</h3>
|
</h3>
|
||||||
{% render_table table %}
|
{% render_table all %}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
{{ block.super }}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
{% comment %}
|
{% comment %}
|
||||||
SPDX-License-Identifier: GPL-3.0-or-later
|
SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
{% endcomment %}
|
{% endcomment %}
|
||||||
{% load i18n perms pretty_money %}
|
{% load i18n perms pretty_money dict_get %}
|
||||||
{% url 'activity:activity_detail' activity.pk as activity_detail_url %}
|
{% url 'activity:activity_detail' activity.pk as activity_detail_url %}
|
||||||
|
|
||||||
<div id="activity_info" class="card bg-light shadow mb-3">
|
<div id="activity_info" class="card bg-light shadow mb-3">
|
||||||
@@ -53,6 +53,12 @@ SPDX-License-Identifier: GPL-3.0-or-later
|
|||||||
<dt class="col-xl-6">{% trans 'opened'|capfirst %}</dt>
|
<dt class="col-xl-6">{% trans 'opened'|capfirst %}</dt>
|
||||||
<dd class="col-xl-6">{{ activity.open|yesno }}</dd>
|
<dd class="col-xl-6">{{ activity.open|yesno }}</dd>
|
||||||
</dl>
|
</dl>
|
||||||
|
{% if show_entries|dict_get:activity %}
|
||||||
|
<h2 class="text-center">
|
||||||
|
{{ entries_count|dict_get:activity }}
|
||||||
|
{% if entries_count|dict_get:activity >= 2 %}{% trans "entries" %}{% else %}{% trans "entry" %}{% endif %}
|
||||||
|
</h2>
|
||||||
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="card-footer text-center">
|
<div class="card-footer text-center">
|
||||||
|
|||||||
0
apps/activity/templatetags/__init__.py
Normal file
12
apps/activity/templatetags/dict_get.py
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
# Copyright (C) 2018-2025 by BDE ENS Paris-Saclay
|
||||||
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
|
||||||
|
from django import template
|
||||||
|
|
||||||
|
|
||||||
|
def dict_get(d, key):
|
||||||
|
return d.get(key)
|
||||||
|
|
||||||
|
|
||||||
|
register = template.Library()
|
||||||
|
register.filter('dict_get', dict_get)
|
||||||
@@ -67,32 +67,65 @@ class ActivityListView(ProtectQuerysetMixin, LoginRequiredMixin, MultiTableMixin
|
|||||||
tables = [
|
tables = [
|
||||||
lambda data: ActivityTable(data, prefix="all-"),
|
lambda data: ActivityTable(data, prefix="all-"),
|
||||||
lambda data: ActivityTable(data, prefix="upcoming-"),
|
lambda data: ActivityTable(data, prefix="upcoming-"),
|
||||||
|
lambda data: ActivityTable(data, prefix="search-"),
|
||||||
]
|
]
|
||||||
extra_context = {"title": _("Activities")}
|
extra_context = {"title": _("Activities")}
|
||||||
|
|
||||||
def get_queryset(self, **kwargs):
|
def get_queryset(self, **kwargs):
|
||||||
return super().get_queryset(**kwargs).distinct()
|
"""
|
||||||
|
Filter the user list with the given pattern.
|
||||||
|
"""
|
||||||
|
return super().get_queryset().distinct()
|
||||||
|
|
||||||
def get_tables_data(self):
|
def get_tables_data(self):
|
||||||
# first table = all activities, second table = upcoming
|
# first table = all activities, second table = upcoming, third table = search
|
||||||
|
|
||||||
|
# table search
|
||||||
|
qs = self.get_queryset().order_by('-date_start')
|
||||||
|
if "search" in self.request.GET and self.request.GET['search']:
|
||||||
|
pattern = self.request.GET['search']
|
||||||
|
|
||||||
|
# check regex
|
||||||
|
valid_regex = is_regex(pattern)
|
||||||
|
suffix = '__iregex' if valid_regex else '__istartswith'
|
||||||
|
prefix = '^' if valid_regex else ''
|
||||||
|
qs = qs.filter(Q(**{f'name{suffix}': prefix + pattern})
|
||||||
|
| Q(**{f'organizer__name{suffix}': prefix + pattern})
|
||||||
|
| Q(**{f'organizer__note__alias__name{suffix}': prefix + pattern}))
|
||||||
|
else:
|
||||||
|
qs = qs.none()
|
||||||
|
search_table = qs.filter(PermissionBackend.filter_queryset(self.request, Activity, 'view'))
|
||||||
|
|
||||||
return [
|
return [
|
||||||
self.get_queryset().order_by("-date_start"),
|
self.get_queryset().order_by("-date_start"),
|
||||||
Activity.objects.filter(date_end__gt=timezone.now())
|
Activity.objects.filter(date_end__gt=timezone.now())
|
||||||
.filter(PermissionBackend.filter_queryset(self.request, Activity, "view"))
|
.filter(PermissionBackend.filter_queryset(self.request, Activity, "view"))
|
||||||
.distinct()
|
.distinct()
|
||||||
.order_by("date_start")
|
.order_by("date_start"),
|
||||||
|
search_table,
|
||||||
]
|
]
|
||||||
|
|
||||||
def get_context_data(self, **kwargs):
|
def get_context_data(self, **kwargs):
|
||||||
context = super().get_context_data(**kwargs)
|
context = super().get_context_data(**kwargs)
|
||||||
|
|
||||||
tables = context["tables"]
|
tables = context["tables"]
|
||||||
for name, table in zip(["table", "upcoming"], tables):
|
for name, table in zip(["all", "upcoming", "table"], tables):
|
||||||
context[name] = table
|
context[name] = table
|
||||||
|
|
||||||
started_activities = self.get_queryset().filter(open=True, valid=True).distinct().all()
|
started_activities = self.get_queryset().filter(open=True, valid=True).distinct().all()
|
||||||
context["started_activities"] = started_activities
|
context["started_activities"] = started_activities
|
||||||
|
|
||||||
|
entries_count = {}
|
||||||
|
show_entries = {}
|
||||||
|
for activity in started_activities:
|
||||||
|
if activity.activity_type.manage_entries:
|
||||||
|
entries = Entry.objects.filter(activity=activity)
|
||||||
|
entries_count[activity] = entries.count()
|
||||||
|
|
||||||
|
show_entries[activity] = True
|
||||||
|
context["entries_count"] = entries_count
|
||||||
|
context["show_entries"] = show_entries
|
||||||
|
|
||||||
return context
|
return context
|
||||||
|
|
||||||
|
|
||||||
@@ -103,12 +136,19 @@ class ActivityDetailView(ProtectQuerysetMixin, LoginRequiredMixin, MultiTableMix
|
|||||||
model = Activity
|
model = Activity
|
||||||
context_object_name = "activity"
|
context_object_name = "activity"
|
||||||
extra_context = {"title": _("Activity detail")}
|
extra_context = {"title": _("Activity detail")}
|
||||||
|
export_formats = ["csv"]
|
||||||
|
|
||||||
tables = [
|
tables = [
|
||||||
lambda data: GuestTable(data, prefix="guests-"),
|
GuestTable,
|
||||||
lambda data: OpenerTable(data, prefix="opener-"),
|
OpenerTable,
|
||||||
]
|
]
|
||||||
|
|
||||||
|
def get_tables(self):
|
||||||
|
tables = super().get_tables()
|
||||||
|
tables[0].prefix = "guests"
|
||||||
|
tables[1].prefix = "opener"
|
||||||
|
return tables
|
||||||
|
|
||||||
def get_tables_data(self):
|
def get_tables_data(self):
|
||||||
return [
|
return [
|
||||||
Guest.objects.filter(activity=self.object)
|
Guest.objects.filter(activity=self.object)
|
||||||
@@ -117,6 +157,51 @@ class ActivityDetailView(ProtectQuerysetMixin, LoginRequiredMixin, MultiTableMix
|
|||||||
.filter(PermissionBackend.filter_queryset(self.request, Opener, "view")),
|
.filter(PermissionBackend.filter_queryset(self.request, Opener, "view")),
|
||||||
]
|
]
|
||||||
|
|
||||||
|
def render_to_response(self, context, **response_kwargs):
|
||||||
|
"""
|
||||||
|
Gère l'export CSV manuel pour MultiTableMixin.
|
||||||
|
"""
|
||||||
|
if "_export" in self.request.GET:
|
||||||
|
import tablib
|
||||||
|
table_name = self.request.GET.get("table")
|
||||||
|
if table_name:
|
||||||
|
tables = self.get_tables()
|
||||||
|
data_list = self.get_tables_data()
|
||||||
|
|
||||||
|
for t, d in zip(tables, data_list):
|
||||||
|
if t.prefix == table_name:
|
||||||
|
# Préparer le CSV
|
||||||
|
dataset = tablib.Dataset()
|
||||||
|
columns = list(t.base_columns) # noms des colonnes
|
||||||
|
dataset.headers = columns
|
||||||
|
|
||||||
|
for row in d:
|
||||||
|
values = []
|
||||||
|
for col in columns:
|
||||||
|
try:
|
||||||
|
val = getattr(row, col, "")
|
||||||
|
# Gestion spéciale pour la colonne 'entry'
|
||||||
|
if col == "entry":
|
||||||
|
if getattr(row, "has_entry", False):
|
||||||
|
val = timezone.localtime(row.entry.time).strftime("%Y-%m-%d %H:%M:%S")
|
||||||
|
else:
|
||||||
|
val = ""
|
||||||
|
values.append(str(val) if val is not None else "")
|
||||||
|
except Exception: # RelatedObjectDoesNotExist ou autre
|
||||||
|
values.append("")
|
||||||
|
dataset.append(values)
|
||||||
|
|
||||||
|
csv_bytes = dataset.export("csv")
|
||||||
|
if isinstance(csv_bytes, str):
|
||||||
|
csv_bytes = csv_bytes.encode("utf-8")
|
||||||
|
|
||||||
|
response = HttpResponse(csv_bytes, content_type="text/csv")
|
||||||
|
response["Content-Disposition"] = f'attachment; filename="{table_name}.csv"'
|
||||||
|
return response
|
||||||
|
|
||||||
|
# Sinon rendu normal
|
||||||
|
return super().render_to_response(context, **response_kwargs)
|
||||||
|
|
||||||
def get_context_data(self, **kwargs):
|
def get_context_data(self, **kwargs):
|
||||||
context = super().get_context_data()
|
context = super().get_context_data()
|
||||||
|
|
||||||
@@ -137,6 +222,14 @@ class ActivityDetailView(ProtectQuerysetMixin, LoginRequiredMixin, MultiTableMix
|
|||||||
"placeholder": ""
|
"placeholder": ""
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if self.object.activity_type.manage_entries:
|
||||||
|
entries = Entry.objects.filter(activity=self.object)
|
||||||
|
context["entries_count"] = {self.object: entries.count()}
|
||||||
|
|
||||||
|
context["show_entries"] = {self.object: timezone.now() > timezone.localtime(self.object.date_start)}
|
||||||
|
else:
|
||||||
|
context["entries_count"] = {self.object: 0}
|
||||||
|
context["show_entries"] = {self.object: False}
|
||||||
|
|
||||||
return context
|
return context
|
||||||
|
|
||||||
|
|||||||
@@ -19,6 +19,10 @@ if "activity" in settings.INSTALLED_APPS:
|
|||||||
from activity.api.urls import register_activity_urls
|
from activity.api.urls import register_activity_urls
|
||||||
register_activity_urls(router, 'activity')
|
register_activity_urls(router, 'activity')
|
||||||
|
|
||||||
|
if "family" in settings.INSTALLED_APPS:
|
||||||
|
from family.api.urls import register_family_urls
|
||||||
|
register_family_urls(router, 'family')
|
||||||
|
|
||||||
if "food" in settings.INSTALLED_APPS:
|
if "food" in settings.INSTALLED_APPS:
|
||||||
from food.api.urls import register_food_urls
|
from food.api.urls import register_food_urls
|
||||||
register_food_urls(router, 'food')
|
register_food_urls(router, 'food')
|
||||||
|
|||||||
0
apps/family/__init__.py
Normal file
0
apps/family/api/__init__.py
Normal file
46
apps/family/api/serializers.py
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
# Copyright (C) 2018-2025 by BDE ENS Paris-Saclay
|
||||||
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
|
||||||
|
from rest_framework import serializers
|
||||||
|
|
||||||
|
from ..models import Family, FamilyMembership, Challenge, Achievement
|
||||||
|
|
||||||
|
|
||||||
|
class FamilySerializer(serializers.ModelSerializer):
|
||||||
|
"""
|
||||||
|
REST API Serializer for Family.
|
||||||
|
The djangorestframework plugin will analyse the model `Family` and parse all fields in the API.
|
||||||
|
"""
|
||||||
|
class Meta:
|
||||||
|
model = Family
|
||||||
|
fields = '__all__'
|
||||||
|
|
||||||
|
|
||||||
|
class FamilyMembershipSerializer(serializers.ModelSerializer):
|
||||||
|
"""
|
||||||
|
REST API Serializer for FamilyMembership.
|
||||||
|
The djangorestframework plugin will analyse the model `FamilyMembership` and parse all fields in the API.
|
||||||
|
"""
|
||||||
|
class Meta:
|
||||||
|
model = FamilyMembership
|
||||||
|
fields = '__all__'
|
||||||
|
|
||||||
|
|
||||||
|
class ChallengeSerializer(serializers.ModelSerializer):
|
||||||
|
"""
|
||||||
|
REST API Serializer for Challenge.
|
||||||
|
The djangorestframework plugin will analyse the model `Challenge` and parse all fields in the API.
|
||||||
|
"""
|
||||||
|
class Meta:
|
||||||
|
model = Challenge
|
||||||
|
fields = '__all__'
|
||||||
|
|
||||||
|
|
||||||
|
class AchievementSerializer(serializers.ModelSerializer):
|
||||||
|
"""
|
||||||
|
REST API Serializer for Achievement.
|
||||||
|
The djangorestframework plugin will analyse the model `Achievement` and parse all fields in the API.
|
||||||
|
"""
|
||||||
|
class Meta:
|
||||||
|
model = Achievement
|
||||||
|
fields = '__all__'
|
||||||
20
apps/family/api/urls.py
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
# Copyright (C) 2018-2025 by BDE ENS Paris-Saclay
|
||||||
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
from django.urls import path
|
||||||
|
|
||||||
|
from .views import FamilyViewSet, FamilyMembershipViewSet, ChallengeViewSet, AchievementViewSet, BatchAchievementsAPIView
|
||||||
|
|
||||||
|
|
||||||
|
def register_family_urls(router, path):
|
||||||
|
"""
|
||||||
|
Configure router for Family REST API
|
||||||
|
"""
|
||||||
|
router.register(path + '/family', FamilyViewSet)
|
||||||
|
router.register(path + '/familymembership', FamilyMembershipViewSet)
|
||||||
|
router.register(path + '/challenge', ChallengeViewSet)
|
||||||
|
router.register(path + '/achievement', AchievementViewSet)
|
||||||
|
|
||||||
|
|
||||||
|
urlpatterns = [
|
||||||
|
path('achievements/batch/', BatchAchievementsAPIView.as_view(), name='batch_achievements')
|
||||||
|
]
|
||||||
98
apps/family/api/views.py
Normal file
@@ -0,0 +1,98 @@
|
|||||||
|
# Copyright (C) 2018-2025 by BDE ENS Paris-Saclay
|
||||||
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
|
||||||
|
from api.viewsets import ReadProtectedModelViewSet
|
||||||
|
from django_filters.rest_framework import DjangoFilterBackend
|
||||||
|
from api.filters import RegexSafeSearchFilter
|
||||||
|
from rest_framework.views import APIView
|
||||||
|
from rest_framework.permissions import IsAuthenticated
|
||||||
|
from rest_framework.response import Response
|
||||||
|
from rest_framework import status
|
||||||
|
|
||||||
|
from .serializers import FamilySerializer, FamilyMembershipSerializer, ChallengeSerializer, AchievementSerializer
|
||||||
|
from ..models import Family, FamilyMembership, Challenge, Achievement
|
||||||
|
|
||||||
|
|
||||||
|
class FamilyViewSet(ReadProtectedModelViewSet):
|
||||||
|
"""
|
||||||
|
REST API View set.
|
||||||
|
The djangorestframework plugin will get all `Family` objects, serialize it to JSON with the given serializer,
|
||||||
|
then render it on /api/family/family/
|
||||||
|
"""
|
||||||
|
queryset = Family.objects.order_by('id')
|
||||||
|
serializer_class = FamilySerializer
|
||||||
|
filter_backends = [DjangoFilterBackend, RegexSafeSearchFilter]
|
||||||
|
filterset_fields = ['name', 'description', 'score', 'rank', ]
|
||||||
|
search_fields = ['$name', '$description', ]
|
||||||
|
|
||||||
|
|
||||||
|
class FamilyMembershipViewSet(ReadProtectedModelViewSet):
|
||||||
|
"""
|
||||||
|
REST API View set.
|
||||||
|
The djangorestframework plugin will get all `FamilyMembership` objects, serialize it to JSON with the given serializer,
|
||||||
|
then render it on /api/family/familymembership/
|
||||||
|
"""
|
||||||
|
queryset = FamilyMembership.objects.order_by('id')
|
||||||
|
serializer_class = FamilyMembershipSerializer
|
||||||
|
filter_backends = [DjangoFilterBackend, RegexSafeSearchFilter]
|
||||||
|
filterset_fields = ['user__username', 'user__first_name', 'user__last_name', 'user__email', 'user__note__alias__name',
|
||||||
|
'user__note__alias__normalized_name', 'family__name', 'family__description', 'year', ]
|
||||||
|
search_fields = ['$user__username', '$user__first_name', '$user__last_name', '$user__email', '$user__note__alias__name',
|
||||||
|
'$user__note__alias__normalized_name', '$family__name', '$family__description', '$year', ]
|
||||||
|
|
||||||
|
|
||||||
|
class ChallengeViewSet(ReadProtectedModelViewSet):
|
||||||
|
"""
|
||||||
|
REST API View set.
|
||||||
|
The djangorestframework plugin will get all `Challenge` objects, serialize it to JSON with the given serializer,
|
||||||
|
then render it on /api/family/challenge/
|
||||||
|
"""
|
||||||
|
queryset = Challenge.objects.order_by('id')
|
||||||
|
serializer_class = ChallengeSerializer
|
||||||
|
filter_backends = [DjangoFilterBackend, RegexSafeSearchFilter]
|
||||||
|
filterset_fields = ['name', 'description', 'points', ]
|
||||||
|
search_fields = ['$name', '$description', '$points', ]
|
||||||
|
|
||||||
|
|
||||||
|
class AchievementViewSet(ReadProtectedModelViewSet):
|
||||||
|
"""
|
||||||
|
REST API View set.
|
||||||
|
The djangorestframework plugin will get all `Achievement` objects, serialize it to JSON with the given serializer,
|
||||||
|
then render it on /api/family/achievement/
|
||||||
|
"""
|
||||||
|
queryset = Achievement.objects.order_by('id')
|
||||||
|
serializer_class = AchievementSerializer
|
||||||
|
filter_backends = [DjangoFilterBackend, RegexSafeSearchFilter]
|
||||||
|
filterset_fields = ['family__name', 'family__description', 'challenge__name', 'challenge__description', 'obtained_at', 'valid', ]
|
||||||
|
search_fields = ['$family__name', '$family__description', '$challenge__name', '$challenge__description', ]
|
||||||
|
|
||||||
|
|
||||||
|
class BatchAchievementsAPIView(APIView):
|
||||||
|
permission_classes = [IsAuthenticated]
|
||||||
|
|
||||||
|
def post(self, request, format=None):
|
||||||
|
family_ids = request.data.get('families')
|
||||||
|
challenge_ids = request.data.get('challenges')
|
||||||
|
families = Family.objects.filter(id__in=family_ids)
|
||||||
|
challenges = Challenge.objects.filter(id__in=challenge_ids)
|
||||||
|
results = []
|
||||||
|
for family in families:
|
||||||
|
for challenge in challenges:
|
||||||
|
a, created = Achievement.objects.get_or_create(family=family, challenge=challenge)
|
||||||
|
if created:
|
||||||
|
results.append({
|
||||||
|
'family': family.name,
|
||||||
|
'challenge': challenge.name,
|
||||||
|
'status': 'created'
|
||||||
|
})
|
||||||
|
else:
|
||||||
|
results.append({
|
||||||
|
'family': family.name,
|
||||||
|
'challenge': challenge.name,
|
||||||
|
'status': 'existed',
|
||||||
|
})
|
||||||
|
for family in families:
|
||||||
|
family.update_score()
|
||||||
|
Family.update_ranking()
|
||||||
|
|
||||||
|
return Response({'results': results}, status=status.HTTP_201_CREATED)
|
||||||
11
apps/family/apps.py
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
# Copyright (C) 2018-2025 by BDE ENS Paris-Saclay
|
||||||
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
|
||||||
|
|
||||||
|
from django.utils.translation import gettext_lazy as _
|
||||||
|
from django.apps import AppConfig
|
||||||
|
|
||||||
|
|
||||||
|
class FamilyConfig(AppConfig):
|
||||||
|
name = 'family'
|
||||||
|
verbose_name = _('family')
|
||||||
44
apps/family/forms.py
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
# Copyright (C) 2018-2025 by BDE ENS Paris-Saclay
|
||||||
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
|
||||||
|
from django import forms
|
||||||
|
from django.forms.widgets import NumberInput
|
||||||
|
from note_kfet.inputs import Autocomplete
|
||||||
|
|
||||||
|
from .models import Challenge, FamilyMembership, User, Family
|
||||||
|
|
||||||
|
|
||||||
|
class ChallengeForm(forms.ModelForm):
|
||||||
|
"""
|
||||||
|
To update a challenge
|
||||||
|
"""
|
||||||
|
class Meta:
|
||||||
|
model = Challenge
|
||||||
|
fields = ('name', 'description', 'points',)
|
||||||
|
widgets = {
|
||||||
|
"points": NumberInput()
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
class FamilyForm(forms.ModelForm):
|
||||||
|
class Meta:
|
||||||
|
model = Family
|
||||||
|
fields = ('name', 'description', )
|
||||||
|
|
||||||
|
|
||||||
|
class FamilyMembershipForm(forms.ModelForm):
|
||||||
|
class Meta:
|
||||||
|
model = FamilyMembership
|
||||||
|
fields = ('user', )
|
||||||
|
|
||||||
|
widgets = {
|
||||||
|
"user":
|
||||||
|
Autocomplete(
|
||||||
|
User,
|
||||||
|
attrs={
|
||||||
|
'api_url': '/api/user/',
|
||||||
|
'name_field': 'username',
|
||||||
|
'placeholder': 'Nom ...',
|
||||||
|
},
|
||||||
|
)
|
||||||
|
}
|
||||||
73
apps/family/migrations/0001_initial.py
Normal file
@@ -0,0 +1,73 @@
|
|||||||
|
# Generated by Django 4.2.21 on 2025-07-06 16:07
|
||||||
|
|
||||||
|
from django.conf import settings
|
||||||
|
from django.db import migrations, models
|
||||||
|
import django.db.models.deletion
|
||||||
|
import django.utils.timezone
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
initial = True
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.CreateModel(
|
||||||
|
name='Challenge',
|
||||||
|
fields=[
|
||||||
|
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||||
|
('name', models.CharField(max_length=255, verbose_name='name')),
|
||||||
|
('description', models.CharField(max_length=255, verbose_name='description')),
|
||||||
|
('points', models.PositiveIntegerField(verbose_name='points')),
|
||||||
|
('obtained', models.PositiveIntegerField(default=0, verbose_name='obtained')),
|
||||||
|
],
|
||||||
|
options={
|
||||||
|
'verbose_name': 'challenge',
|
||||||
|
'verbose_name_plural': 'challenges',
|
||||||
|
},
|
||||||
|
),
|
||||||
|
migrations.CreateModel(
|
||||||
|
name='Family',
|
||||||
|
fields=[
|
||||||
|
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||||
|
('name', models.CharField(max_length=255, unique=True, verbose_name='name')),
|
||||||
|
('description', models.CharField(max_length=255, verbose_name='description')),
|
||||||
|
('score', models.PositiveIntegerField(default=0, verbose_name='score')),
|
||||||
|
('rank', models.PositiveIntegerField(verbose_name='rank')),
|
||||||
|
],
|
||||||
|
options={
|
||||||
|
'verbose_name': 'Family',
|
||||||
|
'verbose_name_plural': 'Families',
|
||||||
|
},
|
||||||
|
),
|
||||||
|
migrations.CreateModel(
|
||||||
|
name='Achievement',
|
||||||
|
fields=[
|
||||||
|
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||||
|
('obtained_at', models.DateTimeField(default=django.utils.timezone.now, verbose_name='obtained at')),
|
||||||
|
('challenge', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='family.challenge')),
|
||||||
|
('family', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='family.family', verbose_name='family')),
|
||||||
|
],
|
||||||
|
options={
|
||||||
|
'verbose_name': 'achievement',
|
||||||
|
'verbose_name_plural': 'achievements',
|
||||||
|
},
|
||||||
|
),
|
||||||
|
migrations.CreateModel(
|
||||||
|
name='FamilyMembership',
|
||||||
|
fields=[
|
||||||
|
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||||
|
('year', models.PositiveIntegerField(default=2025, verbose_name='year')),
|
||||||
|
('family', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name='members', to='family.family', verbose_name='family')),
|
||||||
|
('user', models.OneToOneField(on_delete=django.db.models.deletion.PROTECT, related_name='family_memberships', to=settings.AUTH_USER_MODEL, verbose_name='user')),
|
||||||
|
],
|
||||||
|
options={
|
||||||
|
'verbose_name': 'family membership',
|
||||||
|
'verbose_name_plural': 'family memberships',
|
||||||
|
'unique_together': {('user', 'year')},
|
||||||
|
},
|
||||||
|
),
|
||||||
|
]
|
||||||
18
apps/family/migrations/0002_family_display_image.py
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
# Generated by Django 4.2.23 on 2025-07-17 15:28
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('family', '0001_initial'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='family',
|
||||||
|
name='display_image',
|
||||||
|
field=models.ImageField(default='pic/default.png', max_length=255, upload_to='pic/', verbose_name='display image'),
|
||||||
|
),
|
||||||
|
]
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
# Generated by Django 5.2.4 on 2025-07-21 21:02
|
||||||
|
|
||||||
|
import django.db.models.deletion
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('family', '0002_family_display_image'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='achievement',
|
||||||
|
name='valid',
|
||||||
|
field=models.BooleanField(default=False, verbose_name='valid'),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='familymembership',
|
||||||
|
name='family',
|
||||||
|
field=models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name='memberships', to='family.family', verbose_name='family'),
|
||||||
|
),
|
||||||
|
]
|
||||||
17
apps/family/migrations/0004_remove_challenge_obtained.py
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
# Generated by Django 5.2.4 on 2025-07-22 14:33
|
||||||
|
|
||||||
|
from django.db import migrations
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('family', '0003_achievement_valid_alter_familymembership_family'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.RemoveField(
|
||||||
|
model_name='challenge',
|
||||||
|
name='obtained',
|
||||||
|
),
|
||||||
|
]
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
# Generated by Django 5.2.4 on 2025-08-13 20:26
|
||||||
|
|
||||||
|
from django.db import migrations
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('family', '0004_remove_challenge_obtained'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AlterUniqueTogether(
|
||||||
|
name='achievement',
|
||||||
|
unique_together={('challenge', 'family')},
|
||||||
|
),
|
||||||
|
]
|
||||||
0
apps/family/migrations/__init__.py
Normal file
207
apps/family/models.py
Normal file
@@ -0,0 +1,207 @@
|
|||||||
|
# Copyright (C) 2018-2025 by BDE ENS Paris-Saclay
|
||||||
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
|
||||||
|
from django.db import models, transaction
|
||||||
|
from django.utils import timezone
|
||||||
|
from django.contrib.auth.models import User
|
||||||
|
from django.urls import reverse_lazy
|
||||||
|
from django.utils.translation import gettext_lazy as _
|
||||||
|
|
||||||
|
|
||||||
|
class Family(models.Model):
|
||||||
|
name = models.CharField(
|
||||||
|
max_length=255,
|
||||||
|
verbose_name=_('name'),
|
||||||
|
unique=True,
|
||||||
|
)
|
||||||
|
|
||||||
|
description = models.CharField(
|
||||||
|
max_length=255,
|
||||||
|
verbose_name=_('description'),
|
||||||
|
)
|
||||||
|
|
||||||
|
score = models.PositiveIntegerField(
|
||||||
|
verbose_name=_('score'),
|
||||||
|
default=0,
|
||||||
|
)
|
||||||
|
|
||||||
|
rank = models.PositiveIntegerField(
|
||||||
|
verbose_name=_('rank'),
|
||||||
|
)
|
||||||
|
|
||||||
|
display_image = models.ImageField(
|
||||||
|
verbose_name=_('display image'),
|
||||||
|
max_length=255,
|
||||||
|
blank=False,
|
||||||
|
null=False,
|
||||||
|
upload_to='pic/',
|
||||||
|
default='pic/default.png'
|
||||||
|
)
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
verbose_name = _('Family')
|
||||||
|
verbose_name_plural = _('Families')
|
||||||
|
|
||||||
|
def __str__(self):
|
||||||
|
return self.name
|
||||||
|
|
||||||
|
def get_absolute_url(self):
|
||||||
|
return reverse_lazy('family:family_detail', args=(self.pk,))
|
||||||
|
|
||||||
|
def update_score(self, *args, **kwargs):
|
||||||
|
challenge_set = Challenge.objects.select_for_update().filter(achievement__family=self, achievement__valid=True)
|
||||||
|
points_sum = challenge_set.aggregate(models.Sum("points"))
|
||||||
|
self.score = points_sum["points__sum"] if points_sum["points__sum"] else 0
|
||||||
|
self.save()
|
||||||
|
self.update_ranking()
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def update_ranking(*args, **kwargs):
|
||||||
|
"""
|
||||||
|
Update ranking when adding or removing points
|
||||||
|
"""
|
||||||
|
family_set = Family.objects.select_for_update().all().order_by("-score")
|
||||||
|
for i in range(family_set.count()):
|
||||||
|
if i == 0 or family_set[i].score != family_set[i - 1].score:
|
||||||
|
new_rank = i + 1
|
||||||
|
family = family_set[i]
|
||||||
|
family.rank = new_rank
|
||||||
|
family._force_save = True
|
||||||
|
family.save()
|
||||||
|
|
||||||
|
def save(self, *args, **kwargs):
|
||||||
|
if self.rank is None:
|
||||||
|
last_family = Family.objects.order_by("rank").last()
|
||||||
|
if last_family is None or last_family.score > self.score:
|
||||||
|
self.rank = Family.objects.count() + 1
|
||||||
|
else:
|
||||||
|
self.rank = last_family.rank
|
||||||
|
super().save(*args, **kwargs)
|
||||||
|
|
||||||
|
|
||||||
|
class FamilyMembership(models.Model):
|
||||||
|
user = models.OneToOneField(
|
||||||
|
User,
|
||||||
|
on_delete=models.PROTECT,
|
||||||
|
related_name=_('family_memberships'),
|
||||||
|
verbose_name=_('user'),
|
||||||
|
)
|
||||||
|
|
||||||
|
family = models.ForeignKey(
|
||||||
|
Family,
|
||||||
|
on_delete=models.PROTECT,
|
||||||
|
related_name=_('memberships'),
|
||||||
|
verbose_name=_('family'),
|
||||||
|
)
|
||||||
|
|
||||||
|
year = models.PositiveIntegerField(
|
||||||
|
verbose_name=_('year'),
|
||||||
|
default=timezone.now().year,
|
||||||
|
)
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
unique_together = ('user', 'year',)
|
||||||
|
verbose_name = _('family membership')
|
||||||
|
verbose_name_plural = _('family memberships')
|
||||||
|
|
||||||
|
def __str__(self):
|
||||||
|
return _('Family membership of {user} to {family}').format(user=self.user.username, family=self.family.name, )
|
||||||
|
|
||||||
|
|
||||||
|
class Challenge(models.Model):
|
||||||
|
name = models.CharField(
|
||||||
|
max_length=255,
|
||||||
|
verbose_name=_('name'),
|
||||||
|
)
|
||||||
|
|
||||||
|
description = models.CharField(
|
||||||
|
max_length=255,
|
||||||
|
verbose_name=_('description'),
|
||||||
|
)
|
||||||
|
|
||||||
|
points = models.PositiveIntegerField(
|
||||||
|
verbose_name=_('points'),
|
||||||
|
)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def obtained(self):
|
||||||
|
achievements = Achievement.objects.filter(challenge=self, valid=True)
|
||||||
|
return achievements.count()
|
||||||
|
|
||||||
|
def __str__(self):
|
||||||
|
return self.name
|
||||||
|
|
||||||
|
def get_absolute_url(self):
|
||||||
|
return reverse_lazy('family:challenge_detail', args=(self.pk,))
|
||||||
|
|
||||||
|
@transaction.atomic
|
||||||
|
def save(self, *args, **kwargs):
|
||||||
|
super().save(*args, **kwargs)
|
||||||
|
# Update families who already obtained this challenge
|
||||||
|
achievements = Achievement.objects.filter(challenge=self)
|
||||||
|
for achievement in achievements:
|
||||||
|
achievement.save()
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
verbose_name = _('challenge')
|
||||||
|
verbose_name_plural = _('challenges')
|
||||||
|
|
||||||
|
|
||||||
|
class Achievement(models.Model):
|
||||||
|
challenge = models.ForeignKey(
|
||||||
|
Challenge,
|
||||||
|
on_delete=models.PROTECT,
|
||||||
|
|
||||||
|
)
|
||||||
|
family = models.ForeignKey(
|
||||||
|
Family,
|
||||||
|
on_delete=models.PROTECT,
|
||||||
|
verbose_name=_('family'),
|
||||||
|
)
|
||||||
|
|
||||||
|
obtained_at = models.DateTimeField(
|
||||||
|
verbose_name=_('obtained at'),
|
||||||
|
default=timezone.now,
|
||||||
|
)
|
||||||
|
|
||||||
|
valid = models.BooleanField(
|
||||||
|
verbose_name=_('valid'),
|
||||||
|
default=False,
|
||||||
|
)
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
unique_together = ('challenge', 'family',)
|
||||||
|
verbose_name = _('achievement')
|
||||||
|
verbose_name_plural = _('achievements')
|
||||||
|
|
||||||
|
def __str__(self):
|
||||||
|
return _('Challenge {challenge} carried out by Family {family}').format(challenge=self.challenge.name, family=self.family.name, )
|
||||||
|
|
||||||
|
@transaction.atomic
|
||||||
|
def save(self, *args, update_score=True, **kwargs):
|
||||||
|
"""
|
||||||
|
When saving, also grants points to the family
|
||||||
|
"""
|
||||||
|
self.family = Family.objects.select_for_update().get(pk=self.family_id)
|
||||||
|
self.challenge = Challenge.objects.select_for_update().get(pk=self.challenge_id)
|
||||||
|
|
||||||
|
super().save(*args, **kwargs)
|
||||||
|
|
||||||
|
if update_score:
|
||||||
|
self.family.refresh_from_db()
|
||||||
|
self.family.update_score()
|
||||||
|
|
||||||
|
@transaction.atomic
|
||||||
|
def delete(self, *args, **kwargs):
|
||||||
|
"""
|
||||||
|
When deleting, also removes points from the family
|
||||||
|
"""
|
||||||
|
# Get the family and challenge before deletion
|
||||||
|
self.family = Family.objects.select_for_update().get(pk=self.family_id)
|
||||||
|
|
||||||
|
# Delete the achievement
|
||||||
|
super().delete(*args, **kwargs)
|
||||||
|
|
||||||
|
# Remove points from the family
|
||||||
|
self.family.refresh_from_db()
|
||||||
|
self.family.update_score()
|
||||||
BIN
apps/family/static/family/img/default_picture.png
Normal file
|
After Width: | Height: | Size: 4.0 KiB |
411
apps/family/static/family/js/achievements.js
Normal file
@@ -0,0 +1,411 @@
|
|||||||
|
// Copyright (C) 2018-2025 by BDE ENS Paris-Saclay
|
||||||
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
|
||||||
|
// When a transaction is performed, lock the interface to prevent spam clicks.
|
||||||
|
var LOCK = false
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Refresh the history table on the consumptions page.
|
||||||
|
*/
|
||||||
|
function refreshHistory () {
|
||||||
|
$('#history').load('/family/manage/ #history')
|
||||||
|
}
|
||||||
|
|
||||||
|
$(document).ready(function () {
|
||||||
|
// If hash of a category in the URL, then select this category
|
||||||
|
// else select the first one
|
||||||
|
if (location.hash) {
|
||||||
|
$("a[href='" + location.hash + "']").tab('show')
|
||||||
|
} else {
|
||||||
|
$("a[data-toggle='tab']").first().tab('show')
|
||||||
|
}
|
||||||
|
|
||||||
|
// When selecting a category, change URL
|
||||||
|
$(document.body).on('click', "a[data-toggle='tab']", function () {
|
||||||
|
location.hash = this.getAttribute('href')
|
||||||
|
})
|
||||||
|
|
||||||
|
})
|
||||||
|
|
||||||
|
notes = []
|
||||||
|
notes_display = []
|
||||||
|
buttons = []
|
||||||
|
|
||||||
|
// When the user searches an alias, we update the auto-completion
|
||||||
|
autoCompleteFamily('note', 'note_list', notes, notes_display,
|
||||||
|
'note', 'user_note', 'profile_pic', function () {
|
||||||
|
return true
|
||||||
|
})
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add a transaction from a button.
|
||||||
|
* @param fam Where the money goes
|
||||||
|
* @param amount The price of the item
|
||||||
|
* @param type The type of the transaction (content type id for RecurrentTransaction)
|
||||||
|
* @param category_id The category identifier
|
||||||
|
* @param category_name The category name
|
||||||
|
* @param template_id The identifier of the button
|
||||||
|
* @param template_name The name of the button
|
||||||
|
*/
|
||||||
|
function addChallenge (id, name, amount) {
|
||||||
|
var challenge = null
|
||||||
|
/** Ajout de 1 à chaque clic d'un bouton déjà choisi */
|
||||||
|
buttons.forEach(function (b) {
|
||||||
|
if (b.id === id) {
|
||||||
|
challenge = b
|
||||||
|
}
|
||||||
|
})
|
||||||
|
if (challenge == null) {
|
||||||
|
challenge = {
|
||||||
|
id: id,
|
||||||
|
name: name,
|
||||||
|
}
|
||||||
|
buttons.push(challenge)
|
||||||
|
}
|
||||||
|
|
||||||
|
const dc_obj = true
|
||||||
|
|
||||||
|
const list = 'consos_list'
|
||||||
|
let html = ''
|
||||||
|
buttons.forEach(function (challenge) {
|
||||||
|
html += li('conso_button_' + challenge.id, challenge.name)
|
||||||
|
})
|
||||||
|
document.getElementById(list).innerHTML = html
|
||||||
|
|
||||||
|
buttons.forEach((button) => {
|
||||||
|
document.getElementById(`conso_button_${button.id}`).addEventListener('click', () => {
|
||||||
|
if (LOCK) { return }
|
||||||
|
removeNote(button, 'conso_button', buttons, list)()
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reset the page as its initial state.
|
||||||
|
*/
|
||||||
|
function reset () {
|
||||||
|
notes_display.length = 0
|
||||||
|
notes.length = 0
|
||||||
|
buttons.length = 0
|
||||||
|
document.getElementById('note_list').innerHTML = ''
|
||||||
|
document.getElementById('consos_list').innerHTML = ''
|
||||||
|
document.getElementById('note').value = ''
|
||||||
|
document.getElementById('note').dataset.originTitle = ''
|
||||||
|
$('#note').tooltip('hide')
|
||||||
|
document.getElementById('profile_pic').src = '/static/member/img/default_picture.png'
|
||||||
|
document.getElementById('profile_pic_link').href = '#'
|
||||||
|
refreshHistory()
|
||||||
|
LOCK = false
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Apply all transactions: all notes in `notes` buy each item in `buttons`
|
||||||
|
*/
|
||||||
|
function consumeAll () {
|
||||||
|
if (LOCK) { return }
|
||||||
|
LOCK = true
|
||||||
|
|
||||||
|
let error = false
|
||||||
|
|
||||||
|
if (notes_display.length === 0) {
|
||||||
|
// ... gestion erreur ...
|
||||||
|
error = true
|
||||||
|
}
|
||||||
|
if (buttons.length === 0) {
|
||||||
|
// ... gestion erreur ...
|
||||||
|
error = true
|
||||||
|
}
|
||||||
|
if (error) {
|
||||||
|
LOCK = false
|
||||||
|
return
|
||||||
|
}
|
||||||
|
// Récupérer les IDs des familles et des challenges
|
||||||
|
const family_ids = notes_display.map(fam => fam.id)
|
||||||
|
const challenge_ids = buttons.map(chal => chal.id)
|
||||||
|
|
||||||
|
$.ajax({
|
||||||
|
url: '/family/api/family/achievements/batch/',
|
||||||
|
type: 'POST',
|
||||||
|
data: JSON.stringify({
|
||||||
|
families: family_ids,
|
||||||
|
challenges: challenge_ids
|
||||||
|
}),
|
||||||
|
contentType: 'application/json',
|
||||||
|
headers: {
|
||||||
|
'X-CSRFToken': CSRF_TOKEN
|
||||||
|
},
|
||||||
|
success: function (data) {
|
||||||
|
reset()
|
||||||
|
data.results.forEach(function (result) {
|
||||||
|
if (result.status === 'created') {
|
||||||
|
addMsg(
|
||||||
|
interpolate(gettext('Invalid achievement for challenge %s ' +
|
||||||
|
'and family %s created.'), [result.challenge, result.family]),
|
||||||
|
'success',
|
||||||
|
5000
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
addMsg(
|
||||||
|
interpolate(gettext('An achievement for challenge %s ' +
|
||||||
|
'and family %s already exists.'), [result.challenge, result.family]),
|
||||||
|
'danger',
|
||||||
|
8000
|
||||||
|
)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
var searchbar = document.getElementById("search-input")
|
||||||
|
var search_results = document.getElementById("search-results")
|
||||||
|
|
||||||
|
var old_pattern = null;
|
||||||
|
var firstMatch = null;
|
||||||
|
/**
|
||||||
|
* Updates the button search tab
|
||||||
|
* @param force Forces the update even if the pattern didn't change
|
||||||
|
*/
|
||||||
|
function updateSearch(force = false) {
|
||||||
|
let pattern = searchbar.value
|
||||||
|
if (pattern === "")
|
||||||
|
firstMatch = null;
|
||||||
|
if ((pattern === old_pattern || pattern === "") && !force)
|
||||||
|
return;
|
||||||
|
firstMatch = null;
|
||||||
|
const re = new RegExp(pattern, "i");
|
||||||
|
Array.from(search_results.children).forEach(function(b) {
|
||||||
|
if (re.test(b.innerText)) {
|
||||||
|
b.hidden = false;
|
||||||
|
if (firstMatch === null) {
|
||||||
|
firstMatch = b;
|
||||||
|
}
|
||||||
|
} else
|
||||||
|
b.hidden = true;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
searchbar.addEventListener("input", function (e) {
|
||||||
|
debounce(updateSearch)()
|
||||||
|
});
|
||||||
|
searchbar.addEventListener("keyup", function (e) {
|
||||||
|
if (firstMatch && e.key === "Enter")
|
||||||
|
firstMatch.click()
|
||||||
|
});
|
||||||
|
|
||||||
|
function createshiny() {
|
||||||
|
const list_btn = document.querySelectorAll('.btn-outline-dark')
|
||||||
|
const shiny_class = list_btn[Math.floor(Math.random() * list_btn.length)].classList
|
||||||
|
shiny_class.replace('btn-outline-dark', 'btn-outline-dark-shiny')
|
||||||
|
}
|
||||||
|
createshiny()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Query the 20 first matched notes with a given pattern
|
||||||
|
* @param pattern The pattern that is queried
|
||||||
|
* @param fun For each found note with the matched alias `alias`, fun(note, alias) is called.
|
||||||
|
*/
|
||||||
|
function getMatchedFamilies (pattern, fun) {
|
||||||
|
$.getJSON('/api/family/family/?format=json&alias=' + pattern + '&search=family', fun)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Generate a <li> entry with a given id and text
|
||||||
|
*/
|
||||||
|
function li (id, text, extra_css) {
|
||||||
|
return '<li class="list-group-item py-1 px-2 d-flex justify-content-between align-items-center text-truncate ' +
|
||||||
|
(extra_css || '') + '"' + ' id="' + id + '">' + text + '</li>\n'
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Génère un champ d'auto-complétion pour rechercher une famille par son nom (version simplifiée sans alias)
|
||||||
|
* @param field_id L'identifiant du champ texte où le nom est saisi
|
||||||
|
* @param family_list_id L'identifiant du bloc div où les familles sélectionnées sont affichées
|
||||||
|
* @param families Un tableau contenant les objets famille sélectionnés
|
||||||
|
* @param families_display Un tableau contenant les infos des familles sélectionnées : [nom, id, objet famille, quantité]
|
||||||
|
* @param family_prefix Le préfixe des <li> pour les familles sélectionnées
|
||||||
|
* @param user_family_field L'identifiant du champ qui affiche la famille survolée (optionnel)
|
||||||
|
* @param profile_pic_field L'identifiant du champ qui affiche la photo de la famille survolée (optionnel)
|
||||||
|
* @param family_click Fonction appelée lors du clic sur un nom. Si elle existe et ne retourne pas true, la famille n'est pas affichée.
|
||||||
|
*/
|
||||||
|
function autoCompleteFamily(field_id, family_list_id, families, families_display, family_prefix = 'family', user_family_field = null, profile_pic_field = null, family_click = null) {
|
||||||
|
const field = $('#' + field_id)
|
||||||
|
// Configuration du tooltip
|
||||||
|
field.tooltip({
|
||||||
|
html: true,
|
||||||
|
placement: 'bottom',
|
||||||
|
title: 'Chargement...',
|
||||||
|
trigger: 'manual',
|
||||||
|
container: field.parent(),
|
||||||
|
fallbackPlacement: 'clockwise'
|
||||||
|
})
|
||||||
|
|
||||||
|
// Masquer le tooltip lors d'un clic ailleurs
|
||||||
|
$(document).click(function (e) {
|
||||||
|
if (!e.target.id.startsWith(family_prefix)) {
|
||||||
|
field.tooltip('hide')
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
let old_pattern = null
|
||||||
|
|
||||||
|
// Réinitialiser la recherche au clic
|
||||||
|
field.click(function () {
|
||||||
|
field.tooltip('hide')
|
||||||
|
field.removeClass('is-invalid')
|
||||||
|
field.val('')
|
||||||
|
old_pattern = ''
|
||||||
|
})
|
||||||
|
|
||||||
|
// Sur "Entrée", sélectionner la première famille
|
||||||
|
field.keypress(function (event) {
|
||||||
|
if (event.originalEvent.charCode === 13 && families.length > 0) {
|
||||||
|
const li_obj = field.parent().find('ul li').first()
|
||||||
|
displayFamily(families[0], families[0].name, user_family_field, profile_pic_field)
|
||||||
|
li_obj.trigger('click')
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
// Mise à jour des suggestions lors de la saisie
|
||||||
|
field.keyup(function (e) {
|
||||||
|
field.removeClass('is-invalid')
|
||||||
|
|
||||||
|
if (e.originalEvent.charCode === 13) { return }
|
||||||
|
|
||||||
|
const pattern = field.val()
|
||||||
|
|
||||||
|
if (pattern === old_pattern) { return }
|
||||||
|
old_pattern = pattern
|
||||||
|
families.length = 0
|
||||||
|
|
||||||
|
if (pattern === '') {
|
||||||
|
field.tooltip('hide')
|
||||||
|
families.length = 0
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// Appel à l'API pour récupérer les familles correspondantes
|
||||||
|
$.getJSON('/api/family/family/?format=json&search=' + pattern,
|
||||||
|
function (results) {
|
||||||
|
if (pattern !== $('#' + field_id).val()) { return }
|
||||||
|
|
||||||
|
let matched_html = '<ul class="list-group list-group-flush">'
|
||||||
|
results.results.forEach(function (family) {
|
||||||
|
matched_html += li(family_prefix + '_' + family.id,
|
||||||
|
family.name,
|
||||||
|
'')
|
||||||
|
families.push(family)
|
||||||
|
})
|
||||||
|
matched_html += '</ul>'
|
||||||
|
|
||||||
|
field.attr('data-original-title', matched_html).tooltip('show')
|
||||||
|
|
||||||
|
results.results.forEach(function (family) {
|
||||||
|
const family_obj = $('#' + family_prefix + '_' + family.id)
|
||||||
|
family_obj.hover(function () {
|
||||||
|
displayFamily(family, family.name, user_family_field, profile_pic_field)
|
||||||
|
})
|
||||||
|
family_obj.click(function () {
|
||||||
|
var disp = null
|
||||||
|
families_display.forEach(function (d) {
|
||||||
|
if (d.id === family.id) {
|
||||||
|
disp = d
|
||||||
|
}
|
||||||
|
})
|
||||||
|
if (disp == null) {
|
||||||
|
disp = {
|
||||||
|
name: family.name,
|
||||||
|
id: family.id,
|
||||||
|
family: family,
|
||||||
|
}
|
||||||
|
families_display.push(disp)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (family_click && !family_click()) { return }
|
||||||
|
|
||||||
|
const family_list = $('#' + family_list_id)
|
||||||
|
let html = ''
|
||||||
|
families_display.forEach(function (disp) {
|
||||||
|
html += li(family_prefix + '_' + disp.id,
|
||||||
|
disp.name,
|
||||||
|
'')
|
||||||
|
})
|
||||||
|
|
||||||
|
family_list.html(html)
|
||||||
|
field.tooltip('update')
|
||||||
|
|
||||||
|
families_display.forEach(function (disp) {
|
||||||
|
const line_obj = $('#' + family_prefix + '_' + disp.id)
|
||||||
|
line_obj.hover(function () {
|
||||||
|
displayFamily(disp.family, disp.name, user_family_field, profile_pic_field)
|
||||||
|
})
|
||||||
|
line_obj.click(removeFamily(disp, family_prefix, families_display, family_list_id, user_family_field,
|
||||||
|
profile_pic_field))
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Affiche le nom et la photo d'une famille
|
||||||
|
* @param family L'objet famille à afficher
|
||||||
|
* @param user_family_field L'identifiant du champ où afficher le nom (optionnel)
|
||||||
|
* @param profile_pic_field L'identifiant du champ où afficher la photo (optionnel)
|
||||||
|
*/
|
||||||
|
function displayFamily(family, user_family_field = null, profile_pic_field = null) {
|
||||||
|
if (!family.display_image) {
|
||||||
|
family.display_image = '/static/member/img/default_picture.png'
|
||||||
|
}
|
||||||
|
if (user_family_field !== null) {
|
||||||
|
$('#' + user_family_field).removeAttr('class')
|
||||||
|
$('#' + user_family_field).text(family.name)
|
||||||
|
if (profile_pic_field != null) {
|
||||||
|
$('#' + profile_pic_field).attr('src', family.display_image)
|
||||||
|
// Si tu veux un lien vers la page famille :
|
||||||
|
$('#' + profile_pic_field + '_link').attr('href', '/family/detail/' + family.id + '/')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retire une famille de la liste sélectionnée.
|
||||||
|
* @param d La famille à retirer
|
||||||
|
* @param family_prefix Le préfixe des <li>
|
||||||
|
* @param families_display Le tableau des familles sélectionnées
|
||||||
|
* @param family_list_id L'id du bloc où sont affichées les familles
|
||||||
|
* @param user_family_field Champ d'affichage (optionnel)
|
||||||
|
* @param profile_pic_field Champ photo (optionnel)
|
||||||
|
* @returns une fonction compatible avec les événements jQuery
|
||||||
|
*/
|
||||||
|
function removeFamily(d, family_prefix, families_display, family_list_id, user_family_field = null, profile_pic_field = null) {
|
||||||
|
return function () {
|
||||||
|
const new_families_display = []
|
||||||
|
let html = ''
|
||||||
|
families_display.forEach(function (disp) {
|
||||||
|
})
|
||||||
|
|
||||||
|
families_display.length = 0
|
||||||
|
new_families_display.forEach(function (disp) {
|
||||||
|
families_display.push(disp)
|
||||||
|
})
|
||||||
|
|
||||||
|
$('#' + family_list_id).html(html)
|
||||||
|
families_display.forEach(function (disp) {
|
||||||
|
const obj = $('#' + family_prefix + '_' + disp.id)
|
||||||
|
obj.click(removeFamily(disp, family_prefix, families_display, family_list_id, user_family_field, profile_pic_field))
|
||||||
|
obj.hover(function () {
|
||||||
|
displayFamily(disp.family, user_family_field, profile_pic_field)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
149
apps/family/tables.py
Normal file
@@ -0,0 +1,149 @@
|
|||||||
|
# Copyright (C) 2018-2025 by BDE ENS Paris-Saclay
|
||||||
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
|
||||||
|
import django_tables2 as tables
|
||||||
|
from django.utils.html import format_html
|
||||||
|
from django.utils.translation import gettext_lazy as _
|
||||||
|
from django_tables2 import A
|
||||||
|
from django.urls import reverse, reverse_lazy
|
||||||
|
from note_kfet.middlewares import get_current_request
|
||||||
|
from permission.backends import PermissionBackend
|
||||||
|
|
||||||
|
from .models import Achievement, Challenge, Family, FamilyMembership
|
||||||
|
|
||||||
|
|
||||||
|
class FamilyTable(tables.Table):
|
||||||
|
"""
|
||||||
|
List all families
|
||||||
|
"""
|
||||||
|
|
||||||
|
description = tables.Column(verbose_name=_("Description"))
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
attrs = {
|
||||||
|
'class': 'table table-condensed table-striped table-hover'
|
||||||
|
}
|
||||||
|
model = Family
|
||||||
|
template_name = 'django_tables2/bootstrap4.html'
|
||||||
|
fields = ('name', 'score', 'rank',)
|
||||||
|
order_by = ('rank',)
|
||||||
|
row_attrs = {
|
||||||
|
'class': 'table-row',
|
||||||
|
'data-href': lambda record: reverse('family:family_detail', args=[record.pk]),
|
||||||
|
'style': 'cursor:pointer',
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
class ChallengeTable(tables.Table):
|
||||||
|
"""
|
||||||
|
List all challenges
|
||||||
|
"""
|
||||||
|
|
||||||
|
name = tables.Column(verbose_name=_("Name"))
|
||||||
|
description = tables.Column(verbose_name=_("Description"))
|
||||||
|
points = tables.Column(verbose_name=_("Points"))
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
attrs = {
|
||||||
|
'class': 'table table-condensed table-striped table-hover'
|
||||||
|
}
|
||||||
|
order_by = ('id',)
|
||||||
|
model = Challenge
|
||||||
|
template_name = 'django_tables2/bootstrap4.html'
|
||||||
|
fields = ('name', 'description', 'points',)
|
||||||
|
row_attrs = {
|
||||||
|
'class': 'table-row',
|
||||||
|
'data-href': lambda record: reverse('family:challenge_detail', args=[record.pk]),
|
||||||
|
'style': 'cursor:pointer',
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
class FamilyMembershipTable(tables.Table):
|
||||||
|
"""
|
||||||
|
List all family memberships.
|
||||||
|
"""
|
||||||
|
|
||||||
|
def render_user(self, value):
|
||||||
|
# Display user's name, clickable if permission is granted
|
||||||
|
s = value.username
|
||||||
|
if PermissionBackend.check_perm(get_current_request(), "auth.view_user", value):
|
||||||
|
s = format_html("<a href='{url}'>{name}</a>",
|
||||||
|
url=reverse_lazy('member:user_detail', kwargs={"pk": value.pk}), name=s)
|
||||||
|
return s
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
attrs = {
|
||||||
|
'class': 'table table-condensed table-striped',
|
||||||
|
'style': 'table-layout: fixed;'
|
||||||
|
}
|
||||||
|
template_name = 'django_tables2/bootstrap4.html'
|
||||||
|
fields = ('user',)
|
||||||
|
model = FamilyMembership
|
||||||
|
|
||||||
|
|
||||||
|
class AchievementTable(tables.Table):
|
||||||
|
"""
|
||||||
|
List recent achievements.
|
||||||
|
"""
|
||||||
|
|
||||||
|
challenge = tables.Column(verbose_name=_("Challenge"))
|
||||||
|
|
||||||
|
validate = tables.LinkColumn(
|
||||||
|
'family:achievement_validate',
|
||||||
|
args=[A('id')],
|
||||||
|
verbose_name=_("Validate"),
|
||||||
|
text=_("Validate"),
|
||||||
|
orderable=False,
|
||||||
|
attrs={
|
||||||
|
'th': {
|
||||||
|
'id': 'validate-achievement-header'
|
||||||
|
},
|
||||||
|
'a': {
|
||||||
|
'class': 'btn btn-success',
|
||||||
|
'data-type': 'validate-achievement'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
)
|
||||||
|
|
||||||
|
delete = tables.LinkColumn(
|
||||||
|
'family:achievement_delete',
|
||||||
|
args=[A('id')],
|
||||||
|
verbose_name=_("Delete"),
|
||||||
|
text=_("Delete"),
|
||||||
|
orderable=False,
|
||||||
|
attrs={
|
||||||
|
'th': {
|
||||||
|
'id': 'delete-achievement-header'
|
||||||
|
},
|
||||||
|
'a': {
|
||||||
|
'class': 'btn btn-danger',
|
||||||
|
'data-type': 'delete-achievement'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
)
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
attrs = {
|
||||||
|
'class': 'table table-condensed table-striped table-hover'
|
||||||
|
}
|
||||||
|
model = Achievement
|
||||||
|
fields = ('family', 'challenge', 'challenge__points', 'obtained_at', 'valid')
|
||||||
|
template_name = 'django_tables2/bootstrap4.html'
|
||||||
|
order_by = ('-obtained_at',)
|
||||||
|
|
||||||
|
|
||||||
|
class FamilyAchievementTable(tables.Table):
|
||||||
|
"""
|
||||||
|
Table des défis réalisés par une famille spécifique.
|
||||||
|
"""
|
||||||
|
|
||||||
|
challenge = tables.Column(verbose_name=_("Challenge"))
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
model = Achievement
|
||||||
|
template_name = 'django_tables2/bootstrap4.html'
|
||||||
|
fields = ('challenge', 'challenge__points', 'obtained_at', 'valid')
|
||||||
|
attrs = {
|
||||||
|
'class': 'table table-condensed table-striped table-hover'
|
||||||
|
}
|
||||||
|
order_by = ('-obtained_at',)
|
||||||
25
apps/family/templates/family/achievement_confirm_delete.html
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
{% extends "base.html" %}
|
||||||
|
{% comment %}
|
||||||
|
SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
{% endcomment %}
|
||||||
|
{% load i18n crispy_forms_tags %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
<div class="card bg-light">
|
||||||
|
<div class="card-header text-center">
|
||||||
|
<h4>{% trans "Delete achievement" %}</h4>
|
||||||
|
</div>
|
||||||
|
<div class="card-body">
|
||||||
|
<div class="alert alert-warning">
|
||||||
|
{% blocktrans %}Are you sure you want to delete this achievement? This action can't be undone.{% endblocktrans %}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="card-footer text-center">
|
||||||
|
<form method="post">
|
||||||
|
{% csrf_token %}
|
||||||
|
<a class="btn btn-primary" href="{% url 'family:achievement_list' %}">{% trans "Return to achievements list" %}</a>
|
||||||
|
<button class="btn btn-danger" type="submit">{% trans "Delete" %}</button>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% endblock %}
|
||||||
@@ -0,0 +1,28 @@
|
|||||||
|
{% extends "base.html" %}
|
||||||
|
{% comment %}
|
||||||
|
SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
{% endcomment %}
|
||||||
|
{% load i18n crispy_forms_tags %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
<div class="card bg-light">
|
||||||
|
<div class="card-header text-center">
|
||||||
|
<h4>{% trans "Validate achievement" %}</h4>
|
||||||
|
</div>
|
||||||
|
<div class="card-body">
|
||||||
|
<div class="alert alert-warning">
|
||||||
|
{% blocktrans %}Are you sure you want to validate this achievement? This action can't be undone.{% endblocktrans %}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="card-footer text-center">
|
||||||
|
<form method="post">
|
||||||
|
{% csrf_token %}
|
||||||
|
<a class="btn btn-primary" href="{% url 'family:achievement_list' %}">{% trans "Return to achievements list" %}</a>
|
||||||
|
<form method="post" action="{% url 'family:achievement_validate' pk %}">
|
||||||
|
{% csrf_token %}
|
||||||
|
<button type="submit" class="btn btn-success">{% trans "Validate" %}</button>
|
||||||
|
</form>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% endblock %}
|
||||||
33
apps/family/templates/family/achievement_list.html
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
{% extends "base.html" %}
|
||||||
|
{% comment %}
|
||||||
|
Copyright (C) 2018-2025 by BDE ENS Paris-Saclay
|
||||||
|
SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
{% endcomment %}
|
||||||
|
{% load i18n django_tables2 %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
|
||||||
|
<div class="card mb-4" id="history">
|
||||||
|
<div class="card-header">
|
||||||
|
<p class="card-text font-weight-bold">
|
||||||
|
{% trans "Invalid achievements history" %}
|
||||||
|
</p>
|
||||||
|
<a class="btn btn-sm btn-primary mx-2" href="{% url "family:manage" %}">
|
||||||
|
{% trans "Return to management page" %}
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
{% render_table invalid %}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="card mb-4" id="history">
|
||||||
|
<div class="card-header">
|
||||||
|
<p class="card-text font-weight-bold">
|
||||||
|
{% trans "Valid achievements history" %}
|
||||||
|
</p>
|
||||||
|
<a class="btn btn-sm btn-primary mx-2" href="{% url "family:manage" %}">
|
||||||
|
{% trans "Return to management page" %}
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
{% render_table valid %}
|
||||||
|
</div>
|
||||||
|
{% endblock %}
|
||||||
60
apps/family/templates/family/add_member.html
Normal file
@@ -0,0 +1,60 @@
|
|||||||
|
{% extends "family/base.html" %}
|
||||||
|
{% comment %}
|
||||||
|
SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
{% endcomment %}
|
||||||
|
{% load crispy_forms_tags i18n pretty_money %}
|
||||||
|
|
||||||
|
{% block profile_content %}
|
||||||
|
<div class="card bg-light">
|
||||||
|
<h3 class="card-header text-center">
|
||||||
|
{{ title }}
|
||||||
|
</h3>
|
||||||
|
<div class="card-body">
|
||||||
|
|
||||||
|
<form method="post" action="">
|
||||||
|
{% csrf_token %}
|
||||||
|
{{ form|crispy }}
|
||||||
|
<button class="btn btn-primary" type="submit">{% trans "Submit" %}</button>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
{% block extrajavascript %}
|
||||||
|
<script>
|
||||||
|
function autocompleted(user) {
|
||||||
|
$("#id_last_name").val(user.last_name);
|
||||||
|
$("#id_first_name").val(user.first_name);
|
||||||
|
$.getJSON("/api/members/profile/" + user.id + "/", function (profile) {
|
||||||
|
let fee = profile.paid ? "{{ club.membership_fee_paid }}" : "{{ club.membership_fee_unpaid }}";
|
||||||
|
$("#id_credit_amount").val((Number(fee) / 100).toFixed(2));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
soge_field = $("#id_soge");
|
||||||
|
|
||||||
|
function fillFields() {
|
||||||
|
let checked = soge_field.is(':checked');
|
||||||
|
if (!checked) {
|
||||||
|
$("input").attr('disabled', false);
|
||||||
|
$("#id_user").attr('disabled', true);
|
||||||
|
$("select").attr('disabled', false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
let credit_type = $("#id_credit_type");
|
||||||
|
credit_type.attr('disabled', true);
|
||||||
|
credit_type.val(4);
|
||||||
|
|
||||||
|
let credit_amount = $("#id_credit_amount");
|
||||||
|
credit_amount.attr('disabled', true);
|
||||||
|
credit_amount.val('{{ total_fee }}');
|
||||||
|
|
||||||
|
let bank = $("#id_bank");
|
||||||
|
bank.attr('disabled', true);
|
||||||
|
bank.val('Société générale');
|
||||||
|
}
|
||||||
|
|
||||||
|
soge_field.change(fillFields);
|
||||||
|
</script>
|
||||||
|
{% endblock %}
|
||||||
52
apps/family/templates/family/base.html
Normal file
@@ -0,0 +1,52 @@
|
|||||||
|
{% extends "base.html" %}
|
||||||
|
{% comment %}
|
||||||
|
SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
{% endcomment %}
|
||||||
|
{% load i18n perms %}
|
||||||
|
|
||||||
|
{# Use a fluid-width container #}
|
||||||
|
{% block containertype %}container-fluid{% endblock %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
<div class="row mt-4">
|
||||||
|
<div class="col-xl-4">
|
||||||
|
{% block profile_info %}
|
||||||
|
<div class="card bg-light" id="card-infos">
|
||||||
|
<h4 class="card-header text-center">
|
||||||
|
{{ family.name }}
|
||||||
|
</h4>
|
||||||
|
<div class="text-center">
|
||||||
|
<a href="{% url 'family:update_pic' family.pk %}">
|
||||||
|
<img src="{{ family.display_image.url }}" class="img-thumbnail mt-2">
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
<div class="card-body" id="profile_infos">
|
||||||
|
{% include "family/family_info.html" %}
|
||||||
|
</div>
|
||||||
|
<div class="card-footer">
|
||||||
|
{% if can_add_members %}
|
||||||
|
<a class="btn btn-sm btn-success" href="{% url 'family:family_add_member' family_pk=family.pk %}"
|
||||||
|
data-turbolinks="false"> {% trans "Add member" %}</a>
|
||||||
|
{% endif %}
|
||||||
|
{% if ".change_"|has_perm:family %}
|
||||||
|
<a class="btn btn-sm btn-secondary" href="{% url 'family:family_update' pk=family.pk %}"
|
||||||
|
data-turbolinks="false">
|
||||||
|
<i class="fa fa-edit"></i> {% trans 'Update Profile' %}
|
||||||
|
</a>
|
||||||
|
{% endif %}
|
||||||
|
{% url 'family:family_detail' family.pk as family_detail_url %}
|
||||||
|
{% if request.path_info != family_detail_url %}
|
||||||
|
<a class="btn btn-sm btn-primary" href="{{ family_detail_url }}">{% trans 'View Profile' %}</a>
|
||||||
|
{% endif %}
|
||||||
|
<a class="btn btn-sm btn-primary" href="{% url "family:family_list" %}">
|
||||||
|
{% trans "Return to the family list" %}
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% endblock %}
|
||||||
|
</div>
|
||||||
|
<div class="col-xl-8">
|
||||||
|
{% block profile_content %}{% endblock %}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% endblock %}
|
||||||
36
apps/family/templates/family/challenge_detail.html
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
{% extends "base.html" %}
|
||||||
|
{% comment %}
|
||||||
|
Copyright (C) by BDE ENS Paris-Saclay
|
||||||
|
SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
{% endcomment %}
|
||||||
|
{% load i18n crispy_forms_tags %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
<div class="card bg-white mb-3">
|
||||||
|
<h3 class="card-header text-center">
|
||||||
|
{{ title }} {{ challenge.name }}
|
||||||
|
</h3>
|
||||||
|
<div class="card-body">
|
||||||
|
<ul>
|
||||||
|
{% for field, value in fields %}
|
||||||
|
<li> {{ field }} : {{ value }}</li>
|
||||||
|
{% endfor %}
|
||||||
|
<li> {% trans "Obtained by " %} {{obtained}}
|
||||||
|
{% if obtained > 1 %}
|
||||||
|
{% trans "families" %}
|
||||||
|
{% else %}
|
||||||
|
{% trans "family" %}
|
||||||
|
{% endif %}
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
<a class="btn btn-sm btn-primary" href="{% url "family:challenge_list" %}">
|
||||||
|
{% trans "Return to the challenge list" %}
|
||||||
|
</a>
|
||||||
|
{% if update %}
|
||||||
|
<a class="btn btn-sm btn-secondary" href="{% url "family:challenge_update" pk=challenge.pk %}">
|
||||||
|
{% trans "Update" %}
|
||||||
|
</a>
|
||||||
|
{% endif %}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% endblock %}
|
||||||
21
apps/family/templates/family/challenge_form.html
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
{% extends "base.html" %}
|
||||||
|
{% comment %}
|
||||||
|
Copyright (C) 2018-2025 by BDE ENS Paris-Saclay
|
||||||
|
SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
{% endcomment %}
|
||||||
|
{% load i18n crispy_forms_tags %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
<div class="card bg-white mb-3">
|
||||||
|
<h3 class="card-header text-center">
|
||||||
|
{{ title }}
|
||||||
|
</h3>
|
||||||
|
<div class="card-body" id="form">
|
||||||
|
<form method="post">
|
||||||
|
{% csrf_token %}
|
||||||
|
{{ form | crispy }}
|
||||||
|
<button class="btn btn-primary" type="submit">{% trans "Submit"%}</button>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% endblock %}
|
||||||
42
apps/family/templates/family/challenge_list.html
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
{% extends "base.html" %}
|
||||||
|
{% comment %}
|
||||||
|
Copyright (C) 2018-2025 by BDE ENS Paris-Saclay
|
||||||
|
SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
{% endcomment %}
|
||||||
|
{% load render_table from django_tables2 %}
|
||||||
|
{% load i18n %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-xl-12">
|
||||||
|
<div class="btn-group btn-group-toggle" style="width: 100%; padding: 0 0 2em 0">
|
||||||
|
<a href="{% url "family:family_list" %}" class="btn btn-sm btn-outline-primary">
|
||||||
|
{% trans "Families" %}
|
||||||
|
</a>
|
||||||
|
<a href="#" class="btn btn-sm btn-outline-primary active">
|
||||||
|
{% trans "Challenges" %}
|
||||||
|
</a>
|
||||||
|
{% if can_manage %}
|
||||||
|
<a href="{% url "family:manage" %}" class="btn btn-sm btn-outline-primary">
|
||||||
|
{% trans "Manage" %}
|
||||||
|
</a>
|
||||||
|
{% endif %}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="card bg-white mb-3">
|
||||||
|
<h3 class="card-header text-center">
|
||||||
|
{{ title }}
|
||||||
|
</h3>
|
||||||
|
{% render_table table %}
|
||||||
|
</div>
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
{% block extrajavascript %}
|
||||||
|
<script type="text/javascript">
|
||||||
|
$(".table-row").click(function () {
|
||||||
|
window.document.location = $(this).data("href");
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
{% endblock %}
|
||||||
29
apps/family/templates/family/family_detail.html
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
{% extends "family/base.html" %}
|
||||||
|
{% comment %}
|
||||||
|
Copyright (C) 2018-2025 by BDE ENS Paris-Saclay
|
||||||
|
SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
{% endcomment %}
|
||||||
|
{% load render_table from django_tables2 %}
|
||||||
|
{% load i18n perms %}
|
||||||
|
|
||||||
|
{% block profile_content %}
|
||||||
|
{% if member_list.data %}
|
||||||
|
<div class="card">
|
||||||
|
<div class="card-header position-relative" id="clubListHeading">
|
||||||
|
<i class="fa fa-users"></i> {% trans "Family members" %}
|
||||||
|
</div>
|
||||||
|
{% render_table member_list %}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="my-4"></div>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
{% if achievement_list.data %}
|
||||||
|
<div class="card">
|
||||||
|
<div class="card-header position-relative">
|
||||||
|
<i class="fa fa-trophy"></i> {% trans "Completed challenges" %}
|
||||||
|
</div>
|
||||||
|
{% render_table achievement_list %}
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
|
{% endblock %}
|
||||||
21
apps/family/templates/family/family_form.html
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
{% extends "base.html" %}
|
||||||
|
{% comment %}
|
||||||
|
Copyright (C) 2018-2025 by BDE ENS Paris-Saclay
|
||||||
|
SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
{% endcomment %}
|
||||||
|
{% load i18n crispy_forms_tags %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
<div class="card bg-white mb-3">
|
||||||
|
<h3 class="card-header text-center">
|
||||||
|
{{ title }}
|
||||||
|
</h3>
|
||||||
|
<div class="card-body" id="form">
|
||||||
|
<form method="post">
|
||||||
|
{% csrf_token %}
|
||||||
|
{{ form | crispy }}
|
||||||
|
<button class="btn btn-primary" type="submit">{% trans "Submit"%}</button>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% endblock %}
|
||||||
15
apps/family/templates/family/family_info.html
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
{% load i18n pretty_money perms %}
|
||||||
|
|
||||||
|
<dl class="row">
|
||||||
|
<dt class="col-xl-6">{% trans 'name'|capfirst %}</dt>
|
||||||
|
<dd class="col-xl-6">{{ family.name }}</dd>
|
||||||
|
|
||||||
|
<dt class="col-xl-6">{% trans 'description'|capfirst %}</dt>
|
||||||
|
<dd class="col-xl-6">{{ family.description }}</dd>
|
||||||
|
|
||||||
|
<dt class="col-xl-6">{% trans 'score'|capfirst %}</dt>
|
||||||
|
<dd class="col-xl-6">{{ family.score }}</dd>
|
||||||
|
|
||||||
|
<dt class="col-xl-6">{% trans 'rank'|capfirst %}</dt>
|
||||||
|
<dd class="col-xl-6">{{ family.rank }}</dd>
|
||||||
|
</dl>
|
||||||
43
apps/family/templates/family/family_list.html
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
{% extends "base.html" %}
|
||||||
|
{% comment %}
|
||||||
|
Copyright (C) 2018-2025 by BDE ENS Paris-Saclay
|
||||||
|
SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
{% endcomment %}
|
||||||
|
{% load render_table from django_tables2 %}
|
||||||
|
{% load i18n %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-xl-12">
|
||||||
|
<div class="btn-group btn-group-toggle" style="width: 100%; padding: 0 0 2em 0">
|
||||||
|
<a href="#" class="btn btn-sm btn-outline-primary active">
|
||||||
|
{% trans "Families" %}
|
||||||
|
</a>
|
||||||
|
<a href="{% url "family:challenge_list" %}" class="btn btn-sm btn-outline-primary">
|
||||||
|
{% trans "Challenges" %}
|
||||||
|
</a>
|
||||||
|
{% if can_manage %}
|
||||||
|
<a href="{% url "family:manage" %}" class="btn btn-sm btn-outline-primary">
|
||||||
|
{% trans "Manage" %}
|
||||||
|
</a>
|
||||||
|
{% endif %}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="card bg-white mb-3">
|
||||||
|
<h3 class="card-header text-center">
|
||||||
|
{{ title }}
|
||||||
|
</h3>
|
||||||
|
{% render_table table %}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
{% block extrajavascript %}
|
||||||
|
<script type="text/javascript">
|
||||||
|
$(".table-row").click(function () {
|
||||||
|
window.document.location = $(this).data("href");
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
{% endblock %}
|
||||||
287
apps/family/templates/family/manage.html
Normal file
@@ -0,0 +1,287 @@
|
|||||||
|
{% extends "base.html" %}
|
||||||
|
{% comment %}
|
||||||
|
Copyright (C) 2018-2025 by BDE ENS Paris-Saclay
|
||||||
|
SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
{% endcomment %}
|
||||||
|
{% load i18n static django_tables2 %}
|
||||||
|
|
||||||
|
{% block containertype %}container-fluid{% endblock %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-xl-12">
|
||||||
|
<div class="btn-group btn-group-toggle" style="width: 100%; padding: 0 0 2em 0">
|
||||||
|
<a href="{% url "family:family_list" %}" class="btn btn-sm btn-outline-primary">
|
||||||
|
{% trans "Families" %}
|
||||||
|
</a>
|
||||||
|
<a href="{% url "family:challenge_list" %}" class="btn btn-sm btn-outline-primary">
|
||||||
|
{% trans "Challenges" %}
|
||||||
|
</a>
|
||||||
|
<a href="#" class="btn btn-sm btn-outline-primary active">
|
||||||
|
{% trans "Manage" %}
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="row mb-3">
|
||||||
|
<div class='col-sm-5 col-xl-6' id="infos_div">
|
||||||
|
{% if can_add_achievement %}
|
||||||
|
<div class="row justify-content-center justify-content-md-end">
|
||||||
|
{# Family details column #}
|
||||||
|
<div class="col picture-col">
|
||||||
|
<div class="card bg-light mb-4 text-center">
|
||||||
|
<a id="profile_pic_link" href="#">
|
||||||
|
<img src="{% static "member/img/default_picture.png" %}" id="profile_pic" alt="" class="card-img-top d-none d-sm-block">
|
||||||
|
</a>
|
||||||
|
<div class="card-body text-center text-break p-2">
|
||||||
|
<span id="user_note"><i class="small">{% trans "Please select a family" %}</i></span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{# Family selection column #}
|
||||||
|
<div class="col-xl" id="user_select_div">
|
||||||
|
<div class="card bg-light border-success mb-4">
|
||||||
|
<div class="card-header">
|
||||||
|
<p class="card-text font-weight-bold">
|
||||||
|
{% trans "Families" %}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
<div class="card-body p-0" style="min-height:125px;">
|
||||||
|
<ul class="list-group list-group-flush" id="note_list"></ul>
|
||||||
|
</div>
|
||||||
|
{# User search with autocompletion #}
|
||||||
|
<div class="card-footer">
|
||||||
|
<input class="form-control mx-auto d-block mb-2" placeholder="{% trans "Name" %}" type="text" id="note" autofocus />
|
||||||
|
{% if user_family %}
|
||||||
|
<button class="btn btn-sm btn-secondary btn-block" id="select_my_family">
|
||||||
|
{% trans "Select my family" %} ({{ user_family.name }})
|
||||||
|
</button>
|
||||||
|
{% endif %}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{# Summary of challenges and validate button #}
|
||||||
|
<div class="col-xl-5" id="consos_list_div">
|
||||||
|
<div class="card bg-light border-info mb-4">
|
||||||
|
<div class="card-header">
|
||||||
|
<p class="card-text font-weight-bold">
|
||||||
|
{% trans "Challenges" %}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
<div class="card-body p-0" style="min-height:125px;">
|
||||||
|
<ul class="list-group list-group-flush" id="consos_list"></ul>
|
||||||
|
</div>
|
||||||
|
<div class="card-footer text-center">
|
||||||
|
<span id="consume_all" class="btn btn-primary">
|
||||||
|
{% trans "Validate!" %}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
{# Create family/challenge buttons #}
|
||||||
|
{% if can_add_family or can_add_challenge %}
|
||||||
|
<div class="card bg-light border-success mb-4">
|
||||||
|
<h3 class="card-header font-weight-bold text-center">
|
||||||
|
{% trans "Create a family or challenge" %}
|
||||||
|
</h3>
|
||||||
|
<div class="card-body text-center">
|
||||||
|
{% if can_add_family %}
|
||||||
|
<a class="btn btn-sm btn-primary mx-2" href="{% url "family:family_create" %}">
|
||||||
|
{% trans "Add a family" %}
|
||||||
|
</a>
|
||||||
|
{% endif %}
|
||||||
|
{% if can_add_challenge %}
|
||||||
|
<a class="btn btn-sm btn-primary mx-2" href="{% url "family:challenge_create" %}">
|
||||||
|
{% trans "Add a challenge" %}
|
||||||
|
</a>
|
||||||
|
{% endif %}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{# Buttons column #}
|
||||||
|
<div class="col">
|
||||||
|
{% if can_add_achievement %}
|
||||||
|
<div class="card bg-light border-primary text-center mb-4">
|
||||||
|
{# Tabs for list and search #}
|
||||||
|
<div class="card-header">
|
||||||
|
<ul class="nav nav-tabs nav-fill card-header-tabs">
|
||||||
|
<li class="nav-item">
|
||||||
|
<a class="nav-link font-weight-bold" data-toggle="tab" href="#list">
|
||||||
|
{% trans "List" %}
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
<li class="nav-item">
|
||||||
|
<a class="nav-link font-weight-bold" data-toggle="tab" href="#search">
|
||||||
|
{% trans "Search" %}
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{# Tabs content #}
|
||||||
|
<div class="card-body">
|
||||||
|
<div class="tab-content">
|
||||||
|
<div class="tab-pane" id="list">
|
||||||
|
<div class="d-inline-flex flex-wrap justify-content-center">
|
||||||
|
{% for challenge in all_challenges %}
|
||||||
|
<button class="btn btn-outline-dark rounded-0 flex-fill"
|
||||||
|
id="challenge{{ challenge.id }}" name="button" value="{{ challenge.name }}">
|
||||||
|
{{ challenge.name }} ({{ challenge.points }} {% trans "points" %})
|
||||||
|
</button>
|
||||||
|
{% endfor %}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="tab-pane" id="search">
|
||||||
|
<input class="form-control mx-auto d-block mb-3" placeholder="{% trans "Search challenge..." %}" type="search" id="search-input"/>
|
||||||
|
<div class="d-inline-flex flex-wrap justify-content-center" id="search-results">
|
||||||
|
{% for challenge in all_challenges %}
|
||||||
|
<button class="btn btn-outline-dark rounded-0 flex-fill" hidden
|
||||||
|
id="search_challenge{{ challenge.id }}" name="button" value="{{ challenge.name }}">
|
||||||
|
{{ challenge.name }} ({{ challenge.points }} {% trans "points" %})
|
||||||
|
</button>
|
||||||
|
{% endfor %}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{# achievement history #}
|
||||||
|
{% if table.data %}
|
||||||
|
<div class="card">
|
||||||
|
<div class="card-header position-relative" id="historyListHeading">
|
||||||
|
<a class="stretched-link font-weight-bold"
|
||||||
|
href="{% url 'family:achievement_list' %}" >
|
||||||
|
{% trans "Recent achievements history" %}
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
<div id="history">
|
||||||
|
{% render_table table %}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Popup de validation -->
|
||||||
|
<div class="modal fade" id="validationModal" tabindex="-1" role="dialog" aria-labelledby="validationModalLabel" aria-hidden="true">
|
||||||
|
<div class="modal-dialog modal-dialog-centered" role="document">
|
||||||
|
<div class="modal-content border-success">
|
||||||
|
<div class="modal-header bg-success text-white">
|
||||||
|
<h5 class="modal-title" id="validationModalLabel">{% trans "Confirmation" %}</h5>
|
||||||
|
<button type="button" class="close text-white" data-dismiss="modal" aria-label="Close">
|
||||||
|
<span aria-hidden="true">×</span>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
<div class="modal-body">
|
||||||
|
<p><strong>{% trans "Are you sure you want to validate this challenge?" %}</strong></p>
|
||||||
|
<p>{% trans "To have your challenge officially validated, please send a message with:" %}</p>
|
||||||
|
<ul>
|
||||||
|
<li>{% trans "The name of the family" %}</li>
|
||||||
|
<li>{% trans "The name of the challenge" %}</li>
|
||||||
|
<li>{% trans "A photo or video as proof" %}</li>
|
||||||
|
</ul>
|
||||||
|
<p>
|
||||||
|
<strong>{% trans "Send it via WhatsApp to:" %}</strong>
|
||||||
|
{% if phone_numbers %}"
|
||||||
|
{% for num in phone_numbers %}
|
||||||
|
<a href="https://wa.me/{{ num }}" target="_blank">{{ num }}</a>{% if not forloop.last %}, {% endif %}
|
||||||
|
{% endfor %}
|
||||||
|
{% endif %}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
<div class="modal-footer">
|
||||||
|
<button type="button" class="btn btn-primary" data-dismiss="modal">{% trans "OK" %}</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
{% block extrajavascript %}
|
||||||
|
<script type="text/javascript" src="{% static "family/js/achievements.js" %}"></script>
|
||||||
|
<script type="text/javascript">
|
||||||
|
{% for challenge in all_challenges %}
|
||||||
|
document.getElementById("challenge{{ challenge.id }}").addEventListener("click", function() {
|
||||||
|
addChallenge({{ challenge.id}}, "{{ challenge.name|escapejs }}", {{ challenge.points }});
|
||||||
|
});
|
||||||
|
{% endfor %}
|
||||||
|
|
||||||
|
{% for challenge in all_challenges %}
|
||||||
|
document.getElementById("search_challenge{{ challenge.id }}").addEventListener("click", function() {
|
||||||
|
addChallenge({{ challenge.id}}, "{{ challenge.name|escapejs }}", {{ challenge.points }});
|
||||||
|
});
|
||||||
|
{% endfor %}
|
||||||
|
</script>
|
||||||
|
<script>
|
||||||
|
document.getElementById("consume_all").addEventListener("click", function () {
|
||||||
|
$('#validationModal').modal('show');
|
||||||
|
});
|
||||||
|
|
||||||
|
$('#validationModal .btn-primary').on('click', function () {
|
||||||
|
consumeAll();
|
||||||
|
});
|
||||||
|
|
||||||
|
{% if user_family %}
|
||||||
|
document.getElementById("select_my_family").addEventListener("click", function () {
|
||||||
|
// Simulate selecting the user's family
|
||||||
|
var userFamily = {
|
||||||
|
id: {{ user_family.id }},
|
||||||
|
name: "{{ user_family.name|escapejs }}",
|
||||||
|
display_image: "{{ user_family.display_image.url|default:'/static/member/img/default_picture.png'|escapejs }}"
|
||||||
|
};
|
||||||
|
|
||||||
|
// Check if family is already selected
|
||||||
|
var alreadySelected = false;
|
||||||
|
notes_display.forEach(function (d) {
|
||||||
|
if (d.id === userFamily.id) {
|
||||||
|
alreadySelected = true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!alreadySelected) {
|
||||||
|
// Add the family to the selected families
|
||||||
|
var disp = {
|
||||||
|
name: userFamily.name,
|
||||||
|
id: userFamily.id,
|
||||||
|
family: userFamily,
|
||||||
|
};
|
||||||
|
notes_display.push(disp);
|
||||||
|
|
||||||
|
// Update the display
|
||||||
|
const family_list = $('#note_list');
|
||||||
|
let html = '';
|
||||||
|
notes_display.forEach(function (disp) {
|
||||||
|
html += li('note_' + disp.id, disp.name, '');
|
||||||
|
});
|
||||||
|
|
||||||
|
family_list.html(html);
|
||||||
|
|
||||||
|
// Add click handlers for removal
|
||||||
|
notes_display.forEach(function (disp) {
|
||||||
|
const line_obj = $('#note_' + disp.id);
|
||||||
|
line_obj.hover(function () {
|
||||||
|
displayFamily(disp.family, disp.name, 'user_note', 'profile_pic');
|
||||||
|
});
|
||||||
|
line_obj.click(removeFamily(disp, 'note', notes_display, 'note_list', 'user_note', 'profile_pic'));
|
||||||
|
});
|
||||||
|
|
||||||
|
// Display the family info
|
||||||
|
displayFamily(userFamily, userFamily.name, 'user_note', 'profile_pic');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
{% endif %}
|
||||||
|
</script>
|
||||||
|
{% endblock %}
|
||||||
118
apps/family/templates/family/picture_update.html
Normal file
@@ -0,0 +1,118 @@
|
|||||||
|
{% extends "family/base.html" %}
|
||||||
|
{% comment %}
|
||||||
|
SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
{% endcomment %}
|
||||||
|
{% load i18n crispy_forms_tags %}
|
||||||
|
|
||||||
|
{% block profile_content %}
|
||||||
|
<div class="card bg-light">
|
||||||
|
<h3 class="card-header text-center">
|
||||||
|
{{ title }}
|
||||||
|
</h3>
|
||||||
|
<div class="card-body">
|
||||||
|
<div class="text-center">
|
||||||
|
<form method="post" enctype="multipart/form-data" id="formUpload">
|
||||||
|
{% csrf_token %}
|
||||||
|
{{ form |crispy }}
|
||||||
|
{% if user.note.display_image != "pic/default.png" %}
|
||||||
|
<input type="submit" class="btn btn-primary" value="{% trans "Remove" %}">
|
||||||
|
{% endif %}
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
<!-- MODAL TO CROP THE IMAGE -->
|
||||||
|
<div class="modal fade" id="modalCrop" data-backdrop="static">
|
||||||
|
<div class="modal-dialog">
|
||||||
|
<div class="modal-content">
|
||||||
|
<div class="modal-body-wrapper" style="width: 500px; height: 500px; padding: 16px;">
|
||||||
|
<div class="modal-body" style="width: 100%; height: 100%; padding: 0">
|
||||||
|
<img src="" id="modal-image" style="display: block; max-width: 100%;">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="modal-footer">
|
||||||
|
<div class="btn-group pull-left" role="group">
|
||||||
|
<button type="button" class="btn btn-default" id="js-zoom-in">
|
||||||
|
<span class="glyphicon glyphicon-zoom-in"></span>
|
||||||
|
</button>
|
||||||
|
<button type="button" class="btn btn-default js-zoom-out">
|
||||||
|
<span class="glyphicon glyphicon-zoom-out"></span>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
<button type="button" class="btn btn-default" data-dismiss="modal">{% trans "Nevermind" %}</button>
|
||||||
|
<button type="button" class="btn btn-primary js-crop-and-upload">{% trans "Crop and upload" %}</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
{% block extracss %}
|
||||||
|
<link href="https://cdnjs.cloudflare.com/ajax/libs/cropperjs/1.5.6/cropper.min.css" rel="stylesheet">
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
{% block extrajavascript%}
|
||||||
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/cropperjs/1.5.6/cropper.min.js"></script>
|
||||||
|
<script src="https://cdn.jsdelivr.net/npm/jquery-cropper@1.0.1/dist/jquery-cropper.min.js"></script>
|
||||||
|
<script>
|
||||||
|
$(function () {
|
||||||
|
|
||||||
|
/* SCRIPT TO OPEN THE MODAL WITH THE PREVIEW */
|
||||||
|
$("#id_image").change(function (e) {
|
||||||
|
if (this.files && this.files[0]) {
|
||||||
|
// Check the image size
|
||||||
|
if (this.files[0].size > 2*1024*1024) {
|
||||||
|
alert("Ce fichier est trop volumineux.")
|
||||||
|
} else {
|
||||||
|
// Read the selected image file
|
||||||
|
var reader = new FileReader();
|
||||||
|
reader.onload = function (e) {
|
||||||
|
$("#modal-image").attr("src", e.target.result);
|
||||||
|
$("#modalCrop").modal("show");
|
||||||
|
}
|
||||||
|
reader.readAsDataURL(this.files[0]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
/* SCRIPTS TO HANDLE THE CROPPER BOX */
|
||||||
|
var $image = $("#modal-image");
|
||||||
|
var cropBoxData;
|
||||||
|
var canvasData;
|
||||||
|
$("#modalCrop").on("shown.bs.modal", function () {
|
||||||
|
$image.cropper({
|
||||||
|
viewMode: 1,
|
||||||
|
aspectRatio: 1 / 1,
|
||||||
|
minCropBoxWidth: 200,
|
||||||
|
minCropBoxHeight: 200,
|
||||||
|
ready: function () {
|
||||||
|
$image.cropper("setCanvasData", canvasData);
|
||||||
|
$image.cropper("setCropBoxData", cropBoxData);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}).on("hidden.bs.modal", function () {
|
||||||
|
cropBoxData = $image.cropper("getCropBoxData");
|
||||||
|
canvasData = $image.cropper("getCanvasData");
|
||||||
|
$image.cropper("destroy");
|
||||||
|
});
|
||||||
|
|
||||||
|
$(".js-zoom-in").click(function () {
|
||||||
|
$image.cropper("zoom", 0.1);
|
||||||
|
});
|
||||||
|
|
||||||
|
$(".js-zoom-out").click(function () {
|
||||||
|
$image.cropper("zoom", -0.1);
|
||||||
|
});
|
||||||
|
|
||||||
|
/* SCRIPT TO COLLECT THE DATA AND POST TO THE SERVER */
|
||||||
|
$(".js-crop-and-upload").click(function () {
|
||||||
|
var cropData = $image.cropper("getData");
|
||||||
|
$("#id_x").val(cropData["x"]);
|
||||||
|
$("#id_y").val(cropData["y"]);
|
||||||
|
$("#id_height").val(cropData["height"]);
|
||||||
|
$("#id_width").val(cropData["width"]);
|
||||||
|
$("#formUpload").submit();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
{% endblock %}
|
||||||
0
apps/family/tests/__init__.py
Normal file
328
apps/family/tests/test_family.py
Normal file
@@ -0,0 +1,328 @@
|
|||||||
|
# Copyright (C) 2018-2025 by BDE ENS Paris-Saclay
|
||||||
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
|
||||||
|
import os
|
||||||
|
|
||||||
|
from api.tests import TestAPI
|
||||||
|
from django.contrib.auth.models import User
|
||||||
|
from django.core.files.uploadedfile import SimpleUploadedFile
|
||||||
|
from django.test import TestCase
|
||||||
|
from rest_framework.test import APITestCase
|
||||||
|
from django.urls import reverse
|
||||||
|
from django.utils import timezone
|
||||||
|
|
||||||
|
from ..api.views import FamilyViewSet, FamilyMembershipViewSet, ChallengeViewSet, AchievementViewSet
|
||||||
|
from ..models import Family, FamilyMembership, Challenge, Achievement
|
||||||
|
|
||||||
|
|
||||||
|
class TestFamily(TestCase):
|
||||||
|
"""
|
||||||
|
Test family
|
||||||
|
"""
|
||||||
|
|
||||||
|
def setUp(self):
|
||||||
|
self.user = User.objects.create_superuser(
|
||||||
|
username='admintoto',
|
||||||
|
password='toto1234',
|
||||||
|
email='toto@example.com',
|
||||||
|
)
|
||||||
|
self.client.force_login(self.user)
|
||||||
|
|
||||||
|
sess = self.client.session
|
||||||
|
sess['permission_mask'] = 42
|
||||||
|
sess.save()
|
||||||
|
|
||||||
|
self.family = Family.objects.create(
|
||||||
|
name='Test family',
|
||||||
|
description='',
|
||||||
|
)
|
||||||
|
|
||||||
|
self.challenge = Challenge.objects.create(
|
||||||
|
name='Test challenge',
|
||||||
|
description='',
|
||||||
|
points=100,
|
||||||
|
)
|
||||||
|
|
||||||
|
self.achievement = Achievement.objects.create(
|
||||||
|
family=self.family,
|
||||||
|
challenge=self.challenge,
|
||||||
|
valid=False,
|
||||||
|
)
|
||||||
|
|
||||||
|
def test_family_list(self):
|
||||||
|
"""
|
||||||
|
Test display family list
|
||||||
|
"""
|
||||||
|
response = self.client.get(reverse("family:family_list"))
|
||||||
|
self.assertEqual(response.status_code, 200)
|
||||||
|
|
||||||
|
def test_family_create(self):
|
||||||
|
"""
|
||||||
|
Test create a family
|
||||||
|
"""
|
||||||
|
response = self.client.get(reverse("family:family_create"))
|
||||||
|
self.assertEqual(response.status_code, 200)
|
||||||
|
|
||||||
|
response = self.client.post(reverse("family:family_create"), data={
|
||||||
|
"name": "Family toto",
|
||||||
|
"description": "A test family",
|
||||||
|
})
|
||||||
|
self.assertTrue(Family.objects.filter(name="Family toto").exists())
|
||||||
|
self.assertRedirects(response, reverse("family:manage"), 302, 200)
|
||||||
|
|
||||||
|
def test_family_detail(self):
|
||||||
|
"""
|
||||||
|
Test display the detail of a family
|
||||||
|
"""
|
||||||
|
response = self.client.get(reverse("family:family_detail", args=(self.family.pk,)))
|
||||||
|
self.assertEqual(response.status_code, 200)
|
||||||
|
|
||||||
|
def test_family_update(self):
|
||||||
|
"""
|
||||||
|
Test update a family
|
||||||
|
"""
|
||||||
|
response = self.client.get(reverse("family:family_update", args=(self.family.pk,)))
|
||||||
|
self.assertEqual(response.status_code, 200)
|
||||||
|
|
||||||
|
response = self.client.post(reverse("family:family_update", args=(self.family.pk,)), data=dict(
|
||||||
|
name="Toto family updated",
|
||||||
|
description="A larger description for the test family"
|
||||||
|
))
|
||||||
|
self.assertRedirects(response, self.family.get_absolute_url(), 302, 200)
|
||||||
|
self.assertTrue(Family.objects.filter(name="Toto family updated").exists())
|
||||||
|
|
||||||
|
def test_family_update_picture(self):
|
||||||
|
"""
|
||||||
|
Test update the picture of a family
|
||||||
|
"""
|
||||||
|
response = self.client.get(reverse("family:update_pic", args=(self.family.pk,)))
|
||||||
|
self.assertEqual(response.status_code, 200)
|
||||||
|
|
||||||
|
old_pic = self.family.display_image
|
||||||
|
|
||||||
|
with open("apps/family/static/family/img/default_picture.png", "rb") as f:
|
||||||
|
image = SimpleUploadedFile("image.png", f.read(), "image/png")
|
||||||
|
response = self.client.post(reverse("family:update_pic", args=(self.family.pk,)), dict(
|
||||||
|
image=image,
|
||||||
|
x=0,
|
||||||
|
y=0,
|
||||||
|
width=200,
|
||||||
|
height=200,
|
||||||
|
))
|
||||||
|
self.assertRedirects(response, self.family.get_absolute_url(), 302, 200)
|
||||||
|
|
||||||
|
self.family.refresh_from_db()
|
||||||
|
self.assertTrue(os.path.exists(self.family.display_image.path))
|
||||||
|
os.remove(self.family.display_image.path)
|
||||||
|
|
||||||
|
self.family.display_image = old_pic
|
||||||
|
self.family.save()
|
||||||
|
|
||||||
|
def test_family_add_member(self):
|
||||||
|
"""
|
||||||
|
Test add memberships to a family
|
||||||
|
"""
|
||||||
|
response = self.client.get(reverse("family:family_add_member", args=(self.family.pk,)))
|
||||||
|
self.assertEqual(response.status_code, 200)
|
||||||
|
|
||||||
|
user = User.objects.create(username="totototo")
|
||||||
|
user.profile.registration_valid = True
|
||||||
|
user.profile.email_confirmed = True
|
||||||
|
user.profile.save()
|
||||||
|
user.save()
|
||||||
|
|
||||||
|
response = self.client.post(reverse("family:family_add_member", args=(self.family.pk,)), data=dict(
|
||||||
|
user=user.pk,
|
||||||
|
))
|
||||||
|
self.assertRedirects(response, self.family.get_absolute_url(), 302, 200)
|
||||||
|
|
||||||
|
self.assertTrue(FamilyMembership.objects.filter(user=user, family=self.family, year=timezone.now().year).exists())
|
||||||
|
|
||||||
|
def test_challenge_list(self):
|
||||||
|
"""
|
||||||
|
Test display challenge list
|
||||||
|
"""
|
||||||
|
response = self.client.get(reverse('family:challenge_list'))
|
||||||
|
self.assertEqual(response.status_code, 200)
|
||||||
|
|
||||||
|
def test_challenge_create(self):
|
||||||
|
"""
|
||||||
|
Test create a challenge
|
||||||
|
"""
|
||||||
|
response = self.client.get(reverse("family:challenge_create"))
|
||||||
|
self.assertEqual(response.status_code, 200)
|
||||||
|
|
||||||
|
response = self.client.post(reverse("family:challenge_create"), data={
|
||||||
|
"name": "Challenge for toto",
|
||||||
|
"description": "A test challenge",
|
||||||
|
"points": 50,
|
||||||
|
})
|
||||||
|
self.assertTrue(Challenge.objects.filter(name="Challenge for toto").exists())
|
||||||
|
self.assertRedirects(response, reverse("family:manage"), 302, 200)
|
||||||
|
|
||||||
|
def test_challenge_detail(self):
|
||||||
|
"""
|
||||||
|
Test display the detail of a challenge
|
||||||
|
"""
|
||||||
|
response = self.client.get(reverse("family:challenge_detail", args=(self.challenge.pk,)))
|
||||||
|
self.assertEqual(response.status_code, 200)
|
||||||
|
|
||||||
|
def test_challenge_update(self):
|
||||||
|
"""
|
||||||
|
Test update a challenge
|
||||||
|
"""
|
||||||
|
response = self.client.get(reverse("family:challenge_update", args=(self.challenge.pk,)))
|
||||||
|
self.assertEqual(response.status_code, 200)
|
||||||
|
|
||||||
|
response = self.client.post(reverse("family:challenge_update", args=(self.challenge.pk,)), data=dict(
|
||||||
|
name="Challenge updated",
|
||||||
|
description="Another description",
|
||||||
|
points=10,
|
||||||
|
))
|
||||||
|
self.assertRedirects(response, self.challenge.get_absolute_url(), 302, 200)
|
||||||
|
self.assertTrue(Challenge.objects.filter(name="Challenge updated").exists())
|
||||||
|
|
||||||
|
def test_render_manage_page(self):
|
||||||
|
"""
|
||||||
|
Test render manage page
|
||||||
|
"""
|
||||||
|
response = self.client.get(reverse("family:manage"))
|
||||||
|
self.assertEqual(response.status_code, 200)
|
||||||
|
|
||||||
|
def test_validate_achievement(self):
|
||||||
|
"""
|
||||||
|
Test validate an achievement
|
||||||
|
"""
|
||||||
|
old_family_score = self.family.score
|
||||||
|
|
||||||
|
response = self.client.get(reverse("family:achievement_validate", args=(self.achievement.pk,)))
|
||||||
|
self.assertEqual(response.status_code, 200)
|
||||||
|
|
||||||
|
response = self.client.post(reverse("family:achievement_validate", args=(self.achievement.pk,)))
|
||||||
|
self.assertRedirects(response, reverse("family:achievement_list"), 302, 200)
|
||||||
|
|
||||||
|
self.achievement.refresh_from_db()
|
||||||
|
self.assertIs(self.achievement.valid, True)
|
||||||
|
|
||||||
|
self.family.refresh_from_db()
|
||||||
|
self.assertEqual(self.family.score, old_family_score + self.achievement.challenge.points)
|
||||||
|
|
||||||
|
def test_delete_achievement(self):
|
||||||
|
"""
|
||||||
|
Test delete an achievement
|
||||||
|
"""
|
||||||
|
response = self.client.get(reverse("family:achievement_delete", args=(self.achievement.pk,)))
|
||||||
|
self.assertEqual(response.status_code, 200)
|
||||||
|
|
||||||
|
response = self.client.delete(reverse("family:achievement_delete", args=(self.achievement.pk,)))
|
||||||
|
self.assertRedirects(response, reverse("family:achievement_list"), 302, 200)
|
||||||
|
self.assertFalse(Achievement.objects.filter(pk=self.achievement.pk).exists())
|
||||||
|
|
||||||
|
|
||||||
|
class TestBatchAchievements(APITestCase):
|
||||||
|
def setUp(self):
|
||||||
|
self.user = User.objects.create_superuser(
|
||||||
|
username='admintoto',
|
||||||
|
password='toto1234',
|
||||||
|
email='toto@example.com',
|
||||||
|
)
|
||||||
|
self.client.force_login(self.user)
|
||||||
|
|
||||||
|
sess = self.client.session
|
||||||
|
sess['permission_mask'] = 42
|
||||||
|
sess.save()
|
||||||
|
|
||||||
|
self.families = [
|
||||||
|
Family.objects.create(name=f'Famille {i}', description='') for i in range(2)
|
||||||
|
]
|
||||||
|
self.challenges = [
|
||||||
|
Challenge.objects.create(name=f'Challenge {i}', description='', points=50) for i in range(3)
|
||||||
|
]
|
||||||
|
|
||||||
|
self.achievement = Achievement.objects.create(
|
||||||
|
family=self.families[0],
|
||||||
|
challenge=self.challenges[0],
|
||||||
|
valid=False,
|
||||||
|
)
|
||||||
|
|
||||||
|
self.url = reverse("family:api:batch_achievements")
|
||||||
|
|
||||||
|
def test_batch_achievement_creation(self):
|
||||||
|
family_ids = [f.id for f in self.families]
|
||||||
|
challenge_ids = [c.id for c in self.challenges]
|
||||||
|
response = self.client.post(
|
||||||
|
self.url,
|
||||||
|
data={
|
||||||
|
'families': family_ids,
|
||||||
|
'challenges': challenge_ids
|
||||||
|
},
|
||||||
|
format='json'
|
||||||
|
)
|
||||||
|
|
||||||
|
self.assertEqual(response.status_code, 201)
|
||||||
|
for result in response.data['results']:
|
||||||
|
if result['family'] == self.families[0].name and result['challenge'] == self.challenges[0].name:
|
||||||
|
self.assertEqual(result['status'], 'existed')
|
||||||
|
else:
|
||||||
|
self.assertEqual(result['status'], 'created')
|
||||||
|
|
||||||
|
expected_count = len(family_ids) * len(challenge_ids)
|
||||||
|
self.assertEqual(Achievement.objects.count(), expected_count)
|
||||||
|
|
||||||
|
# Check that correct couples family/challenge exist
|
||||||
|
for f in self.families:
|
||||||
|
for c in self.challenges:
|
||||||
|
self.assertTrue(
|
||||||
|
Achievement.objects.filter(family=f, challenge=c).exists()
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
class TestFamilyAPI(TestAPI):
|
||||||
|
def setUp(self):
|
||||||
|
super().setUp()
|
||||||
|
|
||||||
|
self.family = Family.objects.create(
|
||||||
|
name='Test family',
|
||||||
|
description='',
|
||||||
|
)
|
||||||
|
|
||||||
|
self.familymembership = FamilyMembership.objects.create(
|
||||||
|
user=self.user,
|
||||||
|
family=self.family,
|
||||||
|
)
|
||||||
|
|
||||||
|
self.challenge = Challenge.objects.create(
|
||||||
|
name='Test challenge',
|
||||||
|
description='',
|
||||||
|
points=100,
|
||||||
|
)
|
||||||
|
|
||||||
|
self.achievement = Achievement.objects.create(
|
||||||
|
family=self.family,
|
||||||
|
challenge=self.challenge,
|
||||||
|
valid=False,
|
||||||
|
)
|
||||||
|
|
||||||
|
def test_family_api(self):
|
||||||
|
"""
|
||||||
|
Load Family API page and test all filters and permissions
|
||||||
|
"""
|
||||||
|
self.check_viewset(FamilyViewSet, '/api/family/family/')
|
||||||
|
|
||||||
|
def test_familymembership_api(self):
|
||||||
|
"""
|
||||||
|
Load FamilyMembership API page and test all filters and permissions
|
||||||
|
"""
|
||||||
|
self.check_viewset(FamilyMembershipViewSet, '/api/family/familymembership/')
|
||||||
|
|
||||||
|
def test_challenge_api(self):
|
||||||
|
"""
|
||||||
|
Load Challenge API page and test all filters and permissions
|
||||||
|
"""
|
||||||
|
self.check_viewset(ChallengeViewSet, '/api/family/challenge/')
|
||||||
|
|
||||||
|
def test_achievement_api(self):
|
||||||
|
"""
|
||||||
|
Load Achievement API page and test all filters and permissions
|
||||||
|
"""
|
||||||
|
self.check_viewset(AchievementViewSet, '/api/family/achievement/')
|
||||||
25
apps/family/urls.py
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
# Copyright (C) 2018-2025 by BDE ENS Paris-Saclay
|
||||||
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
|
||||||
|
from django.urls import path, include
|
||||||
|
|
||||||
|
from . import views
|
||||||
|
|
||||||
|
app_name = 'family'
|
||||||
|
urlpatterns = [
|
||||||
|
path('list/', views.FamilyListView.as_view(), name="family_list"),
|
||||||
|
path('create/', views.FamilyCreateView.as_view(), name="family_create"),
|
||||||
|
path('<int:pk>/detail/', views.FamilyDetailView.as_view(), name="family_detail"),
|
||||||
|
path('<int:pk>/update/', views.FamilyUpdateView.as_view(), name="family_update"),
|
||||||
|
path('<int:pk>/update_pic/', views.FamilyPictureUpdateView.as_view(), name="update_pic"),
|
||||||
|
path('<int:family_pk>/add_member/', views.FamilyAddMemberView.as_view(), name="family_add_member"),
|
||||||
|
path('challenge/list/', views.ChallengeListView.as_view(), name="challenge_list"),
|
||||||
|
path('challenge/create/', views.ChallengeCreateView.as_view(), name="challenge_create"),
|
||||||
|
path('challenge/<int:pk>/detail/', views.ChallengeDetailView.as_view(), name="challenge_detail"),
|
||||||
|
path('challenge/<int:pk>/update/', views.ChallengeUpdateView.as_view(), name="challenge_update"),
|
||||||
|
path('manage/', views.FamilyManageView.as_view(), name="manage"),
|
||||||
|
path('achievement/list/', views.AchievementListView.as_view(), name="achievement_list"),
|
||||||
|
path('achievement/<int:pk>/validate/', views.AchievementValidateView.as_view(), name="achievement_validate"),
|
||||||
|
path('achievement/<int:pk>/delete/', views.AchievementDeleteView.as_view(), name="achievement_delete"),
|
||||||
|
path('api/family/', include(('family.api.urls', 'family_api'), namespace='api')),
|
||||||
|
]
|
||||||
469
apps/family/views.py
Normal file
@@ -0,0 +1,469 @@
|
|||||||
|
# Copyright (C) 2018-2025 by BDE ENS Paris-Saclay
|
||||||
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
|
||||||
|
from datetime import date
|
||||||
|
|
||||||
|
from django.conf import settings
|
||||||
|
from django.shortcuts import redirect
|
||||||
|
from django.contrib.auth.mixins import LoginRequiredMixin
|
||||||
|
from django.core.exceptions import PermissionDenied
|
||||||
|
from django.db import transaction
|
||||||
|
from django.views.generic import DetailView, UpdateView, ListView
|
||||||
|
from django.views.generic.edit import DeleteView, FormMixin
|
||||||
|
from django.views.generic.base import TemplateView
|
||||||
|
from django.utils.translation import gettext_lazy as _
|
||||||
|
from django_tables2 import SingleTableView, MultiTableMixin
|
||||||
|
from permission.backends import PermissionBackend
|
||||||
|
from permission.views import ProtectQuerysetMixin, ProtectedCreateView
|
||||||
|
from django.urls import reverse_lazy
|
||||||
|
from member.forms import ImageForm
|
||||||
|
import phonenumbers
|
||||||
|
|
||||||
|
from .models import Family, Challenge, FamilyMembership, User, Achievement
|
||||||
|
from .tables import FamilyTable, ChallengeTable, FamilyMembershipTable, AchievementTable, FamilyAchievementTable
|
||||||
|
from .forms import ChallengeForm, FamilyMembershipForm, FamilyForm
|
||||||
|
|
||||||
|
|
||||||
|
class FamilyCreateView(ProtectQuerysetMixin, ProtectedCreateView):
|
||||||
|
"""
|
||||||
|
Create family
|
||||||
|
"""
|
||||||
|
model = Family
|
||||||
|
extra_context = {"title": _('Create family')}
|
||||||
|
form_class = FamilyForm
|
||||||
|
|
||||||
|
def get_sample_object(self):
|
||||||
|
return Family(
|
||||||
|
name="",
|
||||||
|
description="Sample family",
|
||||||
|
score=0,
|
||||||
|
rank=0,
|
||||||
|
)
|
||||||
|
|
||||||
|
def get_success_url(self):
|
||||||
|
self.object.refresh_from_db()
|
||||||
|
return reverse_lazy("family:manage")
|
||||||
|
|
||||||
|
|
||||||
|
class FamilyListView(ProtectQuerysetMixin, LoginRequiredMixin, SingleTableView):
|
||||||
|
"""
|
||||||
|
List existing Families
|
||||||
|
"""
|
||||||
|
model = Family
|
||||||
|
table_class = FamilyTable
|
||||||
|
extra_context = {"title": _('Families list')}
|
||||||
|
|
||||||
|
def get_context_data(self, **kwargs):
|
||||||
|
context = super().get_context_data(**kwargs)
|
||||||
|
|
||||||
|
fake_family = Family(name="", description="")
|
||||||
|
fake_challenge = Challenge(name="", description="", points=0)
|
||||||
|
can_add_family = PermissionBackend.check_perm(self.request, "family.add_family", fake_family)
|
||||||
|
can_add_challenge = PermissionBackend.check_perm(self.request, "family.add_challenge", fake_challenge)
|
||||||
|
|
||||||
|
if Family.objects.exists() and Challenge.objects.exists():
|
||||||
|
fake_achievement = Achievement(family=Family.objects.first(), challenge=Challenge.objects.first(), valid=False)
|
||||||
|
can_add_achievement = PermissionBackend.check_perm(self.request, "family.add_achievement", fake_achievement)
|
||||||
|
else:
|
||||||
|
can_add_achievement = False
|
||||||
|
|
||||||
|
context["can_manage"] = can_add_family or can_add_challenge or can_add_achievement
|
||||||
|
|
||||||
|
return context
|
||||||
|
|
||||||
|
|
||||||
|
class FamilyDetailView(ProtectQuerysetMixin, LoginRequiredMixin, DetailView):
|
||||||
|
"""
|
||||||
|
Display details of a family
|
||||||
|
"""
|
||||||
|
model = Family
|
||||||
|
context_object_name = "family"
|
||||||
|
extra_context = {"title": _('Family detail')}
|
||||||
|
|
||||||
|
def get_context_data(self, **kwargs):
|
||||||
|
"""
|
||||||
|
Add members list
|
||||||
|
"""
|
||||||
|
context = super().get_context_data(**kwargs)
|
||||||
|
|
||||||
|
family = self.object
|
||||||
|
|
||||||
|
# member list
|
||||||
|
family_member = FamilyMembership.objects.filter(
|
||||||
|
family=family,
|
||||||
|
year=date.today().year,
|
||||||
|
).filter(PermissionBackend.filter_queryset(self.request, FamilyMembership, "view"))\
|
||||||
|
.order_by("user__username")
|
||||||
|
family_member = family_member.distinct("user__username")\
|
||||||
|
if settings.DATABASES["default"]["ENGINE"] == 'django.db.backends.postgresql' else family_member
|
||||||
|
|
||||||
|
membership_table = FamilyMembershipTable(data=family_member, prefix="membership-")
|
||||||
|
membership_table.paginate(per_page=5, page=self.request.GET.get('membership-page', 1))
|
||||||
|
context['member_list'] = membership_table
|
||||||
|
|
||||||
|
# Check if the user has the right to create a membership, to display the button.
|
||||||
|
empty_membership = FamilyMembership(
|
||||||
|
family=family,
|
||||||
|
user=User.objects.first(),
|
||||||
|
year=date.today().year,
|
||||||
|
)
|
||||||
|
context["can_add_members"] = PermissionBackend()\
|
||||||
|
.has_perm(self.request.user, "family.add_membership", empty_membership)
|
||||||
|
|
||||||
|
# Défis réalisé par la famille
|
||||||
|
achievements = Achievement.objects.filter(family=family)
|
||||||
|
achievements_table = FamilyAchievementTable(data=achievements, prefix="achievement-")
|
||||||
|
achievements_table.paginate(per_page=5, page=self.request.GET.get('achievement-page', 1))
|
||||||
|
context["achievement_list"] = achievements_table
|
||||||
|
|
||||||
|
return context
|
||||||
|
|
||||||
|
|
||||||
|
class FamilyUpdateView(ProtectQuerysetMixin, LoginRequiredMixin, UpdateView):
|
||||||
|
"""
|
||||||
|
Update the information of a family.
|
||||||
|
"""
|
||||||
|
model = Family
|
||||||
|
context_object_name = "family"
|
||||||
|
form_class = FamilyForm
|
||||||
|
extra_context = {"title": _('Update family')}
|
||||||
|
|
||||||
|
def get_success_url(self):
|
||||||
|
return reverse_lazy('family:family_detail', kwargs={'pk': self.object.pk})
|
||||||
|
|
||||||
|
|
||||||
|
class FamilyPictureUpdateView(ProtectQuerysetMixin, LoginRequiredMixin, FormMixin, DetailView):
|
||||||
|
"""
|
||||||
|
Update profile picture of the family
|
||||||
|
"""
|
||||||
|
model = Family
|
||||||
|
extra_context = {"title": _("Update family picture")}
|
||||||
|
template_name = 'family/picture_update.html'
|
||||||
|
form_class = ImageForm
|
||||||
|
|
||||||
|
def get_context_data(self, **kwargs):
|
||||||
|
context = super().get_context_data(**kwargs)
|
||||||
|
context['form'] = self.form_class(self.request.POST, self.request.FILES)
|
||||||
|
return context
|
||||||
|
|
||||||
|
def get_success_url(self):
|
||||||
|
"""Redirect to family page after upload"""
|
||||||
|
return reverse_lazy('family:family_detail', kwargs={'pk': self.object.pk})
|
||||||
|
|
||||||
|
def post(self, request, *args, **kwargs):
|
||||||
|
form = self.get_form()
|
||||||
|
self.object = self.get_object()
|
||||||
|
return self.form_valid(form) if form.is_valid() else self.form_invalid(form)
|
||||||
|
|
||||||
|
@transaction.atomic
|
||||||
|
def form_valid(self, form):
|
||||||
|
"""
|
||||||
|
Save the image
|
||||||
|
"""
|
||||||
|
image = form.cleaned_data['image']
|
||||||
|
|
||||||
|
if image is None:
|
||||||
|
image = "pic/default.png"
|
||||||
|
else:
|
||||||
|
# Rename as PNG or GIF
|
||||||
|
extension = image.name.split(".")[-1]
|
||||||
|
if extension == "gif":
|
||||||
|
image.name = "{}_pic.gif".format(self.object.pk)
|
||||||
|
else:
|
||||||
|
image.name = "{}_pic.png".format(self.object.pk)
|
||||||
|
|
||||||
|
# Save
|
||||||
|
self.object.display_image = image
|
||||||
|
self.object.save()
|
||||||
|
return super().form_valid(form)
|
||||||
|
|
||||||
|
|
||||||
|
class FamilyAddMemberView(ProtectQuerysetMixin, ProtectedCreateView):
|
||||||
|
"""
|
||||||
|
Add a membership to a family
|
||||||
|
"""
|
||||||
|
model = FamilyMembership
|
||||||
|
form_class = FamilyMembershipForm
|
||||||
|
template_name = 'family/add_member.html'
|
||||||
|
extra_context = {"title": _("Add a new member to the family")}
|
||||||
|
|
||||||
|
def get_sample_object(self):
|
||||||
|
if "family_pk" in self.kwargs:
|
||||||
|
family = Family.objects.get(pk=self.kwargs["family_pk"])
|
||||||
|
else:
|
||||||
|
family = FamilyMembership.objects.get(pk=self.kwargs["pk"]).family
|
||||||
|
return FamilyMembership(
|
||||||
|
user=self.request.user,
|
||||||
|
family=family,
|
||||||
|
year=date.today().year,
|
||||||
|
)
|
||||||
|
|
||||||
|
def get_context_data(self, **kwargs):
|
||||||
|
context = super().get_context_data(**kwargs)
|
||||||
|
|
||||||
|
family = Family.objects.filter(PermissionBackend.filter_queryset(self.request, Family, "view"))\
|
||||||
|
.get(pk=self.kwargs['family_pk'])
|
||||||
|
|
||||||
|
context['family'] = family
|
||||||
|
|
||||||
|
return context
|
||||||
|
|
||||||
|
@transaction.atomic
|
||||||
|
def form_valid(self, form):
|
||||||
|
"""
|
||||||
|
Create family membership, check that everythinf is good
|
||||||
|
"""
|
||||||
|
family = Family.objects.filter(PermissionBackend.filter_queryset(self.request, Family, "view")) \
|
||||||
|
.get(pk=self.kwargs["family_pk"])
|
||||||
|
|
||||||
|
form.instance.family = family
|
||||||
|
|
||||||
|
return super().form_valid(form)
|
||||||
|
|
||||||
|
def get_success_url(self):
|
||||||
|
return reverse_lazy('family:family_detail', kwargs={'pk': self.object.family.id})
|
||||||
|
|
||||||
|
|
||||||
|
class ChallengeCreateView(ProtectQuerysetMixin, ProtectedCreateView):
|
||||||
|
"""
|
||||||
|
Create challenge
|
||||||
|
"""
|
||||||
|
model = Challenge
|
||||||
|
extra_context = {"title": _('Create challenge')}
|
||||||
|
form_class = ChallengeForm
|
||||||
|
|
||||||
|
def get_sample_object(self):
|
||||||
|
return Challenge(
|
||||||
|
name="",
|
||||||
|
description="Sample challenge",
|
||||||
|
points=0,
|
||||||
|
)
|
||||||
|
|
||||||
|
def get_success_url(self):
|
||||||
|
return reverse_lazy('family:manage')
|
||||||
|
|
||||||
|
|
||||||
|
class ChallengeListView(ProtectQuerysetMixin, LoginRequiredMixin, SingleTableView):
|
||||||
|
"""
|
||||||
|
List all challenges
|
||||||
|
"""
|
||||||
|
model = Challenge
|
||||||
|
table_class = ChallengeTable
|
||||||
|
extra_context = {"title": _('Challenges list')}
|
||||||
|
|
||||||
|
def get_context_data(self, **kwargs):
|
||||||
|
context = super().get_context_data(**kwargs)
|
||||||
|
|
||||||
|
fake_family = Family(name="", description="")
|
||||||
|
fake_challenge = Challenge(name="", description="", points=0)
|
||||||
|
can_add_family = PermissionBackend.check_perm(self.request, "family.add_family", fake_family)
|
||||||
|
can_add_challenge = PermissionBackend.check_perm(self.request, "family.add_challenge", fake_challenge)
|
||||||
|
|
||||||
|
if Family.objects.exists() and Challenge.objects.exists():
|
||||||
|
fake_achievement = Achievement(family=Family.objects.first(), challenge=Challenge.objects.first(), valid=False)
|
||||||
|
can_add_achievement = PermissionBackend.check_perm(self.request, "family.add_achievement", fake_achievement)
|
||||||
|
else:
|
||||||
|
can_add_achievement = False
|
||||||
|
|
||||||
|
context["can_manage"] = can_add_family or can_add_challenge or can_add_achievement
|
||||||
|
|
||||||
|
return context
|
||||||
|
|
||||||
|
|
||||||
|
class ChallengeDetailView(ProtectQuerysetMixin, LoginRequiredMixin, DetailView):
|
||||||
|
"""
|
||||||
|
Display details of a challenge
|
||||||
|
"""
|
||||||
|
model = Challenge
|
||||||
|
context_object_name = "challenge"
|
||||||
|
extra_context = {"title": _('Details of:')}
|
||||||
|
|
||||||
|
def get_context_data(self, **kwargs):
|
||||||
|
context = super().get_context_data(**kwargs)
|
||||||
|
fields = ["name", "description", "points",]
|
||||||
|
|
||||||
|
fields = dict([(field, getattr(self.object, field)) for field in fields])
|
||||||
|
|
||||||
|
context["fields"] = [(
|
||||||
|
Challenge._meta.get_field(field).verbose_name.capitalize(),
|
||||||
|
value) for field, value in fields.items()]
|
||||||
|
context["obtained"] = self.object.obtained
|
||||||
|
context["update"] = PermissionBackend.check_perm(self.request, "family.change_challenge")
|
||||||
|
|
||||||
|
return context
|
||||||
|
|
||||||
|
|
||||||
|
class ChallengeUpdateView(ProtectQuerysetMixin, LoginRequiredMixin, UpdateView):
|
||||||
|
"""
|
||||||
|
Update the information of a challenge
|
||||||
|
"""
|
||||||
|
model = Challenge
|
||||||
|
context_object_name = "challenge"
|
||||||
|
extra_context = {"title": _('Update challenge')}
|
||||||
|
form_class = ChallengeForm
|
||||||
|
|
||||||
|
def get_success_url(self, **kwargs):
|
||||||
|
self.object.refresh_from_db()
|
||||||
|
return reverse_lazy('family:challenge_detail', kwargs={'pk': self.object.pk})
|
||||||
|
|
||||||
|
|
||||||
|
class FamilyManageView(ProtectQuerysetMixin, LoginRequiredMixin, SingleTableView):
|
||||||
|
"""
|
||||||
|
Manage families and challenges
|
||||||
|
"""
|
||||||
|
model = Achievement
|
||||||
|
template_name = 'family/manage.html'
|
||||||
|
table_class = AchievementTable
|
||||||
|
extra_context = {'title': _('Manage families and challenges')}
|
||||||
|
|
||||||
|
def dispatch(self, request, *args, **kwargs):
|
||||||
|
# Check that the user is authenticated
|
||||||
|
if not request.user.is_authenticated:
|
||||||
|
return self.handle_no_permission()
|
||||||
|
|
||||||
|
perm = PermissionBackend.has_model_perm(self.request, Achievement(), "add")
|
||||||
|
perm = perm or PermissionBackend.has_model_perm(self.request, Challenge(), "add")
|
||||||
|
perm = perm or PermissionBackend.has_model_perm(self.request, Family(), "add")
|
||||||
|
if not perm:
|
||||||
|
raise PermissionDenied(_("You are not able to manage families and challenges."))
|
||||||
|
return super().dispatch(request, *args, **kwargs)
|
||||||
|
|
||||||
|
def get_queryset(self, **kwargs):
|
||||||
|
# retrieves only Transaction that user has the right to see.
|
||||||
|
return Achievement.objects.filter(
|
||||||
|
PermissionBackend.filter_queryset(self.request, Achievement, "view")
|
||||||
|
).order_by("-obtained_at").all()
|
||||||
|
|
||||||
|
def get_context_data(self, **kwargs):
|
||||||
|
context = super().get_context_data(**kwargs)
|
||||||
|
|
||||||
|
context['all_challenges'] = Challenge.objects.filter(
|
||||||
|
PermissionBackend.filter_queryset(self.request, Challenge, "view")
|
||||||
|
).order_by('name')
|
||||||
|
|
||||||
|
context["can_add_family"] = PermissionBackend.has_model_perm(self.request, Family(), "add")
|
||||||
|
context["can_add_challenge"] = PermissionBackend.has_model_perm(self.request, Challenge(), "add")
|
||||||
|
context["can_add_achievement"] = PermissionBackend.has_model_perm(self.request, Achievement(), "add")
|
||||||
|
|
||||||
|
# Get the user's family if they have one
|
||||||
|
try:
|
||||||
|
user_family_membership = FamilyMembership.objects.get(user=self.request.user)
|
||||||
|
context["user_family"] = user_family_membership.family
|
||||||
|
except FamilyMembership.DoesNotExist:
|
||||||
|
context["user_family"] = None
|
||||||
|
|
||||||
|
phone_numbers = [
|
||||||
|
u.profile.phone_number for u in User.objects.filter(
|
||||||
|
memberships__roles__id=35,
|
||||||
|
memberships__date_end__gte=date.today(),
|
||||||
|
profile__phone_number__isnull=False
|
||||||
|
).distinct()
|
||||||
|
]
|
||||||
|
formatted_phone_numbers = [phonenumbers.format_number(num, phonenumbers.PhoneNumberFormat.INTERNATIONAL) for num in phone_numbers if num]
|
||||||
|
context["phone_numbers"] = formatted_phone_numbers
|
||||||
|
|
||||||
|
return context
|
||||||
|
|
||||||
|
def get_table(self, **kwargs):
|
||||||
|
table = super().get_table(**kwargs)
|
||||||
|
table.exclude = ('delete', 'validate',)
|
||||||
|
table.orderable = False
|
||||||
|
return table
|
||||||
|
|
||||||
|
def get_table_data(self, **kwargs):
|
||||||
|
qs = super().get_queryset(**kwargs)
|
||||||
|
|
||||||
|
qs = qs.filter(PermissionBackend.filter_queryset(self.request, Achievement, "view"))
|
||||||
|
|
||||||
|
return qs
|
||||||
|
|
||||||
|
|
||||||
|
class AchievementListView(ProtectQuerysetMixin, LoginRequiredMixin, MultiTableMixin, ListView):
|
||||||
|
"""
|
||||||
|
List all achievements
|
||||||
|
"""
|
||||||
|
model = Achievement
|
||||||
|
tables = [AchievementTable, AchievementTable, ]
|
||||||
|
extra_context = {'title': _('Achievement list')}
|
||||||
|
|
||||||
|
def dispatch(self, request, *args, **kwargs):
|
||||||
|
if not request.user.is_authenticated:
|
||||||
|
return self.handle_no_permission()
|
||||||
|
|
||||||
|
if not PermissionBackend.has_model_perm(self.request, Achievement(), "change"):
|
||||||
|
raise PermissionDenied(_("You are not able to see the achievement validation interface."))
|
||||||
|
return super().dispatch(request, *args, **kwargs)
|
||||||
|
|
||||||
|
def get_tables(self, **kwargs):
|
||||||
|
tables = super().get_tables(**kwargs)
|
||||||
|
|
||||||
|
tables[0].prefix = 'invalid-'
|
||||||
|
tables[1].prefix = 'valid-'
|
||||||
|
tables[1].exclude = ('validate', 'delete',)
|
||||||
|
|
||||||
|
return tables
|
||||||
|
|
||||||
|
def get_tables_data(self):
|
||||||
|
table_valid = self.get_queryset().filter(valid=True)
|
||||||
|
table_invalid = self.get_queryset().filter(valid=False)
|
||||||
|
return [table_invalid, table_valid, ]
|
||||||
|
|
||||||
|
def get_context_data(self, **kwargs):
|
||||||
|
context = super().get_context_data(**kwargs)
|
||||||
|
|
||||||
|
tables = context['tables']
|
||||||
|
|
||||||
|
context['invalid'] = tables[0]
|
||||||
|
context['valid'] = tables[1]
|
||||||
|
return context
|
||||||
|
|
||||||
|
|
||||||
|
class AchievementValidateView(ProtectQuerysetMixin, LoginRequiredMixin, TemplateView):
|
||||||
|
"""
|
||||||
|
Validate an achievement obtained by a family
|
||||||
|
"""
|
||||||
|
template_name = 'family/achievement_confirm_validate.html'
|
||||||
|
|
||||||
|
def dispatch(self, request, *args, **kwargs):
|
||||||
|
if not request.user.is_authenticated:
|
||||||
|
return self.handle_no_permission()
|
||||||
|
|
||||||
|
fake_achievement = Achievement(
|
||||||
|
family=Family.objects.first(),
|
||||||
|
challenge=Challenge.objects.first(),
|
||||||
|
valid=False,
|
||||||
|
)
|
||||||
|
if not PermissionBackend.check_perm(self.request, "family.change_achievement_valid", fake_achievement):
|
||||||
|
raise PermissionDenied()
|
||||||
|
return super().dispatch(request, *args, **kwargs)
|
||||||
|
|
||||||
|
def post(self, request, pk):
|
||||||
|
achievement = Achievement.objects.get(pk=pk)
|
||||||
|
|
||||||
|
achievement.valid = True
|
||||||
|
achievement.save()
|
||||||
|
|
||||||
|
return redirect(reverse_lazy('family:achievement_list'))
|
||||||
|
|
||||||
|
|
||||||
|
class AchievementDeleteView(ProtectQuerysetMixin, LoginRequiredMixin, DeleteView):
|
||||||
|
"""
|
||||||
|
Delete an Achievement
|
||||||
|
"""
|
||||||
|
model = Achievement
|
||||||
|
|
||||||
|
def dispatch(self, request, *args, **kwargs):
|
||||||
|
if not request.user.is_authenticated:
|
||||||
|
return self.handle_no_permission()
|
||||||
|
|
||||||
|
fake_achievement = Achievement(
|
||||||
|
family=Family.objects.first(),
|
||||||
|
challenge=Challenge.objects.first(),
|
||||||
|
valid=False,
|
||||||
|
)
|
||||||
|
if not PermissionBackend.check_perm(self.request, "family.change_achievement_valid", fake_achievement):
|
||||||
|
raise PermissionDenied()
|
||||||
|
return super().dispatch(request, *args, **kwargs)
|
||||||
|
|
||||||
|
def get_success_url(self):
|
||||||
|
return reverse_lazy('family:achievement_list')
|
||||||
@@ -2,6 +2,7 @@
|
|||||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
|
||||||
import django_tables2 as tables
|
import django_tables2 as tables
|
||||||
|
from django.utils.translation import gettext_lazy as _
|
||||||
|
|
||||||
from .models import Food
|
from .models import Food
|
||||||
|
|
||||||
@@ -10,10 +11,25 @@ class FoodTable(tables.Table):
|
|||||||
"""
|
"""
|
||||||
List all foods.
|
List all foods.
|
||||||
"""
|
"""
|
||||||
|
qr_code_numbers = tables.Column(empty_values=(), verbose_name=_("QR Codes"), orderable=False)
|
||||||
|
|
||||||
|
date = tables.Column(empty_values=(), verbose_name=_("Arrival/creation date"), orderable=False)
|
||||||
|
|
||||||
|
def render_date(self, record):
|
||||||
|
if record.__class__.__name__ == "BasicFood":
|
||||||
|
return record.arrival_date.strftime("%d/%m/%Y %H:%M")
|
||||||
|
elif record.__class__.__name__ == "TransformedFood":
|
||||||
|
return record.creation_date.strftime("%d/%m/%Y %H:%M")
|
||||||
|
else:
|
||||||
|
return "--"
|
||||||
|
|
||||||
|
def render_qr_code_numbers(self, record):
|
||||||
|
return ", ".join(str(q.qr_code_number) for q in record.QR_code.all())
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = Food
|
model = Food
|
||||||
template_name = 'django_tables2/bootstrap4.html'
|
template_name = 'django_tables2/bootstrap4.html'
|
||||||
fields = ('name', 'owner', 'allergens', 'expiry_date')
|
fields = ('name', 'owner', 'qr_code_numbers', 'allergens', 'date', 'expiry_date')
|
||||||
row_attrs = {
|
row_attrs = {
|
||||||
'class': 'table-row',
|
'class': 'table-row',
|
||||||
'data-href': lambda record: 'detail/' + str(record.pk),
|
'data-href': lambda record: 'detail/' + str(record.pk),
|
||||||
|
|||||||
@@ -34,6 +34,12 @@ SPDX-License-Identifier: GPL-3.0-or-later
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
|
<div class="form-check">
|
||||||
|
<label for="stock_only" class="form-check-label">
|
||||||
|
<input id="stock_only" name="stock_only" type="checkbox" class="checkboxinput form-check-input" checked>
|
||||||
|
{% trans "Filter with only food in stock" %}
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
<input id="searchbar" type="text" class="form-control"
|
<input id="searchbar" type="text" class="form-control"
|
||||||
placeholder="{% trans "Search by attribute such as name..." %}">
|
placeholder="{% trans "Search by attribute such as name..." %}">
|
||||||
</div>
|
</div>
|
||||||
@@ -114,7 +120,26 @@ SPDX-License-Identifier: GPL-3.0-or-later
|
|||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<script type="text/javascript">
|
||||||
|
|
||||||
|
let old_pattern = null;
|
||||||
|
let searchbar_obj = $("#searchbar");
|
||||||
|
let stock_only_obj = $("#stock_only");
|
||||||
|
|
||||||
|
function reloadTable() {
|
||||||
|
let pattern = searchbar_obj.val();
|
||||||
|
|
||||||
|
$("#dynamic-table").load(location.pathname + "?search=" + pattern.replace(" ", "%20") + (
|
||||||
|
stock_only_obj.is(':checked') ? "" : "&stock=1") + " #dynamic-table");
|
||||||
|
}
|
||||||
|
|
||||||
|
searchbar_obj.keyup(reloadTable);
|
||||||
|
stock_only_obj.change(reloadTable);
|
||||||
|
|
||||||
|
$(document).on("click", ".table-row", function () {
|
||||||
|
window.document.location = $(this).data("href");
|
||||||
|
});
|
||||||
|
</script>
|
||||||
<script>
|
<script>
|
||||||
document.addEventListener('DOMContentLoaded', function() {
|
document.addEventListener('DOMContentLoaded', function() {
|
||||||
document.getElementById('goButton').addEventListener('click', function(event) {
|
document.getElementById('goButton').addEventListener('click', function(event) {
|
||||||
|
|||||||
@@ -65,16 +65,24 @@ class FoodListView(ProtectQuerysetMixin, LoginRequiredMixin, MultiTableMixin, Li
|
|||||||
suffix = '__iregex' if valid_regex else '__istartswith'
|
suffix = '__iregex' if valid_regex else '__istartswith'
|
||||||
prefix = '^' if valid_regex else ''
|
prefix = '^' if valid_regex else ''
|
||||||
qs = qs.filter(Q(**{f'name{suffix}': prefix + pattern})
|
qs = qs.filter(Q(**{f'name{suffix}': prefix + pattern})
|
||||||
| Q(**{f'owner__name{suffix}': prefix + pattern}))
|
| Q(**{f'owner__name{suffix}': prefix + pattern})
|
||||||
|
| Q(**{f'owner__note__alias__name{suffix}': prefix + pattern}))
|
||||||
else:
|
else:
|
||||||
qs = qs.none()
|
qs = qs.none()
|
||||||
|
if "stock" not in self.request.GET or not self.request.GET["stock"] == '1':
|
||||||
|
qs = qs.filter(end_of_life='')
|
||||||
|
|
||||||
search_table = qs.filter(PermissionBackend.filter_queryset(self.request, Food, 'view'))
|
search_table = qs.filter(PermissionBackend.filter_queryset(self.request, Food, 'view'))
|
||||||
# table open
|
# table open
|
||||||
open_table = self.get_queryset().order_by('expiry_date').filter(
|
open_table = self.get_queryset().filter(
|
||||||
Q(polymorphic_ctype__model='transformedfood')
|
Q(polymorphic_ctype__model='transformedfood')
|
||||||
| Q(polymorphic_ctype__model='basicfood', basicfood__date_type='DLC')).filter(
|
| Q(polymorphic_ctype__model='basicfood', basicfood__date_type='DLC')).filter(
|
||||||
expiry_date__lt=timezone.now(), end_of_life='').filter(
|
expiry_date__lt=timezone.now(), end_of_life='').filter(
|
||||||
PermissionBackend.filter_queryset(self.request, Food, 'view'))
|
PermissionBackend.filter_queryset(self.request, Food, 'view'))
|
||||||
|
open_table = open_table.union(self.get_queryset().filter(
|
||||||
|
Q(end_of_life='', order__iexact='open')
|
||||||
|
).filter(
|
||||||
|
PermissionBackend.filter_queryset(self.request, Food, 'view'))).order_by('expiry_date')
|
||||||
# table served
|
# table served
|
||||||
served_table = self.get_queryset().order_by('-pk').filter(
|
served_table = self.get_queryset().order_by('-pk').filter(
|
||||||
end_of_life='', is_ready=True).exclude(
|
end_of_life='', is_ready=True).exclude(
|
||||||
@@ -95,6 +103,7 @@ class FoodListView(ProtectQuerysetMixin, LoginRequiredMixin, MultiTableMixin, Li
|
|||||||
owner=club, end_of_life='').filter(
|
owner=club, end_of_life='').filter(
|
||||||
PermissionBackend.filter_queryset(self.request, Food, 'view')
|
PermissionBackend.filter_queryset(self.request, Food, 'view')
|
||||||
))
|
))
|
||||||
|
|
||||||
return [search_table, open_table, served_table] + club_table
|
return [search_table, open_table, served_table] + club_table
|
||||||
|
|
||||||
def get_context_data(self, **kwargs):
|
def get_context_data(self, **kwargs):
|
||||||
@@ -218,7 +227,7 @@ class BasicFoodCreateView(ProtectQuerysetMixin, ProtectedCreateView):
|
|||||||
copy = self.request.GET.get('copy', None)
|
copy = self.request.GET.get('copy', None)
|
||||||
if copy is not None:
|
if copy is not None:
|
||||||
food = BasicFood.objects.get(pk=copy)
|
food = BasicFood.objects.get(pk=copy)
|
||||||
print(context['form'].fields)
|
|
||||||
for field in context['form'].fields:
|
for field in context['form'].fields:
|
||||||
if field == 'allergens':
|
if field == 'allergens':
|
||||||
context['form'].fields[field].initial = getattr(food, field).all()
|
context['form'].fields[field].initial = getattr(food, field).all()
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ from django.conf import settings
|
|||||||
from django.db.models.signals import post_save
|
from django.db.models.signals import post_save
|
||||||
from django.utils.translation import gettext_lazy as _
|
from django.utils.translation import gettext_lazy as _
|
||||||
|
|
||||||
from .signals import save_user_profile
|
from .signals import save_user_profile, update_wei_registration_fee_on_membership_creation, update_wei_registration_fee_on_club_change
|
||||||
|
|
||||||
|
|
||||||
class MemberConfig(AppConfig):
|
class MemberConfig(AppConfig):
|
||||||
@@ -17,7 +17,16 @@ class MemberConfig(AppConfig):
|
|||||||
"""
|
"""
|
||||||
Define app internal signals to interact with other apps
|
Define app internal signals to interact with other apps
|
||||||
"""
|
"""
|
||||||
|
from .models import Membership, Club
|
||||||
post_save.connect(
|
post_save.connect(
|
||||||
save_user_profile,
|
save_user_profile,
|
||||||
sender=settings.AUTH_USER_MODEL,
|
sender=settings.AUTH_USER_MODEL,
|
||||||
)
|
)
|
||||||
|
post_save.connect(
|
||||||
|
update_wei_registration_fee_on_membership_creation,
|
||||||
|
sender=Membership
|
||||||
|
)
|
||||||
|
post_save.connect(
|
||||||
|
update_wei_registration_fee_on_club_change,
|
||||||
|
sender=Club
|
||||||
|
)
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ from django.contrib.auth.forms import AuthenticationForm
|
|||||||
from django.contrib.auth.models import User
|
from django.contrib.auth.models import User
|
||||||
from django.db import transaction
|
from django.db import transaction
|
||||||
from django.forms import CheckboxSelectMultiple
|
from django.forms import CheckboxSelectMultiple
|
||||||
|
from phonenumber_field.formfields import PhoneNumberField
|
||||||
from django.utils import timezone
|
from django.utils import timezone
|
||||||
from django.utils.translation import gettext_lazy as _
|
from django.utils.translation import gettext_lazy as _
|
||||||
from note.models import NoteSpecial, Alias
|
from note.models import NoteSpecial, Alias
|
||||||
@@ -45,6 +46,11 @@ class ProfileForm(forms.ModelForm):
|
|||||||
A form for the extras field provided by the :model:`member.Profile` model.
|
A form for the extras field provided by the :model:`member.Profile` model.
|
||||||
"""
|
"""
|
||||||
# Remove widget=forms.HiddenInput() if you want to use report frequency.
|
# Remove widget=forms.HiddenInput() if you want to use report frequency.
|
||||||
|
phone_number = PhoneNumberField(
|
||||||
|
widget=forms.TextInput(attrs={"type": "tel", "class": "form-control"}),
|
||||||
|
required=False
|
||||||
|
)
|
||||||
|
|
||||||
report_frequency = forms.IntegerField(required=False, initial=0, label=_("Report frequency"))
|
report_frequency = forms.IntegerField(required=False, initial=0, label=_("Report frequency"))
|
||||||
|
|
||||||
last_report = forms.DateTimeField(required=False, disabled=True, label=_("Last report date"))
|
last_report = forms.DateTimeField(required=False, disabled=True, label=_("Last report date"))
|
||||||
@@ -72,7 +78,12 @@ class ProfileForm(forms.ModelForm):
|
|||||||
if not self.instance.section or (("department" in self.changed_data
|
if not self.instance.section or (("department" in self.changed_data
|
||||||
or "promotion" in self.changed_data) and "section" not in self.changed_data):
|
or "promotion" in self.changed_data) and "section" not in self.changed_data):
|
||||||
self.instance.section = self.instance.section_generated
|
self.instance.section = self.instance.section_generated
|
||||||
return super().save(commit)
|
instance = super().save(commit=False)
|
||||||
|
if instance.phone_number:
|
||||||
|
instance.phone_number = instance.phone_number.as_e164
|
||||||
|
if commit:
|
||||||
|
instance.save()
|
||||||
|
return instance
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = Profile
|
model = Profile
|
||||||
|
|||||||
18
apps/member/migrations/0015_alter_profile_promotion.py
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
# Generated by Django 5.2.4 on 2025-08-02 13:43
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('member', '0014_create_bda'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='profile',
|
||||||
|
name='promotion',
|
||||||
|
field=models.PositiveSmallIntegerField(default=2025, help_text='Year of entry to the school (None if not ENS student)', null=True, verbose_name='promotion'),
|
||||||
|
),
|
||||||
|
]
|
||||||
@@ -417,7 +417,7 @@ class Membership(models.Model):
|
|||||||
A membership is valid if today is between the start and the end date.
|
A membership is valid if today is between the start and the end date.
|
||||||
"""
|
"""
|
||||||
if self.date_end is not None:
|
if self.date_end is not None:
|
||||||
return self.date_start.toordinal() <= datetime.datetime.now().toordinal() < self.date_end.toordinal()
|
return self.date_start.toordinal() <= datetime.datetime.now().toordinal() <= self.date_end.toordinal()
|
||||||
else:
|
else:
|
||||||
return self.date_start.toordinal() <= datetime.datetime.now().toordinal()
|
return self.date_start.toordinal() <= datetime.datetime.now().toordinal()
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
# Copyright (C) 2018-2025 by BDE ENS Paris-Saclay
|
# Copyright (C) 2018-2025 by BDE ENS Paris-Saclay
|
||||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
|
||||||
|
from django.conf import settings
|
||||||
|
|
||||||
|
|
||||||
def save_user_profile(instance, created, raw, **_kwargs):
|
def save_user_profile(instance, created, raw, **_kwargs):
|
||||||
"""
|
"""
|
||||||
@@ -13,3 +15,27 @@ def save_user_profile(instance, created, raw, **_kwargs):
|
|||||||
instance.profile.email_confirmed = True
|
instance.profile.email_confirmed = True
|
||||||
instance.profile.registration_valid = True
|
instance.profile.registration_valid = True
|
||||||
instance.profile.save()
|
instance.profile.save()
|
||||||
|
|
||||||
|
|
||||||
|
def update_wei_registration_fee_on_membership_creation(sender, instance, created, **kwargs):
|
||||||
|
if not hasattr(instance, "_no_signal") and 'wei' in settings.INSTALLED_APPS and created:
|
||||||
|
from wei.models import WEIRegistration
|
||||||
|
if instance.club.id == 1 or instance.club.id == 2:
|
||||||
|
registrations = WEIRegistration.objects.filter(
|
||||||
|
user=instance.user,
|
||||||
|
wei__year=instance.date_start.year,
|
||||||
|
)
|
||||||
|
for r in registrations:
|
||||||
|
r._force_save = True
|
||||||
|
r.save()
|
||||||
|
|
||||||
|
|
||||||
|
def update_wei_registration_fee_on_club_change(sender, instance, **kwargs):
|
||||||
|
if not hasattr(instance, "_no_signal") and 'wei' in settings.INSTALLED_APPS and (instance.id == 1 or instance.id == 2):
|
||||||
|
from wei.models import WEIRegistration
|
||||||
|
registrations = WEIRegistration.objects.filter(
|
||||||
|
wei__year=instance.membership_start.year,
|
||||||
|
)
|
||||||
|
for r in registrations:
|
||||||
|
r._force_save = True
|
||||||
|
r.save()
|
||||||
|
|||||||
@@ -92,6 +92,20 @@ class MembershipTable(tables.Table):
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
user_email = tables.Column(
|
||||||
|
verbose_name="Email",
|
||||||
|
accessor="user.email",
|
||||||
|
orderable=False,
|
||||||
|
visible=False,
|
||||||
|
)
|
||||||
|
|
||||||
|
user_full_name = tables.Column(
|
||||||
|
verbose_name=_("Full name"),
|
||||||
|
accessor="user.get_full_name",
|
||||||
|
orderable=False,
|
||||||
|
visible=False,
|
||||||
|
)
|
||||||
|
|
||||||
def render_user(self, value):
|
def render_user(self, value):
|
||||||
# If the user has the right, link the displayed user with the page of its detail.
|
# If the user has the right, link the displayed user with the page of its detail.
|
||||||
s = value.username
|
s = value.username
|
||||||
@@ -149,6 +163,16 @@ class MembershipTable(tables.Table):
|
|||||||
+ "'>" + s + "</a>")
|
+ "'>" + s + "</a>")
|
||||||
return s
|
return s
|
||||||
|
|
||||||
|
def value_user(self, record):
|
||||||
|
return record.user.username if record.user else ""
|
||||||
|
|
||||||
|
def value_club(self, record):
|
||||||
|
return record.club.name if record.club else ""
|
||||||
|
|
||||||
|
def value_roles(self, record):
|
||||||
|
roles = record.roles.all()
|
||||||
|
return ", ".join(str(role) for role in roles)
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
attrs = {
|
attrs = {
|
||||||
'class': 'table table-condensed table-striped',
|
'class': 'table table-condensed table-striped',
|
||||||
|
|||||||
@@ -36,7 +36,13 @@ SPDX-License-Identifier: GPL-3.0-or-later
|
|||||||
{% trans "There is no membership found with this pattern." %}
|
{% trans "There is no membership found with this pattern." %}
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
<div class="card-footer text-center">
|
||||||
|
<button class="btn btn-block btn-primary mb-3" onclick="window.location.href='?_export=csv'">
|
||||||
|
{% trans "Export to CSV" %}
|
||||||
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
|
|||||||
@@ -7,6 +7,19 @@
|
|||||||
<dt class="col-xl-6">{% trans 'username'|capfirst %}</dt>
|
<dt class="col-xl-6">{% trans 'username'|capfirst %}</dt>
|
||||||
<dd class="col-xl-6">{{ user_object.username }}</dd>
|
<dd class="col-xl-6">{{ user_object.username }}</dd>
|
||||||
|
|
||||||
|
{% if family_app_installed %}
|
||||||
|
<dt class="col-xl-6">{% trans 'family'|capfirst %}</dt>
|
||||||
|
<dd class="col-xl-6">
|
||||||
|
{% if families %}
|
||||||
|
{% for fam in families %}
|
||||||
|
<a href="{% url 'family:family_detail' fam.pk %}">{{ fam.name }}</a>{% if not forloop.last %}, {% endif %}
|
||||||
|
{% endfor %}
|
||||||
|
{% else %}
|
||||||
|
<span class="text-muted">Aucune</span>
|
||||||
|
{% endif %}
|
||||||
|
</dd>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
{% if user_object.pk == user.pk %}
|
{% if user_object.pk == user.pk %}
|
||||||
<dt class="col-xl-6">{% trans 'password'|capfirst %}</dt>
|
<dt class="col-xl-6">{% trans 'password'|capfirst %}</dt>
|
||||||
<dd class="col-xl-6">
|
<dd class="col-xl-6">
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ SPDX-License-Identifier: GPL-3.0-or-later
|
|||||||
{{ title }}
|
{{ title }}
|
||||||
</h3>
|
</h3>
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
<form method="post">
|
<form method="post" id="profile-form">
|
||||||
{% csrf_token %}
|
{% csrf_token %}
|
||||||
{{ form | crispy }}
|
{{ form | crispy }}
|
||||||
{{ profile_form | crispy }}
|
{{ profile_form | crispy }}
|
||||||
@@ -21,3 +21,45 @@ SPDX-License-Identifier: GPL-3.0-or-later
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
|
{% block extrajavascript %}
|
||||||
|
<!-- intl-tel-input CSS/JS -->
|
||||||
|
<script>
|
||||||
|
(() => {
|
||||||
|
const input = document.querySelector("input[name='phone_number']");
|
||||||
|
const form = document.querySelector("#profile-form");
|
||||||
|
|
||||||
|
if (!input || !form || input.type === "hidden" || input.disabled || input.readOnly) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const iti = window.intlTelInput(input, {
|
||||||
|
initialCountry: "auto",
|
||||||
|
nationalMode: false,
|
||||||
|
autoPlaceholder: "off",
|
||||||
|
geoIpLookup: callback => {
|
||||||
|
fetch("https://ipapi.co/json")
|
||||||
|
.then(res => res.json())
|
||||||
|
.then(data => callback(data.country_code))
|
||||||
|
.catch(() => callback("fr"));
|
||||||
|
},
|
||||||
|
loadUtils: () => import("https://cdn.jsdelivr.net/npm/intl-tel-input@25.5.2/build/js/utils.js"),
|
||||||
|
});
|
||||||
|
|
||||||
|
form.addEventListener("submit", function(e){
|
||||||
|
if (!input.value.trim()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const number = iti.getNumber(intlTelInput.utils.numberFormat.E164);
|
||||||
|
if (number) {
|
||||||
|
input.value = number;
|
||||||
|
form.submit();
|
||||||
|
} else {
|
||||||
|
e.preventDefault();
|
||||||
|
input.focus();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
})();
|
||||||
|
</script>
|
||||||
|
{% endblock %}
|
||||||
@@ -17,6 +17,7 @@ from django.utils.translation import gettext_lazy as _
|
|||||||
from django.views.generic import DetailView, UpdateView, TemplateView
|
from django.views.generic import DetailView, UpdateView, TemplateView
|
||||||
from django.views.generic.edit import FormMixin
|
from django.views.generic.edit import FormMixin
|
||||||
from django_tables2.views import MultiTableMixin, SingleTableMixin, SingleTableView
|
from django_tables2.views import MultiTableMixin, SingleTableMixin, SingleTableView
|
||||||
|
from django_tables2.export.views import ExportMixin
|
||||||
from rest_framework.authtoken.models import Token
|
from rest_framework.authtoken.models import Token
|
||||||
from api.viewsets import is_regex
|
from api.viewsets import is_regex
|
||||||
from note.models import Alias, NoteClub, NoteUser, Trust
|
from note.models import Alias, NoteClub, NoteUser, Trust
|
||||||
@@ -26,6 +27,7 @@ from note_kfet.middlewares import _set_current_request
|
|||||||
from permission.backends import PermissionBackend
|
from permission.backends import PermissionBackend
|
||||||
from permission.models import Role
|
from permission.models import Role
|
||||||
from permission.views import ProtectQuerysetMixin, ProtectedCreateView
|
from permission.views import ProtectQuerysetMixin, ProtectedCreateView
|
||||||
|
from family.models import Family
|
||||||
from django import forms
|
from django import forms
|
||||||
|
|
||||||
from .forms import UserForm, ProfileForm, ImageForm, ClubForm, MembershipForm, \
|
from .forms import UserForm, ProfileForm, ImageForm, ClubForm, MembershipForm, \
|
||||||
@@ -48,6 +50,15 @@ class CustomLoginView(LoginView):
|
|||||||
self.request.session['permission_mask'] = form.cleaned_data['permission_mask'].rank
|
self.request.session['permission_mask'] = form.cleaned_data['permission_mask'].rank
|
||||||
return super().form_valid(form)
|
return super().form_valid(form)
|
||||||
|
|
||||||
|
def get_context_data(self, **kwargs):
|
||||||
|
context = super().get_context_data(**kwargs)
|
||||||
|
user_agent = self.request.META.get('HTTP_USER_AGENT', '').lower()
|
||||||
|
|
||||||
|
context['display_appstore_badge'] = 'iphone' in user_agent or 'android' not in user_agent
|
||||||
|
context['display_playstore_badge'] = 'android' in user_agent or 'iphone' not in user_agent
|
||||||
|
|
||||||
|
return context
|
||||||
|
|
||||||
|
|
||||||
class UserUpdateView(ProtectQuerysetMixin, LoginRequiredMixin, UpdateView):
|
class UserUpdateView(ProtectQuerysetMixin, LoginRequiredMixin, UpdateView):
|
||||||
"""
|
"""
|
||||||
@@ -206,6 +217,10 @@ class UserDetailView(ProtectQuerysetMixin, LoginRequiredMixin, DetailView):
|
|||||||
modified_note.is_active = True
|
modified_note.is_active = True
|
||||||
context["can_unlock_note"] = not user.note.is_active and PermissionBackend\
|
context["can_unlock_note"] = not user.note.is_active and PermissionBackend\
|
||||||
.check_perm(self.request, "note.change_noteuser_is_active", modified_note)
|
.check_perm(self.request, "note.change_noteuser_is_active", modified_note)
|
||||||
|
if 'family' in settings.INSTALLED_APPS:
|
||||||
|
context["family_app_installed"] = True
|
||||||
|
families = Family.objects.filter(memberships__user=user).distinct()
|
||||||
|
context["families"] = families
|
||||||
|
|
||||||
return context
|
return context
|
||||||
|
|
||||||
@@ -945,11 +960,12 @@ class ClubManageRolesView(ProtectQuerysetMixin, LoginRequiredMixin, UpdateView):
|
|||||||
return reverse_lazy('member:user_detail', kwargs={'pk': self.object.user.id})
|
return reverse_lazy('member:user_detail', kwargs={'pk': self.object.user.id})
|
||||||
|
|
||||||
|
|
||||||
class ClubMembersListView(ProtectQuerysetMixin, LoginRequiredMixin, SingleTableView):
|
class ClubMembersListView(ExportMixin, ProtectQuerysetMixin, LoginRequiredMixin, SingleTableView):
|
||||||
model = Membership
|
model = Membership
|
||||||
table_class = MembershipTable
|
table_class = MembershipTable
|
||||||
template_name = "member/club_members.html"
|
template_name = "member/club_members.html"
|
||||||
extra_context = {"title": _("Members of the club")}
|
extra_context = {"title": _("Members of the club")}
|
||||||
|
export_formats = ["csv"]
|
||||||
|
|
||||||
def get_queryset(self, **kwargs):
|
def get_queryset(self, **kwargs):
|
||||||
qs = super().get_queryset().filter(club_id=self.kwargs["pk"])
|
qs = super().get_queryset().filter(club_id=self.kwargs["pk"])
|
||||||
@@ -981,6 +997,14 @@ class ClubMembersListView(ProtectQuerysetMixin, LoginRequiredMixin, SingleTableV
|
|||||||
|
|
||||||
return qs.distinct()
|
return qs.distinct()
|
||||||
|
|
||||||
|
def get_export_filename(self, export_format):
|
||||||
|
return "members.csv"
|
||||||
|
|
||||||
|
def get_export_content_type(self, export_format):
|
||||||
|
if export_format == "csv":
|
||||||
|
return "text/csv"
|
||||||
|
return super().get_export_content_type(export_format)
|
||||||
|
|
||||||
def get_context_data(self, **kwargs):
|
def get_context_data(self, **kwargs):
|
||||||
context = super().get_context_data(**kwargs)
|
context = super().get_context_data(**kwargs)
|
||||||
club = Club.objects.filter(
|
club = Club.objects.filter(
|
||||||
|
|||||||
@@ -228,7 +228,7 @@ function consume (source, source_alias, dest, quantity, amount, reason, type, ca
|
|||||||
addMsg(interpolate(gettext('Warning, the transaction from the note %s succeed, ' +
|
addMsg(interpolate(gettext('Warning, the transaction from the note %s succeed, ' +
|
||||||
'but the emitter note %s is negative.'), [source_alias, source_alias]), 'warning', 30000)
|
'but the emitter note %s is negative.'), [source_alias, source_alias]), 'warning', 30000)
|
||||||
}
|
}
|
||||||
if (source.membership && source.membership.date_end < new Date().toISOString()) {
|
if (source.membership && source.membership.date_end <= new Date().toISOString()) {
|
||||||
addMsg(interpolate(gettext('Warning, the emitter note %s is no more a BDE member.'), [source_alias]),
|
addMsg(interpolate(gettext('Warning, the emitter note %s is no more a BDE member.'), [source_alias]),
|
||||||
'danger', 30000)
|
'danger', 30000)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -67,6 +67,8 @@ $(document).ready(function () {
|
|||||||
|
|
||||||
last.quantity = 1
|
last.quantity = 1
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (last.note.club) {
|
if (last.note.club) {
|
||||||
$('#last_name').val(last.note.name)
|
$('#last_name').val(last.note.name)
|
||||||
$('#first_name').val(last.note.name)
|
$('#first_name').val(last.note.name)
|
||||||
@@ -111,6 +113,7 @@ $(document).ready(function () {
|
|||||||
dest.removeClass('d-none')
|
dest.removeClass('d-none')
|
||||||
$('#dest_note_list').removeClass('d-none')
|
$('#dest_note_list').removeClass('d-none')
|
||||||
$('#debit_type').addClass('d-none')
|
$('#debit_type').addClass('d-none')
|
||||||
|
$('#reason').val('')
|
||||||
|
|
||||||
$('#source_note_label').text(select_emitters_label)
|
$('#source_note_label').text(select_emitters_label)
|
||||||
$('#dest_note_label').text(select_receveirs_label)
|
$('#dest_note_label').text(select_receveirs_label)
|
||||||
@@ -134,6 +137,7 @@ $(document).ready(function () {
|
|||||||
dest.val('')
|
dest.val('')
|
||||||
dest.tooltip('hide')
|
dest.tooltip('hide')
|
||||||
$('#debit_type').addClass('d-none')
|
$('#debit_type').addClass('d-none')
|
||||||
|
$('#reason').val('Rechargement note')
|
||||||
|
|
||||||
$('#source_note_label').text(transfer_type_label)
|
$('#source_note_label').text(transfer_type_label)
|
||||||
$('#dest_note_label').text(select_receveir_label)
|
$('#dest_note_label').text(select_receveir_label)
|
||||||
@@ -162,6 +166,7 @@ $(document).ready(function () {
|
|||||||
dest.addClass('d-none')
|
dest.addClass('d-none')
|
||||||
dest.tooltip('hide')
|
dest.tooltip('hide')
|
||||||
$('#debit_type').removeClass('d-none')
|
$('#debit_type').removeClass('d-none')
|
||||||
|
$('#reason').val('')
|
||||||
|
|
||||||
$('#source_note_label').text(select_emitter_label)
|
$('#source_note_label').text(select_emitter_label)
|
||||||
$('#dest_note_label').text(transfer_type_label)
|
$('#dest_note_label').text(transfer_type_label)
|
||||||
@@ -305,10 +310,10 @@ $('#btn_transfer').click(function () {
|
|||||||
destination: dest.note.id,
|
destination: dest.note.id,
|
||||||
destination_alias: dest.name
|
destination_alias: dest.name
|
||||||
}).done(function () {
|
}).done(function () {
|
||||||
if (source.note.membership && source.note.membership.date_end < new Date().toISOString()) {
|
if (source.note.membership && source.note.membership.date_end <= new Date().toISOString()) {
|
||||||
addMsg(interpolate(gettext('Warning, the emitter note %s is no more a BDE member.'), [source.name]), 'danger', 30000)
|
addMsg(interpolate(gettext('Warning, the emitter note %s is no more a BDE member.'), [source.name]), 'danger', 30000)
|
||||||
}
|
}
|
||||||
if (dest.note.membership && dest.note.membership.date_end < new Date().toISOString()) {
|
if (dest.note.membership && dest.note.membership.date_end <= new Date().toISOString()) {
|
||||||
addMsg(interpolate(gettext('Warning, the destination note %s is no more a BDE member.'), [dest.name]), 'danger', 30000)
|
addMsg(interpolate(gettext('Warning, the destination note %s is no more a BDE member.'), [dest.name]), 'danger', 30000)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -409,7 +414,7 @@ $('#btn_transfer').click(function () {
|
|||||||
bank: $('#bank').val()
|
bank: $('#bank').val()
|
||||||
}).done(function () {
|
}).done(function () {
|
||||||
addMsg(gettext('Credit/debit succeed!'), 'success', 10000)
|
addMsg(gettext('Credit/debit succeed!'), 'success', 10000)
|
||||||
if (user_note.membership && user_note.membership.date_end < new Date().toISOString()) { addMsg(gettext('Warning, the emitter note %s is no more a BDE member.'), 'danger', 10000) }
|
if (user_note.membership && user_note.membership.date_end <= new Date().toISOString()) { addMsg(gettext('Warning, the emitter note %s is no more a BDE member.'), 'danger', 10000) }
|
||||||
reset()
|
reset()
|
||||||
}).fail(function (err) {
|
}).fail(function (err) {
|
||||||
const errObj = JSON.parse(err.responseText)
|
const errObj = JSON.parse(err.responseText)
|
||||||
|
|||||||
@@ -1391,12 +1391,12 @@
|
|||||||
"wei",
|
"wei",
|
||||||
"weiregistration"
|
"weiregistration"
|
||||||
],
|
],
|
||||||
"query": "{\"wei\": [\"club\"], \"wei__membership_end__gte\": [\"today\"]}",
|
"query": "[\"AND\", {\"wei\": [\"club\"], \"wei__membership_end__gte\": [\"today\"]}, {\"deposit_type\": \"note\"}]",
|
||||||
"type": "change",
|
"type": "change",
|
||||||
"mask": 2,
|
"mask": 2,
|
||||||
"field": "caution_check",
|
"field": "deposit_given",
|
||||||
"permanent": false,
|
"permanent": false,
|
||||||
"description": "Dire si un chèque de caution est donné pour une inscription WEI"
|
"description": "Autoriser une transaction de caution WEI"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -4347,7 +4347,375 @@
|
|||||||
"mask": 3,
|
"mask": 3,
|
||||||
"field": "",
|
"field": "",
|
||||||
"permanent": false,
|
"permanent": false,
|
||||||
"description": "Ajouter un membre au BDE ou à la Kfet"
|
"description": "Faire adhérer BDE ou Kfet"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"model": "permission.permission",
|
||||||
|
"pk": 293,
|
||||||
|
"fields": {
|
||||||
|
"model": [
|
||||||
|
"wei",
|
||||||
|
"weimembership"
|
||||||
|
],
|
||||||
|
"query": "[\"AND\", {\"bus\": [\"membership\", \"weimembership\", \"bus\"]}, {\"club\": [\"club\"], \"club__weiclub__membership_end__gte\": [\"today\"]}]",
|
||||||
|
"type": "change",
|
||||||
|
"mask": 2,
|
||||||
|
"field": "team",
|
||||||
|
"permanent": false,
|
||||||
|
"description": "Modifier l'équipe d'une adhésion WEI à son bus"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"model": "permission.permission",
|
||||||
|
"pk": 294,
|
||||||
|
"fields": {
|
||||||
|
"model": [
|
||||||
|
"wei",
|
||||||
|
"weiregistration"
|
||||||
|
],
|
||||||
|
"query": "[\"AND\", {\"wei__year\": [\"today\", \"year\"], \"wei__membership_start__lte\": [\"today\"], \"wei__membership_end__gte\": [\"today\"]}, {\"deposit_type\": \"check\"}]",
|
||||||
|
"type": "change",
|
||||||
|
"mask": 2,
|
||||||
|
"field": "deposit_given",
|
||||||
|
"permanent": false,
|
||||||
|
"description": "Dire si un chèque de caution a été donné"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"model": "permission.permission",
|
||||||
|
"pk": 295,
|
||||||
|
"fields": {
|
||||||
|
"model": [
|
||||||
|
"wei",
|
||||||
|
"weiregistration"
|
||||||
|
],
|
||||||
|
"query": "{\"wei__year\": [\"today\", \"year\"]}",
|
||||||
|
"type": "view",
|
||||||
|
"mask": 2,
|
||||||
|
"field": "",
|
||||||
|
"permanent": false,
|
||||||
|
"description": "Voir toutes les inscriptions au WEI courant"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"model": "permission.permission",
|
||||||
|
"pk": 296,
|
||||||
|
"fields": {
|
||||||
|
"model": [
|
||||||
|
"wei",
|
||||||
|
"weimembership"
|
||||||
|
],
|
||||||
|
"query": "{\"club__weiclub__year\": [\"today\", \"year\"]}",
|
||||||
|
"type": "view",
|
||||||
|
"mask": 2,
|
||||||
|
"field": "",
|
||||||
|
"permanent": false,
|
||||||
|
"description": "Voir toutes les adhésions au WEI courant"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"model": "permission.permission",
|
||||||
|
"pk": 297,
|
||||||
|
"fields": {
|
||||||
|
"model": [
|
||||||
|
"wei",
|
||||||
|
"weiregistration"
|
||||||
|
],
|
||||||
|
"query": "[\"AND\", {\"user\": [\"user\"], \"wei__membership_start__lte\": [\"today\"], \"wei__membership_end__gte\": [\"today\"]}, [\"OR\", {\"wei\": [\"club\"]}, {\"wei__year\": [\"today\", \"year\"], \"membership\": null}]]",
|
||||||
|
"type": "change",
|
||||||
|
"mask": 1,
|
||||||
|
"field": "deposit_type",
|
||||||
|
"permanent": false,
|
||||||
|
"description": "Modifier le type de caution de mon inscription WEI tant qu'elle n'est pas validée"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"model": "permission.permission",
|
||||||
|
"pk": 298,
|
||||||
|
"fields": {
|
||||||
|
"model": [
|
||||||
|
"wei",
|
||||||
|
"bus"
|
||||||
|
],
|
||||||
|
"query": "{\"pk\": [\"membership\", \"weimembership\", \"bus\", \"pk\"], \"wei__date_end__gte\": [\"today\"]}",
|
||||||
|
"type": "change",
|
||||||
|
"mask": 2,
|
||||||
|
"field": "information_json",
|
||||||
|
"permanent": false,
|
||||||
|
"description": "Modifier les informations du bus"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"model": "permission.permission",
|
||||||
|
"pk": 311,
|
||||||
|
"fields": {
|
||||||
|
"model": [
|
||||||
|
"family",
|
||||||
|
"family"
|
||||||
|
],
|
||||||
|
"query": "{}",
|
||||||
|
"type": "view",
|
||||||
|
"mask": 1,
|
||||||
|
"field": "",
|
||||||
|
"permanent": false,
|
||||||
|
"description": "Voir toutes les familles"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"model": "permission.permission",
|
||||||
|
"pk": 312,
|
||||||
|
"fields": {
|
||||||
|
"model": [
|
||||||
|
"family",
|
||||||
|
"family"
|
||||||
|
],
|
||||||
|
"query": "{}",
|
||||||
|
"type": "add",
|
||||||
|
"mask": 2,
|
||||||
|
"field": "",
|
||||||
|
"permanent": false,
|
||||||
|
"description": "Créer une famille"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"model": "permission.permission",
|
||||||
|
"pk": 313,
|
||||||
|
"fields": {
|
||||||
|
"model": [
|
||||||
|
"family",
|
||||||
|
"family"
|
||||||
|
],
|
||||||
|
"query": "{}",
|
||||||
|
"type": "change",
|
||||||
|
"mask": 2,
|
||||||
|
"field": "",
|
||||||
|
"permanent": false,
|
||||||
|
"description": "Modifier n'importe quelle famille"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"model": "permission.permission",
|
||||||
|
"pk": 314,
|
||||||
|
"fields": {
|
||||||
|
"model": [
|
||||||
|
"family",
|
||||||
|
"family"
|
||||||
|
],
|
||||||
|
"query": "{\"pk\": [\"user\", \"family_memberships\", \"family\", \"pk\"]}",
|
||||||
|
"type": "change",
|
||||||
|
"mask": 2,
|
||||||
|
"field": "",
|
||||||
|
"permanent": false,
|
||||||
|
"description": "Modifier ma famille"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"model": "permission.permission",
|
||||||
|
"pk": 315,
|
||||||
|
"fields": {
|
||||||
|
"model": [
|
||||||
|
"family",
|
||||||
|
"familymembership"
|
||||||
|
],
|
||||||
|
"query": "{}",
|
||||||
|
"type": "view",
|
||||||
|
"mask": 2,
|
||||||
|
"field": "",
|
||||||
|
"permanent": false,
|
||||||
|
"description": "Voir les membres de n'importe quelle famille"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"model": "permission.permission",
|
||||||
|
"pk": 316,
|
||||||
|
"fields": {
|
||||||
|
"model": [
|
||||||
|
"family",
|
||||||
|
"familymembership"
|
||||||
|
],
|
||||||
|
"query": "{\"family\": [\"user\", \"family_memberships\", \"family\"]}",
|
||||||
|
"type": "view",
|
||||||
|
"mask": 1,
|
||||||
|
"field": "",
|
||||||
|
"permanent": false,
|
||||||
|
"description": "Voir les membres de ma famille"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"model": "permission.permission",
|
||||||
|
"pk": 317,
|
||||||
|
"fields": {
|
||||||
|
"model": [
|
||||||
|
"family",
|
||||||
|
"familymembership"
|
||||||
|
],
|
||||||
|
"query": "{}",
|
||||||
|
"type": "add",
|
||||||
|
"mask": 2,
|
||||||
|
"field": "",
|
||||||
|
"permanent": false,
|
||||||
|
"description": "Ajouter un membre à n'importe quelle famille"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"model": "permission.permission",
|
||||||
|
"pk": 318,
|
||||||
|
"fields": {
|
||||||
|
"model": [
|
||||||
|
"family",
|
||||||
|
"familymembership"
|
||||||
|
],
|
||||||
|
"query": "{\"family\": [\"user\", \"family_memberships\", \"family\"]}",
|
||||||
|
"type": "add",
|
||||||
|
"mask": 2,
|
||||||
|
"field": "",
|
||||||
|
"permanent": false,
|
||||||
|
"description": "Ajouter un membre à ma famille"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"model": "permission.permission",
|
||||||
|
"pk": 319,
|
||||||
|
"fields": {
|
||||||
|
"model": [
|
||||||
|
"family",
|
||||||
|
"challenge"
|
||||||
|
],
|
||||||
|
"query": "{}",
|
||||||
|
"type": "view",
|
||||||
|
"mask": 1,
|
||||||
|
"field": "",
|
||||||
|
"permanent": false,
|
||||||
|
"description": "Voir tous les défis"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"model": "permission.permission",
|
||||||
|
"pk": 320,
|
||||||
|
"fields": {
|
||||||
|
"model": [
|
||||||
|
"family",
|
||||||
|
"challenge"
|
||||||
|
],
|
||||||
|
"query": "{}",
|
||||||
|
"type": "add",
|
||||||
|
"mask": 2,
|
||||||
|
"field": "",
|
||||||
|
"permanent": false,
|
||||||
|
"description": "Créer un défi"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"model": "permission.permission",
|
||||||
|
"pk": 321,
|
||||||
|
"fields": {
|
||||||
|
"model": [
|
||||||
|
"family",
|
||||||
|
"challenge"
|
||||||
|
],
|
||||||
|
"query": "{}",
|
||||||
|
"type": "change",
|
||||||
|
"mask": 2,
|
||||||
|
"field": "",
|
||||||
|
"permanent": false,
|
||||||
|
"description": "Modifier un défi"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"model": "permission.permission",
|
||||||
|
"pk": 322,
|
||||||
|
"fields": {
|
||||||
|
"model": [
|
||||||
|
"family",
|
||||||
|
"challenge"
|
||||||
|
],
|
||||||
|
"query": "{}",
|
||||||
|
"type": "delete",
|
||||||
|
"mask": 2,
|
||||||
|
"field": "{}",
|
||||||
|
"permanent": false,
|
||||||
|
"description": "Supprimer un défi"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"model": "permission.permission",
|
||||||
|
"pk": 323,
|
||||||
|
"fields": {
|
||||||
|
"model": [
|
||||||
|
"family",
|
||||||
|
"achievement"
|
||||||
|
],
|
||||||
|
"query": "{}",
|
||||||
|
"type": "view",
|
||||||
|
"mask": 1,
|
||||||
|
"field": "",
|
||||||
|
"permanent": false,
|
||||||
|
"description": "Voir tous les succès"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"model": "permission.permission",
|
||||||
|
"pk": 324,
|
||||||
|
"fields": {
|
||||||
|
"model": [
|
||||||
|
"family",
|
||||||
|
"achievement"
|
||||||
|
],
|
||||||
|
"query": "{}",
|
||||||
|
"type": "add",
|
||||||
|
"mask": 2,
|
||||||
|
"field": "",
|
||||||
|
"permanent": false,
|
||||||
|
"description": "Créer un succès"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"model": "permission.permission",
|
||||||
|
"pk": 325,
|
||||||
|
"fields": {
|
||||||
|
"model": [
|
||||||
|
"family",
|
||||||
|
"achievement"
|
||||||
|
],
|
||||||
|
"query": "{}",
|
||||||
|
"type": "change",
|
||||||
|
"mask": 1,
|
||||||
|
"field": "valid",
|
||||||
|
"permanent": false,
|
||||||
|
"description": "Valider un succès"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"model": "permission.permission",
|
||||||
|
"pk": 326,
|
||||||
|
"fields": {
|
||||||
|
"model": [
|
||||||
|
"family",
|
||||||
|
"achievement"
|
||||||
|
],
|
||||||
|
"query": "{}",
|
||||||
|
"type": "delete",
|
||||||
|
"mask": 1,
|
||||||
|
"field": "",
|
||||||
|
"permanent": false,
|
||||||
|
"description": "Supprimer un succès"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"model": "permission.permission",
|
||||||
|
"pk": 330,
|
||||||
|
"fields": {
|
||||||
|
"model": [
|
||||||
|
"auth",
|
||||||
|
"user"
|
||||||
|
],
|
||||||
|
"query": "{\"memberships__club\": [\"club\"]}",
|
||||||
|
"type": "view",
|
||||||
|
"mask": 2,
|
||||||
|
"field": "email",
|
||||||
|
"permanent": false,
|
||||||
|
"description": "Voir l'adresse mail des membres de son club"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -4404,7 +4772,11 @@
|
|||||||
249,
|
249,
|
||||||
255,
|
255,
|
||||||
256,
|
256,
|
||||||
257
|
257,
|
||||||
|
311,
|
||||||
|
316,
|
||||||
|
319,
|
||||||
|
323
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -4444,7 +4816,8 @@
|
|||||||
159,
|
159,
|
||||||
160,
|
160,
|
||||||
212,
|
212,
|
||||||
222
|
222,
|
||||||
|
297
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -4492,7 +4865,11 @@
|
|||||||
221,
|
221,
|
||||||
247,
|
247,
|
||||||
258,
|
258,
|
||||||
259
|
259,
|
||||||
|
260,
|
||||||
|
263,
|
||||||
|
265,
|
||||||
|
330
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -4504,7 +4881,6 @@
|
|||||||
"name": "Pr\u00e9sident\u22c5e de club",
|
"name": "Pr\u00e9sident\u22c5e de club",
|
||||||
"permissions": [
|
"permissions": [
|
||||||
62,
|
62,
|
||||||
135,
|
|
||||||
142
|
142
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
@@ -4631,7 +5007,10 @@
|
|||||||
176,
|
176,
|
||||||
177,
|
177,
|
||||||
178,
|
178,
|
||||||
183
|
183,
|
||||||
|
294,
|
||||||
|
295,
|
||||||
|
296
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -4764,7 +5143,6 @@
|
|||||||
"name": "Chef\u22c5fe de bus",
|
"name": "Chef\u22c5fe de bus",
|
||||||
"permissions": [
|
"permissions": [
|
||||||
22,
|
22,
|
||||||
84,
|
|
||||||
115,
|
115,
|
||||||
117,
|
117,
|
||||||
118,
|
118,
|
||||||
@@ -4778,7 +5156,9 @@
|
|||||||
287,
|
287,
|
||||||
289,
|
289,
|
||||||
290,
|
290,
|
||||||
291
|
291,
|
||||||
|
293,
|
||||||
|
298
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -4790,7 +5170,6 @@
|
|||||||
"name": "Chef\u22c5fe d'\u00e9quipe",
|
"name": "Chef\u22c5fe d'\u00e9quipe",
|
||||||
"permissions": [
|
"permissions": [
|
||||||
22,
|
22,
|
||||||
84,
|
|
||||||
116,
|
116,
|
||||||
123,
|
123,
|
||||||
124,
|
124,
|
||||||
@@ -4805,8 +5184,7 @@
|
|||||||
"for_club": null,
|
"for_club": null,
|
||||||
"name": "\u00c9lectron libre",
|
"name": "\u00c9lectron libre",
|
||||||
"permissions": [
|
"permissions": [
|
||||||
22,
|
22
|
||||||
84
|
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -4840,6 +5218,7 @@
|
|||||||
"permissions": [
|
"permissions": [
|
||||||
37,
|
37,
|
||||||
41,
|
41,
|
||||||
|
42,
|
||||||
53,
|
53,
|
||||||
54,
|
54,
|
||||||
55,
|
55,
|
||||||
@@ -4891,7 +5270,9 @@
|
|||||||
168,
|
168,
|
||||||
176,
|
176,
|
||||||
177,
|
177,
|
||||||
197
|
197,
|
||||||
|
311,
|
||||||
|
319
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -4957,7 +5338,6 @@
|
|||||||
"name": "Référent⋅e Bus",
|
"name": "Référent⋅e Bus",
|
||||||
"permissions": [
|
"permissions": [
|
||||||
22,
|
22,
|
||||||
84,
|
|
||||||
115,
|
115,
|
||||||
117,
|
117,
|
||||||
118,
|
118,
|
||||||
@@ -4971,7 +5351,9 @@
|
|||||||
287,
|
287,
|
||||||
289,
|
289,
|
||||||
290,
|
290,
|
||||||
291
|
291,
|
||||||
|
293,
|
||||||
|
298
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -5061,6 +5443,39 @@
|
|||||||
]
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"model": "permission.role",
|
||||||
|
"pk": 34,
|
||||||
|
"fields": {
|
||||||
|
"for_club": 1,
|
||||||
|
"name": "Chef·fe de famille",
|
||||||
|
"permissions": [
|
||||||
|
314,
|
||||||
|
318,
|
||||||
|
324
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"model": "permission.role",
|
||||||
|
"pk": 35,
|
||||||
|
"fields": {
|
||||||
|
"for_club": 1,
|
||||||
|
"name": "Respo familles",
|
||||||
|
"permissions": [
|
||||||
|
312,
|
||||||
|
313,
|
||||||
|
315,
|
||||||
|
317,
|
||||||
|
320,
|
||||||
|
321,
|
||||||
|
322,
|
||||||
|
324,
|
||||||
|
325,
|
||||||
|
326
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"model": "wei.weirole",
|
"model": "wei.weirole",
|
||||||
"pk": 12,
|
"pk": 12,
|
||||||
|
|||||||
18
apps/treasury/migrations/0011_sogecredit_valid.py
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
# Generated by Django 5.2.6 on 2025-09-28 20:12
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('treasury', '0010_alter_invoice_bde'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='sogecredit',
|
||||||
|
name='valid',
|
||||||
|
field=models.BooleanField(blank=True, default=False, verbose_name='Valid'),
|
||||||
|
),
|
||||||
|
]
|
||||||
@@ -308,6 +308,12 @@ class SogeCredit(models.Model):
|
|||||||
null=True,
|
null=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
valid = models.BooleanField(
|
||||||
|
default=False,
|
||||||
|
verbose_name=_("Valid"),
|
||||||
|
blank=True,
|
||||||
|
)
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
verbose_name = _("Credit from the Société générale")
|
verbose_name = _("Credit from the Société générale")
|
||||||
verbose_name_plural = _("Credits from the Société générale")
|
verbose_name_plural = _("Credits from the Société générale")
|
||||||
@@ -332,7 +338,7 @@ class SogeCredit(models.Model):
|
|||||||
last_name=self.user.last_name,
|
last_name=self.user.last_name,
|
||||||
first_name=self.user.first_name,
|
first_name=self.user.first_name,
|
||||||
bank="Société générale",
|
bank="Société générale",
|
||||||
valid=False,
|
valid=True,
|
||||||
)
|
)
|
||||||
credit_transaction._force_save = True
|
credit_transaction._force_save = True
|
||||||
credit_transaction.save()
|
credit_transaction.save()
|
||||||
@@ -346,20 +352,18 @@ class SogeCredit(models.Model):
|
|||||||
return super().save(*args, **kwargs)
|
return super().save(*args, **kwargs)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def valid(self):
|
def valid_legacy(self):
|
||||||
return self.credit_transaction and self.credit_transaction.valid
|
return self.credit_transaction and self.credit_transaction.valid
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def amount(self):
|
def amount(self):
|
||||||
if self.valid:
|
if self.valid_legacy:
|
||||||
return self.credit_transaction.total
|
return self.credit_transaction.total
|
||||||
amount = sum(max(transaction.total - 2000, 0) for transaction in self.transactions.all())
|
amount = 0
|
||||||
if 'wei' in settings.INSTALLED_APPS:
|
transactions_wei = self.transactions.filter(membership__club__weiclub__isnull=False)
|
||||||
from wei.models import WEIMembership
|
amount += sum(max(transaction.total - transaction.membership.club.weiclub.fee_soge_credit, 0) for transaction in transactions_wei)
|
||||||
if not WEIMembership.objects\
|
transactions_not_wei = self.transactions.filter(membership__club__weiclub__isnull=True)
|
||||||
.filter(club__weiclub__year=self.credit_transaction.created_at.year, user=self.user).exists():
|
amount += sum(transaction.total for transaction in transactions_not_wei)
|
||||||
# 80 € for people that don't go to WEI
|
|
||||||
amount += 8000
|
|
||||||
return amount
|
return amount
|
||||||
|
|
||||||
def update_transactions(self):
|
def update_transactions(self):
|
||||||
@@ -399,7 +403,7 @@ class SogeCredit(models.Model):
|
|||||||
self.transactions.add(m.transaction)
|
self.transactions.add(m.transaction)
|
||||||
|
|
||||||
for tr in self.transactions.all():
|
for tr in self.transactions.all():
|
||||||
tr.valid = False
|
tr.valid = True
|
||||||
tr.save()
|
tr.save()
|
||||||
|
|
||||||
def invalidate(self):
|
def invalidate(self):
|
||||||
@@ -424,6 +428,7 @@ class SogeCredit(models.Model):
|
|||||||
self.invalidate()
|
self.invalidate()
|
||||||
# Refresh credit amount
|
# Refresh credit amount
|
||||||
self.save()
|
self.save()
|
||||||
|
self.valid = True
|
||||||
self.credit_transaction.valid = True
|
self.credit_transaction.valid = True
|
||||||
self.credit_transaction._force_save = True
|
self.credit_transaction._force_save = True
|
||||||
self.credit_transaction.save()
|
self.credit_transaction.save()
|
||||||
@@ -441,7 +446,7 @@ class SogeCredit(models.Model):
|
|||||||
With Great Power Comes Great Responsibility...
|
With Great Power Comes Great Responsibility...
|
||||||
"""
|
"""
|
||||||
|
|
||||||
total_fee = sum(max(transaction.total - 2000, 0) for transaction in self.transactions.all() if not transaction.valid)
|
total_fee = self.amount
|
||||||
if self.user.note.balance < total_fee:
|
if self.user.note.balance < total_fee:
|
||||||
raise ValidationError(_("This user doesn't have enough money to pay the memberships with its note. "
|
raise ValidationError(_("This user doesn't have enough money to pay the memberships with its note. "
|
||||||
"Please ask her/him to credit the note before invalidating this credit."))
|
"Please ask her/him to credit the note before invalidating this credit."))
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 284 KiB After Width: | Height: | Size: 104 KiB |
@@ -56,6 +56,7 @@ class InvoiceTable(tables.Table):
|
|||||||
model = Invoice
|
model = Invoice
|
||||||
template_name = 'django_tables2/bootstrap4.html'
|
template_name = 'django_tables2/bootstrap4.html'
|
||||||
fields = ('id', 'name', 'object', 'acquitted', 'invoice',)
|
fields = ('id', 'name', 'object', 'acquitted', 'invoice',)
|
||||||
|
order_by = ('-id',)
|
||||||
|
|
||||||
|
|
||||||
class RemittanceTable(tables.Table):
|
class RemittanceTable(tables.Table):
|
||||||
|
|||||||
@@ -168,7 +168,7 @@ class InvoiceUpdateView(ProtectQuerysetMixin, LoginRequiredMixin, UpdateView):
|
|||||||
|
|
||||||
class InvoiceDeleteView(ProtectQuerysetMixin, LoginRequiredMixin, DeleteView):
|
class InvoiceDeleteView(ProtectQuerysetMixin, LoginRequiredMixin, DeleteView):
|
||||||
"""
|
"""
|
||||||
Delete a non-validated WEI registration
|
Delete a non-locked Invoice
|
||||||
"""
|
"""
|
||||||
model = Invoice
|
model = Invoice
|
||||||
extra_context = {"title": _("Delete invoice")}
|
extra_context = {"title": _("Delete invoice")}
|
||||||
@@ -417,7 +417,7 @@ class SogeCreditListView(LoginRequiredMixin, ProtectQuerysetMixin, SingleTableVi
|
|||||||
)
|
)
|
||||||
|
|
||||||
if "valid" not in self.request.GET or not self.request.GET["valid"]:
|
if "valid" not in self.request.GET or not self.request.GET["valid"]:
|
||||||
qs = qs.filter(credit_transaction__valid=False)
|
qs = qs.filter(valid=False)
|
||||||
|
|
||||||
return qs
|
return qs
|
||||||
|
|
||||||
|
|||||||
@@ -77,7 +77,7 @@ class WEIRegistrationViewSet(ReadProtectedModelViewSet):
|
|||||||
filter_backends = [DjangoFilterBackend, RegexSafeSearchFilter]
|
filter_backends = [DjangoFilterBackend, RegexSafeSearchFilter]
|
||||||
filterset_fields = ['user', 'user__username', 'user__first_name', 'user__last_name', 'user__email',
|
filterset_fields = ['user', 'user__username', 'user__first_name', 'user__last_name', 'user__email',
|
||||||
'user__note__alias__name', 'user__note__alias__normalized_name', 'wei', 'wei__name',
|
'user__note__alias__name', 'user__note__alias__normalized_name', 'wei', 'wei__name',
|
||||||
'wei__email', 'wei__year', 'soge_credit', 'deposit_check', 'birth_date', 'gender',
|
'wei__email', 'wei__year', 'soge_credit', 'deposit_given', 'birth_date', 'gender',
|
||||||
'clothing_cut', 'clothing_size', 'first_year', 'emergency_contact_name',
|
'clothing_cut', 'clothing_size', 'first_year', 'emergency_contact_name',
|
||||||
'emergency_contact_phone', ]
|
'emergency_contact_phone', ]
|
||||||
search_fields = ['$user__username', '$user__first_name', '$user__last_name', '$user__email',
|
search_fields = ['$user__username', '$user__first_name', '$user__last_name', '$user__email',
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
# Copyright (C) 2018-2025 by BDE ENS Paris-Saclay
|
# Copyright (C) 2018-2025 by BDE ENS Paris-Saclay
|
||||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
|
||||||
from .registration import WEIForm, WEIRegistrationForm, WEIRegistration1AForm, WEIRegistration2AForm, WEIMembership1AForm, \
|
from .registration import WEIForm, WEIRegistrationForm, WEIMembership1AForm, \
|
||||||
WEIMembershipForm, BusForm, BusTeamForm
|
WEIMembershipForm, BusForm, BusTeamForm
|
||||||
from .surveys import WEISurvey, WEISurveyInformation, WEISurveyAlgorithm, CurrentSurvey
|
from .surveys import WEISurvey, WEISurveyInformation, WEISurveyAlgorithm, CurrentSurvey
|
||||||
|
|
||||||
__all__ = [
|
__all__ = [
|
||||||
'WEIForm', 'WEIRegistrationForm', 'WEIRegistration1AForm', 'WEIRegistration2AForm', 'WEIMembership1AForm', 'WEIMembershipForm', 'BusForm', 'BusTeamForm',
|
'WEIForm', 'WEIRegistrationForm', 'WEIMembership1AForm', 'WEIMembershipForm', 'BusForm', 'BusTeamForm',
|
||||||
'WEISurvey', 'WEISurveyInformation', 'WEISurveyAlgorithm', 'CurrentSurvey',
|
'WEISurvey', 'WEISurveyInformation', 'WEISurveyAlgorithm', 'CurrentSurvey',
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ class WEIRegistrationForm(forms.ModelForm):
|
|||||||
fields = [
|
fields = [
|
||||||
'user', 'soge_credit', 'birth_date', 'gender', 'clothing_size',
|
'user', 'soge_credit', 'birth_date', 'gender', 'clothing_size',
|
||||||
'health_issues', 'emergency_contact_name', 'emergency_contact_phone',
|
'health_issues', 'emergency_contact_name', 'emergency_contact_phone',
|
||||||
'first_year', 'information_json', 'deposit_check'
|
'first_year', 'information_json', 'deposit_given', 'deposit_type'
|
||||||
]
|
]
|
||||||
widgets = {
|
widgets = {
|
||||||
"user": Autocomplete(
|
"user": Autocomplete(
|
||||||
@@ -59,30 +59,17 @@ class WEIRegistrationForm(forms.ModelForm):
|
|||||||
'minDate': '1900-01-01',
|
'minDate': '1900-01-01',
|
||||||
'maxDate': '2100-01-01'
|
'maxDate': '2100-01-01'
|
||||||
}),
|
}),
|
||||||
"deposit_check": forms.BooleanField(
|
"deposit_given": forms.CheckboxInput(
|
||||||
required=False,
|
attrs={'class': 'form-check-input'},
|
||||||
),
|
),
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
class WEIRegistration2AForm(WEIRegistrationForm):
|
|
||||||
class Meta(WEIRegistrationForm.Meta):
|
|
||||||
fields = WEIRegistrationForm.Meta.fields + ['deposit_type']
|
|
||||||
widgets = WEIRegistrationForm.Meta.widgets.copy()
|
|
||||||
widgets.update({
|
|
||||||
"deposit_type": forms.RadioSelect(),
|
"deposit_type": forms.RadioSelect(),
|
||||||
})
|
}
|
||||||
|
|
||||||
|
|
||||||
class WEIRegistration1AForm(WEIRegistrationForm):
|
|
||||||
class Meta(WEIRegistrationForm.Meta):
|
|
||||||
fields = WEIRegistrationForm.Meta.fields
|
|
||||||
|
|
||||||
|
|
||||||
class WEIChooseBusForm(forms.Form):
|
class WEIChooseBusForm(forms.Form):
|
||||||
bus = forms.ModelMultipleChoiceField(
|
bus = forms.ModelMultipleChoiceField(
|
||||||
queryset=Bus.objects,
|
queryset=Bus.objects,
|
||||||
label=_("bus"),
|
label=_("Bus"),
|
||||||
help_text=_("This choice is not definitive. The WEI organizers are free to attribute for you a bus and a team,"
|
help_text=_("This choice is not definitive. The WEI organizers are free to attribute for you a bus and a team,"
|
||||||
+ " in particular if you are a free eletron."),
|
+ " in particular if you are a free eletron."),
|
||||||
widget=CheckboxSelectMultiple(),
|
widget=CheckboxSelectMultiple(),
|
||||||
@@ -174,7 +161,7 @@ class WEIMembership1AForm(WEIMembershipForm):
|
|||||||
"""
|
"""
|
||||||
Used to confirm registrations of first year members without choosing a bus now.
|
Used to confirm registrations of first year members without choosing a bus now.
|
||||||
"""
|
"""
|
||||||
deposit_check = None
|
deposit_given = None
|
||||||
roles = None
|
roles = None
|
||||||
|
|
||||||
def clean(self):
|
def clean(self):
|
||||||
|
|||||||
@@ -10,20 +10,223 @@ from django import forms
|
|||||||
from django.db import transaction
|
from django.db import transaction
|
||||||
from django.db.models import Q
|
from django.db.models import Q
|
||||||
from django.utils.translation import gettext_lazy as _
|
from django.utils.translation import gettext_lazy as _
|
||||||
|
from django.utils.safestring import mark_safe
|
||||||
|
|
||||||
from .base import WEISurvey, WEISurveyInformation, WEISurveyAlgorithm, WEIBusInformation
|
from .base import WEISurvey, WEISurveyInformation, WEISurveyAlgorithm, WEIBusInformation
|
||||||
from ...models import WEIMembership, Bus
|
from ...models import WEIMembership, Bus
|
||||||
|
|
||||||
WORDS = [
|
WORDS = {
|
||||||
'13 organisé', '3ième mi temps', 'Années 2000', 'Apéro', 'BBQ', 'BP', 'Beauf', 'Binge drinking', 'Bon enfant',
|
'list': [
|
||||||
'Cartouche', 'Catacombes', 'Chansons paillardes', 'Chansons populaires', 'Chanteur', 'Chartreuse', 'Chill',
|
'Fiesta', 'Graillance', 'Move it move it', 'Calme', 'Nerd et geek', 'Jeux de rôles et danse rock',
|
||||||
'Core', 'DJ', 'Dancefloor', 'Danse', 'David Guetta', 'Disco', 'Eau de vie', 'Électro', 'Escalade', 'Familial',
|
'Strass et paillettes', 'Spectaculaire', 'Splendide', 'Flow inégalable', 'Rap', 'Battles légendaires',
|
||||||
'Fanfare', 'Fracassage', 'Féria', 'Hard rock', 'Hoeggarden', 'House', 'Huit-six', 'IPA', 'Inclusif', 'Inferno',
|
'Techno', 'Alcool', 'Kiffeur·euse', 'Rugby', 'Médiéval', 'Festif',
|
||||||
'Introverti', 'Jager bomb', 'Jazz', 'Jeux d\'alcool', 'Jeux de rôles', 'Jeux vidéo', 'Jul', 'Jus de fruit',
|
'Stylé', 'Chipie', 'Rétro', 'Vache', 'Farfadet', 'Fanfare',
|
||||||
'Karaoké', 'LGBTQI+', 'Lady Gaga', 'Loup garou', 'Morning beer', 'Métal', 'Nuit blanche', 'Ovalie', 'Psychedelic',
|
],
|
||||||
'Pétanque', 'Rave', 'Reggae', 'Rhum', 'Ricard', 'Rock', 'Rosé', 'Rétro', 'Séducteur', 'Techno', 'Thérapie taxi',
|
'questions': {
|
||||||
'Théâtre', 'Trap', 'Turn up', 'Underground', 'Volley', 'Wati B', 'Zinédine Zidane',
|
"alcool": [
|
||||||
]
|
"""Sur une échelle allant de 0 (= 0 alcool ou très peu) à 5 (= la fontaine de jouvence alcoolique),
|
||||||
|
quel niveau de consommation d’alcool souhaiterais-tu ?""",
|
||||||
|
{
|
||||||
|
42: 4,
|
||||||
|
47: 1,
|
||||||
|
48: 3,
|
||||||
|
45: 3.5,
|
||||||
|
44: 4,
|
||||||
|
46: 5,
|
||||||
|
43: 3,
|
||||||
|
49: 3
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"voie_post_bac": [
|
||||||
|
"""Si la DA du bus de ton choix correspondait à une voie post-bac, laquelle serait-elle ?""",
|
||||||
|
{
|
||||||
|
42: "Double licence cuisine/arts du cirque option burger",
|
||||||
|
47: "BTS Exploration de donjon",
|
||||||
|
48: "Ecole des stars en herbe",
|
||||||
|
45: "Déscolarisation précoce",
|
||||||
|
44: "Rattrapage pour excès de kiff",
|
||||||
|
46: "Double cursus STAPS / Licence d’histoire",
|
||||||
|
43: "Recherche active d’un sugar daddy/d’un sugar mommy",
|
||||||
|
49: "Licence de musicologie"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"boite": [
|
||||||
|
"""Tu es seul·e sur une île déserte et devant toi il y a une sombre boîte de taille raisonnable.
|
||||||
|
Qu’y a-t-il à l’intérieur ?""",
|
||||||
|
{
|
||||||
|
42: "Un burgouzz de valouzz",
|
||||||
|
47: "Un ocarina (pour me téléporter hors de ce bourbier)",
|
||||||
|
48: "Des paillettes, un micro de karaoké et une enceinte bluetooth",
|
||||||
|
45: "Un kebab",
|
||||||
|
44: "Une 86 et un caisson pour taper du pied",
|
||||||
|
46: "Une épée, un ballon et une tireuse",
|
||||||
|
43: "Des lunettes de soleil",
|
||||||
|
49: "Mon instrument de musique"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"tardif": [
|
||||||
|
"""Il est 00h, tu as passé la journée à la plage avec tes copains et iels te proposent de prolonger parce
|
||||||
|
qu’après tout, il n’y a plus personne sur la plage à cette heure-ci. Tu n’habites pas loin mais t’enchaînes
|
||||||
|
demain avec une journée similaire avec un autre groupe d’amis parce que t’es trop #busy. Que fais-tu ?""",
|
||||||
|
{
|
||||||
|
42: "On veut se déchaîner toute la nuit !!",
|
||||||
|
47: "Je prends une glace et chill un moment avant d’aller dormir",
|
||||||
|
48: "J’enfile mes boogie shoes pour enflammer le dancefloor avec elleux et lancer un concours de slay, le perdant finit la bouteille de rhum",
|
||||||
|
45: "La fête continuuuuue",
|
||||||
|
44: "Soirée sangria plage → boîte → lever de soleil sur la plage",
|
||||||
|
46: "Minuit ? C’est l’heure du genepi. On commence les alcools forts !!",
|
||||||
|
43: "T’enchaînes direct (faut pas les priver de ta présence)",
|
||||||
|
49: "On continue en mode chill (soirée potins)"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"cohesion": [
|
||||||
|
"""C’est la rentrée de Seconde et tu découvres ta classe, tes camarades et ta prof principale!!!
|
||||||
|
qui vous propose une activité de cohésion. Laquelle est-elle ?""",
|
||||||
|
{
|
||||||
|
42: "Un relais cubi en ventriglisse",
|
||||||
|
47: "Un jeu de rôle",
|
||||||
|
48: "Organiser la soirée de l’année dans le lycée. Le thème : SLAY (Spotlight, Love, Amaze/All-night, Yeah), paillettes, disco",
|
||||||
|
45: "La prof de français propose un slam parce qu'elle pense que c'est du rap littéraire qui fera plaisir aux élèves",
|
||||||
|
44: "P’tit escape game + apéro",
|
||||||
|
46: "Joute avec des boucliers Gilbert",
|
||||||
|
43: "Tournage d’un clip de confessions nocturnes de Diam’s",
|
||||||
|
49: "Je sais pas j’ai raté mon BAFA"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"artiste": [
|
||||||
|
"""C’est l’été et la saison des festivals a commencé. Tu regardes la programmation du festival
|
||||||
|
pas loin de chez toi et tu découvres avec joie la présence d’un·e artiste. De qui s’agit-il ?""",
|
||||||
|
{
|
||||||
|
42: "Moto-Moto (il chantera son fameux tube “je les aime grosses, je les aime bombées”)",
|
||||||
|
47: "Hatsune Miku",
|
||||||
|
48: "Rihanna",
|
||||||
|
45: "Vald",
|
||||||
|
44: "Qui connaît vraiment les noms des artistes de tech ?",
|
||||||
|
46: "Perceval",
|
||||||
|
43: "Fatal bazooka",
|
||||||
|
49: "Måneskin"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"annonce_noel": [
|
||||||
|
"""C’est Noël et tu revois toute ta famille, oncles, tantes, cousin·e·s, grands-parents, la totale.
|
||||||
|
D’un coup, tu te lèves, tapotes de manière pompeuse sur ton verre avec un de tes couverts.
|
||||||
|
Qu’annonces-tu ?""",
|
||||||
|
{
|
||||||
|
42: """« Chère famille. Je sais bien que nous avions dit : pas de politique à table.
|
||||||
|
Je ne peux toutefois me retenir de vous annoncer une grande nouvelle…
|
||||||
|
j’ai décidé de quitter la ville pour consacrer ma vie au culte du Roi Julian.
|
||||||
|
A moi la jungle luxuriante, là où le soleil chaud caresse les palmiers,
|
||||||
|
où les lémuriens dansent avec frénésie et où chaque repas est une ode au burger sauvage.
|
||||||
|
Longue vie à Sa Majesté le Roi Julian ! »""",
|
||||||
|
47: "« J’ai perdu »",
|
||||||
|
48: "« Mes chers parents je pars, j’arrête l’ENS pour devenir DJ slay à Ibiza »",
|
||||||
|
45: "J’interromps le repas pour rapper les 6min de bande organisée",
|
||||||
|
44: "« Digestif ? Pétanque ? Les deux ? »",
|
||||||
|
46: "« Montjoie St Denis à bas la Macronie »",
|
||||||
|
43: "« Je suis enceinte » (c’est faux j’ai juste besoin d’attention)",
|
||||||
|
49: """Discours de remerciement :
|
||||||
|
je lance un powerpoint de 65 slides et sors une feuille A4 blanche (je fais semblant de lire mon discours dessus)"""
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"vacances": [
|
||||||
|
"""Les vacances sont là et t’aimerais bien partir quelque part, mais où ?""",
|
||||||
|
{
|
||||||
|
42: "A Madagascar, à bord d’un bus conduit par des pingouins",
|
||||||
|
47: "Dans ma chambre",
|
||||||
|
48: "Rio de Janeiro",
|
||||||
|
45: "N'importe où tant qu'on peut sortir tous les soirs",
|
||||||
|
44: "Tu suis les plans du club ski ou de piratens",
|
||||||
|
46: "Carcassonne",
|
||||||
|
43: "Coachella",
|
||||||
|
49: "Dans les montagnes de la république populaire d’Auvergne-Rhônes-Alpes pour profiter de la fraîcheur, de la nature et de mes ami·e·s"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"loisir": [
|
||||||
|
"""T’as fini ta journée de cours et tu t’apprêtes à profiter d’une activité/hobby/loisir de ton choix.
|
||||||
|
Laquelle est-ce ?""",
|
||||||
|
{
|
||||||
|
42: "Cueillir des noix de coco",
|
||||||
|
47: "Essayer de travailler puis chill avec des potes autour d’un jeu en buvant du thé",
|
||||||
|
48: "Repet du nouveau spectacle de mon club, before (potins) puis sortie avec les potes jusqu’au bout de la night",
|
||||||
|
45: "Zoner avec les copaings jusqu’à pas d’heure",
|
||||||
|
44: "Go Kfet pour se faire traquenard jusqu’à 3h du mat",
|
||||||
|
46: "Déterminer ce qui est le plus solide entre mon crâne et une ecocup",
|
||||||
|
43: "Revoir pour la 6e fois gossip girl au fond de ton lit",
|
||||||
|
49: "Jouer de mon instrument préféré avec les copains/copines pour préparer le prochain concert #solidays"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"plan": [
|
||||||
|
"""Tu reçois un message sur la conversation de groupe que tu partages avec tes potes :
|
||||||
|
vous êtes chaud·e·s pour vous retrouver. Quel plan t’attire le plus ?""",
|
||||||
|
{
|
||||||
|
42: """Après-midi piscine, puis before arrosé de mojito,
|
||||||
|
avant d’aller s’éclater en pot avec toute la savane et de finir sur un after spécial pina colada""",
|
||||||
|
47: """(matin) : Ptit jeu de rôle
|
||||||
|
(repas) : le traditionnel poké-tacos
|
||||||
|
(juste après le repas) : combat avec des épées en mousse avec les copains!
|
||||||
|
(16h00) : pause thé
|
||||||
|
(fin d’après midi) : initiation à la danse rock
|
||||||
|
(soirée) : découverte d’un jeu de société avec des règles obscures
|
||||||
|
""",
|
||||||
|
48: "Soirée champagne and chic : spectacle et dîner au moulin rouge puis soirée sur les champs",
|
||||||
|
45: "Se regrouper pour une soirée, même si il n’est encore que 10h",
|
||||||
|
44: "P’tit poké qui termine en koin koin avec after poker",
|
||||||
|
46: "Une dégustation de bière, un rugby et toute autre activité joviale",
|
||||||
|
43: "Un brunch de pour papoter puis friperies",
|
||||||
|
49: "Soirée raclette !"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
'stats': [
|
||||||
|
{
|
||||||
|
"question": """Le WEI est structuré par bus, et au sein de chaque bus, par équipes.
|
||||||
|
Pour toi, être dans une équipe où tout le monde reste sobre (primo-entrants comme encadrants) c'est :""",
|
||||||
|
"answers": [
|
||||||
|
(1, "Inenvisageable"),
|
||||||
|
(2, "À contre cœur"),
|
||||||
|
(3, "Pourquoi pas"),
|
||||||
|
(4, "Souhaitable"),
|
||||||
|
(5, "Nécessaire"),
|
||||||
|
],
|
||||||
|
"help_text": "(De toute façon aucun alcool n'est consommé pendant les trajets du bus, ni aller, ni retour.)",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"question": "Faire partie d'un bus qui n'apporte pas de boisson alcoolisée pour ses membres, pour toi c'est :",
|
||||||
|
"answers": [
|
||||||
|
(1, "Inenvisageable"),
|
||||||
|
(2, "À contre cœur"),
|
||||||
|
(3, "Pourquoi pas"),
|
||||||
|
(4, "Souhaitable"),
|
||||||
|
(5, "Nécessaire"),
|
||||||
|
],
|
||||||
|
"help_text": """(Tout les bus apportent de l'alcool cette année, cette question sert à l'organisation pour l'année prochaine.
|
||||||
|
De plus il y aura de toute façon de l'alcool commun au WEI et aucun alcool n'est consommé pendant les trajets en bus.)""",
|
||||||
|
},
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
IMAGES = {
|
||||||
|
"vacances": {
|
||||||
|
49: "/static/wei/img/logo_auvergne_rhone_alpes.jpg",
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
NB_WORDS = 5
|
||||||
|
|
||||||
|
|
||||||
|
class OptionalImageRadioSelect(forms.RadioSelect):
|
||||||
|
def __init__(self, images=None, *args, **kwargs):
|
||||||
|
self.images = images or {}
|
||||||
|
super().__init__(*args, **kwargs)
|
||||||
|
|
||||||
|
def create_option(self, name, value, label, selected, index, subindex=None, attrs=None):
|
||||||
|
option = super().create_option(name, value, label, selected, index, subindex=subindex, attrs=attrs)
|
||||||
|
img_url = self.images.get(value)
|
||||||
|
if img_url:
|
||||||
|
option['label'] = mark_safe(f'{label} <img src="{img_url}" style="height:32px;vertical-align:middle;">')
|
||||||
|
else:
|
||||||
|
option['label'] = label
|
||||||
|
return option
|
||||||
|
|
||||||
|
|
||||||
class WEISurveyForm2025(forms.Form):
|
class WEISurveyForm2025(forms.Form):
|
||||||
@@ -32,11 +235,6 @@ class WEISurveyForm2025(forms.Form):
|
|||||||
Members choose 20 words, from which we calculate the best associated bus.
|
Members choose 20 words, from which we calculate the best associated bus.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
word = forms.ChoiceField(
|
|
||||||
label=_("Choose a word:"),
|
|
||||||
widget=forms.RadioSelect(),
|
|
||||||
)
|
|
||||||
|
|
||||||
def set_registration(self, registration):
|
def set_registration(self, registration):
|
||||||
"""
|
"""
|
||||||
Filter the bus selector with the buses of the current WEI.
|
Filter the bus selector with the buses of the current WEI.
|
||||||
@@ -48,34 +246,52 @@ class WEISurveyForm2025(forms.Form):
|
|||||||
registration._force_save = True
|
registration._force_save = True
|
||||||
registration.save()
|
registration.save()
|
||||||
|
|
||||||
if self.data:
|
rng = Random((information.step + 1) * information.seed)
|
||||||
self.fields["word"].choices = [(w, w) for w in WORDS]
|
|
||||||
|
if information.step == 0:
|
||||||
|
self.fields["words"] = forms.MultipleChoiceField(
|
||||||
|
label=_(f"Select {NB_WORDS} words that describe the WEI experience you want to have."),
|
||||||
|
choices=[(w, w) for w in WORDS['list']],
|
||||||
|
widget=forms.CheckboxSelectMultiple(),
|
||||||
|
required=True,
|
||||||
|
)
|
||||||
if self.is_valid():
|
if self.is_valid():
|
||||||
return
|
return
|
||||||
|
|
||||||
rng = Random((information.step + 1) * information.seed)
|
all_preferred_words = WORDS['list']
|
||||||
|
|
||||||
buses = WEISurveyAlgorithm2025.get_buses()
|
|
||||||
informations = {bus: WEIBusInformation2025(bus) for bus in buses}
|
|
||||||
scores = sum((list(informations[bus].scores.values()) for bus in buses), [])
|
|
||||||
if scores:
|
|
||||||
average_score = sum(scores) / len(scores)
|
|
||||||
else:
|
|
||||||
average_score = 0
|
|
||||||
|
|
||||||
preferred_words = {bus: [word for word in WORDS
|
|
||||||
if informations[bus].scores[word] >= average_score]
|
|
||||||
for bus in buses}
|
|
||||||
|
|
||||||
# Correction : proposer plusieurs mots différents à chaque étape
|
|
||||||
n_choices = 4 # Nombre de mots à proposer à chaque étape
|
|
||||||
all_preferred_words = set()
|
|
||||||
for bus_words in preferred_words.values():
|
|
||||||
all_preferred_words.update(bus_words)
|
|
||||||
all_preferred_words = list(all_preferred_words)
|
|
||||||
rng.shuffle(all_preferred_words)
|
rng.shuffle(all_preferred_words)
|
||||||
words = all_preferred_words[:n_choices]
|
self.fields["words"].choices = [(w, w) for w in all_preferred_words]
|
||||||
self.fields["word"].choices = [(w, w) for w in words]
|
elif information.step <= len(WORDS['questions']):
|
||||||
|
questions = list(WORDS['questions'].items())
|
||||||
|
idx = information.step - 1
|
||||||
|
if idx < len(questions):
|
||||||
|
q, (desc, answers) = questions[idx]
|
||||||
|
if q == 'alcool':
|
||||||
|
choices = [(i / 2, str(i / 2)) for i in range(11)]
|
||||||
|
else:
|
||||||
|
choices = [(k, v) for k, v in answers.items()]
|
||||||
|
rng.shuffle(choices)
|
||||||
|
self.fields[q] = forms.ChoiceField(
|
||||||
|
label=desc,
|
||||||
|
choices=choices,
|
||||||
|
widget=OptionalImageRadioSelect(images=IMAGES.get(q, {})),
|
||||||
|
required=True,
|
||||||
|
)
|
||||||
|
elif information.step == len(WORDS['questions']) + 1:
|
||||||
|
for i, v in enumerate(WORDS['stats']):
|
||||||
|
self.fields[f'stat_{i}'] = forms.ChoiceField(
|
||||||
|
label=v['question'],
|
||||||
|
choices=v['answers'],
|
||||||
|
widget=forms.RadioSelect(),
|
||||||
|
required=False,
|
||||||
|
help_text=_(v.get('help_text', ''))
|
||||||
|
)
|
||||||
|
|
||||||
|
def clean_words(self):
|
||||||
|
data = self.cleaned_data['words']
|
||||||
|
if len(data) != NB_WORDS:
|
||||||
|
raise forms.ValidationError(_(f"Please choose exactly {NB_WORDS} words"))
|
||||||
|
return data
|
||||||
|
|
||||||
|
|
||||||
class WEIBusInformation2025(WEIBusInformation):
|
class WEIBusInformation2025(WEIBusInformation):
|
||||||
@@ -86,8 +302,6 @@ class WEIBusInformation2025(WEIBusInformation):
|
|||||||
|
|
||||||
def __init__(self, bus):
|
def __init__(self, bus):
|
||||||
self.scores = {}
|
self.scores = {}
|
||||||
for word in WORDS:
|
|
||||||
self.scores[word] = 0
|
|
||||||
super().__init__(bus)
|
super().__init__(bus)
|
||||||
|
|
||||||
|
|
||||||
@@ -95,7 +309,9 @@ class BusInformationForm2025(forms.ModelForm):
|
|||||||
class Meta:
|
class Meta:
|
||||||
model = Bus
|
model = Bus
|
||||||
fields = ['information_json']
|
fields = ['information_json']
|
||||||
widgets = {}
|
widgets = {
|
||||||
|
'information_json': forms.HiddenInput(),
|
||||||
|
}
|
||||||
|
|
||||||
def __init__(self, *args, words=None, **kwargs):
|
def __init__(self, *args, words=None, **kwargs):
|
||||||
super().__init__(*args, **kwargs)
|
super().__init__(*args, **kwargs)
|
||||||
@@ -108,7 +324,7 @@ class BusInformationForm2025(forms.ModelForm):
|
|||||||
except (json.JSONDecodeError, TypeError, AttributeError):
|
except (json.JSONDecodeError, TypeError, AttributeError):
|
||||||
initial_scores = {}
|
initial_scores = {}
|
||||||
if words is None:
|
if words is None:
|
||||||
words = WORDS
|
words = WORDS['list']
|
||||||
self.words = words
|
self.words = words
|
||||||
|
|
||||||
choices = [(i, str(i)) for i in range(6)] # [(0, '0'), (1, '1'), ..., (5, '5')]
|
choices = [(i, str(i)) for i in range(6)] # [(0, '0'), (1, '1'), ..., (5, '5')]
|
||||||
@@ -117,7 +333,7 @@ class BusInformationForm2025(forms.ModelForm):
|
|||||||
label=word,
|
label=word,
|
||||||
choices=choices,
|
choices=choices,
|
||||||
coerce=int,
|
coerce=int,
|
||||||
initial=initial_scores.get(word, 0),
|
initial=initial_scores.get(word, 0) if word in initial_scores else None,
|
||||||
required=True,
|
required=True,
|
||||||
widget=forms.RadioSelect,
|
widget=forms.RadioSelect,
|
||||||
help_text=_("Rate between 0 and 5."),
|
help_text=_("Rate between 0 and 5."),
|
||||||
@@ -145,10 +361,26 @@ class WEISurveyInformation2025(WEISurveyInformation):
|
|||||||
step = 0
|
step = 0
|
||||||
|
|
||||||
def __init__(self, registration):
|
def __init__(self, registration):
|
||||||
for i in range(1, 21):
|
for i in range(1, NB_WORDS + 1):
|
||||||
setattr(self, "word" + str(i), None)
|
setattr(self, "word" + str(i), None)
|
||||||
|
for q in WORDS['questions']:
|
||||||
|
setattr(self, q, None)
|
||||||
super().__init__(registration)
|
super().__init__(registration)
|
||||||
|
|
||||||
|
def reset(self, registration):
|
||||||
|
"""
|
||||||
|
Réinitialise complètement le questionnaire : step, seed, mots choisis et réponses aux questions.
|
||||||
|
"""
|
||||||
|
self.step = 0
|
||||||
|
self.seed = 0
|
||||||
|
for i in range(1, NB_WORDS + 1):
|
||||||
|
setattr(self, f"word{i}", None)
|
||||||
|
for q in WORDS['questions']:
|
||||||
|
setattr(self, q, None)
|
||||||
|
self.save(registration)
|
||||||
|
registration._force_save = True
|
||||||
|
registration.save()
|
||||||
|
|
||||||
|
|
||||||
class WEISurvey2025(WEISurvey):
|
class WEISurvey2025(WEISurvey):
|
||||||
"""
|
"""
|
||||||
@@ -174,9 +406,26 @@ class WEISurvey2025(WEISurvey):
|
|||||||
|
|
||||||
@transaction.atomic
|
@transaction.atomic
|
||||||
def form_valid(self, form):
|
def form_valid(self, form):
|
||||||
word = form.cleaned_data["word"]
|
if self.information.step == 0:
|
||||||
|
words = form.cleaned_data['words']
|
||||||
|
for i, word in enumerate(words, 1):
|
||||||
|
setattr(self.information, "word" + str(i), word)
|
||||||
|
self.information.step += 1
|
||||||
|
self.save()
|
||||||
|
elif 1 <= self.information.step <= len(WORDS['questions']):
|
||||||
|
questions = list(WORDS['questions'].keys())
|
||||||
|
idx = self.information.step - 1
|
||||||
|
if idx < len(questions):
|
||||||
|
q = questions[idx]
|
||||||
|
setattr(self.information, q, form.cleaned_data[q])
|
||||||
|
self.information.step += 1
|
||||||
|
self.save()
|
||||||
|
else:
|
||||||
|
for i, __ in enumerate(WORDS['stats']):
|
||||||
|
ans = form.cleaned_data.get(f'stat_{i}')
|
||||||
|
if ans is not None:
|
||||||
|
setattr(self.information, f'stat_{i}', ans)
|
||||||
self.information.step += 1
|
self.information.step += 1
|
||||||
setattr(self.information, "word" + str(self.information.step), word)
|
|
||||||
self.save()
|
self.save()
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
@@ -187,7 +436,7 @@ class WEISurvey2025(WEISurvey):
|
|||||||
"""
|
"""
|
||||||
The survey is complete once the bus is chosen.
|
The survey is complete once the bus is chosen.
|
||||||
"""
|
"""
|
||||||
return self.information.step == 20
|
return self.information.step > len(WORDS['questions']) + 1
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
@lru_cache()
|
@lru_cache()
|
||||||
@@ -199,24 +448,42 @@ class WEISurvey2025(WEISurvey):
|
|||||||
return sum([cls.get_algorithm_class().get_bus_information(bus).scores[word] for bus in buses]) / buses.count()
|
return sum([cls.get_algorithm_class().get_bus_information(bus).scores[word] for bus in buses]) / buses.count()
|
||||||
|
|
||||||
@lru_cache()
|
@lru_cache()
|
||||||
def score(self, bus):
|
def score_questions(self, bus):
|
||||||
|
"""
|
||||||
|
The score given by the answers to the questions
|
||||||
|
"""
|
||||||
|
if not self.is_complete():
|
||||||
|
raise ValueError("Survey is not ended, can't calculate score")
|
||||||
|
s = sum(1 for q in WORDS['questions'] if q != 'alcool' and getattr(self.information, q) == bus.pk)
|
||||||
|
if 'alcool' in WORDS['questions'] and bus.pk in WORDS['questions']['alcool'][1] and hasattr(self.information, 'alcool'):
|
||||||
|
s -= abs(float(self.information.alcool) - float(WORDS['questions']['alcool'][1][bus.pk]))
|
||||||
|
return s
|
||||||
|
|
||||||
|
@lru_cache()
|
||||||
|
def score_words(self, bus):
|
||||||
|
"""
|
||||||
|
The score given by the choice of words
|
||||||
|
"""
|
||||||
if not self.is_complete():
|
if not self.is_complete():
|
||||||
raise ValueError("Survey is not ended, can't calculate score")
|
raise ValueError("Survey is not ended, can't calculate score")
|
||||||
|
|
||||||
bus_info = self.get_algorithm_class().get_bus_information(bus)
|
bus_info = self.get_algorithm_class().get_bus_information(bus)
|
||||||
# Score is the given score by the bus subtracted to the mid-score of the buses.
|
# Score is the given score by the bus subtracted to the mid-score of the buses.
|
||||||
s = sum(bus_info.scores[getattr(self.information, 'word' + str(i))]
|
s = sum(bus_info.scores[getattr(self.information, 'word' + str(i))]
|
||||||
- self.word_mean(getattr(self.information, 'word' + str(i))) for i in range(1, 21)) / 20
|
- self.word_mean(getattr(self.information, 'word' + str(i))) for i in range(1, 1 + NB_WORDS)) / self.get_algorithm_class().get_buses().count()
|
||||||
return s
|
return s
|
||||||
|
|
||||||
@lru_cache()
|
@lru_cache()
|
||||||
def scores_per_bus(self):
|
def scores_per_bus(self):
|
||||||
return {bus: self.score(bus) for bus in self.get_algorithm_class().get_buses()}
|
return {bus: (self.score_questions(bus), self.score_words(bus)) for bus in self.get_algorithm_class().get_buses()}
|
||||||
|
|
||||||
@lru_cache()
|
@lru_cache()
|
||||||
def ordered_buses(self):
|
def ordered_buses(self):
|
||||||
|
"""
|
||||||
|
Order the buses by the score_questions of the survey.
|
||||||
|
"""
|
||||||
values = list(self.scores_per_bus().items())
|
values = list(self.scores_per_bus().items())
|
||||||
values.sort(key=lambda item: -item[1])
|
values.sort(key=lambda item: -item[1][0])
|
||||||
return values
|
return values
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
@@ -243,10 +510,18 @@ class WEISurveyAlgorithm2025(WEISurveyAlgorithm):
|
|||||||
def get_bus_information_form(cls):
|
def get_bus_information_form(cls):
|
||||||
return BusInformationForm2025
|
return BusInformationForm2025
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def get_buses(cls):
|
||||||
|
|
||||||
|
if not hasattr(cls, '_buses'):
|
||||||
|
cls._buses = Bus.objects.filter(wei__year=cls.get_survey_class().get_year(), size__gt=0).all().exclude(name='Staff')
|
||||||
|
return cls._buses
|
||||||
|
|
||||||
def run_algorithm(self, display_tqdm=False):
|
def run_algorithm(self, display_tqdm=False):
|
||||||
"""
|
"""
|
||||||
Gale-Shapley algorithm implementation.
|
Gale-Shapley algorithm implementation.
|
||||||
We modify it to allow buses to have multiple "weddings".
|
We modify it to allow buses to have multiple "weddings".
|
||||||
|
We use lexigographical order on both scores
|
||||||
"""
|
"""
|
||||||
surveys = list(self.get_survey_class()(r) for r in self.get_registrations()) # All surveys
|
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
|
surveys = [s for s in surveys if s.is_complete()] # Don't consider invalid surveys
|
||||||
@@ -307,7 +582,7 @@ class WEISurveyAlgorithm2025(WEISurveyAlgorithm):
|
|||||||
while free_surveys: # Some students are not affected
|
while free_surveys: # Some students are not affected
|
||||||
survey = free_surveys[0]
|
survey = free_surveys[0]
|
||||||
buses = survey.ordered_buses() # Preferences of the student
|
buses = survey.ordered_buses() # Preferences of the student
|
||||||
for bus, current_score in buses:
|
for bus, current_scores in buses:
|
||||||
if self.get_bus_information(bus).has_free_seats(surveys, quotas):
|
if self.get_bus_information(bus).has_free_seats(surveys, quotas):
|
||||||
# Selected bus has free places. Put student in the bus
|
# Selected bus has free places. Put student in the bus
|
||||||
survey.select_bus(bus)
|
survey.select_bus(bus)
|
||||||
@@ -322,8 +597,8 @@ class WEISurveyAlgorithm2025(WEISurveyAlgorithm):
|
|||||||
for survey2 in surveys:
|
for survey2 in surveys:
|
||||||
if not survey2.information.valid or survey2.information.get_selected_bus() != bus:
|
if not survey2.information.valid or survey2.information.get_selected_bus() != bus:
|
||||||
continue
|
continue
|
||||||
score2 = survey2.score(bus)
|
score2 = survey2.score_words(bus)
|
||||||
if current_score <= score2: # Ignore better students
|
if current_scores[1] <= score2: # Ignore better students
|
||||||
continue
|
continue
|
||||||
if least_preferred_survey is None or score2 < least_score:
|
if least_preferred_survey is None or score2 < least_score:
|
||||||
least_preferred_survey = survey2
|
least_preferred_survey = survey2
|
||||||
|
|||||||
@@ -0,0 +1,23 @@
|
|||||||
|
# Generated by Django 5.2.4 on 2025-07-19 12:17
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('wei', '0015_remove_weiclub_caution_amount_and_more'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='weiregistration',
|
||||||
|
name='fee',
|
||||||
|
field=models.PositiveIntegerField(blank=True, default=0, verbose_name='fee'),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='weiclub',
|
||||||
|
name='fee_soge_credit',
|
||||||
|
field=models.PositiveIntegerField(default=2000, verbose_name='membership fee (soge credit)'),
|
||||||
|
),
|
||||||
|
]
|
||||||
18
apps/wei/migrations/0017_alter_weiclub_fee_soge_credit.py
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
# Generated by Django 5.2.4 on 2025-08-02 13:43
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('wei', '0016_weiregistration_fee_alter_weiclub_fee_soge_credit'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='weiclub',
|
||||||
|
name='fee_soge_credit',
|
||||||
|
field=models.PositiveIntegerField(default=0, verbose_name='membership fee (soge credit)'),
|
||||||
|
),
|
||||||
|
]
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
# Generated by Django 5.2.4 on 2025-08-02 17:59
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('wei', '0017_alter_weiclub_fee_soge_credit'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.RemoveField(
|
||||||
|
model_name='weiregistration',
|
||||||
|
name='deposit_check',
|
||||||
|
),
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='weiregistration',
|
||||||
|
name='deposit_given',
|
||||||
|
field=models.BooleanField(default=False, verbose_name='Deposit given'),
|
||||||
|
),
|
||||||
|
]
|
||||||
@@ -40,7 +40,7 @@ class WEIClub(Club):
|
|||||||
|
|
||||||
fee_soge_credit = models.PositiveIntegerField(
|
fee_soge_credit = models.PositiveIntegerField(
|
||||||
verbose_name=_("membership fee (soge credit)"),
|
verbose_name=_("membership fee (soge credit)"),
|
||||||
default=2000,
|
default=0,
|
||||||
)
|
)
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
@@ -202,9 +202,9 @@ class WEIRegistration(models.Model):
|
|||||||
verbose_name=_("Credit from Société générale"),
|
verbose_name=_("Credit from Société générale"),
|
||||||
)
|
)
|
||||||
|
|
||||||
deposit_check = models.BooleanField(
|
deposit_given = models.BooleanField(
|
||||||
default=False,
|
default=False,
|
||||||
verbose_name=_("Deposit check given")
|
verbose_name=_("Deposit given")
|
||||||
)
|
)
|
||||||
|
|
||||||
deposit_type = models.CharField(
|
deposit_type = models.CharField(
|
||||||
@@ -285,6 +285,12 @@ class WEIRegistration(models.Model):
|
|||||||
"encoded in JSON"),
|
"encoded in JSON"),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
fee = models.PositiveIntegerField(
|
||||||
|
default=0,
|
||||||
|
verbose_name=_('fee'),
|
||||||
|
blank=True,
|
||||||
|
)
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
unique_together = ('user', 'wei',)
|
unique_together = ('user', 'wei',)
|
||||||
verbose_name = _("WEI User")
|
verbose_name = _("WEI User")
|
||||||
@@ -309,7 +315,25 @@ class WEIRegistration(models.Model):
|
|||||||
self.information_json = json.dumps(information, indent=2)
|
self.information_json = json.dumps(information, indent=2)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def fee(self):
|
def is_validated(self):
|
||||||
|
try:
|
||||||
|
return self.membership is not None
|
||||||
|
except AttributeError:
|
||||||
|
return False
|
||||||
|
|
||||||
|
@property
|
||||||
|
def validation_status(self):
|
||||||
|
"""
|
||||||
|
Define an order to have easier access to validatable registrations
|
||||||
|
"""
|
||||||
|
if self.fee + (self.wei.deposit_amount if self.deposit_type == 'note' else 0) > self.user.note.balance:
|
||||||
|
return 2
|
||||||
|
elif self.first_year:
|
||||||
|
return 1
|
||||||
|
else:
|
||||||
|
return 0
|
||||||
|
|
||||||
|
def calculate_fee(self):
|
||||||
bde = Club.objects.get(pk=1)
|
bde = Club.objects.get(pk=1)
|
||||||
kfet = Club.objects.get(pk=2)
|
kfet = Club.objects.get(pk=2)
|
||||||
|
|
||||||
@@ -336,12 +360,9 @@ class WEIRegistration(models.Model):
|
|||||||
|
|
||||||
return fee
|
return fee
|
||||||
|
|
||||||
@property
|
def save(self, *args, **kwargs):
|
||||||
def is_validated(self):
|
self.fee = self.calculate_fee()
|
||||||
try:
|
super().save(*args, **kwargs)
|
||||||
return self.membership is not None
|
|
||||||
except AttributeError:
|
|
||||||
return False
|
|
||||||
|
|
||||||
|
|
||||||
class WEIMembership(Membership):
|
class WEIMembership(Membership):
|
||||||
|
|||||||
BIN
apps/wei/static/wei/img/logo_auvergne_rhone_alpes.jpg
Normal file
|
After Width: | Height: | Size: 34 KiB |
@@ -58,8 +58,8 @@ class WEIRegistrationTable(tables.Table):
|
|||||||
|
|
||||||
validate = tables.Column(
|
validate = tables.Column(
|
||||||
verbose_name=_("Validate"),
|
verbose_name=_("Validate"),
|
||||||
orderable=False,
|
orderable=True,
|
||||||
accessor=A('pk'),
|
accessor='validate_status',
|
||||||
attrs={
|
attrs={
|
||||||
'th': {
|
'th': {
|
||||||
'id': 'validate-membership-header'
|
'id': 'validate-membership-header'
|
||||||
@@ -71,7 +71,7 @@ class WEIRegistrationTable(tables.Table):
|
|||||||
'wei:wei_delete_registration',
|
'wei:wei_delete_registration',
|
||||||
args=[A('pk')],
|
args=[A('pk')],
|
||||||
orderable=False,
|
orderable=False,
|
||||||
verbose_name=_("delete"),
|
verbose_name=_("Delete"),
|
||||||
text=_("Delete"),
|
text=_("Delete"),
|
||||||
attrs={
|
attrs={
|
||||||
'th': {
|
'th': {
|
||||||
@@ -84,6 +84,35 @@ class WEIRegistrationTable(tables.Table):
|
|||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def render_deposit_type(self, record):
|
||||||
|
if record.first_year:
|
||||||
|
return format_html("∅")
|
||||||
|
if record.deposit_type == 'check':
|
||||||
|
# TODO Install Font Awesome 6 to acces more icons (and keep compaibility with current used v4)
|
||||||
|
return format_html("""
|
||||||
|
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 640 640" width="1.5em" height="1.5em"
|
||||||
|
fill="currentColor" style="position: relative; left: -0.15em;">
|
||||||
|
<path d="
|
||||||
|
M128 128C92.7 128 64 156.7 64 192L64 448C64 483.3 92.7 512 128 512L512 512
|
||||||
|
C547.3 512 576 483.3 576 448L576 192C576 156.7 547.3 128 512 128L128 128z
|
||||||
|
M360 352L488 352C501.3 352 512 362.7 512 376C512 389.3 501.3 400 488 400L360 400
|
||||||
|
C346.7 400 336 389.3 336 376C336 362.7 346.7 352 360 352z
|
||||||
|
M336 264C336 250.7 346.7 240 360 240L488 240C501.3 240 512 250.7 512 264
|
||||||
|
C512 277.3 501.3 288 488 288L360 288C346.7 288 336 277.3 336 264z
|
||||||
|
M212 208C223 208 232 217 232 228L232 232L240 232C251 232 260 241 260 252
|
||||||
|
C260 263 251 272 240 272L192.5 272C185.6 272 180 277.6 180 284.5
|
||||||
|
C180 290.6 184.4 295.8 190.4 296.8L232.1 303.8C257.4 308 276 329.9 276 355.6
|
||||||
|
C276 381.7 257 403.3 232 407.4L232 412.1C232 423.1 223 432.1 212 432.1
|
||||||
|
C201 432.1 192 423.1 192 412.1L192 408.1L168 408.1C157 408.1 148 399.1 148 388.1
|
||||||
|
C148 377.1 157 368.1 168 368.1L223.5 368.1C230.4 368.1 236 362.5 236 355.6
|
||||||
|
C236 349.5 231.6 344.3 225.6 343.3L183.9 336.3C158.5 332 140 310.1 140 284.5
|
||||||
|
C140 255.7 163.2 232.3 192 232L192 228C192 217 201 208 212 208z
|
||||||
|
" />
|
||||||
|
</svg>
|
||||||
|
""")
|
||||||
|
if record.deposit_type == 'note':
|
||||||
|
return format_html("<i class=\"fa fa-exchange\"></i>")
|
||||||
|
|
||||||
def render_validate(self, record):
|
def render_validate(self, record):
|
||||||
hasperm = PermissionBackend.check_perm(
|
hasperm = PermissionBackend.check_perm(
|
||||||
get_current_request(), "wei.add_weimembership", WEIMembership(
|
get_current_request(), "wei.add_weimembership", WEIMembership(
|
||||||
@@ -98,12 +127,13 @@ class WEIRegistrationTable(tables.Table):
|
|||||||
if not hasperm:
|
if not hasperm:
|
||||||
return format_html("<span class='no-perm'></span>")
|
return format_html("<span class='no-perm'></span>")
|
||||||
|
|
||||||
url = reverse_lazy('wei:wei_update_registration', args=(record.pk,)) + '?validate=true'
|
url = reverse_lazy('wei:validate_registration', args=(record.pk,))
|
||||||
text = _('Validate')
|
text = _('Validate')
|
||||||
if record.fee > record.user.note.balance and not record.soge_credit:
|
status = record.validation_status
|
||||||
|
if status == 2:
|
||||||
btn_class = 'btn-secondary'
|
btn_class = 'btn-secondary'
|
||||||
tooltip = _("The user does not have enough money.")
|
tooltip = _("The user does not have enough money.")
|
||||||
elif record.first_year:
|
elif status == 1:
|
||||||
btn_class = 'btn-info'
|
btn_class = 'btn-info'
|
||||||
tooltip = _("The user is in first year. You may validate the credit, the algorithm will run later.")
|
tooltip = _("The user is in first year. You may validate the credit, the algorithm will run later.")
|
||||||
else:
|
else:
|
||||||
@@ -121,10 +151,11 @@ class WEIRegistrationTable(tables.Table):
|
|||||||
attrs = {
|
attrs = {
|
||||||
'class': 'table table-condensed table-striped table-hover'
|
'class': 'table table-condensed table-striped table-hover'
|
||||||
}
|
}
|
||||||
|
order_by = ('validate', 'user',)
|
||||||
model = WEIRegistration
|
model = WEIRegistration
|
||||||
template_name = 'django_tables2/bootstrap4.html'
|
template_name = 'django_tables2/bootstrap4.html'
|
||||||
fields = ('user', 'user__first_name', 'user__last_name', 'first_year', 'deposit_check',
|
fields = ('user', 'user__first_name', 'user__last_name', 'first_year', 'deposit_given',
|
||||||
'edit', 'validate', 'delete',)
|
'deposit_type', 'edit', 'validate', 'delete',)
|
||||||
row_attrs = {
|
row_attrs = {
|
||||||
'class': 'table-row',
|
'class': 'table-row',
|
||||||
'id': lambda record: "row-" + str(record.pk),
|
'id': lambda record: "row-" + str(record.pk),
|
||||||
@@ -134,8 +165,8 @@ class WEIRegistrationTable(tables.Table):
|
|||||||
|
|
||||||
class WEIMembershipTable(tables.Table):
|
class WEIMembershipTable(tables.Table):
|
||||||
user = tables.LinkColumn(
|
user = tables.LinkColumn(
|
||||||
'wei:wei_update_registration',
|
'wei:wei_update_membership',
|
||||||
args=[A('registration__pk')],
|
args=[A('pk')],
|
||||||
)
|
)
|
||||||
|
|
||||||
year = tables.Column(
|
year = tables.Column(
|
||||||
@@ -156,6 +187,35 @@ class WEIMembershipTable(tables.Table):
|
|||||||
def render_year(self, record):
|
def render_year(self, record):
|
||||||
return str(record.user.profile.ens_year) + "A"
|
return str(record.user.profile.ens_year) + "A"
|
||||||
|
|
||||||
|
def render_registration__deposit_type(self, record):
|
||||||
|
if record.registration.first_year:
|
||||||
|
return format_html("∅")
|
||||||
|
if record.registration.deposit_type == 'check':
|
||||||
|
# TODO Install Font Awesome 6 to acces more icons (and keep compaibility with current used v4)
|
||||||
|
return format_html("""
|
||||||
|
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 640 640" width="1.5em" height="1.5em"
|
||||||
|
fill="currentColor" style="position: relative; left: -0.15em;">
|
||||||
|
<path d="
|
||||||
|
M128 128C92.7 128 64 156.7 64 192L64 448C64 483.3 92.7 512 128 512L512 512
|
||||||
|
C547.3 512 576 483.3 576 448L576 192C576 156.7 547.3 128 512 128L128 128z
|
||||||
|
M360 352L488 352C501.3 352 512 362.7 512 376C512 389.3 501.3 400 488 400L360 400
|
||||||
|
C346.7 400 336 389.3 336 376C336 362.7 346.7 352 360 352z
|
||||||
|
M336 264C336 250.7 346.7 240 360 240L488 240C501.3 240 512 250.7 512 264
|
||||||
|
C512 277.3 501.3 288 488 288L360 288C346.7 288 336 277.3 336 264z
|
||||||
|
M212 208C223 208 232 217 232 228L232 232L240 232C251 232 260 241 260 252
|
||||||
|
C260 263 251 272 240 272L192.5 272C185.6 272 180 277.6 180 284.5
|
||||||
|
C180 290.6 184.4 295.8 190.4 296.8L232.1 303.8C257.4 308 276 329.9 276 355.6
|
||||||
|
C276 381.7 257 403.3 232 407.4L232 412.1C232 423.1 223 432.1 212 432.1
|
||||||
|
C201 432.1 192 423.1 192 412.1L192 408.1L168 408.1C157 408.1 148 399.1 148 388.1
|
||||||
|
C148 377.1 157 368.1 168 368.1L223.5 368.1C230.4 368.1 236 362.5 236 355.6
|
||||||
|
C236 349.5 231.6 344.3 225.6 343.3L183.9 336.3C158.5 332 140 310.1 140 284.5
|
||||||
|
C140 255.7 163.2 232.3 192 232L192 228C192 217 201 208 212 208z
|
||||||
|
" />
|
||||||
|
</svg>
|
||||||
|
""")
|
||||||
|
if record.registration.deposit_type == 'note':
|
||||||
|
return format_html("<i class=\"fa fa-exchange\"></i>")
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
attrs = {
|
attrs = {
|
||||||
'class': 'table table-condensed table-striped table-hover'
|
'class': 'table table-condensed table-striped table-hover'
|
||||||
@@ -163,7 +223,7 @@ class WEIMembershipTable(tables.Table):
|
|||||||
model = WEIMembership
|
model = WEIMembership
|
||||||
template_name = 'django_tables2/bootstrap4.html'
|
template_name = 'django_tables2/bootstrap4.html'
|
||||||
fields = ('user', 'user__last_name', 'user__first_name', 'registration__gender', 'user__profile__department',
|
fields = ('user', 'user__last_name', 'user__first_name', 'registration__gender', 'user__profile__department',
|
||||||
'year', 'bus', 'team', 'registration__deposit_check', )
|
'year', 'bus', 'team', 'registration__deposit_given', 'registration__deposit_type')
|
||||||
row_attrs = {
|
row_attrs = {
|
||||||
'class': 'table-row',
|
'class': 'table-row',
|
||||||
'id': lambda record: "row-" + str(record.pk),
|
'id': lambda record: "row-" + str(record.pk),
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ SPDX-License-Identifier: GPL-3.0-or-later
|
|||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{% if club.deposit_amount > 0 %}
|
{% if club.deposit_amount > 0 %}
|
||||||
<dt class="col-xl-6">{% trans 'Deposit amount'|capfirst %}</dt>
|
<dt class="col-xl-6">{% trans 'deposit amount'|capfirst %}</dt>
|
||||||
<dd class="col-xl-6">{{ club.deposit_amount|pretty_money }}</dd>
|
<dd class="col-xl-6">{{ club.deposit_amount|pretty_money }}</dd>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ SPDX-License-Identifier: GPL-3.0-or-later
|
|||||||
<a class="btn btn-primary btn-sm my-1" href="{% url 'wei:update_bus' pk=object.pk %}"
|
<a class="btn btn-primary btn-sm my-1" href="{% url 'wei:update_bus' pk=object.pk %}"
|
||||||
data-turbolinks="false">{% trans "Edit" %}</a>
|
data-turbolinks="false">{% trans "Edit" %}</a>
|
||||||
<a class="btn btn-primary btn-sm my-1" href="{% url 'wei:update_bus_info' pk=object.pk %}"
|
<a class="btn btn-primary btn-sm my-1" href="{% url 'wei:update_bus_info' pk=object.pk %}"
|
||||||
data-turbolinks="false">{% trans "Edit information" %}</a>
|
data-turbolinks="false">{% trans "Edit information for survey" %}</a>
|
||||||
<a class="btn btn-primary btn-sm my-1" href="{% url 'wei:add_team' pk=object.pk %}"
|
<a class="btn btn-primary btn-sm my-1" href="{% url 'wei:add_team' pk=object.pk %}"
|
||||||
data-turbolinks="false">{% trans "Add team" %}</a>
|
data-turbolinks="false">{% trans "Add team" %}</a>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -31,15 +31,29 @@ SPDX-License-Identifier: GPL-3.0-or-later
|
|||||||
<a class="btn btn-success" href="{% url "wei:wei_register_1A_myself" wei_pk=club.pk %}" data-turbolinks="false">
|
<a class="btn btn-success" href="{% url "wei:wei_register_1A_myself" wei_pk=club.pk %}" data-turbolinks="false">
|
||||||
{% trans "Register to the WEI! – 1A" %}
|
{% trans "Register to the WEI! – 1A" %}
|
||||||
</a>
|
</a>
|
||||||
{% endif %}
|
|
||||||
<a class="btn btn-success" href="{% url "wei:wei_register_2A_myself" wei_pk=club.pk %}" data-turbolinks="false">
|
|
||||||
{% trans "Register to the WEI! – 2A+" %}</a>
|
|
||||||
{% else %}
|
{% else %}
|
||||||
|
<a class="btn btn-success" href="{% url "wei:wei_register_2A_myself" wei_pk=club.pk %}" data-turbolinks="false">
|
||||||
|
{% trans "Register to the WEI! – 2A+" %}
|
||||||
|
</a>
|
||||||
|
{% endif %}
|
||||||
|
{% else %}
|
||||||
|
{% if registration.validated %}
|
||||||
<a class="btn btn-warning" href="{% url "wei:wei_update_registration" pk=my_registration.pk %}"
|
<a class="btn btn-warning" href="{% url "wei:wei_update_registration" pk=my_registration.pk %}"
|
||||||
data-turbolinks="false">
|
data-turbolinks="false">
|
||||||
{% trans "Update my registration" %}
|
{% trans "Update my registration" %}
|
||||||
</a>
|
</a>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
{% if my_registration.first_year %}
|
||||||
|
{% if not survey_complete %}
|
||||||
|
<a class="btn btn-warning" href="{% url "wei:wei_survey" pk=my_registration.pk %}" data-turbolinks="false">
|
||||||
|
{% trans "Continue survey" %}
|
||||||
|
</a>
|
||||||
|
{% endif %}
|
||||||
|
<a class="btn btn-warning" href="{% url "wei:wei_survey" pk=my_registration.pk %}?reset=true" data-turbolinks="false">
|
||||||
|
{% trans "Restart survey" %}
|
||||||
|
</a>
|
||||||
|
{% endif %}
|
||||||
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
@@ -67,20 +81,6 @@ SPDX-License-Identifier: GPL-3.0-or-later
|
|||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{% if history_list.data %}
|
|
||||||
<div class="card bg-white mb-3">
|
|
||||||
<div class="card-header position-relative" id="historyListHeading">
|
|
||||||
<a class="stretched-link font-weight-bold text-decoration-none" {% if "note.view_note"|has_perm:club.note %}
|
|
||||||
href="{% url 'note:transactions' pk=club.note.pk %}" {% endif %}>
|
|
||||||
<i class="fa fa-euro"></i> {% trans "Transaction history" %}
|
|
||||||
</a>
|
|
||||||
</div>
|
|
||||||
<div id="history_list">
|
|
||||||
{% render_table history_list %}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
{% endif %}
|
|
||||||
|
|
||||||
{% if pre_registrations.data %}
|
{% if pre_registrations.data %}
|
||||||
<div class="card bg-white mb-3">
|
<div class="card bg-white mb-3">
|
||||||
<div class="card-header position-relative" id="historyListHeading">
|
<div class="card-header position-relative" id="historyListHeading">
|
||||||
@@ -99,6 +99,19 @@ SPDX-License-Identifier: GPL-3.0-or-later
|
|||||||
<a href="{% url 'wei:wei_1A_list' pk=object.pk %}" class="btn btn-block btn-info">{% trans "Attribute buses" %}</a>
|
<a href="{% url 'wei:wei_1A_list' pk=object.pk %}" class="btn btn-block btn-info">{% trans "Attribute buses" %}</a>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
|
{% if history_list.data %}
|
||||||
|
<div class="card bg-white mt-3">
|
||||||
|
<div class="card-header position-relative" id="historyListHeading">
|
||||||
|
<a class="stretched-link font-weight-bold text-decoration-none" {% if "note.view_note"|has_perm:club.note %}
|
||||||
|
href="{% url 'note:transactions' pk=club.note.pk %}" {% endif %}>
|
||||||
|
<i class="fa fa-euro"></i> {% trans "Transaction history" %}
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
<div id="history_list">
|
||||||
|
{% render_table history_list %}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
|
|||||||
@@ -96,7 +96,7 @@ SPDX-License-Identifier: GPL-3.0-or-later
|
|||||||
{% endif %}
|
{% endif %}
|
||||||
{% else %}
|
{% else %}
|
||||||
<dt class="col-xl-6">{% trans 'Deposit check given'|capfirst %}</dt>
|
<dt class="col-xl-6">{% trans 'Deposit check given'|capfirst %}</dt>
|
||||||
<dd class="col-xl-6">{{ registration.deposit_check|yesno }}</dd>
|
<dd class="col-xl-6">{{ registration.deposit_given|yesno }}</dd>
|
||||||
|
|
||||||
{% with information=registration.information %}
|
{% with information=registration.information %}
|
||||||
<dt class="col-xl-6">{% trans 'preferred bus'|capfirst %}</dt>
|
<dt class="col-xl-6">{% trans 'preferred bus'|capfirst %}</dt>
|
||||||
@@ -143,12 +143,13 @@ SPDX-License-Identifier: GPL-3.0-or-later
|
|||||||
{% endblocktrans %}
|
{% endblocktrans %}
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<div class="alert {% if registration.user.note.balance < fee %}alert-danger{% else %}alert-success{% endif %}">
|
<div class="alert {% if registration.validation_status == 2 %}alert-danger{% else %}alert-success{% endif %}">
|
||||||
<h5>{% trans "Required payments:" %}</h5>
|
<h5>{% trans "Required payments:" %}</h5>
|
||||||
<ul>
|
<ul>
|
||||||
<li>{% blocktrans trimmed with amount=fee|pretty_money %}
|
<li>{% blocktrans trimmed with amount=fee|pretty_money %}
|
||||||
Membership fees: {{ amount }}
|
Membership fees: {{ amount }}
|
||||||
{% endblocktrans %}</li>
|
{% endblocktrans %}</li>
|
||||||
|
{% if not registration.first_year %}
|
||||||
{% if registration.deposit_type == 'note' %}
|
{% if registration.deposit_type == 'note' %}
|
||||||
<li>{% blocktrans trimmed with amount=club.deposit_amount|pretty_money %}
|
<li>{% blocktrans trimmed with amount=club.deposit_amount|pretty_money %}
|
||||||
Deposit (by Note transaction): {{ amount }}
|
Deposit (by Note transaction): {{ amount }}
|
||||||
@@ -158,6 +159,7 @@ SPDX-License-Identifier: GPL-3.0-or-later
|
|||||||
Deposit (by check): {{ amount }}
|
Deposit (by check): {{ amount }}
|
||||||
{% endblocktrans %}</li>
|
{% endblocktrans %}</li>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
{% endif %}
|
||||||
<li><strong>{% blocktrans trimmed with total=total_needed|pretty_money %}
|
<li><strong>{% blocktrans trimmed with total=total_needed|pretty_money %}
|
||||||
Total needed: {{ total }}
|
Total needed: {{ total }}
|
||||||
{% endblocktrans %}</strong></li>
|
{% endblocktrans %}</strong></li>
|
||||||
@@ -167,9 +169,9 @@ SPDX-License-Identifier: GPL-3.0-or-later
|
|||||||
{% endblocktrans %}</p>
|
{% endblocktrans %}</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{% if not registration.deposit_check and not registration.first_year and registration.caution_type == 'check' %}
|
{% if not registration.deposit_given and not registration.first_year and registration.caution_type == 'check' %}
|
||||||
<div class="alert alert-danger">
|
<div class="alert alert-danger">
|
||||||
{% trans "The user didn't give her/his caution check." %}
|
{% trans "The user didn't give her/his caution." %}
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
@@ -213,7 +215,6 @@ SPDX-License-Identifier: GPL-3.0-or-later
|
|||||||
$("input[name='bus']:checked").each(function (ignored) {
|
$("input[name='bus']:checked").each(function (ignored) {
|
||||||
buses.push($(this).parent().text().trim());
|
buses.push($(this).parent().text().trim());
|
||||||
});
|
});
|
||||||
console.log(buses);
|
|
||||||
$("input[name='team']").each(function () {
|
$("input[name='team']").each(function () {
|
||||||
let label = $(this).parent();
|
let label = $(this).parent();
|
||||||
$(this).parent().addClass('d-none');
|
$(this).parent().addClass('d-none');
|
||||||
|
|||||||
46
apps/wei/templates/wei/weimembership_update.html
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
{% extends "base.html" %}
|
||||||
|
{% comment %}
|
||||||
|
Copyright (C) 2018-2025 by BDE ENS Paris-Saclay
|
||||||
|
SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
{% endcomment %}
|
||||||
|
{% load i18n crispy_forms_tags %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
<div class="card bg-white mb-3">
|
||||||
|
<h3 class="card-header text-center">
|
||||||
|
{{ title }}
|
||||||
|
</h3>
|
||||||
|
<div class="card-body" id="form">
|
||||||
|
<form method="post">
|
||||||
|
{% csrf_token %}
|
||||||
|
{{ form | crispy }}
|
||||||
|
<button class="btn btn-primary" type="submit">{% trans "Submit"%}</button>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
{% block extrajavascript %}
|
||||||
|
<script>
|
||||||
|
$(document).ready(function () {
|
||||||
|
function refreshTeams() {
|
||||||
|
let buses = [];
|
||||||
|
$("input[name='bus']:checked").each(function (ignored) {
|
||||||
|
buses.push($(this).parent().text().trim());
|
||||||
|
});
|
||||||
|
$("input[name='team']").each(function () {
|
||||||
|
let label = $(this).parent();
|
||||||
|
$(this).parent().addClass('d-none');
|
||||||
|
buses.forEach(function (bus) {
|
||||||
|
if (label.text().includes(bus))
|
||||||
|
label.removeClass('d-none');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
$("input[name='bus']").change(refreshTeams);
|
||||||
|
|
||||||
|
refreshTeams();
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
{% endblock %}
|
||||||
@@ -11,7 +11,7 @@ SPDX-License-Identifier: GPL-3.0-or-later
|
|||||||
{{ title }}
|
{{ title }}
|
||||||
</h3>
|
</h3>
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
<form method="post">
|
<form id="registration-form" method="post">
|
||||||
{% csrf_token %}
|
{% csrf_token %}
|
||||||
{{ form|crispy }}
|
{{ form|crispy }}
|
||||||
{{ membership_form|crispy }}
|
{{ membership_form|crispy }}
|
||||||
@@ -22,6 +22,46 @@ SPDX-License-Identifier: GPL-3.0-or-later
|
|||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block extrajavascript %}
|
{% block extrajavascript %}
|
||||||
|
<!-- intl-tel-input CSS/JS -->
|
||||||
|
<script>
|
||||||
|
(() => {
|
||||||
|
const input = document.querySelector("input[name='emergency_contact_phone']");
|
||||||
|
const form = document.querySelector("#registration-form");
|
||||||
|
|
||||||
|
if (!input || !form || input.type === "hidden" || input.disabled || input.readOnly) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const iti = window.intlTelInput(input, {
|
||||||
|
initialCountry: "auto",
|
||||||
|
nationalMode: false,
|
||||||
|
autoPlaceholder: "off",
|
||||||
|
geoIpLookup: callback => {
|
||||||
|
fetch("https://ipapi.co/json")
|
||||||
|
.then(res => res.json())
|
||||||
|
.then(data => callback(data.country_code))
|
||||||
|
.catch(() => callback("fr"));
|
||||||
|
},
|
||||||
|
loadUtils: () => import("https://cdn.jsdelivr.net/npm/intl-tel-input@25.5.2/build/js/utils.js"),
|
||||||
|
});
|
||||||
|
|
||||||
|
form.addEventListener("submit", function(e){
|
||||||
|
if (!input.value.trim()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const number = iti.getNumber(intlTelInput.utils.numberFormat.E164);
|
||||||
|
if (number) {
|
||||||
|
input.value = number;
|
||||||
|
form.submit();
|
||||||
|
} else {
|
||||||
|
e.preventDefault();
|
||||||
|
input.focus();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
})();
|
||||||
|
</script>
|
||||||
|
|
||||||
{% if not object.membership %}
|
{% if not object.membership %}
|
||||||
<script>
|
<script>
|
||||||
$(document).ready(function () {
|
$(document).ready(function () {
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import random
|
|||||||
from django.contrib.auth.models import User
|
from django.contrib.auth.models import User
|
||||||
from django.test import TestCase
|
from django.test import TestCase
|
||||||
|
|
||||||
from ..forms.surveys.wei2025 import WEIBusInformation2025, WEISurvey2025, WORDS, WEISurveyInformation2025
|
from ..forms.surveys.wei2025 import WEIBusInformation2025, WEISurvey2025, WORDS, NB_WORDS, WEISurveyInformation2025
|
||||||
from ..models import Bus, WEIClub, WEIRegistration
|
from ..models import Bus, WEIClub, WEIRegistration
|
||||||
|
|
||||||
|
|
||||||
@@ -30,12 +30,12 @@ class TestWEIAlgorithm(TestCase):
|
|||||||
)
|
)
|
||||||
|
|
||||||
self.buses = []
|
self.buses = []
|
||||||
for i in range(10):
|
for i in range(8):
|
||||||
bus = Bus.objects.create(wei=self.wei, name=f"Bus {i}", size=10)
|
bus = Bus.objects.create(wei=self.wei, name=f"Bus {i}", size=10)
|
||||||
self.buses.append(bus)
|
self.buses.append(bus)
|
||||||
information = WEIBusInformation2025(bus)
|
information = WEIBusInformation2025(bus)
|
||||||
for word in WORDS:
|
for word in WORDS['list']:
|
||||||
information.scores[word] = random.randint(0, 101)
|
information.scores[word] = random.randint(0, 6)
|
||||||
information.save()
|
information.save()
|
||||||
bus.save()
|
bus.save()
|
||||||
|
|
||||||
@@ -53,9 +53,11 @@ class TestWEIAlgorithm(TestCase):
|
|||||||
birth_date='2000-01-01',
|
birth_date='2000-01-01',
|
||||||
)
|
)
|
||||||
information = WEISurveyInformation2025(registration)
|
information = WEISurveyInformation2025(registration)
|
||||||
for j in range(1, 21):
|
for j in range(1, 1 + NB_WORDS):
|
||||||
setattr(information, f'word{j}', random.choice(WORDS))
|
setattr(information, f'word{j}', random.choice(WORDS['list']))
|
||||||
information.step = 20
|
for q in WORDS['questions']:
|
||||||
|
setattr(information, q, random.choice(list(WORDS['questions'][q][1].keys())))
|
||||||
|
information.step = len(WORDS['questions']) + 2
|
||||||
information.save(registration)
|
information.save(registration)
|
||||||
registration.save()
|
registration.save()
|
||||||
|
|
||||||
@@ -74,7 +76,7 @@ class TestWEIAlgorithm(TestCase):
|
|||||||
Buses are full of first year people, ensure that they are happy
|
Buses are full of first year people, ensure that they are happy
|
||||||
"""
|
"""
|
||||||
# Add a lot of users
|
# Add a lot of users
|
||||||
for i in range(95):
|
for i in range(80):
|
||||||
user = User.objects.create(username=f"user{i}")
|
user = User.objects.create(username=f"user{i}")
|
||||||
registration = WEIRegistration.objects.create(
|
registration = WEIRegistration.objects.create(
|
||||||
user=user,
|
user=user,
|
||||||
@@ -83,11 +85,14 @@ class TestWEIAlgorithm(TestCase):
|
|||||||
birth_date='2000-01-01',
|
birth_date='2000-01-01',
|
||||||
)
|
)
|
||||||
information = WEISurveyInformation2025(registration)
|
information = WEISurveyInformation2025(registration)
|
||||||
for j in range(1, 21):
|
for j in range(1, 1 + NB_WORDS):
|
||||||
setattr(information, f'word{j}', random.choice(WORDS))
|
setattr(information, f'word{j}', random.choice(WORDS['list']))
|
||||||
information.step = 20
|
for q in WORDS['questions']:
|
||||||
|
setattr(information, q, random.choice(list(WORDS['questions'][q][1].keys())))
|
||||||
|
information.step = len(WORDS['questions']) + 2
|
||||||
information.save(registration)
|
information.save(registration)
|
||||||
registration.save()
|
registration.save()
|
||||||
|
survey = WEISurvey2025(registration)
|
||||||
|
|
||||||
# Run algorithm
|
# Run algorithm
|
||||||
WEISurvey2025.get_algorithm_class()().run_algorithm()
|
WEISurvey2025.get_algorithm_class()().run_algorithm()
|
||||||
@@ -102,10 +107,23 @@ class TestWEIAlgorithm(TestCase):
|
|||||||
survey = WEISurvey2025(r)
|
survey = WEISurvey2025(r)
|
||||||
chosen_bus = survey.information.get_selected_bus()
|
chosen_bus = survey.information.get_selected_bus()
|
||||||
buses = survey.ordered_buses()
|
buses = survey.ordered_buses()
|
||||||
score = min(v for bus, v in buses if bus == chosen_bus)
|
self.assertIn(chosen_bus, [x[0] for x in buses])
|
||||||
max_score = buses[0][1]
|
score_questions, score_words = next(scores for bus, scores in buses if bus == chosen_bus)
|
||||||
penalty += (max_score - score) ** 2
|
max_score_questions = max(buses[i][1][0] for i in range(len(buses)))
|
||||||
|
max_score_words = max(buses[i][1][1] for i in range(len(buses)))
|
||||||
self.assertLessEqual(max_score - score, 25) # Always less than 25 % of tolerance
|
penalty += (max_score_words - score_words) ** 2
|
||||||
|
penalty += (max_score_questions - score_questions) ** 2
|
||||||
self.assertLessEqual(penalty / 100, 25) # Tolerance of 5 %
|
self.assertLessEqual(penalty / 100, 25) # Tolerance of 5 %
|
||||||
|
|
||||||
|
# There shouldn't be users who would prefer to switch buses
|
||||||
|
for r1 in WEIRegistration.objects.filter(wei=self.wei).all():
|
||||||
|
survey1 = WEISurvey2025(r1)
|
||||||
|
bus1 = survey1.information.get_selected_bus()
|
||||||
|
for r2 in WEIRegistration.objects.filter(wei=self.wei, pk__gt=r1.pk):
|
||||||
|
survey2 = WEISurvey2025(r2)
|
||||||
|
bus2 = survey2.information.get_selected_bus()
|
||||||
|
|
||||||
|
prefer_switch_bus_words = survey1.score_words(bus2) > survey1.score_words(bus1) and survey2.score_words(bus1) > survey2.score_words(bus2)
|
||||||
|
prefer_switch_bus_questions = survey1.score_questions(bus2) > survey1.score_questions(bus1) and\
|
||||||
|
survey2.score_questions(bus1) > survey2.score_questions(bus2)
|
||||||
|
self.assertFalse(prefer_switch_bus_words and prefer_switch_bus_questions)
|
||||||
|
|||||||
@@ -101,7 +101,7 @@ class TestWEIRegistration(TestCase):
|
|||||||
user_id=self.user.id,
|
user_id=self.user.id,
|
||||||
wei_id=self.wei.id,
|
wei_id=self.wei.id,
|
||||||
soge_credit=True,
|
soge_credit=True,
|
||||||
deposit_check=True,
|
deposit_given=True,
|
||||||
birth_date=date(2000, 1, 1),
|
birth_date=date(2000, 1, 1),
|
||||||
gender="nonbinary",
|
gender="nonbinary",
|
||||||
clothing_cut="male",
|
clothing_cut="male",
|
||||||
@@ -642,7 +642,7 @@ class TestWEIRegistration(TestCase):
|
|||||||
last_name="admin",
|
last_name="admin",
|
||||||
first_name="admin",
|
first_name="admin",
|
||||||
bank="Société générale",
|
bank="Société générale",
|
||||||
deposit_check=True,
|
deposit_given=True,
|
||||||
))
|
))
|
||||||
self.assertEqual(response.status_code, 200)
|
self.assertEqual(response.status_code, 200)
|
||||||
self.assertFalse(response.context["form"].is_valid())
|
self.assertFalse(response.context["form"].is_valid())
|
||||||
@@ -657,7 +657,7 @@ class TestWEIRegistration(TestCase):
|
|||||||
last_name="admin",
|
last_name="admin",
|
||||||
first_name="admin",
|
first_name="admin",
|
||||||
bank="Société générale",
|
bank="Société générale",
|
||||||
deposit_check=True,
|
deposit_given=True,
|
||||||
))
|
))
|
||||||
self.assertRedirects(response, reverse("wei:wei_registrations", kwargs=dict(pk=self.registration.wei.pk)), 302, 200)
|
self.assertRedirects(response, reverse("wei:wei_registrations", kwargs=dict(pk=self.registration.wei.pk)), 302, 200)
|
||||||
|
|
||||||
@@ -680,7 +680,7 @@ class TestWEIRegistration(TestCase):
|
|||||||
self.assertTrue(soge_credit.exists())
|
self.assertTrue(soge_credit.exists())
|
||||||
soge_credit = soge_credit.get()
|
soge_credit = soge_credit.get()
|
||||||
self.assertTrue(membership.transaction in soge_credit.transactions.all())
|
self.assertTrue(membership.transaction in soge_credit.transactions.all())
|
||||||
self.assertFalse(membership.transaction.valid)
|
self.assertTrue(membership.transaction.valid)
|
||||||
|
|
||||||
# Check that if the WEI is started, we can't update a wei
|
# Check that if the WEI is started, we can't update a wei
|
||||||
self.wei.date_start = date(2000, 1, 1)
|
self.wei.date_start = date(2000, 1, 1)
|
||||||
@@ -813,7 +813,7 @@ class TestWeiAPI(TestAPI):
|
|||||||
user_id=self.user.id,
|
user_id=self.user.id,
|
||||||
wei_id=self.wei.id,
|
wei_id=self.wei.id,
|
||||||
soge_credit=True,
|
soge_credit=True,
|
||||||
deposit_check=True,
|
deposit_given=True,
|
||||||
birth_date=date(2000, 1, 1),
|
birth_date=date(2000, 1, 1),
|
||||||
gender="nonbinary",
|
gender="nonbinary",
|
||||||
clothing_cut="male",
|
clothing_cut="male",
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ from .views import CurrentWEIDetailView, WEI1AListView, WEIListView, WEICreateVi
|
|||||||
WEIRegistrationsView, WEIMembershipsView, MemberListRenderView, BusInformationUpdateView, \
|
WEIRegistrationsView, WEIMembershipsView, MemberListRenderView, BusInformationUpdateView, \
|
||||||
BusCreateView, BusManageView, BusUpdateView, BusTeamCreateView, BusTeamManageView, BusTeamUpdateView, \
|
BusCreateView, BusManageView, BusUpdateView, BusTeamCreateView, BusTeamManageView, BusTeamUpdateView, \
|
||||||
WEIAttributeBus1AView, WEIAttributeBus1ANextView, WEIRegister1AView, WEIRegister2AView, WEIUpdateRegistrationView, \
|
WEIAttributeBus1AView, WEIAttributeBus1ANextView, WEIRegister1AView, WEIRegister2AView, WEIUpdateRegistrationView, \
|
||||||
WEIDeleteRegistrationView, WEIValidateRegistrationView, WEISurveyView, WEISurveyEndView, WEIClosedView
|
WEIDeleteRegistrationView, WEIValidateRegistrationView, WEISurveyView, WEISurveyEndView, WEIClosedView, WEIUpdateMembershipView
|
||||||
|
|
||||||
app_name = 'wei'
|
app_name = 'wei'
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
@@ -43,4 +43,6 @@ urlpatterns = [
|
|||||||
path('bus-1A/<int:pk>/', WEIAttributeBus1AView.as_view(), name="wei_bus_1A"),
|
path('bus-1A/<int:pk>/', WEIAttributeBus1AView.as_view(), name="wei_bus_1A"),
|
||||||
path('bus-1A/next/<int:pk>/', WEIAttributeBus1ANextView.as_view(), name="wei_bus_1A_next"),
|
path('bus-1A/next/<int:pk>/', WEIAttributeBus1ANextView.as_view(), name="wei_bus_1A_next"),
|
||||||
path('update-bus-info/<int:pk>/', BusInformationUpdateView.as_view(), name="update_bus_info"),
|
path('update-bus-info/<int:pk>/', BusInformationUpdateView.as_view(), name="update_bus_info"),
|
||||||
|
|
||||||
|
path('edit_membership/<int:pk>/', WEIUpdateMembershipView.as_view(), name="wei_update_membership"),
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ from django.contrib.auth.mixins import LoginRequiredMixin
|
|||||||
from django.contrib.auth.models import User
|
from django.contrib.auth.models import User
|
||||||
from django.core.exceptions import PermissionDenied
|
from django.core.exceptions import PermissionDenied
|
||||||
from django.db import transaction
|
from django.db import transaction
|
||||||
from django.db.models import Q, Count
|
from django.db.models import Q, Count, Case, When, Value, IntegerField, F
|
||||||
from django.db.models.functions.text import Lower
|
from django.db.models.functions.text import Lower
|
||||||
from django import forms
|
from django import forms
|
||||||
from django.http import HttpResponse, Http404
|
from django.http import HttpResponse, Http404
|
||||||
@@ -35,7 +35,7 @@ from permission.views import ProtectQuerysetMixin, ProtectedCreateView
|
|||||||
|
|
||||||
from .forms.registration import WEIChooseBusForm
|
from .forms.registration import WEIChooseBusForm
|
||||||
from .models import WEIClub, WEIRegistration, WEIMembership, Bus, BusTeam, WEIRole
|
from .models import WEIClub, WEIRegistration, WEIMembership, Bus, BusTeam, WEIRole
|
||||||
from .forms import WEIForm, WEIRegistrationForm, WEIRegistration1AForm, WEIRegistration2AForm, BusForm, BusTeamForm, WEIMembership1AForm, \
|
from .forms import WEIForm, WEIRegistrationForm, BusForm, BusTeamForm, WEIMembership1AForm, \
|
||||||
WEIMembershipForm, CurrentSurvey
|
WEIMembershipForm, CurrentSurvey
|
||||||
from .tables import BusRepartitionTable, BusTable, BusTeamTable, WEITable, WEIRegistrationTable, \
|
from .tables import BusRepartitionTable, BusTable, BusTeamTable, WEITable, WEIRegistrationTable, \
|
||||||
WEIRegistration1ATable, WEIMembershipTable
|
WEIRegistration1ATable, WEIMembershipTable
|
||||||
@@ -133,6 +133,23 @@ class WEIDetailView(ProtectQuerysetMixin, LoginRequiredMixin, MultiTableMixin, D
|
|||||||
membership=None,
|
membership=None,
|
||||||
wei=club
|
wei=club
|
||||||
)
|
)
|
||||||
|
# Annotate the query to be able to sort registrations on validate status
|
||||||
|
pre_registrations = pre_registrations.annotate(
|
||||||
|
deposit=Case(
|
||||||
|
When(deposit_type='note', then=F('wei__deposit_amount')),
|
||||||
|
default=Value(0),
|
||||||
|
output_field=IntegerField()
|
||||||
|
)
|
||||||
|
).annotate(
|
||||||
|
total_fee=F('fee') + F('deposit')
|
||||||
|
).annotate(
|
||||||
|
validate_status=Case(
|
||||||
|
When(total_fee__gt=F('user__note__balance'), then=Value(2)),
|
||||||
|
When(first_year=True, then=Value(1)),
|
||||||
|
default=Value(0),
|
||||||
|
output_field=IntegerField(),
|
||||||
|
)
|
||||||
|
)
|
||||||
buses = Bus.objects.filter(PermissionBackend.filter_queryset(self.request, Bus, "view")) \
|
buses = Bus.objects.filter(PermissionBackend.filter_queryset(self.request, Bus, "view")) \
|
||||||
.filter(wei=self.object).annotate(count=Count("memberships")).order_by("name")
|
.filter(wei=self.object).annotate(count=Count("memberships")).order_by("name")
|
||||||
return [club_transactions, club_member, pre_registrations, buses, ]
|
return [club_transactions, club_member, pre_registrations, buses, ]
|
||||||
@@ -149,6 +166,7 @@ class WEIDetailView(ProtectQuerysetMixin, LoginRequiredMixin, MultiTableMixin, D
|
|||||||
my_registration = WEIRegistration.objects.filter(wei=club, user=self.request.user)
|
my_registration = WEIRegistration.objects.filter(wei=club, user=self.request.user)
|
||||||
if my_registration.exists():
|
if my_registration.exists():
|
||||||
my_registration = my_registration.get()
|
my_registration = my_registration.get()
|
||||||
|
context["survey_complete"] = CurrentSurvey(my_registration).is_complete()
|
||||||
else:
|
else:
|
||||||
my_registration = None
|
my_registration = None
|
||||||
context["my_registration"] = my_registration
|
context["my_registration"] = my_registration
|
||||||
@@ -196,6 +214,8 @@ class WEIDetailView(ProtectQuerysetMixin, LoginRequiredMixin, MultiTableMixin, D
|
|||||||
|
|
||||||
context["not_first_year"] = WEIMembership.objects.filter(user=self.request.user).exists()
|
context["not_first_year"] = WEIMembership.objects.filter(user=self.request.user).exists()
|
||||||
|
|
||||||
|
context["registration_validated"] = WEIMembership.objects.filter(registration=my_registration).exists() if my_registration else False
|
||||||
|
|
||||||
qs = WEIMembership.objects.filter(club=club, registration__first_year=True, bus__isnull=True)
|
qs = WEIMembership.objects.filter(club=club, registration__first_year=True, bus__isnull=True)
|
||||||
context["can_validate_1a"] = PermissionBackend.check_perm(
|
context["can_validate_1a"] = PermissionBackend.check_perm(
|
||||||
self.request, "wei.change_weimembership_bus", qs.first()) if qs.exists() else False
|
self.request, "wei.change_weimembership_bus", qs.first()) if qs.exists() else False
|
||||||
@@ -260,6 +280,23 @@ class WEIRegistrationsView(ProtectQuerysetMixin, LoginRequiredMixin, SingleTable
|
|||||||
|
|
||||||
def get_queryset(self, **kwargs):
|
def get_queryset(self, **kwargs):
|
||||||
qs = super().get_queryset(**kwargs).filter(wei=self.club, membership=None).distinct()
|
qs = super().get_queryset(**kwargs).filter(wei=self.club, membership=None).distinct()
|
||||||
|
# Annotate the query to be able to sort registrations on validate status
|
||||||
|
qs = qs.annotate(
|
||||||
|
deposit=Case(
|
||||||
|
When(deposit_type='note', then=F('wei__deposit_amount')),
|
||||||
|
default=Value(0),
|
||||||
|
output_field=IntegerField()
|
||||||
|
)
|
||||||
|
).annotate(
|
||||||
|
total_fee=F('fee') + F('deposit')
|
||||||
|
).annotate(
|
||||||
|
validate_status=Case(
|
||||||
|
When(total_fee__gt=F('user__note__balance'), then=Value(2)),
|
||||||
|
When(first_year=True, then=Value(1)),
|
||||||
|
default=Value(0),
|
||||||
|
output_field=IntegerField(),
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
pattern = self.request.GET.get("search", "")
|
pattern = self.request.GET.get("search", "")
|
||||||
|
|
||||||
@@ -510,7 +547,7 @@ class WEIRegister1AView(ProtectQuerysetMixin, ProtectedCreateView):
|
|||||||
Register a new user to the WEI
|
Register a new user to the WEI
|
||||||
"""
|
"""
|
||||||
model = WEIRegistration
|
model = WEIRegistration
|
||||||
form_class = WEIRegistration1AForm
|
form_class = WEIRegistrationForm
|
||||||
extra_context = {"title": _("Register first year student to the WEI")}
|
extra_context = {"title": _("Register first year student to the WEI")}
|
||||||
|
|
||||||
def get_sample_object(self):
|
def get_sample_object(self):
|
||||||
@@ -560,8 +597,8 @@ class WEIRegister1AView(ProtectQuerysetMixin, ProtectedCreateView):
|
|||||||
# Cacher les champs pendant l'inscription initiale
|
# Cacher les champs pendant l'inscription initiale
|
||||||
if "first_year" in form.fields:
|
if "first_year" in form.fields:
|
||||||
del form.fields["first_year"]
|
del form.fields["first_year"]
|
||||||
if "deposit_check" in form.fields:
|
if "deposit_given" in form.fields:
|
||||||
del form.fields["deposit_check"]
|
del form.fields["deposit_given"]
|
||||||
if "information_json" in form.fields:
|
if "information_json" in form.fields:
|
||||||
del form.fields["information_json"]
|
del form.fields["information_json"]
|
||||||
if "deposit_type" in form.fields:
|
if "deposit_type" in form.fields:
|
||||||
@@ -606,7 +643,7 @@ class WEIRegister2AView(ProtectQuerysetMixin, ProtectedCreateView):
|
|||||||
Register an old user to the WEI
|
Register an old user to the WEI
|
||||||
"""
|
"""
|
||||||
model = WEIRegistration
|
model = WEIRegistration
|
||||||
form_class = WEIRegistration2AForm
|
form_class = WEIRegistrationForm
|
||||||
extra_context = {"title": _("Register old student to the WEI")}
|
extra_context = {"title": _("Register old student to the WEI")}
|
||||||
|
|
||||||
def get_sample_object(self):
|
def get_sample_object(self):
|
||||||
@@ -670,8 +707,8 @@ class WEIRegister2AView(ProtectQuerysetMixin, ProtectedCreateView):
|
|||||||
# Cacher les champs pendant l'inscription initiale
|
# Cacher les champs pendant l'inscription initiale
|
||||||
if "first_year" in form.fields:
|
if "first_year" in form.fields:
|
||||||
del form.fields["first_year"]
|
del form.fields["first_year"]
|
||||||
if "deposit_check" in form.fields:
|
if "deposit_given" in form.fields:
|
||||||
del form.fields["deposit_check"]
|
del form.fields["deposit_given"]
|
||||||
if "information_json" in form.fields:
|
if "information_json" in form.fields:
|
||||||
del form.fields["information_json"]
|
del form.fields["information_json"]
|
||||||
|
|
||||||
@@ -739,14 +776,11 @@ class WEIUpdateRegistrationView(ProtectQuerysetMixin, LoginRequiredMixin, Update
|
|||||||
if today >= wei.date_start or today < wei.membership_start:
|
if today >= wei.date_start or today < wei.membership_start:
|
||||||
return redirect(reverse_lazy('wei:wei_closed', args=(wei.pk,)))
|
return redirect(reverse_lazy('wei:wei_closed', args=(wei.pk,)))
|
||||||
# Store the validate parameter in the view's state
|
# Store the validate parameter in the view's state
|
||||||
self.should_validate = request.GET.get('validate', False)
|
|
||||||
return super().dispatch(request, *args, **kwargs)
|
return super().dispatch(request, *args, **kwargs)
|
||||||
|
|
||||||
def get_context_data(self, **kwargs):
|
def get_context_data(self, **kwargs):
|
||||||
context = super().get_context_data(**kwargs)
|
context = super().get_context_data(**kwargs)
|
||||||
context["club"] = self.object.wei
|
context["club"] = self.object.wei
|
||||||
# Pass the validate parameter to the template
|
|
||||||
context["should_validate"] = self.should_validate
|
|
||||||
|
|
||||||
if self.object.is_validated:
|
if self.object.is_validated:
|
||||||
membership_form = self.get_membership_form(instance=self.object.membership,
|
membership_form = self.get_membership_form(instance=self.object.membership,
|
||||||
@@ -767,11 +801,6 @@ class WEIUpdateRegistrationView(ProtectQuerysetMixin, LoginRequiredMixin, Update
|
|||||||
choose_bus_form.fields["team"].queryset = BusTeam.objects.filter(bus__wei=context["club"])
|
choose_bus_form.fields["team"].queryset = BusTeam.objects.filter(bus__wei=context["club"])
|
||||||
context["membership_form"] = choose_bus_form
|
context["membership_form"] = choose_bus_form
|
||||||
|
|
||||||
if not self.object.soge_credit and self.object.user.profile.soge:
|
|
||||||
form = context["form"]
|
|
||||||
form.fields["soge_credit"].disabled = True
|
|
||||||
form.fields["soge_credit"].help_text = _("You already opened an account in the Société générale.")
|
|
||||||
|
|
||||||
return context
|
return context
|
||||||
|
|
||||||
def get_form(self, form_class=None):
|
def get_form(self, form_class=None):
|
||||||
@@ -780,15 +809,23 @@ class WEIUpdateRegistrationView(ProtectQuerysetMixin, LoginRequiredMixin, Update
|
|||||||
# The auto-json-format may cause issues with the default field remove
|
# The auto-json-format may cause issues with the default field remove
|
||||||
if "information_json" in form.fields:
|
if "information_json" in form.fields:
|
||||||
del form.fields["information_json"]
|
del form.fields["information_json"]
|
||||||
# Masquer le champ deposit_check pour tout le monde dans le formulaire de modification
|
# Masquer le champ deposit_given pour tout le monde dans le formulaire de modification
|
||||||
if "deposit_check" in form.fields:
|
if "deposit_given" in form.fields:
|
||||||
del form.fields["deposit_check"]
|
form.fields["deposit_given"].help_text = _("Tick if the deposit check has been given")
|
||||||
|
if self.object.first_year or self.object.deposit_type == 'note':
|
||||||
|
del form.fields["deposit_given"]
|
||||||
|
|
||||||
# S'assurer que le champ deposit_type est obligatoire pour les 2A+
|
# S'assurer que le champ deposit_type est obligatoire pour les 2A+
|
||||||
if not self.object.first_year and "deposit_type" in form.fields:
|
if "deposit_type" in form.fields:
|
||||||
|
if self.object.first_year:
|
||||||
|
del form.fields["deposit_type"]
|
||||||
|
else:
|
||||||
form.fields["deposit_type"].required = True
|
form.fields["deposit_type"].required = True
|
||||||
form.fields["deposit_type"].help_text = _("Choose how you want to pay the deposit")
|
form.fields["deposit_type"].help_text = _("Choose how you want to pay the deposit")
|
||||||
form.fields["deposit_type"].widget = forms.RadioSelect(choices=form.fields["deposit_type"].choices)
|
|
||||||
|
if self.object.user.profile.soge:
|
||||||
|
form.fields["soge_credit"].disabled = True
|
||||||
|
form.fields["soge_credit"].help_text = _("You already opened an account in the Société générale.")
|
||||||
|
|
||||||
return form
|
return form
|
||||||
|
|
||||||
@@ -849,7 +886,6 @@ class WEIUpdateRegistrationView(ProtectQuerysetMixin, LoginRequiredMixin, Update
|
|||||||
information["preferred_roles_name"] = [role.name for role in choose_bus_form.cleaned_data["roles"]]
|
information["preferred_roles_name"] = [role.name for role in choose_bus_form.cleaned_data["roles"]]
|
||||||
form.instance.information = information
|
form.instance.information = information
|
||||||
|
|
||||||
# Sauvegarder le type de caution pour les 2A+
|
|
||||||
if "deposit_type" in form.cleaned_data:
|
if "deposit_type" in form.cleaned_data:
|
||||||
form.instance.deposit_type = form.cleaned_data["deposit_type"]
|
form.instance.deposit_type = form.cleaned_data["deposit_type"]
|
||||||
form.instance.save()
|
form.instance.save()
|
||||||
@@ -862,9 +898,6 @@ class WEIUpdateRegistrationView(ProtectQuerysetMixin, LoginRequiredMixin, Update
|
|||||||
survey = CurrentSurvey(self.object)
|
survey = CurrentSurvey(self.object)
|
||||||
if not survey.is_complete():
|
if not survey.is_complete():
|
||||||
return reverse_lazy("wei:wei_survey", kwargs={"pk": self.object.pk})
|
return reverse_lazy("wei:wei_survey", kwargs={"pk": self.object.pk})
|
||||||
# On redirige vers la validation uniquement si c'est explicitement demandé (et stocké dans la vue)
|
|
||||||
if self.should_validate and self.request.user.has_perm("wei.add_weimembership"):
|
|
||||||
return reverse_lazy("wei:validate_registration", kwargs={"pk": self.object.pk})
|
|
||||||
return reverse_lazy("wei:wei_detail", kwargs={"pk": self.object.wei.pk})
|
return reverse_lazy("wei:wei_detail", kwargs={"pk": self.object.wei.pk})
|
||||||
|
|
||||||
|
|
||||||
@@ -963,9 +996,9 @@ class WEIValidateRegistrationView(ProtectQuerysetMixin, ProtectedCreateView):
|
|||||||
|
|
||||||
form = context["form"]
|
form = context["form"]
|
||||||
if registration.soge_credit:
|
if registration.soge_credit:
|
||||||
form.fields["credit_amount"].initial = registration.fee
|
form.fields["credit_amount"].initial = fee
|
||||||
else:
|
else:
|
||||||
form.fields["credit_amount"].initial = max(0, registration.fee - registration.user.note.balance)
|
form.fields["credit_amount"].initial = max(0, fee - registration.user.note.balance)
|
||||||
|
|
||||||
return context
|
return context
|
||||||
|
|
||||||
@@ -988,17 +1021,18 @@ class WEIValidateRegistrationView(ProtectQuerysetMixin, ProtectedCreateView):
|
|||||||
form.fields["last_name"].initial = registration.user.last_name
|
form.fields["last_name"].initial = registration.user.last_name
|
||||||
form.fields["first_name"].initial = registration.user.first_name
|
form.fields["first_name"].initial = registration.user.first_name
|
||||||
|
|
||||||
# Ajouter le champ deposit_check uniquement pour les non-première année et le rendre obligatoire
|
# Ajouter le champ deposit_given uniquement pour les non-première année et le rendre obligatoire
|
||||||
if not registration.first_year:
|
if not registration.first_year:
|
||||||
if registration.deposit_type == 'check':
|
if registration.deposit_type == 'check':
|
||||||
form.fields["deposit_check"] = forms.BooleanField(
|
form.fields["deposit_given"] = forms.BooleanField(
|
||||||
required=True,
|
required=True,
|
||||||
initial=registration.deposit_check,
|
disabled=True,
|
||||||
|
initial=registration.deposit_given,
|
||||||
label=_("Deposit check given"),
|
label=_("Deposit check given"),
|
||||||
help_text=_("Please make sure the check is given before validating the registration")
|
help_text=_("Only treasurers can validate this field")
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
form.fields["deposit_check"] = forms.BooleanField(
|
form.fields["deposit_given"] = forms.BooleanField(
|
||||||
required=True,
|
required=True,
|
||||||
initial=False,
|
initial=False,
|
||||||
label=_("Create deposit transaction"),
|
label=_("Create deposit transaction"),
|
||||||
@@ -1039,8 +1073,8 @@ class WEIValidateRegistrationView(ProtectQuerysetMixin, ProtectedCreateView):
|
|||||||
club = registration.wei
|
club = registration.wei
|
||||||
user = registration.user
|
user = registration.user
|
||||||
|
|
||||||
if "deposit_check" in form.data:
|
if "deposit_given" in form.data:
|
||||||
registration.deposit_check = form.data["deposit_check"] == "on"
|
registration.deposit_given = form.data["deposit_given"] == "on"
|
||||||
registration.save()
|
registration.save()
|
||||||
membership = form.instance
|
membership = form.instance
|
||||||
membership.user = user
|
membership.user = user
|
||||||
@@ -1052,7 +1086,7 @@ class WEIValidateRegistrationView(ProtectQuerysetMixin, ProtectedCreateView):
|
|||||||
|
|
||||||
fee = club.membership_fee_paid if user.profile.paid else club.membership_fee_unpaid
|
fee = club.membership_fee_paid if user.profile.paid else club.membership_fee_unpaid
|
||||||
if registration.soge_credit:
|
if registration.soge_credit:
|
||||||
fee = 2000
|
fee = registration.wei.fee_soge_credit
|
||||||
|
|
||||||
kfet = club.parent_club
|
kfet = club.parent_club
|
||||||
bde = kfet.parent_club
|
bde = kfet.parent_club
|
||||||
@@ -1096,16 +1130,16 @@ class WEIValidateRegistrationView(ProtectQuerysetMixin, ProtectedCreateView):
|
|||||||
'credit': credit_amount,
|
'credit': credit_amount,
|
||||||
'needed': total_needed}
|
'needed': total_needed}
|
||||||
)
|
)
|
||||||
return super().form_invalid(form)
|
return self.form_invalid(form)
|
||||||
|
|
||||||
if credit_amount:
|
if credit_amount:
|
||||||
if not last_name:
|
if not last_name:
|
||||||
form.add_error('last_name', _("This field is required."))
|
form.add_error('last_name', _("This field is required."))
|
||||||
return super().form_invalid(form)
|
return self.form_invalid(form)
|
||||||
|
|
||||||
if not first_name:
|
if not first_name:
|
||||||
form.add_error('first_name', _("This field is required."))
|
form.add_error('first_name', _("This field is required."))
|
||||||
return super().form_invalid(form)
|
return self.form_invalid(form)
|
||||||
|
|
||||||
# Credit note before adding the membership
|
# Credit note before adding the membership
|
||||||
SpecialTransaction.objects.create(
|
SpecialTransaction.objects.create(
|
||||||
@@ -1149,11 +1183,60 @@ class WEIValidateRegistrationView(ProtectQuerysetMixin, ProtectedCreateView):
|
|||||||
|
|
||||||
return super().form_valid(form)
|
return super().form_valid(form)
|
||||||
|
|
||||||
|
def form_invalid(self, form):
|
||||||
|
registration = getattr(form.instance, "registration", None)
|
||||||
|
if registration is not None:
|
||||||
|
registration.deposit_given = False
|
||||||
|
registration.save()
|
||||||
|
return super().form_invalid(form)
|
||||||
|
|
||||||
def get_success_url(self):
|
def get_success_url(self):
|
||||||
self.object.refresh_from_db()
|
self.object.refresh_from_db()
|
||||||
return reverse_lazy("wei:wei_registrations", kwargs={"pk": self.object.club.pk})
|
return reverse_lazy("wei:wei_registrations", kwargs={"pk": self.object.club.pk})
|
||||||
|
|
||||||
|
|
||||||
|
class WEIUpdateMembershipView(ProtectQuerysetMixin, LoginRequiredMixin, UpdateView):
|
||||||
|
"""
|
||||||
|
Update a membership for the WEI
|
||||||
|
"""
|
||||||
|
model = WEIMembership
|
||||||
|
context_object_name = "membership"
|
||||||
|
template_name = "wei/weimembership_update.html"
|
||||||
|
extra_context = {"title": _("Update WEI Membership")}
|
||||||
|
|
||||||
|
def dispatch(self, request, *args, **kwargs):
|
||||||
|
wei = self.get_object().registration.wei
|
||||||
|
today = date.today()
|
||||||
|
# We can't update a registration once the WEI is started and before the membership start date
|
||||||
|
if today >= wei.date_start or today < wei.membership_start:
|
||||||
|
return redirect(reverse_lazy('wei:wei_closed', args=(wei.pk,)))
|
||||||
|
# Store the validate parameter in the view's state
|
||||||
|
return super().dispatch(request, *args, **kwargs)
|
||||||
|
|
||||||
|
def get_form(self):
|
||||||
|
form = WEIMembershipForm(
|
||||||
|
self.request.POST or None,
|
||||||
|
self.request.FILES or None,
|
||||||
|
instance=self.object,
|
||||||
|
wei=self.object.registration.wei,
|
||||||
|
)
|
||||||
|
|
||||||
|
form.fields["roles"].initial = self.object.roles.all()
|
||||||
|
form.fields["bus"].initial = self.object.bus
|
||||||
|
form.fields["team"].initial = self.object.team
|
||||||
|
|
||||||
|
del form.fields["credit_type"]
|
||||||
|
del form.fields["credit_amount"]
|
||||||
|
del form.fields["first_name"]
|
||||||
|
del form.fields["last_name"]
|
||||||
|
del form.fields["bank"]
|
||||||
|
|
||||||
|
return form
|
||||||
|
|
||||||
|
def get_success_url(self):
|
||||||
|
return reverse_lazy("wei:wei_detail", kwargs={"pk": self.object.registration.wei.pk})
|
||||||
|
|
||||||
|
|
||||||
class WEISurveyView(LoginRequiredMixin, BaseFormView, DetailView):
|
class WEISurveyView(LoginRequiredMixin, BaseFormView, DetailView):
|
||||||
"""
|
"""
|
||||||
Display the survey for the WEI for first year members.
|
Display the survey for the WEI for first year members.
|
||||||
@@ -1176,6 +1259,10 @@ class WEISurveyView(LoginRequiredMixin, BaseFormView, DetailView):
|
|||||||
|
|
||||||
if not self.survey:
|
if not self.survey:
|
||||||
self.survey = CurrentSurvey(obj)
|
self.survey = CurrentSurvey(obj)
|
||||||
|
|
||||||
|
if request.GET.get("reset") == "true":
|
||||||
|
info = self.survey.information
|
||||||
|
info.reset(obj)
|
||||||
# If the survey is complete, then display the end page.
|
# If the survey is complete, then display the end page.
|
||||||
if self.survey.is_complete():
|
if self.survey.is_complete():
|
||||||
return redirect(reverse_lazy('wei:wei_survey_end', args=(self.survey.registration.pk,)))
|
return redirect(reverse_lazy('wei:wei_survey_end', args=(self.survey.registration.pk,)))
|
||||||
|
|||||||
@@ -4366,6 +4366,14 @@ msgstr ""
|
|||||||
msgid "Forgotten your password or username?"
|
msgid "Forgotten your password or username?"
|
||||||
msgstr "Passwort oder Username vergessen?"
|
msgstr "Passwort oder Username vergessen?"
|
||||||
|
|
||||||
|
#: note_kfet/templates/registration/login.html:44
|
||||||
|
msgid "Download on the AppStore"
|
||||||
|
msgstr "Im AppStore herunterladen"
|
||||||
|
|
||||||
|
#: note_kfet/templates/registration/login.html:48
|
||||||
|
msgid "Get it on Google Play"
|
||||||
|
msgstr "Bei Google Play herunterladen"
|
||||||
|
|
||||||
#: note_kfet/templates/registration/password_change_done.html:13
|
#: note_kfet/templates/registration/password_change_done.html:13
|
||||||
msgid "Your password was changed."
|
msgid "Your password was changed."
|
||||||
msgstr "Ihr Passwort wurde geändert."
|
msgstr "Ihr Passwort wurde geändert."
|
||||||
|
|||||||
@@ -4281,6 +4281,14 @@ msgstr ""
|
|||||||
msgid "Forgotten your password or username?"
|
msgid "Forgotten your password or username?"
|
||||||
msgstr "¿ Contraseña o nombre de usuario olvidado ?"
|
msgstr "¿ Contraseña o nombre de usuario olvidado ?"
|
||||||
|
|
||||||
|
#: note_kfet/templates/registration/login.html:44
|
||||||
|
msgid "Download on the AppStore"
|
||||||
|
msgstr "Descargar en la AppStore"
|
||||||
|
|
||||||
|
#: note_kfet/templates/registration/login.html:48
|
||||||
|
msgid "Get it on Google Play"
|
||||||
|
msgstr "Descargar en Google Play"
|
||||||
|
|
||||||
#: note_kfet/templates/registration/password_change_done.html:13
|
#: note_kfet/templates/registration/password_change_done.html:13
|
||||||
msgid "Your password was changed."
|
msgid "Your password was changed."
|
||||||
msgstr "Su contraseña fue cambiada con éxito."
|
msgstr "Su contraseña fue cambiada con éxito."
|
||||||
|
|||||||
@@ -151,3 +151,33 @@ msgid "An error occured while (in)validating this transaction:"
|
|||||||
msgstr ""
|
msgstr ""
|
||||||
"Une erreur est survenue lors de la validation/dévalidation de cette "
|
"Une erreur est survenue lors de la validation/dévalidation de cette "
|
||||||
"transaction :"
|
"transaction :"
|
||||||
|
|
||||||
|
msgid "Recent achievements history"
|
||||||
|
msgstr "Historique des derniers succès"
|
||||||
|
|
||||||
|
msgid "Family"
|
||||||
|
msgstr "Famille"
|
||||||
|
|
||||||
|
msgid "obtained at"
|
||||||
|
msgstr "Réalisé le"
|
||||||
|
|
||||||
|
msgid "Return to the family list"
|
||||||
|
msgstr "Retour à la liste des familles"
|
||||||
|
|
||||||
|
msgid "rank"
|
||||||
|
msgstr "rang"
|
||||||
|
|
||||||
|
msgid "Challenge"
|
||||||
|
msgstr "Défis"
|
||||||
|
|
||||||
|
msgid "Invalid achievements history"
|
||||||
|
msgstr "Historique des défis invalides"
|
||||||
|
|
||||||
|
msgid "Valid achievements history"
|
||||||
|
msgstr "Historique des défis valides"
|
||||||
|
|
||||||
|
msgid "Return to management page"
|
||||||
|
msgstr "Retour à la page de gestion"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -72,6 +72,7 @@ INSTALLED_APPS = [
|
|||||||
# Note apps
|
# Note apps
|
||||||
'api',
|
'api',
|
||||||
'activity',
|
'activity',
|
||||||
|
'family',
|
||||||
'food',
|
'food',
|
||||||
'logs',
|
'logs',
|
||||||
'member',
|
'member',
|
||||||
@@ -305,8 +306,8 @@ PIC_WIDTH = 200
|
|||||||
PIC_RATIO = 1
|
PIC_RATIO = 1
|
||||||
|
|
||||||
# Custom phone number format
|
# Custom phone number format
|
||||||
PHONENUMBER_DB_FORMAT = 'NATIONAL'
|
PHONENUMBER_DB_FORMAT = 'E164'
|
||||||
PHONENUMBER_DEFAULT_REGION = 'FR'
|
PHONENUMBER_DEFAULT_REGION = None
|
||||||
|
|
||||||
# We add custom information to CAS, in order to give a normalized name to other services
|
# We add custom information to CAS, in order to give a normalized name to other services
|
||||||
CAS_AUTH_CLASS = 'member.auth.CustomAuthUser'
|
CAS_AUTH_CLASS = 'member.auth.CustomAuthUser'
|
||||||
|
|||||||
50
note_kfet/static/img/appstore_badge_fr.svg
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
<svg id="livetype" xmlns="http://www.w3.org/2000/svg" width="126.50751" height="40" viewBox="0 0 126.50751 40">
|
||||||
|
<title>Download_on_the_App_Store_Badge_FR_RGB_blk_100517</title>
|
||||||
|
<g>
|
||||||
|
<g>
|
||||||
|
<path d="M116.97821,0H9.53468c-.3667,0-.729,0-1.09473.002-.30615.002-.60986.00781-.91895.0127A13.21476,13.21476,0,0,0,5.5171.19141a6.66509,6.66509,0,0,0-1.90088.627A6.43779,6.43779,0,0,0,1.99757,1.99707,6.25844,6.25844,0,0,0,.81935,3.61816a6.60119,6.60119,0,0,0-.625,1.90332,12.993,12.993,0,0,0-.1792,2.002C.00587,7.83008.00489,8.1377,0,8.44434V31.5586c.00489.3105.00587.6113.01515.9219a12.99232,12.99232,0,0,0,.1792,2.0019,6.58756,6.58756,0,0,0,.625,1.9043A6.20778,6.20778,0,0,0,1.99757,38.001a6.27445,6.27445,0,0,0,1.61865,1.1787,6.70082,6.70082,0,0,0,1.90088.6308,13.45514,13.45514,0,0,0,2.0039.1768c.30909.0068.6128.0107.91895.0107C8.80567,40,9.168,40,9.53468,40H116.97821c.3594,0,.7246,0,1.084-.002.3047,0,.6172-.0039.9219-.0107a13.279,13.279,0,0,0,2-.1768,6.80432,6.80432,0,0,0,1.9082-.6308,6.27742,6.27742,0,0,0,1.6172-1.1787,6.39482,6.39482,0,0,0,1.1816-1.6143,6.60413,6.60413,0,0,0,.6191-1.9043,13.50641,13.50641,0,0,0,.1856-2.0019c.0039-.3106.0039-.6114.0039-.9219.0078-.3633.0078-.7246.0078-1.0938V9.53613c0-.36621,0-.72949-.0078-1.09179,0-.30664,0-.61426-.0039-.9209a13.50709,13.50709,0,0,0-.1856-2.002,6.6177,6.6177,0,0,0-.6191-1.90332,6.46619,6.46619,0,0,0-2.7988-2.7998,6.76753,6.76753,0,0,0-1.9082-.627,13.04394,13.04394,0,0,0-2-.17676c-.3047-.00488-.6172-.01074-.9219-.01269-.3594-.002-.7246-.002-1.084-.002Z" style="fill: #a6a6a6"/>
|
||||||
|
<path d="M8.44482,39.125c-.30467,0-.602-.0039-.90428-.0107a12.68714,12.68714,0,0,1-1.86914-.1631,5.88381,5.88381,0,0,1-1.65674-.5479,5.40573,5.40573,0,0,1-1.397-1.0166,5.32082,5.32082,0,0,1-1.02051-1.3965,5.72186,5.72186,0,0,1-.543-1.6572,12.41351,12.41351,0,0,1-.1665-1.875c-.00634-.2109-.01464-.9131-.01464-.9131V8.44434S.88185,7.75293.8877,7.5498a12.37138,12.37138,0,0,1,.16552-1.87207,5.75577,5.75577,0,0,1,.54347-1.6621A5.37365,5.37365,0,0,1,2.61182,2.61768,5.56562,5.56562,0,0,1,4.01417,1.59521a5.82309,5.82309,0,0,1,1.65332-.54394A12.58579,12.58579,0,0,1,7.543.88721L8.44532.875h109.612l.9131.0127a12.38493,12.38493,0,0,1,1.8584.16259,5.93833,5.93833,0,0,1,1.6709.54785,5.59375,5.59375,0,0,1,2.415,2.41993,5.76267,5.76267,0,0,1,.5352,1.64892,12.995,12.995,0,0,1,.1738,1.88721c.0029.2832.0029.5874.0029.89014.0079.375.0079.73193.0079,1.09179V30.4648c0,.3633,0,.7178-.0079,1.0752,0,.3252,0,.6231-.0039.9297a12.73126,12.73126,0,0,1-.1709,1.8535,5.739,5.739,0,0,1-.54,1.67,5.48029,5.48029,0,0,1-1.0156,1.3857,5.4129,5.4129,0,0,1-1.3994,1.0225,5.86168,5.86168,0,0,1-1.668.5498,12.54218,12.54218,0,0,1-1.8692.1631c-.2929.0068-.5996.0107-.8974.0107l-1.084.002Z"/>
|
||||||
|
</g>
|
||||||
|
<g>
|
||||||
|
<g id="_Group_" data-name="<Group>">
|
||||||
|
<g id="_Group_2" data-name="<Group>">
|
||||||
|
<g id="_Group_3" data-name="<Group>">
|
||||||
|
<path id="_Path_" data-name="<Path>" d="M24.7718,20.30068a4.94881,4.94881,0,0,1,2.35656-4.15206,5.06566,5.06566,0,0,0-3.99116-2.15768c-1.67924-.17626-3.30719,1.00483-4.1629,1.00483-.87227,0-2.18977-.98733-3.6085-.95814a5.31529,5.31529,0,0,0-4.47292,2.72787c-1.934,3.34842-.49141,8.26947,1.3612,10.97608.9269,1.32535,2.01018,2.8058,3.42763,2.7533,1.38706-.05753,1.9051-.88448,3.5794-.88448,1.65876,0,2.14479.88448,3.591.8511,1.48838-.02416,2.42613-1.33124,3.32051-2.66914A10.962,10.962,0,0,0,27.691,24.69985,4.78205,4.78205,0,0,1,24.7718,20.30068Z" style="fill: #fff"/>
|
||||||
|
<path id="_Path_2" data-name="<Path>" d="M22.04017,12.21089a4.87248,4.87248,0,0,0,1.11452-3.49062,4.95746,4.95746,0,0,0-3.20758,1.65961,4.63634,4.63634,0,0,0-1.14371,3.36139A4.09905,4.09905,0,0,0,22.04017,12.21089Z" style="fill: #fff"/>
|
||||||
|
</g>
|
||||||
|
</g>
|
||||||
|
</g>
|
||||||
|
<g id="_Group_4" data-name="<Group>">
|
||||||
|
<g>
|
||||||
|
<path d="M35.65528,14.70166V9.57813h-1.877V8.73486h4.67676v.84326H36.582v5.12354Z" style="fill: #fff"/>
|
||||||
|
<path d="M42.76466,13.48584a1.828,1.828,0,0,1-1.95117,1.30273,2.04531,2.04531,0,0,1-2.08008-2.32422,2.07685,2.07685,0,0,1,2.07617-2.35254c1.25293,0,2.00879.856,2.00879,2.27v.31006H39.63868v.0498a1.1902,1.1902,0,0,0,1.19922,1.29,1.07934,1.07934,0,0,0,1.07129-.5459Zm-3.126-1.45117H41.9131a1.08647,1.08647,0,0,0-1.1084-1.1665A1.15162,1.15162,0,0,0,39.63868,12.03467ZM40.2754,9.4458l1.03809-1.42236h1.042L41.19337,9.4458Z" style="fill: #fff"/>
|
||||||
|
<path d="M44.05274,8.44092h.88867v6.26074h-.88867Z" style="fill: #fff"/>
|
||||||
|
<path d="M50.208,13.48584a1.828,1.828,0,0,1-1.95117,1.30273,2.04531,2.04531,0,0,1-2.08008-2.32422,2.07685,2.07685,0,0,1,2.07617-2.35254c1.25293,0,2.00879.856,2.00879,2.27v.31006H47.082v.0498a1.1902,1.1902,0,0,0,1.19922,1.29,1.07934,1.07934,0,0,0,1.07129-.5459Zm-3.126-1.45117h2.27441a1.08647,1.08647,0,0,0-1.1084-1.1665A1.15162,1.15162,0,0,0,47.082,12.03467Zm.63672-2.58887,1.03809-1.42236h1.042L48.63673,9.4458Z" style="fill: #fff"/>
|
||||||
|
<path d="M54.40333,11.67041a1.00546,1.00546,0,0,0-1.06348-.76465c-.74414,0-1.19922.57031-1.19922,1.52979,0,.97607.459,1.55908,1.19922,1.55908a.97873.97873,0,0,0,1.06348-.74023h.86426a1.762,1.762,0,0,1-1.92285,1.53418,2.06791,2.06791,0,0,1-2.11328-2.353,2.05305,2.05305,0,0,1,2.1084-2.32373,1.77731,1.77731,0,0,1,1.92773,1.55859Z" style="fill: #fff"/>
|
||||||
|
<path d="M56.44728,8.44092h.88086v2.48145h.07031a1.3856,1.3856,0,0,1,1.373-.80664,1.48339,1.48339,0,0,1,1.55078,1.67871v2.90723h-.88965v-2.688c0-.71924-.335-1.0835-.96289-1.0835a1.05194,1.05194,0,0,0-1.13379,1.1416v2.62988h-.88867Z" style="fill: #fff"/>
|
||||||
|
<path d="M61.43946,13.42822c0-.81055.60352-1.27783,1.6748-1.34424l1.21973-.07031V11.625c0-.47559-.31445-.74414-.92188-.74414-.49609,0-.83984.18213-.93848.50049h-.86035c.09082-.77344.81836-1.26953,1.83984-1.26953,1.12891,0,1.76514.562,1.76514,1.51318v3.07666h-.855v-.63281H64.293a1.515,1.515,0,0,1-1.35254.707A1.36026,1.36026,0,0,1,61.43946,13.42822Zm2.89453-.38477V12.667l-1.09961.07031c-.62012.0415-.90137.25244-.90137.64941,0,.40527.35156.64111.835.64111A1.0615,1.0615,0,0,0,64.334,13.04346Z" style="fill: #fff"/>
|
||||||
|
<path d="M66.60987,10.19873h.85547v.69043h.06641a1.22092,1.22092,0,0,1,1.21582-.76514,1.86836,1.86836,0,0,1,.39648.03711v.877a2.43442,2.43442,0,0,0-.49609-.05371A1.05507,1.05507,0,0,0,67.49855,12.043v2.65869h-.88867Z" style="fill: #fff"/>
|
||||||
|
<path d="M69.96144,15.15234h.90918c.0752.32666.45117.5376,1.05078.5376.74023,0,1.17871-.35156,1.17871-.94678v-.86426H73.0337a1.51433,1.51433,0,0,1-1.38965.75635c-1.14941,0-1.86035-.88867-1.86035-2.23682,0-1.373.71875-2.27441,1.86914-2.27441a1.56045,1.56045,0,0,1,1.41406.79395h.07031v-.71924h.85156v4.54c0,1.02979-.80664,1.68311-2.08008,1.68311C70.7837,16.42188,70.05616,15.91748,69.96144,15.15234Zm3.15527-2.7583c0-.897-.46387-1.47168-1.2207-1.47168-.76465,0-1.19434.57471-1.19434,1.47168,0,.89746.42969,1.47217,1.19434,1.47217C72.65773,13.86621,73.11671,13.2959,73.11671,12.394Z" style="fill: #fff"/>
|
||||||
|
<path d="M79.21241,13.48584a1.828,1.828,0,0,1-1.95117,1.30273,2.04531,2.04531,0,0,1-2.08008-2.32422,2.07685,2.07685,0,0,1,2.07617-2.35254c1.25293,0,2.00879.856,2.00879,2.27v.31006H76.08644v.0498a1.1902,1.1902,0,0,0,1.19922,1.29,1.07934,1.07934,0,0,0,1.07129-.5459Zm-3.126-1.45117h2.27441a1.08647,1.08647,0,0,0-1.1084-1.1665A1.15162,1.15162,0,0,0,76.08644,12.03467Z" style="fill: #fff"/>
|
||||||
|
<path d="M80.45948,10.19873H81.315v.69043h.06641a1.22092,1.22092,0,0,1,1.21582-.76514,1.86836,1.86836,0,0,1,.39648.03711v.877a2.43442,2.43442,0,0,0-.49609-.05371A1.05507,1.05507,0,0,0,81.34815,12.043v2.65869h-.88867Z" style="fill: #fff"/>
|
||||||
|
<path d="M86.19581,12.44824c0-1.42285.73145-2.32422,1.86914-2.32422a1.484,1.484,0,0,1,1.38086.79h.06641V8.44092h.88867v6.26074h-.85156v-.71143H89.479a1.56284,1.56284,0,0,1-1.41406.78564C86.91944,14.77588,86.19581,13.87451,86.19581,12.44824Zm.918,0c0,.95508.4502,1.52979,1.20313,1.52979.749,0,1.21191-.583,1.21191-1.52588,0-.93848-.46777-1.52979-1.21191-1.52979C87.56886,10.92236,87.11378,11.501,87.11378,12.44824Z" style="fill: #fff"/>
|
||||||
|
<path d="M91.60206,13.42822c0-.81055.60352-1.27783,1.6748-1.34424l1.21973-.07031V11.625c0-.47559-.31445-.74414-.92187-.74414-.49609,0-.83984.18213-.93848.50049h-.86035c.09082-.77344.81836-1.26953,1.83984-1.26953,1.12891,0,1.76563.562,1.76563,1.51318v3.07666h-.85547v-.63281h-.07031a1.515,1.515,0,0,1-1.35254.707A1.36026,1.36026,0,0,1,91.60206,13.42822Zm2.89453-.38477V12.667L93.397,12.7373c-.62012.0415-.90137.25244-.90137.64941,0,.40527.35156.64111.835.64111A1.0615,1.0615,0,0,0,94.49659,13.04346Z" style="fill: #fff"/>
|
||||||
|
<path d="M96.773,10.19873h.85547v.71533h.06641a1.348,1.348,0,0,1,1.34375-.80225,1.46456,1.46456,0,0,1,1.55859,1.6748v2.915h-.88867V12.00977c0-.72363-.31445-1.0835-.97168-1.0835a1.03294,1.03294,0,0,0-1.0752,1.14111v2.63428H96.773Z" style="fill: #fff"/>
|
||||||
|
<path d="M103.61769,10.11182c1.0127,0,1.6748.47119,1.76172,1.26514h-.85254c-.082-.33057-.40527-.5415-.90918-.5415-.49609,0-.873.23535-.873.58691,0,.269.22754.43848.71582.55029l.748.17334c.85645.19873,1.25781.56689,1.25781,1.22852,0,.84766-.79,1.41406-1.86523,1.41406-1.07129,0-1.76953-.48389-1.84863-1.28174h.88965a.91365.91365,0,0,0,.97949.562c.55371,0,.94727-.248.94727-.60791,0-.26855-.21094-.44238-.66211-.5498l-.78516-.18213c-.85645-.20264-1.25293-.58691-1.25293-1.25684C101.86866,10.67383,102.60011,10.11182,103.61769,10.11182Z" style="fill: #fff"/>
|
||||||
|
</g>
|
||||||
|
</g>
|
||||||
|
</g>
|
||||||
|
<g>
|
||||||
|
<path d="M35.19825,18.06689h1.85938V30.48535H35.19825Z" style="fill: #fff"/>
|
||||||
|
<path d="M39.29786,22.61084l1.01563-4.54395h1.80664l-1.23047,4.54395Z" style="fill: #fff"/>
|
||||||
|
<path d="M49.14649,27.12891H44.4131l-1.13672,3.35645H41.27149l4.4834-12.41846h2.083l4.4834,12.41846H50.28224Zm-4.24316-1.54883h3.752l-1.84961-5.44775h-.05176Z" style="fill: #fff"/>
|
||||||
|
<path d="M62.00294,25.959c0,2.81348-1.50586,4.62109-3.77832,4.62109a3.0693,3.0693,0,0,1-2.84863-1.584h-.043v4.48438h-1.8584V21.43115h1.79883V22.937h.03418a3.21162,3.21162,0,0,1,2.88281-1.60059C60.48829,21.33643,62.00294,23.15283,62.00294,25.959Zm-1.91016,0c0-1.8335-.94727-3.03857-2.39258-3.03857-1.41992,0-2.375,1.23047-2.375,3.03857,0,1.82422.95508,3.0459,2.375,3.0459C59.14552,29.00488,60.09278,27.80859,60.09278,25.959Z" style="fill: #fff"/>
|
||||||
|
<path d="M71.9673,25.959c0,2.81348-1.50586,4.62109-3.77832,4.62109a3.0693,3.0693,0,0,1-2.84863-1.584h-.043v4.48438H63.43946V21.43115H65.2378V22.937H65.272a3.21162,3.21162,0,0,1,2.88281-1.60059C70.45265,21.33643,71.9673,23.15283,71.9673,25.959Zm-1.91016,0c0-1.8335-.94727-3.03857-2.39258-3.03857-1.41992,0-2.375,1.23047-2.375,3.03857,0,1.82422.95508,3.0459,2.375,3.0459C69.10987,29.00488,70.05714,27.80859,70.05714,25.959Z" style="fill: #fff"/>
|
||||||
|
<path d="M78.55323,27.02539c.1377,1.23145,1.334,2.04,2.96875,2.04,1.56641,0,2.69336-.80859,2.69336-1.91895,0-.96387-.67969-1.541-2.28906-1.93652l-1.60937-.38818C78.03663,24.271,76.978,23.20459,76.978,21.47412c0-2.14258,1.86719-3.61426,4.51855-3.61426,2.624,0,4.42285,1.47168,4.4834,3.61426H84.104c-.1123-1.23926-1.13672-1.9873-2.63379-1.9873s-2.52148.75684-2.52148,1.8584c0,.87793.6543,1.39453,2.25488,1.79l1.36816.33594c2.54785.60254,3.60645,1.62646,3.60645,3.44287,0,2.32324-1.85059,3.77832-4.79395,3.77832-2.75391,0-4.61328-1.4209-4.7334-3.667Z" style="fill: #fff"/>
|
||||||
|
<path d="M90.19,19.28857v2.14258h1.72168v1.47168H90.19v4.9917c0,.77539.34473,1.13672,1.10156,1.13672a5.80752,5.80752,0,0,0,.61133-.043v1.46289a5.10351,5.10351,0,0,1-1.03223.08594c-1.833,0-2.54785-.68848-2.54785-2.44434V22.90283H87.00636V21.43115h1.31641V19.28857Z" style="fill: #fff"/>
|
||||||
|
<path d="M92.90773,25.959c0-2.84912,1.67773-4.63916,4.29395-4.63916,2.625,0,4.29492,1.79,4.29492,4.63916,0,2.85645-1.66113,4.63867-4.29492,4.63867C94.56886,30.59766,92.90773,28.81543,92.90773,25.959Zm6.69531,0c0-1.95459-.89551-3.10791-2.40137-3.10791s-2.40039,1.16211-2.40039,3.10791c0,1.96191.89453,3.10645,2.40039,3.10645S99.603,27.9209,99.603,25.959Z" style="fill: #fff"/>
|
||||||
|
<path d="M103.02882,21.43115h1.77246v1.541h.043a2.1594,2.1594,0,0,1,2.17773-1.63574,2.86616,2.86616,0,0,1,.63672.06934V23.144a2.59794,2.59794,0,0,0-.835-.1123,1.8728,1.8728,0,0,0-1.93652,2.0835v5.37012h-1.8584Z" style="fill: #fff"/>
|
||||||
|
<path d="M116.22608,27.82617c-.25,1.64355-1.85059,2.77148-3.89844,2.77148-2.63379,0-4.26855-1.76465-4.26855-4.5957,0-2.84033,1.64355-4.68213,4.19043-4.68213,2.50488,0,4.08008,1.7207,4.08008,4.46631v.63672h-6.39453v.1123a2.358,2.358,0,0,0,2.43555,2.56445,2.04834,2.04834,0,0,0,2.09082-1.27344ZM109.94386,25.124h4.52637a2.17744,2.17744,0,0,0-2.2207-2.29834A2.29214,2.29214,0,0,0,109.94386,25.124Z" style="fill: #fff"/>
|
||||||
|
</g>
|
||||||
|
</g>
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 12 KiB |
220
note_kfet/static/img/appstore_badge_fr_preorder.svg
Normal file
@@ -0,0 +1,220 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!-- Generator: Adobe Illustrator 21.1.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
|
||||||
|
<svg version="1.1" id="livetype" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
|
||||||
|
width="127.5px" height="41px" viewBox="0 0 127.5 41" enable-background="new 0 0 127.5 41" xml:space="preserve">
|
||||||
|
<g>
|
||||||
|
<g>
|
||||||
|
<g>
|
||||||
|
<g>
|
||||||
|
<g>
|
||||||
|
<g>
|
||||||
|
<path fill="#A6A6A6" d="M116.9740829,0H9.5381069C9.1714067,0,8.8090963,0,8.4433765,0.001953
|
||||||
|
C8.1372271,0.003906,7.8335166,0.009766,7.5244284,0.014648C6.8589067,0.03125,6.1850767,0.072266,5.5205269,0.191406
|
||||||
|
C4.8510966,0.308594,4.2290268,0.508789,3.6196468,0.818359C3.0210168,1.125,2.4741282,1.52344,2.0009968,1.99707
|
||||||
|
c-0.47852,0.4736301-0.875,1.0224601-1.17822,1.6210901c-0.311039,0.6084001-0.508305,1.2334001-0.6250041,1.9033201
|
||||||
|
c-0.120606,0.6621099-0.162109,1.3320398-0.179199,2.0019598C0.0092958,7.83008,0.0083198,8.1377001,0.0034284,8.4443398
|
||||||
|
c0,0.3622999,0,0.7255802,0,1.0917902v20.928669c0,0.3691998,0,0.7304993,0,1.0937996
|
||||||
|
c0.0048914,0.3105011,0.0058674,0.6112995,0.0151454,0.9218998c0.01709,0.669899,0.058593,1.3398018,0.179199,2.0018997
|
||||||
|
c0.116699,0.6699028,0.313965,1.2979012,0.6250041,1.9043007c0.30322,0.5956993,0.6997,1.1445999,1.17822,1.6142998
|
||||||
|
c0.4731314,0.4775009,1.02002,0.875,1.61865,1.1786995c0.60938,0.3125,1.2314498,0.5098,1.9008801,0.6308022
|
||||||
|
c0.6645498,0.1191978,1.3383799,0.1582985,2.0039015,0.1767998c0.3090882,0.0067978,0.6127987,0.0107002,0.9189482,0.0107002
|
||||||
|
C8.8090963,40,9.1714067,40,9.5381069,40h107.4359741c0.3593979,0,0.7246017,0,1.0839996-0.0019989
|
||||||
|
c0.3047028,0,0.6172028-0.0039024,0.9218979-0.0107002c0.6699066-0.0185013,1.3418045-0.0576019,2-0.1767998
|
||||||
|
c0.6699066-0.1210022,1.2929001-0.3183022,1.9082031-0.6308022c0.5976028-0.3036995,1.1445007-0.7011986,1.6172028-1.1786995
|
||||||
|
c0.4764938-0.4696999,0.8730011-1.0186005,1.1815948-1.6142998c0.3066025-0.6063995,0.5059052-1.2343979,0.6191025-1.9043007
|
||||||
|
c0.1231003-0.6620979,0.1621017-1.3320007,0.1856003-2.0018997c0.0038986-0.3106003,0.0038986-0.6113987,0.0038986-0.9218998
|
||||||
|
c0.0078049-0.3633003,0.0078049-0.7245998,0.0078049-1.0937996V9.53613c0-0.36621,0-0.7294903-0.0078049-1.0917902
|
||||||
|
c0-0.3066397,0-0.6142597-0.0038986-0.9208999c-0.0234985-0.66992-0.0625-1.3398499-0.1856003-2.0019598
|
||||||
|
c-0.1131973-0.66992-0.3125-1.29492-0.6191025-1.9033201c-0.3085938-0.59863-0.705101-1.14746-1.1815948-1.6210901
|
||||||
|
c-0.472702-0.47363-1.0195999-0.87207-1.6172028-1.1787109c-0.615303-0.30957-1.2382965-0.509765-1.9082031-0.626953
|
||||||
|
c-0.6581955-0.11914-1.3300934-0.160156-2-0.176758c-0.3046951-0.004882-0.6171951-0.010742-0.9218979-0.012695
|
||||||
|
C117.6986847,0,117.3334808,0,116.9740829,0L116.9740829,0z"/>
|
||||||
|
<path d="M8.4482479,39.125c-0.3046713,0-0.6020412-0.0038986-0.9042811-0.0107002
|
||||||
|
c-0.5590801-0.0157013-1.2221699-0.0468979-1.8691401-0.1631012
|
||||||
|
c-0.6103497-0.1103973-1.1528397-0.2901001-1.6567397-0.5478973c-0.5214901-0.2646027-0.9902401-0.6063995-1.39697-1.0166016
|
||||||
|
C2.2070467,36.9804993,1.8667167,36.5136986,1.6006068,35.9902c-0.25928-0.5047989-0.43653-1.0467987-0.5429784-1.6571999
|
||||||
|
c-0.1220616-0.672802-0.1533116-1.3554993-0.1665-1.875c-0.0063416-0.2108994-0.0146416-0.9130993-0.0146416-0.9130993
|
||||||
|
V8.4443398c0,0,0.00879-0.6914096,0.0146416-0.8945398c0.0131884-0.5239201,0.0444384-1.2060499,0.16552-1.8720698
|
||||||
|
c0.1069484-0.61377,0.2841799-1.1552701,0.5434684-1.6621003C1.8657284,3.49121,2.2065668,3.02197,2.6152482,2.6176801
|
||||||
|
C3.0288267,2.2036099,3.4995267,1.86084,4.0175967,1.59521C4.5312667,1.33447,5.0727768,1.15625,5.6709166,1.05127
|
||||||
|
c0.6733317-0.120606,1.3559604-0.150879,1.8754902-0.164063L8.4487467,0.875h109.6044388l0.9131012,0.012695
|
||||||
|
c0.5126953,0.012696,1.1952972,0.042969,1.8583984,0.162595c0.6025009,0.1054701,1.1474991,0.28467,1.6708984,0.54785
|
||||||
|
c0.5127029,0.2627,0.982399,0.6054699,1.3916016,1.01563c0.4092026,0.40625,0.7518997,0.8779299,1.0233994,1.4043002
|
||||||
|
c0.2578049,0.51123,0.4336014,1.0527296,0.535202,1.6489196c0.1161957,0.6308603,0.152298,1.27881,0.1737976,1.8872104
|
||||||
|
c0.0028992,0.2831998,0.0028992,0.5873995,0.0028992,0.8901396c0.0079041,0.375,0.0079041,0.7319298,0.0079041,1.0917902
|
||||||
|
v20.928669c0,0.3633003,0,0.7178001-0.0079041,1.075201c0,0.3251991,0,0.6231003-0.0038986,0.9296989
|
||||||
|
c-0.0205002,0.5889015-0.0566025,1.2364006-0.1708984,1.8535004
|
||||||
|
c-0.1035004,0.6133003-0.2792969,1.1553001-0.5400009,1.6699982
|
||||||
|
c-0.2695007,0.5195007-0.6122971,0.9892006-1.0156021,1.3857002c-0.4131012,0.4180031-0.881897,0.7588005-1.3993988,1.0225029
|
||||||
|
c-0.5186005,0.2635994-1.0478973,0.4384003-1.6679993,0.5497971
|
||||||
|
c-0.6406021,0.1162033-1.3037033,0.1473999-1.8692017,0.1631012
|
||||||
|
c-0.2929001,0.0068016-0.5996017,0.0107002-0.8973999,0.0107002l-1.0839996,0.0019989L8.4482479,39.125z"/>
|
||||||
|
</g>
|
||||||
|
</g>
|
||||||
|
</g>
|
||||||
|
</g>
|
||||||
|
</g>
|
||||||
|
<g>
|
||||||
|
<g>
|
||||||
|
<g id="XMLID_20_">
|
||||||
|
<g id="XMLID_22_">
|
||||||
|
<g id="XMLID_23_">
|
||||||
|
<path id="XMLID_25_" fill="#FFFFFF" d="M24.7752247,20.3006763c-0.0250111-2.7508278,2.2523365-4.0894947,2.3565578-4.1520615
|
||||||
|
c-1.2895851-1.880518-3.2889214-2.137701-3.9911613-2.1576748c-1.679245-0.1762638-3.307188,1.0048323-4.1629009,1.0048323
|
||||||
|
c-0.8722668,0-2.1897697-0.9873343-3.6085024-0.9581413c-1.8263159,0.0283384-3.5356064,1.0857515-4.4729214,2.7278662
|
||||||
|
c-1.9339523,3.3484154-0.4914045,8.2694664,1.3612013,10.976078c0.9269009,1.3253498,2.0101776,2.8057976,3.4276295,2.7533016
|
||||||
|
c1.387064-0.0575314,1.9051018-0.8844776,3.5793953-0.8844776c1.6587582,0,2.1447868,0.8844776,3.5910034,0.8511028
|
||||||
|
c1.4883842-0.0241566,2.4261265-1.3312416,3.3205109-2.6691399c1.0711498-1.5195389,1.5012684-3.0158634,1.518425-3.092514
|
||||||
|
C27.6598072,24.6881542,24.8035622,23.598732,24.7752247,20.3006763z"/>
|
||||||
|
<path id="XMLID_24_" fill="#FFFFFF" d="M22.043602,12.2108879c0.7456875-0.933217,1.2562122-2.2023182,1.1145172-3.4906235
|
||||||
|
c-1.0798607,0.0478859-2.4303074,0.7464542-3.2075748,1.6596127
|
||||||
|
c-0.6877289,0.8039846-1.3024769,2.1223364-1.1437111,3.3613911
|
||||||
|
C20.0196838,13.8313208,21.2650547,13.1294231,22.043602,12.2108879z"/>
|
||||||
|
</g>
|
||||||
|
</g>
|
||||||
|
</g>
|
||||||
|
</g>
|
||||||
|
<g id="XMLID_1_">
|
||||||
|
<g>
|
||||||
|
<path fill="#FFFFFF" d="M37.5542183,8.7348633c1.1660156,0,1.9677734,0.8061523,1.9677734,1.9887695
|
||||||
|
c0,1.1660156-0.8261719,1.9682617-1.9970703,1.9682617H36.144062v2.0097656h-0.9267578V8.7348633H37.5542183z
|
||||||
|
M36.144062,11.8774414h1.1660156c0.7978516,0,1.265625-0.4135742,1.265625-1.1538086
|
||||||
|
c0-0.7568359-0.4511719-1.1704102-1.265625-1.1704102H36.144062V11.8774414z"/>
|
||||||
|
<path fill="#FFFFFF" d="M40.7358589,10.1987305h0.8554688v0.6904297h0.0664062
|
||||||
|
c0.1279297-0.4423828,0.6279297-0.7651367,1.2158203-0.7651367c0.1318359,0,0.3017578,0.012207,0.3964844,0.0371094v0.8769531
|
||||||
|
c-0.0742188-0.0249023-0.3388672-0.0537109-0.4960938-0.0537109c-0.6738281,0-1.1494141,0.4257812-1.1494141,1.0585938
|
||||||
|
v2.6586914h-0.8886719V10.1987305z"/>
|
||||||
|
<path fill="#FFFFFF" d="M47.9438667,13.4858398c-0.2021484,0.8066406-0.921875,1.3027344-1.9511719,1.3027344
|
||||||
|
c-1.2900391,0-2.0800781-0.8847656-2.0800781-2.3242188c0-1.4389648,0.8066406-2.3525391,2.0761719-2.3525391
|
||||||
|
c1.2529297,0,2.0087891,0.855957,2.0087891,2.2700195v0.3100586h-3.1796875v0.0498047
|
||||||
|
c0.0292969,0.7895508,0.4882812,1.2900391,1.1992188,1.2900391c0.5380859,0,0.90625-0.1943359,1.0712891-0.5458984H47.9438667z
|
||||||
|
M44.8178902,12.034668h2.2744141c-0.0205078-0.7070312-0.4501953-1.1665039-1.1083984-1.1665039
|
||||||
|
C45.3266792,10.8681641,44.8676949,11.331543,44.8178902,12.034668z M45.4546089,9.4458008l1.0380859-1.4223633h1.0419922
|
||||||
|
l-1.1621094,1.4223633H45.4546089z"/>
|
||||||
|
<path fill="#FFFFFF" d="M52.1391792,11.6704102c-0.1035156-0.4379883-0.4677734-0.7646484-1.0634766-0.7646484
|
||||||
|
c-0.7441406,0-1.1992188,0.5703125-1.1992188,1.5297852c0,0.9760742,0.4589844,1.559082,1.1992188,1.559082
|
||||||
|
c0.5625,0,0.9472656-0.2563477,1.0634766-0.7402344h0.8642578c-0.1162109,0.9057617-0.8105469,1.5341797-1.9228516,1.5341797
|
||||||
|
c-1.3115234,0-2.1132812-0.8847656-2.1132812-2.3530273c0-1.4428711,0.7978516-2.3237305,2.1083984-2.3237305
|
||||||
|
c1.1289062,0,1.8115234,0.6572266,1.9277344,1.5585938H52.1391792z"/>
|
||||||
|
<path fill="#FFFFFF" d="M53.9184761,12.4482422c0-1.4516602,0.8105469-2.3364258,2.125-2.3364258
|
||||||
|
c1.3115234,0,2.1220703,0.8847656,2.1220703,2.3364258c0,1.4594727-0.8066406,2.340332-2.1220703,2.340332
|
||||||
|
C54.7251167,14.7885742,53.9184761,13.9077148,53.9184761,12.4482422z M57.2514839,12.4482422
|
||||||
|
c0-0.9760742-0.4384766-1.546875-1.2080078-1.546875c-0.7724609,0-1.2070312,0.5708008-1.2070312,1.546875
|
||||||
|
c0,0.9838867,0.4345703,1.550293,1.2070312,1.550293C56.8130074,13.9985352,57.2514839,13.4282227,57.2514839,12.4482422z"/>
|
||||||
|
<path fill="#FFFFFF" d="M59.3579292,10.1987305h0.8554688v0.7236328h0.0664062
|
||||||
|
c0.1982422-0.5087891,0.6533203-0.8105469,1.2529297-0.8105469c0.6162109,0,1.0419922,0.3183594,1.2402344,0.8105469h0.0703125
|
||||||
|
c0.2275391-0.4921875,0.7441406-0.8105469,1.3691444-0.8105469c0.9086914,0,1.4379883,0.5498047,1.4379883,1.4882812v3.1015625
|
||||||
|
h-0.8881836v-2.8696289c0-0.6079102-0.2900391-0.9057617-0.8730507-0.9057617
|
||||||
|
c-0.5742188,0-0.9501953,0.4135742-0.9501953,0.9428711v2.8325195H62.065937v-2.956543
|
||||||
|
c0-0.5087891-0.3388672-0.8188477-0.8681641-0.8188477c-0.5419922,0-0.9511719,0.4423828-0.9511719,1.0214844v2.7539062
|
||||||
|
h-0.8886719V10.1987305z"/>
|
||||||
|
<path fill="#FFFFFF" d="M67.024437,10.1987305h0.8554688v0.7236328h0.0664062
|
||||||
|
c0.1982422-0.5087891,0.6533203-0.8105469,1.2529297-0.8105469c0.6162109,0,1.0419922,0.3183594,1.2402344,0.8105469h0.0703125
|
||||||
|
c0.2275391-0.4921875,0.7441406-0.8105469,1.3691406-0.8105469c0.9091797,0,1.4384766,0.5498047,1.4384766,1.4882812v3.1015625
|
||||||
|
h-0.8886719v-2.8696289c0-0.6079102-0.2900391-0.9057617-0.8730469-0.9057617
|
||||||
|
c-0.5742188,0-0.9501953,0.4135742-0.9501953,0.9428711v2.8325195h-0.8730469v-2.956543
|
||||||
|
c0-0.5087891-0.3388672-0.8188477-0.8681641-0.8188477c-0.5419922,0-0.9511719,0.4423828-0.9511719,1.0214844v2.7539062
|
||||||
|
H67.024437V10.1987305z"/>
|
||||||
|
<path fill="#FFFFFF" d="M74.4345932,13.4282227c0-0.8105469,0.6035156-1.277832,1.6748047-1.3442383l1.2197266-0.0703125V11.625
|
||||||
|
c0-0.4755859-0.3144531-0.7441406-0.921875-0.7441406c-0.4960938,0-0.8398438,0.1821289-0.9384766,0.5004883h-0.8603516
|
||||||
|
c0.0908203-0.7734375,0.8183594-1.2695312,1.8398438-1.2695312c1.1289062,0,1.765625,0.5620117,1.765625,1.5131836v3.0766602
|
||||||
|
h-0.8554688v-0.6328125h-0.0703125c-0.2685547,0.4506836-0.7607422,0.7070312-1.3525391,0.7070312
|
||||||
|
C75.0674057,14.7758789,74.4345932,14.2509766,74.4345932,13.4282227z M77.3291245,13.043457v-0.3764648l-1.0996094,0.0703125
|
||||||
|
c-0.6201172,0.0415039-0.9013672,0.2524414-0.9013672,0.6494141c0,0.4052734,0.3515625,0.6411133,0.8349609,0.6411133
|
||||||
|
C76.8330307,14.027832,77.3291245,13.6015625,77.3291245,13.043457z"/>
|
||||||
|
<path fill="#FFFFFF" d="M79.6054916,10.1987305h0.8554688v0.715332h0.0664062
|
||||||
|
c0.21875-0.5004883,0.6660156-0.8022461,1.34375-0.8022461c1.0048828,0,1.5585938,0.6035156,1.5585938,1.6748047v2.9150391
|
||||||
|
h-0.8886719v-2.6918945c0-0.7236328-0.3144531-1.0834961-0.9716797-1.0834961s-1.0751953,0.4384766-1.0751953,1.1411133
|
||||||
|
v2.6342773h-0.8886719V10.1987305z"/>
|
||||||
|
<path fill="#FFFFFF" d="M84.5810776,12.4482422c0-1.4228516,0.7314453-2.3242188,1.8691406-2.3242188
|
||||||
|
c0.6162109,0,1.1367188,0.293457,1.3808594,0.7900391h0.0664062V8.440918h0.8886719v6.2607422h-0.8515625v-0.7114258h-0.0703125
|
||||||
|
c-0.2685547,0.4921875-0.7939453,0.7856445-1.4140625,0.7856445
|
||||||
|
C85.3047104,14.7758789,84.5810776,13.8745117,84.5810776,12.4482422z M85.4990463,12.4482422
|
||||||
|
c0,0.9550781,0.4501953,1.5297852,1.203125,1.5297852c0.7490234,0,1.2119141-0.5830078,1.2119141-1.5258789
|
||||||
|
c0-0.9384766-0.4677734-1.5297852-1.2119141-1.5297852C85.9541245,10.9223633,85.4990463,11.5009766,85.4990463,12.4482422z"/>
|
||||||
|
<path fill="#FFFFFF" d="M94.0517807,13.4858398c-0.2021484,0.8066406-0.921875,1.3027344-1.9511719,1.3027344
|
||||||
|
c-1.2900391,0-2.0800781-0.8847656-2.0800781-2.3242188c0-1.4389648,0.8066406-2.3525391,2.0761719-2.3525391
|
||||||
|
c1.2529297,0,2.0087891,0.855957,2.0087891,2.2700195v0.3100586h-3.1796875v0.0498047
|
||||||
|
c0.0292969,0.7895508,0.4882812,1.2900391,1.1992188,1.2900391c0.5380859,0,0.90625-0.1943359,1.0712891-0.5458984H94.0517807z
|
||||||
|
M90.9258041,12.034668h2.2744141c-0.0205078-0.7070312-0.4501953-1.1665039-1.1083984-1.1665039
|
||||||
|
C91.4345932,10.8681641,90.9756088,11.331543,90.9258041,12.034668z"/>
|
||||||
|
<path fill="#FFFFFF" d="M95.2998276,10.1987305h0.8554688v0.6904297h0.0664062
|
||||||
|
c0.1279297-0.4423828,0.6279297-0.7651367,1.2158203-0.7651367c0.1318359,0,0.3017578,0.012207,0.3964844,0.0371094v0.8769531
|
||||||
|
c-0.0742188-0.0249023-0.3388672-0.0537109-0.4960938-0.0537109c-0.6738281,0-1.1494141,0.4257812-1.1494141,1.0585938
|
||||||
|
v2.6586914h-0.8886719V10.1987305z"/>
|
||||||
|
<path fill="#FFFFFF" d="M102.9043198,10.1118164c1.0126953,0,1.6748047,0.4711914,1.7617188,1.2651367h-0.8525391
|
||||||
|
c-0.0820312-0.3305664-0.4052734-0.5415039-0.9091797-0.5415039c-0.4960938,0-0.8730469,0.2353516-0.8730469,0.5869141
|
||||||
|
c0,0.269043,0.2275391,0.4384766,0.7158203,0.550293l0.7480469,0.1733398
|
||||||
|
c0.8564453,0.1987305,1.2578125,0.5668945,1.2578125,1.2285156c0,0.8476562-0.7900391,1.4140625-1.8652344,1.4140625
|
||||||
|
c-1.0712891,0-1.7695312-0.4838867-1.8486328-1.2817383h0.8896484c0.1113281,0.347168,0.4423828,0.5620117,0.9794922,0.5620117
|
||||||
|
c0.5537109,0,0.9472656-0.2480469,0.9472656-0.6079102c0-0.2685547-0.2109375-0.4423828-0.6621094-0.5498047
|
||||||
|
l-0.7851562-0.1821289c-0.8564453-0.2026367-1.2529297-0.5869141-1.2529297-1.2568359
|
||||||
|
C101.1552963,10.6738281,101.8867416,10.1118164,102.9043198,10.1118164z"/>
|
||||||
|
<path fill="#FFFFFF" d="M109.7461166,14.7016602h-0.8564453v-0.715332h-0.0703125
|
||||||
|
c-0.21875,0.5126953-0.6777344,0.8022461-1.3603516,0.8022461c-0.9960938,0-1.5507812-0.6079102-1.5507812-1.6665039v-2.9233398
|
||||||
|
h0.8896484v2.6918945c0,0.7275391,0.2929688,1.0751953,0.9462891,1.0751953
|
||||||
|
c0.7197266,0,1.1123047-0.4262695,1.1123047-1.1333008v-2.6337891h0.8896484V14.7016602z"/>
|
||||||
|
<path fill="#FFFFFF" d="M111.1621323,10.1987305h0.8554688v0.6904297h0.0664062
|
||||||
|
c0.1279297-0.4423828,0.6279297-0.7651367,1.2158203-0.7651367c0.1318359,0,0.3017578,0.012207,0.3964844,0.0371094v0.8769531
|
||||||
|
c-0.0742188-0.0249023-0.3388672-0.0537109-0.4960938-0.0537109c-0.6738281,0-1.1494141,0.4257812-1.1494141,1.0585938
|
||||||
|
v2.6586914h-0.8886719V10.1987305z"/>
|
||||||
|
</g>
|
||||||
|
</g>
|
||||||
|
</g>
|
||||||
|
<g>
|
||||||
|
<path fill="#FFFFFF" d="M35.2016792,18.0668945h1.859375v12.418457h-1.859375V18.0668945z"/>
|
||||||
|
<path fill="#FFFFFF" d="M39.3012886,22.6108398l1.015625-4.5439453h1.8066406l-1.2304688,4.5439453H39.3012886z"/>
|
||||||
|
<path fill="#FFFFFF" d="M49.1489449,27.1289062h-4.7333984l-1.1367188,3.3564453h-2.0048828l4.4833984-12.418457h2.0830078
|
||||||
|
l4.4833984,12.418457H50.284687L49.1489449,27.1289062z M44.9057808,25.5800781h3.7519531l-1.8496094-5.4477539h-0.0517578
|
||||||
|
L44.9057808,25.5800781z"/>
|
||||||
|
<path fill="#FFFFFF" d="M62.0063667,25.9589844c0,2.8134766-1.5058594,4.6210938-3.7783203,4.6210938
|
||||||
|
c-1.2900391,0-2.3144531-0.5771484-2.8486328-1.5839844h-0.0429688v4.484375h-1.8583984V21.4311523h1.7988281v1.5058594h0.0341797
|
||||||
|
c0.5166016-0.9716797,1.6181641-1.6005859,2.8828125-1.6005859C60.4917183,21.3364258,62.0063667,23.152832,62.0063667,25.9589844
|
||||||
|
z M60.0962105,25.9589844c0-1.8334961-0.9472656-3.0385742-2.3925781-3.0385742c-1.4199219,0-2.375,1.2304688-2.375,3.0385742
|
||||||
|
c0,1.8242188,0.9550781,3.0458984,2.375,3.0458984C59.1489449,29.0048828,60.0962105,27.8085938,60.0962105,25.9589844z"/>
|
||||||
|
<path fill="#FFFFFF" d="M71.970726,25.9589844c0,2.8134766-1.5058594,4.6210938-3.7783203,4.6210938
|
||||||
|
c-1.2900391,0-2.3144531-0.5771484-2.8486328-1.5839844h-0.0429688v4.484375h-1.857914V21.4311523h1.7983437v1.5058594h0.0341797
|
||||||
|
c0.5166016-0.9716797,1.6181641-1.6005859,2.8828125-1.6005859C70.4560776,21.3364258,71.970726,23.152832,71.970726,25.9589844z
|
||||||
|
M70.0605698,25.9589844c0-1.8334961-0.9472656-3.0385742-2.3925781-3.0385742c-1.4199219,0-2.375,1.2304688-2.375,3.0385742
|
||||||
|
c0,1.8242188,0.9550781,3.0458984,2.375,3.0458984C69.1133041,29.0048828,70.0605698,27.8085938,70.0605698,25.9589844z"/>
|
||||||
|
<path fill="#FFFFFF" d="M78.5566635,27.0253906c0.1376953,1.2314453,1.3339844,2.0400391,2.96875,2.0400391
|
||||||
|
c1.5664062,0,2.6933594-0.8085938,2.6933594-1.9189453c0-0.9638672-0.6796875-1.5410156-2.2890625-1.9365234l-1.609375-0.3881836
|
||||||
|
c-2.2802734-0.5507812-3.3388672-1.6171875-3.3388672-3.3476562c0-2.1425781,1.8671875-3.6142578,4.5185547-3.6142578
|
||||||
|
c2.6240234,0,4.4228516,1.4716797,4.4833984,3.6142578h-1.8759766c-0.1123047-1.2392578-1.1367188-1.9873047-2.6337891-1.9873047
|
||||||
|
s-2.5214844,0.7568359-2.5214844,1.8583984c0,0.8779297,0.6542969,1.3945312,2.2548828,1.7900391l1.3681641,0.3359375
|
||||||
|
c2.5478516,0.6025391,3.6064453,1.6264648,3.6064453,3.4428711c0,2.3232422-1.8505859,3.7783203-4.7939453,3.7783203
|
||||||
|
c-2.7539062,0-4.6132812-1.4208984-4.7333984-3.6669922H78.5566635z"/>
|
||||||
|
<path fill="#FFFFFF" d="M90.1924057,19.2885742v2.1425781h1.7216797v1.4716797h-1.7216797v4.9916992
|
||||||
|
c0,0.7753906,0.3447266,1.1367188,1.1015625,1.1367188c0.1894531,0,0.4912109-0.0263672,0.6113281-0.0429688v1.4628906
|
||||||
|
c-0.2060547,0.0517578-0.6191406,0.0859375-1.0322266,0.0859375c-1.8330078,0-2.5478516-0.6884766-2.5478516-2.4443359V22.902832
|
||||||
|
H87.008812v-1.4716797h1.3164062v-2.1425781H90.1924057z"/>
|
||||||
|
<path fill="#FFFFFF" d="M92.9101791,25.9589844c0-2.8491211,1.6777344-4.6391602,4.2939453-4.6391602
|
||||||
|
c2.625,0,4.2949219,1.7900391,4.2949219,4.6391602c0,2.8564453-1.6611328,4.6386719-4.2949219,4.6386719
|
||||||
|
C94.571312,30.5976562,92.9101791,28.8154297,92.9101791,25.9589844z M99.6054916,25.9589844
|
||||||
|
c0-1.9545898-0.8955078-3.1079102-2.4013672-3.1079102s-2.4013672,1.1621094-2.4013672,3.1079102
|
||||||
|
c0,1.9619141,0.8955078,3.1064453,2.4013672,3.1064453S99.6054916,27.9208984,99.6054916,25.9589844z"/>
|
||||||
|
<path fill="#FFFFFF" d="M103.0312729,21.4311523h1.7724609v1.5410156h0.0429688
|
||||||
|
c0.2841797-1.0244141,1.1103516-1.6357422,2.1777344-1.6357422c0.2666016,0,0.4902344,0.0351562,0.6367188,0.0693359v1.7382812
|
||||||
|
c-0.1464844-0.0605469-0.4736328-0.1123047-0.8349609-0.1123047c-1.1962891,0-1.9365234,0.8095703-1.9365234,2.0834961v5.3701172
|
||||||
|
h-1.8583984V21.4311523z"/>
|
||||||
|
<path fill="#FFFFFF" d="M116.2295151,27.8261719c-0.25,1.6435547-1.8505859,2.7714844-3.8984375,2.7714844
|
||||||
|
c-2.6337891,0-4.2685547-1.7646484-4.2685547-4.5957031c0-2.840332,1.6435547-4.6821289,4.1904297-4.6821289
|
||||||
|
c2.5048828,0,4.0800781,1.7207031,4.0800781,4.4663086v0.6367188h-6.3945312v0.1123047
|
||||||
|
c0,1.5488281,0.9726562,2.5644531,2.4355469,2.5644531c1.0322266,0,1.8417969-0.4902344,2.0908203-1.2734375H116.2295151z
|
||||||
|
M109.9472885,25.1240234h4.5263672c-0.0429688-1.3862305-0.9296875-2.2983398-2.2207031-2.2983398
|
||||||
|
C110.970726,22.8256836,110.0420151,23.7553711,109.9472885,25.1240234z"/>
|
||||||
|
</g>
|
||||||
|
</g>
|
||||||
|
<g>
|
||||||
|
</g>
|
||||||
|
<g>
|
||||||
|
</g>
|
||||||
|
<g>
|
||||||
|
</g>
|
||||||
|
<g>
|
||||||
|
</g>
|
||||||
|
<g>
|
||||||
|
</g>
|
||||||
|
<g>
|
||||||
|
</g>
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 18 KiB |
63
note_kfet/static/img/playstore_badge_fr.svg
Normal file
@@ -0,0 +1,63 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<svg id="artwork" xmlns="http://www.w3.org/2000/svg" version="1.1" viewBox="0 0 135 40">
|
||||||
|
<!-- Generator: Adobe Illustrator 29.2.1, SVG Export Plug-In . SVG Version: 2.1.0 Build 116) -->
|
||||||
|
<defs>
|
||||||
|
<style>
|
||||||
|
.st0 {
|
||||||
|
fill: #4285f4;
|
||||||
|
}
|
||||||
|
|
||||||
|
.st1 {
|
||||||
|
isolation: isolate;
|
||||||
|
}
|
||||||
|
|
||||||
|
.st2 {
|
||||||
|
fill: #a6a6a6;
|
||||||
|
}
|
||||||
|
|
||||||
|
.st3 {
|
||||||
|
fill: #34a853;
|
||||||
|
}
|
||||||
|
|
||||||
|
.st4 {
|
||||||
|
fill: #fbbc04;
|
||||||
|
}
|
||||||
|
|
||||||
|
.st5 {
|
||||||
|
fill: #fff;
|
||||||
|
}
|
||||||
|
|
||||||
|
.st6 {
|
||||||
|
fill: #ea4335;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</defs>
|
||||||
|
<g>
|
||||||
|
<rect width="135" height="40" rx="5" ry="5"/>
|
||||||
|
<path class="st2" d="M130,.8c2.3,0,4.2,1.9,4.2,4.2v30c0,2.3-1.9,4.2-4.2,4.2H5c-2.3,0-4.2-1.9-4.2-4.2V5c0-2.3,1.9-4.2,4.2-4.2h125M130,0H5C2.2,0,0,2.2,0,5v30c0,2.8,2.2,5,5,5h125c2.8,0,5-2.2,5-5V5c0-2.8-2.2-5-5-5h0Z"/>
|
||||||
|
<path class="st5" d="M68.1,21.8c-2.4,0-4.3,1.8-4.3,4.3s1.9,4.3,4.3,4.3,4.3-1.8,4.3-4.3-1.9-4.3-4.3-4.3ZM68.1,28.6c-1.3,0-2.4-1.1-2.4-2.6s1.1-2.6,2.4-2.6,2.4,1,2.4,2.6-1.1,2.6-2.4,2.6ZM58.8,21.8c-2.4,0-4.3,1.8-4.3,4.3s1.9,4.3,4.3,4.3,4.3-1.8,4.3-4.3-1.9-4.3-4.3-4.3ZM58.8,28.6c-1.3,0-2.4-1.1-2.4-2.6s1.1-2.6,2.4-2.6,2.4,1,2.4,2.6-1.1,2.6-2.4,2.6ZM47.7,23.1v1.8h4.3c-.1,1-.5,1.8-1,2.3-.6.6-1.6,1.3-3.3,1.3-2.7,0-4.7-2.1-4.7-4.8s2.1-4.8,4.7-4.8,2.5.6,3.3,1.3l1.3-1.3c-1.1-1-2.5-1.8-4.5-1.8-3.6,0-6.7,3-6.7,6.6s3.1,6.6,6.7,6.6,3.4-.6,4.6-1.9c1.2-1.2,1.6-2.9,1.6-4.2s0-.8,0-1.1h-6.1,0ZM93.1,24.5c-.4-1-1.4-2.7-3.6-2.7s-4,1.7-4,4.3,1.8,4.3,4.2,4.3,3.1-1.2,3.5-1.9l-1.4-1c-.5.7-1.1,1.2-2.1,1.2s-1.6-.4-2.1-1.3l5.7-2.4-.2-.5h0ZM87.3,25.9c0-1.6,1.3-2.5,2.2-2.5s1.4.4,1.6.9c0,0-3.8,1.6-3.8,1.6ZM82.6,30h1.9v-12.5h-1.9v12.5ZM79.6,22.7h0c-.4-.5-1.2-1-2.2-1-2.1,0-4.1,1.9-4.1,4.3s1.9,4.2,4.1,4.2,1.8-.5,2.2-1h0v.6c0,1.6-.9,2.5-2.3,2.5s-1.9-.8-2.1-1.5l-1.6.7c.5,1.1,1.7,2.5,3.8,2.5s4-1.3,4-4.4v-7.6h-1.8s0,.7,0,.7ZM77.4,28.6c-1.3,0-2.4-1.1-2.4-2.6s1.1-2.6,2.4-2.6,2.3,1.1,2.3,2.6-1,2.6-2.3,2.6ZM101.8,17.5h-4.5v12.5h1.9v-4.7h2.6c2.1,0,4.1-1.5,4.1-3.9s-2-3.9-4.1-3.9ZM101.9,23.5h-2.7v-4.3h2.7c1.4,0,2.2,1.2,2.2,2.1s-.8,2.1-2.2,2.1h0ZM113.4,21.7c-1.4,0-2.8.6-3.3,1.9l1.7.7c.4-.7,1-.9,1.7-.9s1.9.6,2,1.6h0c-.3,0-1.1-.4-1.9-.4-1.8,0-3.6,1-3.6,2.8s1.5,2.8,3.1,2.8,1.9-.6,2.4-1.2h0v1h1.8v-4.8c0-2.2-1.7-3.5-3.8-3.5h0ZM113.2,28.6c-.6,0-1.5-.3-1.5-1.1s1.1-1.3,2-1.3,1.2.2,1.7.4c-.1,1.2-1.1,2-2.2,2ZM123.7,22l-2.1,5.4h0l-2.2-5.4h-2l3.3,7.6-1.9,4.2h1.9l5.1-11.8h-2.1ZM106.9,30h1.9v-12.5h-1.9v12.5Z"/>
|
||||||
|
<g>
|
||||||
|
<path class="st6" d="M20.7,19.4l-10.6,11.3s0,0,0,0c.3,1.2,1.4,2.1,2.8,2.1s1-.1,1.5-.4h0s12-6.9,12-6.9l-5.6-6.1Z"/>
|
||||||
|
<path class="st4" d="M31.5,17.5h0s-5.2-3-5.2-3l-5.8,5.2,5.8,5.8,5.1-3c.9-.5,1.5-1.4,1.5-2.5s-.6-2-1.5-2.5h0Z"/>
|
||||||
|
<path class="st0" d="M10.1,9.3c0,.2,0,.5,0,.7v20c0,.3,0,.5,0,.7l11-11s-11-10.4-11-10.4Z"/>
|
||||||
|
<path class="st3" d="M20.8,20l5.5-5.5-12-6.9c-.4-.3-.9-.4-1.5-.4-1.3,0-2.5.9-2.8,2.1h0s10.7,10.7,10.7,10.7h0Z"/>
|
||||||
|
</g>
|
||||||
|
</g>
|
||||||
|
<g class="st1">
|
||||||
|
<g class="st1">
|
||||||
|
<path class="st5" d="M41.8,6.9h2c.6,0,1.2.1,1.7.4s.9.6,1.1,1.1c.3.5.4,1,.4,1.6s-.1,1.1-.4,1.6c-.3.5-.6.8-1.1,1.1s-1,.4-1.7.4h-2v-6.2ZM43.8,12.2c.7,0,1.2-.2,1.6-.6.4-.4.6-.9.6-1.6s-.2-1.2-.6-1.6c-.4-.4-.9-.6-1.6-.6h-1v4.4h1Z"/>
|
||||||
|
<path class="st5" d="M48.1,6.9h1v6.2h-1v-6.2Z"/>
|
||||||
|
<path class="st5" d="M50.9,12.8c-.4-.3-.7-.7-.9-1.3l.9-.4c0,.3.3.6.5.8s.5.3.8.3.6,0,.8-.2c.2-.2.3-.4.3-.7s0-.5-.3-.6-.5-.3-1-.5h-.4c-.4-.3-.8-.5-1.1-.8-.3-.3-.4-.6-.4-1.1s0-.6.3-.9c.2-.3.4-.5.7-.6.3-.2.6-.2,1-.2.5,0,1,.1,1.3.4s.5.6.7.9l-.9.4c0-.2-.2-.4-.4-.5-.2-.2-.4-.2-.7-.2s-.5,0-.7.2-.3.3-.3.6,0,.4.3.5c.2.1.4.3.8.4h.4c.5.3.9.6,1.2.9s.4.7.4,1.2-.1.7-.3,1c-.2.3-.5.5-.8.6-.3.1-.7.2-1,.2-.5,0-1-.2-1.4-.5Z"/>
|
||||||
|
<path class="st5" d="M55.5,6.9h2.2c.4,0,.7,0,1,.2.3.2.6.4.7.7s.3.6.3,1,0,.7-.3,1-.4.5-.7.7c-.3.2-.6.2-1,.2h-1.2v2.4h-1v-6.2ZM57.7,9.8c.2,0,.4,0,.6-.1.2,0,.3-.2.4-.4,0-.2.1-.3.1-.5s0-.3-.1-.5c0-.2-.2-.3-.4-.4-.2,0-.3-.1-.6-.1h-1.2v2h1.2Z"/>
|
||||||
|
<path class="st5" d="M61.9,12.8c-.5-.3-.9-.7-1.2-1.2-.3-.5-.4-1-.4-1.6s.1-1.1.4-1.6c.3-.5.7-.9,1.2-1.2.5-.3,1-.4,1.6-.4s1.1.1,1.6.4c.5.3.9.7,1.2,1.2.3.5.4,1,.4,1.6s-.1,1.1-.4,1.6c-.3.5-.7.9-1.2,1.2-.5.3-1,.4-1.6.4s-1.2-.1-1.6-.4ZM64.6,12c.3-.2.6-.5.8-.8.2-.4.3-.8.3-1.2s0-.9-.3-1.2-.5-.6-.8-.8-.7-.3-1.1-.3-.8,0-1.1.3c-.3.2-.6.5-.8.8s-.3.8-.3,1.2.1.9.3,1.2c.2.4.5.6.8.8.3.2.7.3,1.1.3s.8,0,1.1-.3Z"/>
|
||||||
|
<path class="st5" d="M67.9,6.9h1.2l2.8,4.5h0v-1.2c0,0,0-3.3,0-3.3h1v6.2h-1l-2.9-4.8h0v1.2c0,0,0,3.6,0,3.6h-1v-6.2Z"/>
|
||||||
|
<path class="st5" d="M74.2,6.9h1v6.2h-1v-6.2Z"/>
|
||||||
|
<path class="st5" d="M76.6,6.9h2.3c.3,0,.6,0,.9.2.3.1.5.3.7.6.2.3.3.5.3.8s0,.6-.2.8c-.2.2-.4.4-.6.5h0c.3.2.6.3.8.6s.3.6.3.9,0,.6-.3.9c-.2.3-.4.5-.7.6-.3.1-.6.2-1,.2h-2.4v-6.2ZM78.9,9.5c.3,0,.5,0,.7-.3.2-.2.3-.4.3-.6s0-.4-.2-.6c-.2-.2-.4-.3-.6-.3h-1.4v1.7h1.3ZM79,12.2c.3,0,.5,0,.7-.3.2-.2.3-.4.3-.6s0-.5-.3-.6c-.2-.2-.4-.3-.7-.3h-1.4v1.8h1.5Z"/>
|
||||||
|
<path class="st5" d="M82,6.9h1v5.3h2.7v.9h-3.6v-6.2Z"/>
|
||||||
|
<path class="st5" d="M86.7,6.9h3.8v.9h-2.8v1.7h2.5v.9h-2.5v1.7h2.8v.9h-3.8v-6.2Z"/>
|
||||||
|
<path class="st5" d="M93.9,12.8c-.4-.3-.7-.7-.9-1.3l.9-.4c0,.3.3.6.5.8.2.2.5.3.8.3s.6,0,.8-.2c.2-.2.3-.4.3-.7s0-.5-.3-.6-.5-.3-1-.5h-.4c-.4-.3-.8-.5-1.1-.8-.3-.3-.4-.6-.4-1.1s0-.6.3-.9.4-.5.7-.6.6-.2,1-.2c.5,0,1,.1,1.3.4.3.3.5.6.7.9l-.9.4c0-.2-.2-.4-.4-.5-.2-.2-.4-.2-.7-.2s-.5,0-.7.2-.3.3-.3.6,0,.4.3.5c.2.1.4.3.8.4h.4c.5.3.9.6,1.2.9s.4.7.4,1.2-.1.7-.3,1c-.2.3-.5.5-.8.6-.3.1-.7.2-1,.2-.5,0-1-.2-1.4-.5Z"/>
|
||||||
|
<path class="st5" d="M99.5,13c-.4-.2-.6-.5-.8-.9s-.3-.8-.3-1.3v-3.8h1v3.9c0,.5.1.8.4,1.1s.6.4,1,.4.8-.1,1-.4c.2-.3.4-.7.4-1.1v-3.9h1v3.8c0,.5,0,.9-.3,1.3s-.5.7-.8.9c-.4.2-.8.3-1.3.3s-.9-.1-1.2-.3Z"/>
|
||||||
|
<path class="st5" d="M104.4,6.9h2.2c.4,0,.7,0,1,.2.3.2.5.4.7.7.2.3.3.6.3,1s-.1.8-.4,1.1c-.3.3-.6.5-1,.7h0s1.7,2.5,1.7,2.5h0c0,0-1.1,0-1.1,0l-1.6-2.4h-.7v2.4h-1v-6.2ZM106.5,9.8c.3,0,.5,0,.7-.3s.3-.4.3-.7,0-.3-.1-.5c0-.2-.2-.3-.3-.4-.2,0-.3-.1-.5-.1h-1.2v2h1.2Z"/>
|
||||||
|
</g>
|
||||||
|
</g>
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 5.8 KiB |
66
note_kfet/static/img/playstore_badge_fr_preorder.svg
Normal file
@@ -0,0 +1,66 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<svg id="artwork" xmlns="http://www.w3.org/2000/svg" version="1.1" viewBox="0 0 135 40">
|
||||||
|
<!-- Generator: Adobe Illustrator 29.2.1, SVG Export Plug-In . SVG Version: 2.1.0 Build 116) -->
|
||||||
|
<defs>
|
||||||
|
<style>
|
||||||
|
.st0 {
|
||||||
|
fill: #4285f4;
|
||||||
|
}
|
||||||
|
|
||||||
|
.st1 {
|
||||||
|
isolation: isolate;
|
||||||
|
}
|
||||||
|
|
||||||
|
.st2 {
|
||||||
|
fill: #a6a6a6;
|
||||||
|
}
|
||||||
|
|
||||||
|
.st3 {
|
||||||
|
fill: #34a853;
|
||||||
|
}
|
||||||
|
|
||||||
|
.st4 {
|
||||||
|
fill: #fbbc04;
|
||||||
|
}
|
||||||
|
|
||||||
|
.st5 {
|
||||||
|
fill: #fff;
|
||||||
|
}
|
||||||
|
|
||||||
|
.st6 {
|
||||||
|
fill: #ea4335;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</defs>
|
||||||
|
<g>
|
||||||
|
<rect width="135" height="40" rx="5" ry="5"/>
|
||||||
|
<path class="st2" d="M130,.8c2.3,0,4.2,1.9,4.2,4.2v30c0,2.3-1.9,4.2-4.2,4.2H5c-2.3,0-4.2-1.9-4.2-4.2V5c0-2.3,1.9-4.2,4.2-4.2h125M130,0H5C2.2,0,0,2.2,0,5v30c0,2.8,2.2,5,5,5h125c2.8,0,5-2.2,5-5V5c0-2.8-2.2-5-5-5h0Z"/>
|
||||||
|
<path class="st5" d="M68.1,21.8c-2.4,0-4.3,1.8-4.3,4.3s1.9,4.3,4.3,4.3,4.3-1.8,4.3-4.3-1.9-4.3-4.3-4.3ZM68.1,28.6c-1.3,0-2.4-1.1-2.4-2.6s1.1-2.6,2.4-2.6,2.4,1,2.4,2.6-1.1,2.6-2.4,2.6ZM58.8,21.8c-2.4,0-4.3,1.8-4.3,4.3s1.9,4.3,4.3,4.3,4.3-1.8,4.3-4.3-1.9-4.3-4.3-4.3ZM58.8,28.6c-1.3,0-2.4-1.1-2.4-2.6s1.1-2.6,2.4-2.6,2.4,1,2.4,2.6-1.1,2.6-2.4,2.6ZM47.7,23.1v1.8h4.3c-.1,1-.5,1.8-1,2.3-.6.6-1.6,1.3-3.3,1.3-2.7,0-4.7-2.1-4.7-4.8s2.1-4.8,4.7-4.8,2.5.6,3.3,1.3l1.3-1.3c-1.1-1-2.5-1.8-4.5-1.8-3.6,0-6.7,3-6.7,6.6s3.1,6.6,6.7,6.6,3.4-.6,4.6-1.9c1.2-1.2,1.6-2.9,1.6-4.2s0-.8,0-1.1h-6.1,0ZM93.1,24.5c-.4-1-1.4-2.7-3.6-2.7s-4,1.7-4,4.3,1.8,4.3,4.2,4.3,3.1-1.2,3.5-1.9l-1.4-1c-.5.7-1.1,1.2-2.1,1.2s-1.6-.4-2.1-1.3l5.7-2.4-.2-.5h0ZM87.3,25.9c0-1.6,1.3-2.5,2.2-2.5s1.4.4,1.6.9c0,0-3.8,1.6-3.8,1.6ZM82.6,30h1.9v-12.5h-1.9v12.5ZM79.6,22.7h0c-.4-.5-1.2-1-2.2-1-2.1,0-4.1,1.9-4.1,4.3s1.9,4.2,4.1,4.2,1.8-.5,2.2-1h0v.6c0,1.6-.9,2.5-2.3,2.5s-1.9-.8-2.1-1.5l-1.6.7c.5,1.1,1.7,2.5,3.8,2.5s4-1.3,4-4.4v-7.6h-1.8s0,.7,0,.7ZM77.4,28.6c-1.3,0-2.4-1.1-2.4-2.6s1.1-2.6,2.4-2.6,2.3,1.1,2.3,2.6-1,2.6-2.3,2.6ZM101.8,17.5h-4.5v12.5h1.9v-4.7h2.6c2.1,0,4.1-1.5,4.1-3.9s-2-3.9-4.1-3.9ZM101.9,23.5h-2.7v-4.3h2.7c1.4,0,2.2,1.2,2.2,2.1s-.8,2.1-2.2,2.1h0ZM113.4,21.7c-1.4,0-2.8.6-3.3,1.9l1.7.7c.4-.7,1-.9,1.7-.9s1.9.6,2,1.6h0c-.3,0-1.1-.4-1.9-.4-1.8,0-3.6,1-3.6,2.8s1.5,2.8,3.1,2.8,1.9-.6,2.4-1.2h0v1h1.8v-4.8c0-2.2-1.7-3.5-3.8-3.5h0ZM113.2,28.6c-.6,0-1.5-.3-1.5-1.1s1.1-1.3,2-1.3,1.2.2,1.7.4c-.1,1.2-1.1,2-2.2,2ZM123.7,22l-2.1,5.4h0l-2.2-5.4h-2l3.3,7.6-1.9,4.2h1.9l5.1-11.8h-2.1ZM106.9,30h1.9v-12.5h-1.9v12.5Z"/>
|
||||||
|
<g>
|
||||||
|
<path class="st6" d="M20.7,19.4l-10.6,11.3s0,0,0,0c.3,1.2,1.4,2.1,2.8,2.1s1-.1,1.5-.4h0s12-6.9,12-6.9l-5.6-6.1Z"/>
|
||||||
|
<path class="st4" d="M31.5,17.5h0s-5.2-3-5.2-3l-5.8,5.2,5.8,5.8,5.1-3c.9-.5,1.5-1.4,1.5-2.5s-.6-2-1.5-2.5h0Z"/>
|
||||||
|
<path class="st0" d="M10.1,9.3c0,.2,0,.5,0,.7v20c0,.3,0,.5,0,.7l11-11s-11-10.4-11-10.4Z"/>
|
||||||
|
<path class="st3" d="M20.8,20l5.5-5.5-12-6.9c-.4-.3-.9-.4-1.5-.4-1.3,0-2.5.9-2.8,2.1h0s10.7,10.7,10.7,10.7h0Z"/>
|
||||||
|
</g>
|
||||||
|
</g>
|
||||||
|
<g class="st1">
|
||||||
|
<g class="st1">
|
||||||
|
<path class="st5" d="M42.1,12.8c-.4-.3-.6-.7-.8-1.2l.8-.3c0,.3.2.6.5.8.2.2.5.3.8.3s.5,0,.7-.2c.2-.1.3-.3.3-.6s0-.4-.3-.6c-.2-.2-.5-.3-.9-.5h-.4c-.4-.3-.7-.5-1-.7-.3-.3-.4-.6-.4-1s0-.5.2-.8c.2-.2.4-.4.6-.6.3-.1.6-.2.9-.2.5,0,.9.1,1.2.4.3.2.5.5.6.8l-.8.3c0-.2-.2-.3-.3-.5s-.4-.2-.6-.2-.5,0-.7.2c-.2.1-.3.3-.3.5s0,.4.2.5c.2.1.4.3.8.4h.4c.5.3.9.5,1.1.8.3.3.4.6.4,1.1s0,.7-.3.9c-.2.3-.4.4-.7.6-.3.1-.6.2-.9.2-.5,0-.9-.1-1.3-.4Z"/>
|
||||||
|
<path class="st5" d="M46.4,7.4h3.5v.9h-2.6v1.6h2.3v.8h-2.3v1.6h2.6v.9h-3.5v-5.7Z"/>
|
||||||
|
<path class="st5" d="M52.8,7.4h2c.3,0,.6,0,.9.2.3.1.5.4.7.6s.3.6.3.9,0,.6-.3.9-.4.5-.7.6c-.3.1-.6.2-.9.2h-1.1v2.2h-.9v-5.7ZM54.8,10.1c.2,0,.4,0,.5-.1s.3-.2.3-.3.1-.3.1-.4,0-.3-.1-.4-.2-.2-.3-.3c-.1,0-.3-.1-.5-.1h-1.1v1.8h1.1Z"/>
|
||||||
|
<path class="st5" d="M57.6,7.4h2c.3,0,.7,0,.9.2s.5.4.7.6.2.6.2.9-.1.7-.4,1-.6.5-.9.6h0s1.6,2.3,1.6,2.3h0s-1,0-1,0l-1.5-2.2h-.7v2.2h-.9v-5.7ZM59.6,10.1c.3,0,.5,0,.7-.3.2-.2.3-.4.3-.7s0-.3-.1-.4-.2-.3-.3-.3-.3-.1-.5-.1h-1.1v1.8h1.1Z"/>
|
||||||
|
<path class="st5" d="M62.5,7.4h3.5v.9h-2.6v1.6h2.3v.8h-2.3v1.6h2.6v.9h-3.5v-5.7ZM64.2,5.9h1l-.6,1.1h-.7l.4-1.1Z"/>
|
||||||
|
<path class="st5" d="M67.1,7.4h.9v5.7h-.9v-5.7Z"/>
|
||||||
|
<path class="st5" d="M69.3,7.4h1.1l2.6,4.2h0v-1.1s0-3.1,0-3.1h.9v5.7h-.9l-2.7-4.4h0v1.1s0,3.3,0,3.3h-.9v-5.7Z"/>
|
||||||
|
<path class="st5" d="M75.5,12.8c-.4-.3-.6-.7-.8-1.2l.8-.3c0,.3.2.6.5.8.2.2.5.3.8.3s.5,0,.7-.2c.2-.1.3-.3.3-.6s0-.4-.3-.6c-.2-.2-.5-.3-.9-.5h-.4c-.4-.3-.7-.5-1-.7s-.4-.6-.4-1,0-.5.2-.8c.2-.2.4-.4.6-.6.3-.1.6-.2.9-.2.5,0,.9.1,1.2.4.3.2.5.5.6.8l-.8.3c0-.2-.2-.3-.3-.5-.2-.1-.4-.2-.6-.2s-.5,0-.7.2c-.2.1-.3.3-.3.5s0,.4.2.5.4.3.8.4h.4c.5.3.9.5,1.1.8.3.3.4.6.4,1.1s0,.7-.3.9c-.2.3-.4.4-.7.6-.3.1-.6.2-.9.2-.5,0-.9-.1-1.3-.4Z"/>
|
||||||
|
<path class="st5" d="M80.9,12.9c-.5-.3-.8-.6-1.1-1.1s-.4-1-.4-1.5.1-1.1.4-1.5.6-.8,1.1-1.1,1-.4,1.5-.4.8,0,1.2.2c.4.2.7.4.9.7l-.6.6c-.2-.2-.4-.4-.7-.5-.2-.1-.5-.2-.8-.2s-.7,0-1.1.3c-.3.2-.6.4-.8.7-.2.3-.3.7-.3,1.1s0,.8.3,1.1c.2.3.4.6.8.7s.7.3,1.1.3c.6,0,1.2-.3,1.6-.8l.6.6c-.3.3-.6.6-1,.8-.4.2-.8.3-1.3.3s-1.1-.1-1.5-.4Z"/>
|
||||||
|
<path class="st5" d="M85.7,7.4h2c.3,0,.7,0,.9.2.3.1.5.4.7.6.2.3.2.6.2.9s-.1.7-.4,1-.6.5-.9.6h0s1.6,2.3,1.6,2.3h0s-1,0-1,0l-1.5-2.2h-.7v2.2h-.9v-5.7ZM87.7,10.1c.3,0,.5,0,.7-.3.2-.2.3-.4.3-.7s0-.3-.1-.4c0-.1-.2-.3-.3-.3s-.3-.1-.5-.1h-1.1v1.8h1.1Z"/>
|
||||||
|
<path class="st5" d="M90.6,7.4h.9v5.7h-.9v-5.7Z"/>
|
||||||
|
<path class="st5" d="M92.8,7.4h2c.3,0,.7,0,.9.2.3.1.5.4.7.6.2.3.2.6.2.9s-.1.7-.4,1-.6.5-.9.6h0s1.6,2.3,1.6,2.3h0s-1,0-1,0l-1.5-2.2h-.7v2.2h-.9v-5.7ZM94.8,10.1c.3,0,.5,0,.7-.3s.3-.4.3-.7,0-.3-.1-.4c0-.1-.2-.3-.3-.3s-.3-.1-.5-.1h-1.1v1.8h1.1Z"/>
|
||||||
|
<path class="st5" d="M97.7,7.4h3.5v.9h-2.6v1.6h2.3v.8h-2.3v1.6h2.6v.9h-3.5v-5.7Z"/>
|
||||||
|
<path class="st5" d="M104.3,12.8c-.4-.3-.6-.7-.8-1.2l.8-.3c0,.3.2.6.5.8.2.2.5.3.8.3s.5,0,.7-.2c.2-.1.3-.3.3-.6s0-.4-.3-.6c-.2-.2-.5-.3-.9-.5h-.4c-.4-.3-.7-.5-1-.7s-.4-.6-.4-1,0-.5.2-.8c.2-.2.4-.4.6-.6.3-.1.6-.2.9-.2.5,0,.9.1,1.2.4.3.2.5.5.6.8l-.8.3c0-.2-.2-.3-.3-.5-.2-.1-.4-.2-.6-.2s-.5,0-.7.2c-.2.1-.3.3-.3.5s0,.4.2.5.4.3.8.4h.4c.5.3.9.5,1.1.8.3.3.4.6.4,1.1s0,.7-.3.9c-.2.3-.4.4-.7.6-.3.1-.6.2-.9.2-.5,0-.9-.1-1.3-.4Z"/>
|
||||||
|
<path class="st5" d="M109.5,13c-.3-.2-.6-.5-.8-.8-.2-.4-.3-.8-.3-1.2v-3.5h.9v3.6c0,.4.1.8.3,1,.2.3.5.4.9.4s.7-.1.9-.4c.2-.3.3-.6.3-1v-3.6h.9v3.5c0,.5,0,.9-.3,1.2-.2.4-.4.6-.8.8-.3.2-.7.3-1.2.3s-.8,0-1.1-.3Z"/>
|
||||||
|
<path class="st5" d="M114,7.4h2c.3,0,.7,0,.9.2.3.1.5.4.7.6.2.3.2.6.2.9s-.1.7-.4,1-.6.5-.9.6h0s1.6,2.3,1.6,2.3h0s-1,0-1,0l-1.5-2.2h-.7v2.2h-.9v-5.7ZM116,10.1c.3,0,.5,0,.7-.3s.3-.4.3-.7,0-.3-.1-.4c0-.1-.2-.3-.3-.3s-.3-.1-.5-.1h-1.1v1.8h1.1Z"/>
|
||||||
|
</g>
|
||||||
|
</g>
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 6.4 KiB |
@@ -30,6 +30,8 @@ SPDX-License-Identifier: GPL-3.0-or-later
|
|||||||
<link rel="stylesheet" href="{% static "font-awesome/css/font-awesome.min.css" %}">
|
<link rel="stylesheet" href="{% static "font-awesome/css/font-awesome.min.css" %}">
|
||||||
<link rel="stylesheet" href="{% static "css/custom.css" %}">
|
<link rel="stylesheet" href="{% static "css/custom.css" %}">
|
||||||
|
|
||||||
|
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/intl-tel-input@25.5.2/build/css/intlTelInput.css">
|
||||||
|
|
||||||
{# JQuery, Bootstrap and Turbolinks JavaScript #}
|
{# JQuery, Bootstrap and Turbolinks JavaScript #}
|
||||||
<script src="{% static "jquery/jquery.min.js" %}"></script>
|
<script src="{% static "jquery/jquery.min.js" %}"></script>
|
||||||
<script src="{% static "popper.js/umd/popper.min.js" %}"></script>
|
<script src="{% static "popper.js/umd/popper.min.js" %}"></script>
|
||||||
@@ -41,6 +43,8 @@ SPDX-License-Identifier: GPL-3.0-or-later
|
|||||||
{# Translation in javascript files #}
|
{# Translation in javascript files #}
|
||||||
<script src="{% static "js/jsi18n/"|add:LANGUAGE_CODE|add:".js" %}"></script>
|
<script src="{% static "js/jsi18n/"|add:LANGUAGE_CODE|add:".js" %}"></script>
|
||||||
|
|
||||||
|
<script src="https://cdn.jsdelivr.net/npm/intl-tel-input@25.5.2/build/js/intlTelInput.min.js"></script>
|
||||||
|
|
||||||
{# If extra ressources are needed for a form, load here #}
|
{# If extra ressources are needed for a form, load here #}
|
||||||
{% if form.media %}
|
{% if form.media %}
|
||||||
{{ form.media }}
|
{{ form.media }}
|
||||||
@@ -79,6 +83,13 @@ SPDX-License-Identifier: GPL-3.0-or-later
|
|||||||
<a class="nav-link {% if request.path_info == url %}active{% endif %}" href="{{ url }}"><i class="fa fa-exchange"></i> {% trans 'Transfer' %}</a>
|
<a class="nav-link {% if request.path_info == url %}active{% endif %}" href="{{ url }}"><i class="fa fa-exchange"></i> {% trans 'Transfer' %}</a>
|
||||||
</li>
|
</li>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
{% if user.is_authenticated %}
|
||||||
|
<li class="nav-item">
|
||||||
|
{% url 'family:family_list' as url %}
|
||||||
|
<a class="nav-link {% if request.path_info == url %}active{% endif %}" href="{{ url }}"><i class="fa fa-home"></i> {% trans 'Families' %}</a>
|
||||||
|
</li>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
{% if "auth.user"|model_list_length >= 2 %}
|
{% if "auth.user"|model_list_length >= 2 %}
|
||||||
<li class="nav-item">
|
<li class="nav-item">
|
||||||
{% url 'member:user_list' as url %}
|
{% url 'member:user_list' as url %}
|
||||||
|
|||||||
@@ -39,6 +39,23 @@ SPDX-License-Identifier: GPL-2.0-or-later
|
|||||||
<a href="{% url 'password_reset' %}"
|
<a href="{% url 'password_reset' %}"
|
||||||
class="badge badge-light">{% trans 'Forgotten your password or username?' %}</a>
|
class="badge badge-light">{% trans 'Forgotten your password or username?' %}</a>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
|
<div class="text-center mt-4">
|
||||||
|
{% now "Ymd" as current_date_str %}
|
||||||
|
|
||||||
|
{% if display_appstore_badge %}
|
||||||
|
<a href="https://apps.apple.com/fr/app/la-note-kfet/id6754661723" class="d-inline-block mx-1" aria-label="{% trans 'Download on the AppStore' %}" style="cursor: pointer;">
|
||||||
|
<img src="{% static 'img/' %}{% if current_date_str < '20260201' %}appstore_badge_fr_preorder.svg{% else %}appstore_badge_fr.svg{% endif %}"
|
||||||
|
alt="{% trans 'Download on the AppStore' %}" style="height: 50px;">
|
||||||
|
</a>
|
||||||
|
{% endif %}
|
||||||
|
{% if display_playstore_badge %}
|
||||||
|
<a href="https://play.google.com/store/apps/details?id=org.crans.bde.note&hl=fr" class="d-inline-block mx-1" aria-label="{% trans 'Get it on Google Play' %}" style="cursor: pointer;">
|
||||||
|
<img src="{% static 'img/' %}{% if current_date_str < '20260201' %}playstore_badge_fr_preorder.svg{% else %}playstore_badge_fr.svg{% endif %}"
|
||||||
|
alt="{% trans 'Get it on Google Play' %}" style="height: 50px;">
|
||||||
|
</a>
|
||||||
|
{% endif %}
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
@@ -19,7 +19,7 @@ SPDX-License-Identifier: GPL-3.0-or-later
|
|||||||
{% endblocktrans %}
|
{% endblocktrans %}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<form method="post">
|
<form method="post" id="profile_form">
|
||||||
{% csrf_token %}
|
{% csrf_token %}
|
||||||
{{ form|crispy }}
|
{{ form|crispy }}
|
||||||
{{ profile_form|crispy }}
|
{{ profile_form|crispy }}
|
||||||
@@ -31,3 +31,45 @@ SPDX-License-Identifier: GPL-3.0-or-later
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
|
{% block extrajavascript %}
|
||||||
|
<!-- intl-tel-input CSS/JS -->
|
||||||
|
<script>
|
||||||
|
(() => {
|
||||||
|
const input = document.querySelector("input[name='phone_number']");
|
||||||
|
const form = document.querySelector("#profile_form");
|
||||||
|
|
||||||
|
if (!input || !form || input.type === "hidden" || input.disabled || input.readOnly) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const iti = window.intlTelInput(input, {
|
||||||
|
initialCountry: "auto",
|
||||||
|
nationalMode: false,
|
||||||
|
autoPlaceholder: "off",
|
||||||
|
geoIpLookup: callback => {
|
||||||
|
fetch("https://ipapi.co/json")
|
||||||
|
.then(res => res.json())
|
||||||
|
.then(data => callback(data.country_code))
|
||||||
|
.catch(() => callback("fr"));
|
||||||
|
},
|
||||||
|
loadUtils: () => import("https://cdn.jsdelivr.net/npm/intl-tel-input@25.5.2/build/js/utils.js"),
|
||||||
|
});
|
||||||
|
|
||||||
|
form.addEventListener("submit", function(e){
|
||||||
|
if (!input.value.trim()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const number = iti.getNumber(intlTelInput.utils.numberFormat.E164);
|
||||||
|
if (number) {
|
||||||
|
input.value = number;
|
||||||
|
form.submit();
|
||||||
|
} else {
|
||||||
|
e.preventDefault();
|
||||||
|
input.focus();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
})();
|
||||||
|
</script>
|
||||||
|
{% endblock %}
|
||||||
@@ -21,8 +21,9 @@ urlpatterns = [
|
|||||||
path('activity/', include('activity.urls')),
|
path('activity/', include('activity.urls')),
|
||||||
path('treasury/', include('treasury.urls')),
|
path('treasury/', include('treasury.urls')),
|
||||||
path('wei/', include('wei.urls')),
|
path('wei/', include('wei.urls')),
|
||||||
path('food/',include('food.urls')),
|
path('food/', include('food.urls')),
|
||||||
path('wrapped/',include('wrapped.urls')),
|
path('wrapped/', include('wrapped.urls')),
|
||||||
|
path('family/', include('family.urls')),
|
||||||
|
|
||||||
# Include Django Contrib and Core routers
|
# Include Django Contrib and Core routers
|
||||||
path('i18n/', include('django.conf.urls.i18n')),
|
path('i18n/', include('django.conf.urls.i18n')),
|
||||||
|
|||||||
@@ -12,10 +12,11 @@ django-filter~=25.1
|
|||||||
django-mailer~=2.3.2
|
django-mailer~=2.3.2
|
||||||
django-oauth-toolkit~=3.0.1
|
django-oauth-toolkit~=3.0.1
|
||||||
django-phonenumber-field~=8.1.0
|
django-phonenumber-field~=8.1.0
|
||||||
django-polymorphic~=3.1.0
|
django-polymorphic~=4.1.0
|
||||||
djangorestframework~=3.16.0
|
djangorestframework~=3.16.0
|
||||||
django-rest-polymorphic~=0.1.10
|
django-rest-polymorphic~=0.1.10
|
||||||
django-tables2~=2.7.5
|
django-tables2~=2.7.5
|
||||||
python-memcached~=1.62
|
python-memcached~=1.62
|
||||||
phonenumbers~=9.0.8
|
phonenumbers~=9.0.8
|
||||||
|
tablib~=3.8.0
|
||||||
Pillow>=11.3.0
|
Pillow>=11.3.0
|
||||||
|
|||||||