1
0
mirror of https://gitlab.crans.org/bde/nk20 synced 2024-11-30 04:13:01 +00:00

Compare commits

..

No commits in common. "6c9cf73848d637f4874f4d8dba5890a7308ed278" and "a096dc44271dcd46769c197bd1419a08a189d89c" have entirely different histories.

4 changed files with 9 additions and 53 deletions

View File

@ -8,15 +8,12 @@ from django.conf import settings
from django.contrib.auth.models import User from django.contrib.auth.models import User
from django.core.exceptions import ValidationError from django.core.exceptions import ValidationError
from django.db import models from django.db import models
from django.db.models import Q
from django.template import loader from django.template import loader
from django.urls import reverse, reverse_lazy from django.urls import reverse, reverse_lazy
from django.utils import timezone from django.utils import timezone
from django.utils.encoding import force_bytes from django.utils.encoding import force_bytes
from django.utils.http import urlsafe_base64_encode from django.utils.http import urlsafe_base64_encode
from django.utils.translation import gettext_lazy as _ from django.utils.translation import gettext_lazy as _
from permission.models import Role
from registration.tokens import email_validation_token from registration.tokens import email_validation_token
from note.models import MembershipTransaction from note.models import MembershipTransaction
@ -385,17 +382,6 @@ class Membership(models.Model):
if hasattr(self, '_force_save'): if hasattr(self, '_force_save'):
parent_membership._force_save = True parent_membership._force_save = True
parent_membership.save() parent_membership.save()
parent_membership.refresh_from_db()
if self.club.parent_club.name == "BDE":
parent_membership.roles.set(
Role.objects.filter(Q(name="Adhérent BDE") | Q(name="Membre de club")).all())
elif self.club.parent_club.name == "Kfet":
parent_membership.roles.set(
Role.objects.filter(Q(name="Adhérent Kfet") | Q(name="Membre de club")).all())
else:
parent_membership.roles.set(Role.objects.filter(name="Membre de club").all())
parent_membership.save()
else: else:
raise ValidationError(_('User is not a member of the parent club') raise ValidationError(_('User is not a member of the parent club')
+ ' ' + self.club.parent_club.name) + ' ' + self.club.parent_club.name)

View File

@ -631,12 +631,7 @@ class ClubAddMemberView(ProtectQuerysetMixin, LoginRequiredMixin, CreateView):
ret = super().form_valid(form) ret = super().form_valid(form)
if club.name == "BDE": member_role = Role.objects.filter(name="Membre de club").all()
member_role = Role.objects.filter(Q(name="Adhérent BDE") | Q(name="Membre de club")).all()
elif club.name == "Kfet":
member_role = Role.objects.filter(Q(name="Adhérent Kfet") | Q(name="Membre de club")).all()
else:
member_role = Role.objects.filter(name="Membre de club").all()
form.instance.roles.set(member_role) form.instance.roles.set(member_role)
form.instance._force_save = True form.instance._force_save = True
form.instance.save() form.instance.save()
@ -675,10 +670,8 @@ class ClubAddMemberView(ProtectQuerysetMixin, LoginRequiredMixin, CreateView):
membership.refresh_from_db() membership.refresh_from_db()
if old_membership.exists(): if old_membership.exists():
membership.roles.set(old_membership.get().roles.all()) membership.roles.set(old_membership.get().roles.all())
elif c.name == "BDE": else:
membership.roles.set(Role.objects.filter(Q(name="Adhérent BDE") | Q(name="Membre de club")).all()) membership.roles.add(Role.objects.get(name="Adhérent Kfet"))
elif c.name == "Kfet":
membership.roles.set(Role.objects.filter(Q(name="Adhérent Kfet") | Q(name="Membre de club")).all())
membership.save() membership.save()
return ret return ret

View File

@ -61,7 +61,7 @@
"fields": { "fields": {
"model": [ "model": [
"note", "note",
"note" "noteuser"
], ],
"query": "{\"pk\": [\"user\", \"note\", \"pk\"]}", "query": "{\"pk\": [\"user\", \"note\", \"pk\"]}",
"type": "view", "type": "view",
@ -2221,9 +2221,9 @@
"fields": { "fields": {
"model": [ "model": [
"note", "note",
"note" "noteclub"
], ],
"query": "{\"noteclub__club\": [\"club\"]}", "query": "{\"club\": [\"club\"]}",
"type": "view", "type": "view",
"mask": 2, "mask": 2,
"field": "", "field": "",
@ -2343,22 +2343,6 @@
"description": "Supprimer une activité non validée" "description": "Supprimer une activité non validée"
} }
}, },
{
"model": "permission.permission",
"pk": 150,
"fields": {
"model": [
"note",
"note"
],
"query": "{}",
"type": "view",
"mask": 2,
"field": "",
"permanent": false,
"description": "Voir toutes les notes"
}
},
{ {
"model": "permission.role", "model": "permission.role",
"pk": 1, "pk": 1,
@ -2538,8 +2522,7 @@
139, 139,
143, 143,
146, 146,
147, 147
150
] ]
} }
}, },
@ -2694,8 +2677,7 @@
146, 146,
147, 147,
148, 148,
149, 149
150
] ]
} }
}, },
@ -2755,7 +2737,6 @@
"for_club": null, "for_club": null,
"name": "GC WEI", "name": "GC WEI",
"permissions": [ "permissions": [
22,
76, 76,
85, 85,
86, 86,
@ -2789,7 +2770,6 @@
"for_club": null, "for_club": null,
"name": "Chef de bus", "name": "Chef de bus",
"permissions": [ "permissions": [
22,
84, 84,
117, 117,
118, 118,
@ -2807,7 +2787,6 @@
"for_club": null, "for_club": null,
"name": "Chef d'\u00e9quipe", "name": "Chef d'\u00e9quipe",
"permissions": [ "permissions": [
22,
84, 84,
116, 116,
123, 123,
@ -2823,7 +2802,6 @@
"for_club": null, "for_club": null,
"name": "\u00c9lectron libre", "name": "\u00c9lectron libre",
"permissions": [ "permissions": [
22,
84 84
] ]
} }
@ -2835,7 +2813,6 @@
"for_club": null, "for_club": null,
"name": "\u00c9lectron libre (avec perm)", "name": "\u00c9lectron libre (avec perm)",
"permissions": [ "permissions": [
22,
84 84
] ]
} }

View File

@ -12,7 +12,7 @@
{% include "member/club_info.html" %} {% include "member/club_info.html" %}
{% endwith %} {% endwith %}
{% elif note.user %} {% elif note.user %}
{% with user_object=note.user %} {% with user=note.user %}
{% include "member/profile_info.html" %} {% include "member/profile_info.html" %}
{% endwith %} {% endwith %}
{% endif %} {% endif %}