1
0
mirror of https://gitlab.crans.org/bde/nk20 synced 2025-08-03 14:16:54 +02:00

Compare commits

...

45 Commits

Author SHA1 Message Date
thomasl
007f9cce36 Merge branch 'respo_comm_permissions' into 'main'
Draft: Respo comm permissions

See merge request bde/nk20!281
2025-02-12 10:18:45 +01:00
quark
694f54e1c4 Merge branch 'fix_activity_view' into 'main'
fix issue with activity entry view

See merge request bde/nk20!282
2025-02-12 10:18:33 +01:00
quark
0d0fdef363 fix issue with activity entry view 2025-02-09 17:58:38 +01:00
quark
f6649f155a linters 2025-02-09 16:51:31 +01:00
thomasl
5707abf9e2 Update file views.py 2025-02-09 16:22:03 +01:00
thomasl
056c4029f8 Update file views.py 2025-02-09 16:19:26 +01:00
thomasl
bfd865b3e3 Update file views.py 2025-02-09 16:14:28 +01:00
thomasl
6ceb43cb66 Update file views.py 2025-02-09 16:07:30 +01:00
thomasl
9635004520 Update file views.py 2025-02-09 15:56:12 +01:00
thomasl
05e21ed229 Update file views.py 2025-02-09 15:51:05 +01:00
thomasl
b2ccc4aede Update file views.py 2025-02-09 15:50:13 +01:00
thomasl
6229652dea Update file views.py 2025-02-09 15:47:32 +01:00
thomasl
eee87dcf13 Update file views.py 2025-02-09 15:42:20 +01:00
thomasl
bcf21507e5 Update file views.py 2025-02-09 15:39:08 +01:00
thomasl
6127ced143 Update file views.py 2025-02-09 15:33:37 +01:00
thomasl
f63e5dcb5a Update file views.py 2025-02-09 15:26:39 +01:00
thomasl
73aa0098bf Update file views.py 2025-02-09 15:20:03 +01:00
thomasl
694a5c7bd8 Update file initial.json 2025-02-09 13:05:10 +01:00
thomasl
a4480258d7 Update file initial.json 2025-02-09 12:45:46 +01:00
thomasl
821efbf78b Merge branch 'Automation_mailing_lists' into 'main'
Automation mailing lists

See merge request bde/nk20!280
2025-02-02 14:53:04 +01:00
thomasl
a209e0d366 Update file forms.py 2025-02-02 14:30:53 +01:00
thomasl
ef485e0628 Update file forms.py 2025-02-02 14:06:22 +01:00
thomasl
1481aa0635 Update file forms.py 2025-02-02 14:05:05 +01:00
thomasl
867bf9fd25 Update file forms.py 2025-02-02 13:33:41 +01:00
thomasl
47fda0ea36 Update file forms.py 2025-02-02 13:17:19 +01:00
thomasl
623290827a Update file forms.py 2025-01-27 16:34:45 +01:00
thomasl
a87ce625f3 Update file note.cron 2025-01-25 13:55:21 +01:00
thomasl
3559787fa7 Merge branch 'New_permission' into 'main'
New permission

See merge request bde/nk20!278
2025-01-18 15:41:15 +01:00
thomasl
bd6ed27ae5 Update 2 files
- /apps/permission/fixtures/initial.json
- /apps/permission/admin.py
2025-01-18 15:11:57 +01:00
thomasl
43dc676747 Update file initial.json 2025-01-18 12:57:42 +01:00
thomasl
caaeab6b0b Update file initial.json 2025-01-17 19:39:26 +01:00
thomasl
54ba786884 Update file initial.json 2025-01-17 19:03:59 +01:00
thomasl
80e109114f Update file initial.json 2025-01-17 18:23:28 +01:00
mcngnt
787005e60d Merge branch 'finito_sda' into 'main'
finitio le message sda

