From 8c0ccdfdd02d9f4d83f3a0efd5bd483ab4b25d40 Mon Sep 17 00:00:00 2001 From: Yohann D'ANELLO Date: Mon, 27 Apr 2020 20:25:02 +0200 Subject: [PATCH] Don't change the password of another member (+ minor fixes on WEI app) --- apps/member/models.py | 2 +- apps/wei/models.py | 2 ++ apps/wei/views.py | 2 +- templates/member/profile_info.html | 14 ++++++++------ templates/registration/future_profile_detail.html | 7 ------- templates/wei/weimembership_form.html | 4 +++- 6 files changed, 15 insertions(+), 16 deletions(-) diff --git a/apps/member/models.py b/apps/member/models.py index e1c829a4..17b8f044 100644 --- a/apps/member/models.py +++ b/apps/member/models.py @@ -119,7 +119,7 @@ class Profile(models.Model): def soge(self): if "treasury" in settings.INSTALLED_APPS: from treasury.models import SogeCredit - return SogeCredit.objects.filter(user=self.user, credit_transaction=None).exists() + return SogeCredit.objects.filter(user=self.user, credit_transaction__isnull=False).exists() return False class Meta: diff --git a/apps/wei/models.py b/apps/wei/models.py index 3b41fdd0..9cee0d61 100644 --- a/apps/wei/models.py +++ b/apps/wei/models.py @@ -2,6 +2,7 @@ # SPDX-License-Identifier: GPL-3.0-or-later import json +from datetime import date from django.conf import settings from django.contrib.auth.models import User @@ -17,6 +18,7 @@ class WEIClub(Club): """ year = models.PositiveIntegerField( unique=True, + default=date.today().year, verbose_name=_("year"), ) diff --git a/apps/wei/views.py b/apps/wei/views.py index b35e27be..597a44d4 100644 --- a/apps/wei/views.py +++ b/apps/wei/views.py @@ -780,7 +780,7 @@ class WEIValidateRegistrationView(ProtectQuerysetMixin, LoginRequiredMixin, Crea ret = super().form_valid(form) membership.refresh_from_db() - membership.roles.add(WEIRole.objects.get("Adhérent WEI")) + membership.roles.add(WEIRole.objects.get(name="Adhérent WEI")) return ret diff --git a/templates/member/profile_info.html b/templates/member/profile_info.html index 74856355..7be10ba1 100644 --- a/templates/member/profile_info.html +++ b/templates/member/profile_info.html @@ -17,12 +17,14 @@
{% trans 'username'|capfirst %}
{{ object.username }}
-
{% trans 'password'|capfirst %}
-
- - {% trans 'Change password' %} - -
+ {% if object.pk == user.pk %} +
{% trans 'password'|capfirst %}
+
+ + {% trans 'Change password' %} + +
+ {% endif %}
{% trans 'section'|capfirst %}
{{ object.profile.section }}
diff --git a/templates/registration/future_profile_detail.html b/templates/registration/future_profile_detail.html index 8c78fb8d..1d2d08c7 100644 --- a/templates/registration/future_profile_detail.html +++ b/templates/registration/future_profile_detail.html @@ -31,13 +31,6 @@ {% endif %} -
{% trans 'password'|capfirst %}
-
- - {% trans 'Change password' %} - -
-
{% trans 'section'|capfirst %}
{{ object.profile.section }}
diff --git a/templates/wei/weimembership_form.html b/templates/wei/weimembership_form.html index 0cde7fe6..995b6c1a 100644 --- a/templates/wei/weimembership_form.html +++ b/templates/wei/weimembership_form.html @@ -119,8 +119,10 @@