mirror of
https://gitlab.crans.org/bde/nk20
synced 2025-08-03 06:03:58 +02:00
Compare commits
17 Commits
wei
...
f6ee7481f0
Author | SHA1 | Date | |
---|---|---|---|
|
f6ee7481f0 | ||
|
3b7f8b87c4 | ||
|
0992a8a7ee | ||
|
12477b33cb | ||
|
8c3ae338ea | ||
|
4975c1ab6f | ||
|
61999a31a5 | ||
|
b217f7ceec | ||
|
03c1bb41b6 | ||
|
f03c13a4b8 | ||
|
e6f3084588 | ||
|
145e55da75 | ||
|
d3ba95cdca | ||
|
8ffb0ebb56 | ||
|
5038af9e34 | ||
|
819b4214c9 | ||
|
b8a93b0b75 |
@@ -32,7 +32,7 @@ class ActivityForm(forms.ModelForm):
|
||||
def clean_organizer(self):
|
||||
organizer = self.cleaned_data['organizer']
|
||||
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
|
||||
|
||||
def clean_date_end(self):
|
||||
|
@@ -38,6 +38,7 @@ SPDX-License-Identifier: GPL-3.0-or-later
|
||||
</a>
|
||||
|
||||
<input id="alias" type="text" class="form-control" placeholder="Nom/note ...">
|
||||
<button id="trigger" class="btn btn-secondary">Click me !</button>
|
||||
|
||||
<hr>
|
||||
|
||||
@@ -63,15 +64,46 @@ SPDX-License-Identifier: GPL-3.0-or-later
|
||||
refreshBalance();
|
||||
}
|
||||
|
||||
function process_qrcode() {
|
||||
let name = alias_obj.val();
|
||||
$.get("/api/note/note?search=" + name + "&format=json").done(
|
||||
function (res) {
|
||||
let note = res.results[0];
|
||||
$.post("/api/activity/entry/?format=json", {
|
||||
csrfmiddlewaretoken: CSRF_TOKEN,
|
||||
activity: {{ activity.id }},
|
||||
note: note.id,
|
||||
guest: null
|
||||
}).done(function () {
|
||||
addMsg(interpolate(gettext(
|
||||
"Entry made for %s whose balance is %s €"),
|
||||
[note.name, note.balance / 100]), "success", 4000);
|
||||
reloadTable(true);
|
||||
}).fail(function (xhr) {
|
||||
errMsg(xhr.responseJSON, 4000);
|
||||
});
|
||||
}).fail(function (xhr) {
|
||||
errMsg(xhr.responseJSON, 4000);
|
||||
});
|
||||
}
|
||||
|
||||
alias_obj.keyup(function(event) {
|
||||
let code = event.originalEvent.keyCode
|
||||
if (65 <= code <= 122 || code === 13) {
|
||||
debounce(reloadTable)()
|
||||
}
|
||||
if (code === 0)
|
||||
process_qrcode();
|
||||
});
|
||||
|
||||
$(document).ready(init);
|
||||
|
||||
alias_obj2 = document.getElementById("alias");
|
||||
$("#trigger").click(function (e) {
|
||||
addMsg("Clicked", "success", 1000);
|
||||
alias_obj.val(alias_obj.val() + "\0");
|
||||
alias_obj2.dispatchEvent(new KeyboardEvent('keyup'));
|
||||
})
|
||||
function init() {
|
||||
$(".table-row").click(function (e) {
|
||||
let target = e.target.parentElement;
|
||||
@@ -168,4 +200,4 @@ SPDX-License-Identifier: GPL-3.0-or-later
|
||||
});
|
||||
}
|
||||
</script>
|
||||
{% endblock %}
|
||||
{% endblock %}
|
||||
|
@@ -1,18 +0,0 @@
|
||||
# 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'),
|
||||
),
|
||||
]
|
@@ -60,7 +60,10 @@
|
||||
{% if user_object.pk == user.pk %}
|
||||
<div class="text-center">
|
||||
<a class="small badge badge-secondary" href="{% url 'member:auth_token' %}">
|
||||
<i class="fa fa-cogs"></i>{% trans 'API token' %}
|
||||
<i class="fa fa-cogs"></i> {% trans 'API token' %}
|
||||
</a>
|
||||
<a class="small badge badge-secondary" href="{% url 'member:qr_code' user_object.pk %}">
|
||||
<i class="fa fa-qrcode"></i> {% trans 'QR Code' %}
|
||||
</a>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
36
apps/member/templates/member/qr_code.html
Normal file
36
apps/member/templates/member/qr_code.html
Normal file
@@ -0,0 +1,36 @@
|
||||
{% extends "base.html" %}
|
||||
{% comment %}
|
||||
SPDX-License-Identifier: GPL-3.0-or-later
|
||||
{% endcomment %}
|
||||
{% load i18n %}
|
||||
|
||||
{% block content %}
|
||||
<div class="card bg-light">
|
||||
<h3 class="card-header text-center">
|
||||
{% trans "QR Code for" %} {{ user_object.username }} ({{ user_object.first_name }} {{user_object.last_name }})
|
||||
</h3>
|
||||
<div class="text-center" id="qrcode">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
{% endblock %}
|
||||
|
||||
{% block extrajavascript %}
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/qrcodejs/1.0.0/qrcode.min.js" integrity="sha512-CNgIRecGo7nphbeZ04Sc13ka07paqdeTu0WR1IM4kNcpmBAUSHSQX0FslNhTDadL4O5SAGapGt4FodqL8My0mA==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
|
||||
<script>
|
||||
var qrc = new QRCode(document.getElementById("qrcode"), {
|
||||
text: "{{ user_object.pk }}\0",
|
||||
width: 1024,
|
||||
height: 1024
|
||||
});
|
||||
</script>
|
||||
{% endblock %}
|
||||
|
||||
{% block extracss %}
|
||||
<style>
|
||||
img {
|
||||
width: 100%
|
||||
}
|
||||
</style>
|
||||
{% endblock %}
|
@@ -25,4 +25,5 @@ urlpatterns = [
|
||||
path('user/<int:pk>/aliases/', views.ProfileAliasView.as_view(), name="user_alias"),
|
||||
path('user/<int:pk>/trust', views.ProfileTrustView.as_view(), name="user_trust"),
|
||||
path('manage-auth-token/', views.ManageAuthTokens.as_view(), name='auth_token'),
|
||||
path('user/<int:pk>/qr_code/', views.QRCodeView.as_view(), name='qr_code'),
|
||||
]
|
||||
|
@@ -402,6 +402,14 @@ class ManageAuthTokens(LoginRequiredMixin, TemplateView):
|
||||
context['token'] = Token.objects.get_or_create(user=self.request.user)[0]
|
||||
return context
|
||||
|
||||
class QRCodeView(LoginRequiredMixin, DetailView):
|
||||
"""
|
||||
Affiche le QR Code
|
||||
"""
|
||||
model = User
|
||||
context_object_name = "user_object"
|
||||
template_name = "member/qr_code.html"
|
||||
extra_context = {"title": _("QR Code")}
|
||||
|
||||
# ******************************* #
|
||||
# CLUB #
|
||||
|
@@ -1391,12 +1391,12 @@
|
||||
"wei",
|
||||
"weiregistration"
|
||||
],
|
||||
"query": "[\"AND\", {\"wei\": [\"club\"], \"wei__membership_end__gte\": [\"today\"]}, {\"deposit_type\": \"note\"}]",
|
||||
"query": "{\"wei\": [\"club\"], \"wei__membership_end__gte\": [\"today\"]}",
|
||||
"type": "change",
|
||||
"mask": 2,
|
||||
"field": "deposit_given",
|
||||
"field": "caution_check",
|
||||
"permanent": false,
|
||||
"description": "Autoriser une transaction de caution WEI"
|
||||
"description": "Dire si un chèque de caution est donné pour une inscription WEI"
|
||||
}
|
||||
},
|
||||
{
|
||||
@@ -4366,70 +4366,6 @@
|
||||
"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.role",
|
||||
"pk": 1,
|
||||
@@ -4524,8 +4460,7 @@
|
||||
159,
|
||||
160,
|
||||
212,
|
||||
222,
|
||||
297
|
||||
222
|
||||
]
|
||||
}
|
||||
},
|
||||
@@ -4712,10 +4647,7 @@
|
||||
176,
|
||||
177,
|
||||
178,
|
||||
183,
|
||||
294,
|
||||
295,
|
||||
296
|
||||
183
|
||||
]
|
||||
}
|
||||
},
|
||||
|
@@ -353,11 +353,13 @@ class SogeCredit(models.Model):
|
||||
def amount(self):
|
||||
if self.valid:
|
||||
return self.credit_transaction.total
|
||||
amount = 0
|
||||
transactions_wei = self.transactions.filter(membership__club__weiclub__isnull=False)
|
||||
amount += sum(max(transaction.total - transaction.membership.club.weiclub.fee_soge_credit, 0) for transaction in transactions_wei)
|
||||
transactions_not_wei = self.transactions.filter(membership__club__weiclub__isnull=True)
|
||||
amount += sum(transaction.total for transaction in transactions_not_wei)
|
||||
amount = sum(max(transaction.total - 2000, 0) for transaction in self.transactions.all())
|
||||
if 'wei' in settings.INSTALLED_APPS:
|
||||
from wei.models import WEIMembership
|
||||
if not WEIMembership.objects\
|
||||
.filter(club__weiclub__year=self.credit_transaction.created_at.year, user=self.user).exists():
|
||||
# 80 € for people that don't go to WEI
|
||||
amount += 8000
|
||||
return amount
|
||||
|
||||
def update_transactions(self):
|
||||
@@ -439,7 +441,7 @@ class SogeCredit(models.Model):
|
||||
With Great Power Comes Great Responsibility...
|
||||
"""
|
||||
|
||||
total_fee = self.amount
|
||||
total_fee = sum(max(transaction.total - 2000, 0) for transaction in self.transactions.all() if not transaction.valid)
|
||||
if self.user.note.balance < total_fee:
|
||||
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."))
|
||||
|
@@ -77,7 +77,7 @@ class WEIRegistrationViewSet(ReadProtectedModelViewSet):
|
||||
filter_backends = [DjangoFilterBackend, RegexSafeSearchFilter]
|
||||
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',
|
||||
'wei__email', 'wei__year', 'soge_credit', 'deposit_given', 'birth_date', 'gender',
|
||||
'wei__email', 'wei__year', 'soge_credit', 'deposit_check', 'birth_date', 'gender',
|
||||
'clothing_cut', 'clothing_size', 'first_year', 'emergency_contact_name',
|
||||
'emergency_contact_phone', ]
|
||||
search_fields = ['$user__username', '$user__first_name', '$user__last_name', '$user__email',
|
||||
|
@@ -44,7 +44,7 @@ class WEIRegistrationForm(forms.ModelForm):
|
||||
fields = [
|
||||
'user', 'soge_credit', 'birth_date', 'gender', 'clothing_size',
|
||||
'health_issues', 'emergency_contact_name', 'emergency_contact_phone',
|
||||
'first_year', 'information_json', 'deposit_given', 'deposit_type'
|
||||
'first_year', 'information_json', 'deposit_check', 'deposit_type'
|
||||
]
|
||||
widgets = {
|
||||
"user": Autocomplete(
|
||||
@@ -59,8 +59,8 @@ class WEIRegistrationForm(forms.ModelForm):
|
||||
'minDate': '1900-01-01',
|
||||
'maxDate': '2100-01-01'
|
||||
}),
|
||||
"deposit_given": forms.CheckboxInput(
|
||||
attrs={'class': 'form-check-input'},
|
||||
"deposit_check": forms.BooleanField(
|
||||
required=False,
|
||||
),
|
||||
"deposit_type": forms.RadioSelect(),
|
||||
}
|
||||
@@ -69,7 +69,7 @@ class WEIRegistrationForm(forms.ModelForm):
|
||||
class WEIChooseBusForm(forms.Form):
|
||||
bus = forms.ModelMultipleChoiceField(
|
||||
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,"
|
||||
+ " in particular if you are a free eletron."),
|
||||
widget=CheckboxSelectMultiple(),
|
||||
@@ -161,7 +161,7 @@ class WEIMembership1AForm(WEIMembershipForm):
|
||||
"""
|
||||
Used to confirm registrations of first year members without choosing a bus now.
|
||||
"""
|
||||
deposit_given = None
|
||||
deposit_check = None
|
||||
roles = None
|
||||
|
||||
def clean(self):
|
||||
|
@@ -365,7 +365,7 @@ class WEISurvey2025(WEISurvey):
|
||||
return sum([cls.get_algorithm_class().get_bus_information(bus).scores[word] for bus in buses]) / buses.count()
|
||||
|
||||
@lru_cache()
|
||||
def score_questions(self, bus):
|
||||
def score(self, bus):
|
||||
"""
|
||||
The score given by the answers to the questions
|
||||
"""
|
||||
@@ -386,12 +386,12 @@ class WEISurvey2025(WEISurvey):
|
||||
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.
|
||||
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, 1 + NB_WORDS)) / self.get_algorithm_class().get_buses().count()
|
||||
- self.word_mean(getattr(self.information, 'word' + str(i))) for i in range(1, 1 + NB_WORDS))
|
||||
return s
|
||||
|
||||
@lru_cache()
|
||||
def scores_per_bus(self):
|
||||
return {bus: (self.score_questions(bus), self.score_words(bus)) for bus in self.get_algorithm_class().get_buses()}
|
||||
return {bus: (self.score(bus), self.score_words(bus)) for bus in self.get_algorithm_class().get_buses()}
|
||||
|
||||
@lru_cache()
|
||||
def ordered_buses(self):
|
||||
@@ -399,7 +399,8 @@ class WEISurvey2025(WEISurvey):
|
||||
Force the choice of bus to be in the 3 preferred buses according to the words
|
||||
"""
|
||||
values = list(self.scores_per_bus().items())
|
||||
values.sort(key=lambda item: -item[1][0])
|
||||
values.sort(key=lambda item: -item[1][1])
|
||||
values = values[:3]
|
||||
return values
|
||||
|
||||
@classmethod
|
||||
@@ -508,17 +509,17 @@ class WEISurveyAlgorithm2025(WEISurveyAlgorithm):
|
||||
else:
|
||||
# Current bus has not enough places. Remove the least preferred student from the bus if existing
|
||||
least_preferred_survey = None
|
||||
least_score = -1
|
||||
least_scores = (-1, -1)
|
||||
# Find the least student in the bus that has a lower score than the current student
|
||||
for survey2 in surveys:
|
||||
if not survey2.information.valid or survey2.information.get_selected_bus() != bus:
|
||||
continue
|
||||
score2 = survey2.score_questions(bus)
|
||||
if current_scores[1] <= score2: # Ignore better students
|
||||
scores2 = survey2.score(bus), survey2.score_words(bus)
|
||||
if current_scores <= scores2: # Ignore better students
|
||||
continue
|
||||
if least_preferred_survey is None or score2 < least_score:
|
||||
if least_preferred_survey is None or scores2 < least_scores:
|
||||
least_preferred_survey = survey2
|
||||
least_score = score2
|
||||
least_scores = scores2
|
||||
|
||||
if least_preferred_survey is not None:
|
||||
# Remove the least student from the bus and put the current student in.
|
||||
|
@@ -1,18 +0,0 @@
|
||||
# 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)'),
|
||||
),
|
||||
]
|
@@ -1,22 +0,0 @@
|
||||
# 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(
|
||||
verbose_name=_("membership fee (soge credit)"),
|
||||
default=0,
|
||||
default=2000,
|
||||
)
|
||||
|
||||
class Meta:
|
||||
@@ -202,9 +202,9 @@ class WEIRegistration(models.Model):
|
||||
verbose_name=_("Credit from Société générale"),
|
||||
)
|
||||
|
||||
deposit_given = models.BooleanField(
|
||||
deposit_check = models.BooleanField(
|
||||
default=False,
|
||||
verbose_name=_("Deposit given")
|
||||
verbose_name=_("Deposit check given")
|
||||
)
|
||||
|
||||
deposit_type = models.CharField(
|
||||
|
@@ -84,35 +84,6 @@ 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):
|
||||
hasperm = PermissionBackend.check_perm(
|
||||
get_current_request(), "wei.add_weimembership", WEIMembership(
|
||||
@@ -154,8 +125,8 @@ class WEIRegistrationTable(tables.Table):
|
||||
order_by = ('validate', 'user',)
|
||||
model = WEIRegistration
|
||||
template_name = 'django_tables2/bootstrap4.html'
|
||||
fields = ('user', 'user__first_name', 'user__last_name', 'first_year', 'deposit_given',
|
||||
'deposit_type', 'edit', 'validate', 'delete',)
|
||||
fields = ('user', 'user__first_name', 'user__last_name', 'first_year', 'deposit_check',
|
||||
'edit', 'validate', 'delete',)
|
||||
row_attrs = {
|
||||
'class': 'table-row',
|
||||
'id': lambda record: "row-" + str(record.pk),
|
||||
@@ -187,35 +158,6 @@ class WEIMembershipTable(tables.Table):
|
||||
def render_year(self, record):
|
||||
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:
|
||||
attrs = {
|
||||
'class': 'table table-condensed table-striped table-hover'
|
||||
@@ -223,7 +165,7 @@ class WEIMembershipTable(tables.Table):
|
||||
model = WEIMembership
|
||||
template_name = 'django_tables2/bootstrap4.html'
|
||||
fields = ('user', 'user__last_name', 'user__first_name', 'registration__gender', 'user__profile__department',
|
||||
'year', 'bus', 'team', 'registration__deposit_given', 'registration__deposit_type')
|
||||
'year', 'bus', 'team', 'registration__deposit_check', )
|
||||
row_attrs = {
|
||||
'class': 'table-row',
|
||||
'id': lambda record: "row-" + str(record.pk),
|
||||
|
@@ -96,7 +96,7 @@ SPDX-License-Identifier: GPL-3.0-or-later
|
||||
{% endif %}
|
||||
{% else %}
|
||||
<dt class="col-xl-6">{% trans 'Deposit check given'|capfirst %}</dt>
|
||||
<dd class="col-xl-6">{{ registration.deposit_given|yesno }}</dd>
|
||||
<dd class="col-xl-6">{{ registration.deposit_check|yesno }}</dd>
|
||||
|
||||
{% with information=registration.information %}
|
||||
<dt class="col-xl-6">{% trans 'preferred bus'|capfirst %}</dt>
|
||||
@@ -169,9 +169,9 @@ SPDX-License-Identifier: GPL-3.0-or-later
|
||||
{% endblocktrans %}</p>
|
||||
</div>
|
||||
|
||||
{% if not registration.deposit_given and not registration.first_year and registration.caution_type == 'check' %}
|
||||
{% if not registration.deposit_check and not registration.first_year and registration.caution_type == 'check' %}
|
||||
<div class="alert alert-danger">
|
||||
{% trans "The user didn't give her/his caution." %}
|
||||
{% trans "The user didn't give her/his caution check." %}
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
|
@@ -105,25 +105,11 @@ class TestWEIAlgorithm(TestCase):
|
||||
survey = WEISurvey2025(r)
|
||||
chosen_bus = survey.information.get_selected_bus()
|
||||
buses = survey.ordered_buses()
|
||||
'''print(buses)
|
||||
print(chosen_bus)'''
|
||||
self.assertIn(chosen_bus, [x[0] for x in buses])
|
||||
score_questions, score_words = next(scores for bus, scores in buses if bus == chosen_bus)
|
||||
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)))
|
||||
penalty += (max_score_words - score_words) ** 2
|
||||
penalty += (max_score_questions - score_questions) ** 2
|
||||
score = min(v for bus, (v, __) in buses if bus == chosen_bus)
|
||||
max_score = buses[0][1][0]
|
||||
penalty += (max_score - score) ** 2
|
||||
|
||||
self.assertLessEqual(max_score - score, 1) # Always less than 25 % of tolerance
|
||||
|
||||
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,
|
||||
wei_id=self.wei.id,
|
||||
soge_credit=True,
|
||||
deposit_given=True,
|
||||
deposit_check=True,
|
||||
birth_date=date(2000, 1, 1),
|
||||
gender="nonbinary",
|
||||
clothing_cut="male",
|
||||
@@ -642,7 +642,7 @@ class TestWEIRegistration(TestCase):
|
||||
last_name="admin",
|
||||
first_name="admin",
|
||||
bank="Société générale",
|
||||
deposit_given=True,
|
||||
deposit_check=True,
|
||||
))
|
||||
self.assertEqual(response.status_code, 200)
|
||||
self.assertFalse(response.context["form"].is_valid())
|
||||
@@ -657,7 +657,7 @@ class TestWEIRegistration(TestCase):
|
||||
last_name="admin",
|
||||
first_name="admin",
|
||||
bank="Société générale",
|
||||
deposit_given=True,
|
||||
deposit_check=True,
|
||||
))
|
||||
self.assertRedirects(response, reverse("wei:wei_registrations", kwargs=dict(pk=self.registration.wei.pk)), 302, 200)
|
||||
|
||||
@@ -813,7 +813,7 @@ class TestWeiAPI(TestAPI):
|
||||
user_id=self.user.id,
|
||||
wei_id=self.wei.id,
|
||||
soge_credit=True,
|
||||
deposit_given=True,
|
||||
deposit_check=True,
|
||||
birth_date=date(2000, 1, 1),
|
||||
gender="nonbinary",
|
||||
clothing_cut="male",
|
||||
|
@@ -594,8 +594,8 @@ class WEIRegister1AView(ProtectQuerysetMixin, ProtectedCreateView):
|
||||
# Cacher les champs pendant l'inscription initiale
|
||||
if "first_year" in form.fields:
|
||||
del form.fields["first_year"]
|
||||
if "deposit_given" in form.fields:
|
||||
del form.fields["deposit_given"]
|
||||
if "deposit_check" in form.fields:
|
||||
del form.fields["deposit_check"]
|
||||
if "information_json" in form.fields:
|
||||
del form.fields["information_json"]
|
||||
if "deposit_type" in form.fields:
|
||||
@@ -704,8 +704,8 @@ class WEIRegister2AView(ProtectQuerysetMixin, ProtectedCreateView):
|
||||
# Cacher les champs pendant l'inscription initiale
|
||||
if "first_year" in form.fields:
|
||||
del form.fields["first_year"]
|
||||
if "deposit_given" in form.fields:
|
||||
del form.fields["deposit_given"]
|
||||
if "deposit_check" in form.fields:
|
||||
del form.fields["deposit_check"]
|
||||
if "information_json" in form.fields:
|
||||
del form.fields["information_json"]
|
||||
|
||||
@@ -798,6 +798,11 @@ class WEIUpdateRegistrationView(ProtectQuerysetMixin, LoginRequiredMixin, Update
|
||||
choose_bus_form.fields["team"].queryset = BusTeam.objects.filter(bus__wei=context["club"])
|
||||
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
|
||||
|
||||
def get_form(self, form_class=None):
|
||||
@@ -806,11 +811,9 @@ class WEIUpdateRegistrationView(ProtectQuerysetMixin, LoginRequiredMixin, Update
|
||||
# The auto-json-format may cause issues with the default field remove
|
||||
if "information_json" in form.fields:
|
||||
del form.fields["information_json"]
|
||||
# Masquer le champ deposit_given pour tout le monde dans le formulaire de modification
|
||||
if "deposit_given" in form.fields:
|
||||
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"]
|
||||
# Masquer le champ deposit_check pour tout le monde dans le formulaire de modification
|
||||
if "deposit_check" in form.fields:
|
||||
del form.fields["deposit_check"]
|
||||
|
||||
# S'assurer que le champ deposit_type est obligatoire pour les 2A+
|
||||
if "deposit_type" in form.fields:
|
||||
@@ -820,10 +823,6 @@ class WEIUpdateRegistrationView(ProtectQuerysetMixin, LoginRequiredMixin, Update
|
||||
form.fields["deposit_type"].required = True
|
||||
form.fields["deposit_type"].help_text = _("Choose how you want to pay the deposit")
|
||||
|
||||
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
|
||||
|
||||
def get_membership_form(self, data=None, instance=None):
|
||||
@@ -1018,18 +1017,17 @@ class WEIValidateRegistrationView(ProtectQuerysetMixin, ProtectedCreateView):
|
||||
form.fields["last_name"].initial = registration.user.last_name
|
||||
form.fields["first_name"].initial = registration.user.first_name
|
||||
|
||||
# Ajouter le champ deposit_given uniquement pour les non-première année et le rendre obligatoire
|
||||
# Ajouter le champ deposit_check uniquement pour les non-première année et le rendre obligatoire
|
||||
if not registration.first_year:
|
||||
if registration.deposit_type == 'check':
|
||||
form.fields["deposit_given"] = forms.BooleanField(
|
||||
form.fields["deposit_check"] = forms.BooleanField(
|
||||
required=True,
|
||||
disabled=True,
|
||||
initial=registration.deposit_given,
|
||||
initial=registration.deposit_check,
|
||||
label=_("Deposit check given"),
|
||||
help_text=_("Only treasurers can validate this field")
|
||||
help_text=_("Please make sure the check is given before validating the registration")
|
||||
)
|
||||
else:
|
||||
form.fields["deposit_given"] = forms.BooleanField(
|
||||
form.fields["deposit_check"] = forms.BooleanField(
|
||||
required=True,
|
||||
initial=False,
|
||||
label=_("Create deposit transaction"),
|
||||
@@ -1070,8 +1068,8 @@ class WEIValidateRegistrationView(ProtectQuerysetMixin, ProtectedCreateView):
|
||||
club = registration.wei
|
||||
user = registration.user
|
||||
|
||||
if "deposit_given" in form.data:
|
||||
registration.deposit_given = form.data["deposit_given"] == "on"
|
||||
if "deposit_check" in form.data:
|
||||
registration.deposit_check = form.data["deposit_check"] == "on"
|
||||
registration.save()
|
||||
membership = form.instance
|
||||
membership.user = user
|
||||
@@ -1183,7 +1181,7 @@ class WEIValidateRegistrationView(ProtectQuerysetMixin, ProtectedCreateView):
|
||||
def form_invalid(self, form):
|
||||
registration = getattr(form.instance, "registration", None)
|
||||
if registration is not None:
|
||||
registration.deposit_given = False
|
||||
registration.deposit_check = False
|
||||
registration.save()
|
||||
return super().form_invalid(form)
|
||||
|
||||
|
@@ -3152,10 +3152,8 @@ msgid "Note transaction"
|
||||
msgstr "Transaction Note"
|
||||
|
||||
#: apps/wei/models.py:217
|
||||
#, fuzzy
|
||||
#| msgid "Credit type"
|
||||
msgid "deposit type"
|
||||
msgstr "Type de rechargement"
|
||||
msgstr "type de caution"
|
||||
|
||||
#: apps/wei/models.py:221 apps/wei/templates/wei/weimembership_form.html:64
|
||||
msgid "birth date"
|
||||
@@ -4095,14 +4093,6 @@ msgstr "La note est indisponible pour le moment"
|
||||
msgid "Thank you for your understanding -- The Respos Info of BDE"
|
||||
msgstr "Merci de votre compréhension -- Les Respos Info du BDE"
|
||||
|
||||
#: note_kfet/templates/base_search.html:15
|
||||
msgid "Search by attribute such as name..."
|
||||
msgstr "Chercher par un attribut tel que le nom..."
|
||||
|
||||
#: note_kfet/templates/base_search.html:23
|
||||
msgid "There is no results."
|
||||
msgstr "Il n'y a pas de résultat."
|
||||
|
||||
#: note_kfet/templates/cas/logged.html:8
|
||||
msgid ""
|
||||
"<h3>Log In Successful</h3>You have successfully logged into the Central "
|
||||
|
Reference in New Issue
Block a user