See merge request bde/nk20!279
2025-01-06 00:11:01 +01:00
mcngnt
414e103686 finitio le message sda 2025-01-05 23:17:01 +01:00
thomasl
942d887c2e Update file initial.json 2024-12-23 18:31:11 +01:00
thomasl
a63c34fe37 Update file initial.json 2024-12-22 21:38:17 +01:00
thomasl
2be6133458 Update file initial.json 2024-12-22 20:42:20 +01:00
quark
7975fe47a6 Merge branch 'sda' into 'main'
Donation goal la note kfet x les SdA

See merge request bde/nk20!277
2024-10-10 23:44:22 +02:00
quark
476fbceeea Donation goal la note kfet x les SdA 2024-10-10 01:48:23 +02:00
mcngnt
8fbaa0bdc8 Merge branch 'linters' into 'main'
fix linters for WEI 2024 survey

See merge request bde/nk20!274
2024-10-03 16:51:04 +02:00
thomasl
a0de63effd Merge branch 'beta' into 'main'
Correction translation of sport events ml

See merge request bde/nk20!276
2024-09-18 13:52:33 +02:00
korenstin
09fb1d227e Correction translation of sport events ml 2024-09-18 08:54:04 +02:00
thomasl
2e27d4f05c Merge branch 'non-BDE-members-permission-fix' into 'main'
Added some necessary rights

See merge request bde/nk20!275
2024-09-17 17:24:30 +02:00
bleizi
3c34033bf5 fix linters for WEI 2024 survey 2024-09-12 13:41:04 +02:00
9 changed files with 126 additions and 14 deletions

View File

@@ -329,7 +329,7 @@ class ActivityEntryView(LoginRequiredMixin, SingleTableMixin, TemplateView):
context["noteuser_ctype"] = ContentType.objects.get_for_model(NoteUser).pk context["noteuser_ctype"] = ContentType.objects.get_for_model(NoteUser).pk
context["notespecial_ctype"] = ContentType.objects.get_for_model(NoteSpecial).pk context["notespecial_ctype"] = ContentType.objects.get_for_model(NoteSpecial).pk
activities_open = Activity.objects.filter(open=True).filter( activities_open = Activity.objects.filter(open=True, activity_type__manage_entries=True).filter(
PermissionBackend.filter_queryset(self.request, Activity, "view")).distinct().all() PermissionBackend.filter_queryset(self.request, Activity, "view")).distinct().all()
context["activities_open"] = [a for a in activities_open context["activities_open"] = [a for a in activities_open
if PermissionBackend.check_perm(self.request, if PermissionBackend.check_perm(self.request,

View File

@@ -44,7 +44,8 @@ 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.
""" """
report_frequency = forms.IntegerField(required=False, initial=0, label=_("Report frequency")) # Remove widget=forms.HiddenInput() if you want to use report frequency.
report_frequency = forms.IntegerField(required=False, initial=0, label=_("Report frequency"), widget=forms.HiddenInput())
last_report = forms.DateTimeField(required=False, disabled=True, label=_("Last report date")) last_report = forms.DateTimeField(required=False, disabled=True, label=_("Last report date"))
@@ -76,7 +77,8 @@ class ProfileForm(forms.ModelForm):
class Meta: class Meta:
model = Profile model = Profile
fields = '__all__' fields = '__all__'
exclude = ('user', 'email_confirmed', 'registration_valid', ) # Remove ml_[asso]_registration from exclude if the concerned association uses nk20 to manage its mailing list.
exclude = ('user', 'email_confirmed', 'registration_valid', 'ml_sport_registration', )
class ImageForm(forms.Form): class ImageForm(forms.Form):

View File

@@ -26,6 +26,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 django import forms
from .forms import UserForm, ProfileForm, ImageForm, ClubForm, MembershipForm, \ from .forms import UserForm, ProfileForm, ImageForm, ClubForm, MembershipForm, \
CustomAuthenticationForm, MembershipRolesForm CustomAuthenticationForm, MembershipRolesForm
@@ -72,11 +73,19 @@ class UserUpdateView(ProtectQuerysetMixin, LoginRequiredMixin, UpdateView):
form.fields['email'].required = True form.fields['email'].required = True
form.fields['email'].help_text = _("This address must be valid.") form.fields['email'].help_text = _("This address must be valid.")
if PermissionBackend.check_perm(self.request, "member.change_profile", context['user_object'].profile): profile_form = self.profile_form(instance=context['user_object'].profile,
context['profile_form'] = self.profile_form(instance=context['user_object'].profile, data=self.request.POST if self.request.POST else None)
data=self.request.POST if self.request.POST else None) if not self.object.profile.report_frequency:
if not self.object.profile.report_frequency: del profile_form.fields["last_report"]
del context['profile_form'].fields["last_report"]
fields_to_check = list(profile_form.fields.keys())
# Delete the fields for which the user does not have the permission to modify
for field_name in fields_to_check:
if not PermissionBackend.check_perm(self.request, f"member.change_profile_{field_name}", context['user_object'].profile):
profile_form.fields[field_name].widget = forms.HiddenInput()
context['profile_form'] = profile_form
return context return context

View File

@@ -31,3 +31,4 @@ class RoleAdmin(admin.ModelAdmin):
Admin customisation for Role Admin customisation for Role
""" """
list_display = ('name', ) list_display = ('name', )
filter_horizontal = ('permissions',)

View File

@@ -3800,6 +3800,106 @@
"description": "Voir les utilisateurs adhérents au club parent" "description": "Voir les utilisateurs adhérents au club parent"
} }
}, },
{
"model": "permission.permission",
"pk": 242,
"fields": {
"model": [
"note",
"transaction"
],
"query": "[\"AND\", {\"destination\": [\"club\", \"note\"]}, [\"OR\", {\"source__balance__gte\": {\"F\": [\"SUB\", [\"MUL\", [\"F\", \"amount\"], [\"F\", \"quantity\"]], 2000]}}, {\"valid\": false}]]",
"type": "add",
"mask": 2,
"field": "",
"permanent": false,
"description": "Créer une transaction vers la note d'un club"
}
},
{
"model": "permission.permission",
"pk": 243,
"fields": {
"model": [
"member",
"profile"
],
"query": "{\"user__memberships__club\": [\"club\"], \"user__memberships__date_start__lte\": [\"today\"],\"user__memberships__date_end__gte\": [\"today\"]}",
"type": "view",
"mask": 3,
"field": "",
"permanent": false,
"description": "Voir les profils des membres du club"
}
},
{
"model": "permission.permission",
"pk": 244,
"fields": {
"model": [
"member",
"profile"
],
"query": "{}",
"type": "change",
"mask": 3,
"field": "ml_events_registration",
"permanent": false,
"description": "Modifier l'abonnement à la Newsletter BDE pour n'importe quel profil"
}
},
{
"model": "permission.permission",
"pk": 245,
"fields": {
"model": [
"member",
"profile"
],
"query": "{}",
"type": "change",
"mask": 3,
"field": "ml_art_registration",
"permanent": false,
"description": "Modifier l'abonnement à la Newsletter Art pour n'importe quel profil"
}
},
{
"model": "permission.permission",
"pk": 246,
"fields": {
"model": [
"member",
"profile"
],
"query": "{}",
"type": "change",
"mask": 3,
"field": "ml_sport_registration",
"permanent": false,
"description": "Modifier l'abonnement à la Newsletter Sport pour n'importe quel profil"
}
},
{
"model": "permission.permission",
"pk": 247,
"fields": {
"model": [
"member",
"profile"
],
"query": "{}",
"type": "view",
"mask": 3,
"field": [
"ml_events_registration",
"ml_art_registration",
"ml_sport_registration"
],
"permanent": false,
"description": "Voir les abonnements aux Newsletters de n'importe quel profil"
}
},
{ {
"model": "permission.role", "model": "permission.role",
"pk": 1, "pk": 1,
@@ -4377,7 +4477,7 @@
238 238
] ]
} }
}, },
{ {
"model": "wei.weirole", "model": "wei.weirole",
"pk": 12, "pk": 12,

View File

@@ -279,7 +279,6 @@ class WEISurveyAlgorithm2024(WEISurveyAlgorithm):
# surveys = [s for s in surveys if s.bus_id != None] # surveys = [s for s in surveys if s.bus_id != None]
# surveys = [s for s in surveys if not hasattr(s.information, 'hardcoded') or not s.information.hardcoded] # surveys = [s for s in surveys if not hasattr(s.information, 'hardcoded') or not s.information.hardcoded]
# surveys = [s for s in surveys if s.registration.user_id in free_users] # surveys = [s for s in surveys if s.registration.user_id in free_users]
# hardcoded_first_year_mb = WEIMembership.objects.filter(bus != None,registration__first_year=True) # hardcoded_first_year_mb = WEIMembership.objects.filter(bus != None,registration__first_year=True)
@@ -288,15 +287,13 @@ class WEISurveyAlgorithm2024(WEISurveyAlgorithm):
hardcoded_first_year_mb = WEIMembership.objects.filter(registration__first_year=True) hardcoded_first_year_mb = WEIMembership.objects.filter(registration__first_year=True)
hardcoded_first_year = {mb.user.id if mb.bus else None: mb.bus.id if mb.bus else None for mb in hardcoded_first_year_mb} hardcoded_first_year = {mb.user.id if mb.bus else None: mb.bus.id if mb.bus else None for mb in hardcoded_first_year_mb}
# Reset previous algorithm run # Reset previous algorithm run
for survey in surveys: for survey in surveys:
survey.free() survey.free()
if survey.registration.user_id in hardcoded_first_year.keys(): if survey.registration.user_id in hardcoded_first_year.keys():
survey.select_bus(hardcoded_first_year[s.registration.user_id]) survey.select_bus(hardcoded_first_year[survey.registration.user_id])
survey.save() survey.save()
non_men = [s for s in surveys if s.registration.gender != 'male'] non_men = [s for s in surveys if s.registration.gender != 'male']
men = [s for s in surveys if s.registration.gender == 'male'] men = [s for s in surveys if s.registration.gender == 'male']

View File

@@ -1032,6 +1032,7 @@ msgid ""
"Register on the mailing list to stay informed of the sport events of the " "Register on the mailing list to stay informed of the sport events of the "
"campus (1 mail/week)" "campus (1 mail/week)"
msgstr "" msgstr ""
"S'inscrire sur la liste de diffusion pour rester informé·e des actualités "
"sportives sur le campus (1 mail par semaine)" "sportives sur le campus (1 mail par semaine)"
#: apps/member/models.py:113 #: apps/member/models.py:113

View File

@@ -26,3 +26,5 @@ MAILTO=notekfet2020@lists.crans.org
00 9 * * * root cd /var/www/note_kfet && env/bin/python manage.py refresh_highlighted_buttons -v 0 00 9 * * * root cd /var/www/note_kfet && env/bin/python manage.py refresh_highlighted_buttons -v 0
# Vider les tokens Oauth2 # Vider les tokens Oauth2
00 6 * * * root cd /var/www/note_kfet && env/bin/python manage.py cleartokens -v 0 00 6 * * * root cd /var/www/note_kfet && env/bin/python manage.py cleartokens -v 0
# Envoyer la liste des abonnés à la NL BDA
00 8 * * 0 root cd /var/www/note_kfet && env/bin/python manage.py extract_ml_registrations -t art -v 0

View File

@@ -158,7 +158,7 @@ SPDX-License-Identifier: GPL-3.0-or-later
</div> </div>
</nav> </nav>
<div class="{% block containertype %}container{% endblock %} my-3"> <div class="{% block containertype %}container{% endblock %} my-3">
<div id="messages"> <div id="messages">
{% if user.is_authenticated %} {% if user.is_authenticated %}
{% if not user|is_member:"BDE" %} {% if not user|is_member:"BDE" %}
<div class="alert alert-danger"> <div class="alert alert-danger">