+
+
+
+ {% block sidebar %}
+ {% endblock %}
-
+
+
+ {# Display django.contrib.messages as Bootstrap alerts #}
+ {% bootstrap_messages %}
-
-
-
-
-
- {% block sidebar %}
- {% endblock %}
-
+ {% block content %}{% endblock %}
+
+
+
+ {% if user.is_authenticated %}
+
+
{{ user.first_name }} {{ user.last_name }}
-
-
- {# Display django.contrib.messages as Bootstrap alerts #}
- {% bootstrap_messages %}
-
- {% block content %}{% endblock %}
-
-
-
- {% if request_user.is_authenticated %}
-
-
{{ request_user.first_name }} {{ request_user.last_name }}
-
-
-
- Pseudo |
- {{ request_user.username }} |
-
-
- Nom |
- {{ request_user.last_name }} |
-
-
- Prénom |
- {{ request_user.first_name }} |
-
-
- {% else %}
-
Vous n'êtes pas authentifié
- {% endif %}
-
-
+
+
+ Pseudo |
+ {{ user.username }} |
+
+
+ Nom |
+ {{ user.last_name }} |
+
+
+ Prénom |
+ {{ user.first_name }} |
+
+
+ {% else %}
+
Vous n'êtes pas authentifié
+ {% endif %}
+
+
-
+
- {# Read the documentation for more information #}
-
+{# Read the documentation for more information #}
+
diff --git a/theme/templates/admin/base_site.html b/theme/templates/admin/base_site.html
index 1199750..f8ee871 100644
--- a/theme/templates/admin/base_site.html
+++ b/theme/templates/admin/base_site.html
@@ -26,12 +26,13 @@ SPDX-License-Identifier: GPL-3.0-or-later
{% endblock %}
{% block userlinks %}
{# Link to our apps outside of admin #}
-
{% trans 'My profile' %} /
-
Media /
+
{% trans 'Library' %} /
{% if user.is_authenticated %}
- {% if is_perm %}
+ {% if perms.users.add_user %}
Nouveau utilisateur /
+ {% endif %}
+ {% if user.is_staff %}
Statistiques /
{% endif %}
diff --git a/users/admin.py b/users/admin.py
index 1d9121a..0fc53ff 100644
--- a/users/admin.py
+++ b/users/admin.py
@@ -7,17 +7,13 @@ from django.contrib.auth.admin import UserAdmin as BaseUserAdmin
from django.utils.translation import ugettext_lazy as _
from reversion.admin import VersionAdmin
-from .models import Adhesion, Clef, ListRight, Request, Right, User
+from .models import Adhesion, Clef, Request, User
class RequestAdmin(admin.ModelAdmin):
list_display = ('user', 'type', 'created_at', 'expires_at')
-class RightAdmin(VersionAdmin):
- list_display = ('user', 'right')
-
-
class ClefAdmin(VersionAdmin):
list_display = ('nom', 'proprio', 'commentaire')
# TODO order by nom
@@ -27,10 +23,6 @@ class AdhesionAdmin(VersionAdmin):
list_display = ('annee_debut', 'annee_fin')
-class ListRightAdmin(VersionAdmin):
- list_display = ('listright',)
-
-
class IsAdherentFilter(admin.SimpleListFilter):
title = _('adherent status')
parameter_name = 'is_adherent'
@@ -44,7 +36,7 @@ class IsAdherentFilter(admin.SimpleListFilter):
value = self.value()
if value == 'Yes':
# Get current membership year and list all members
- last_adh_year = Adhesion.objects.all().order_by('annee_debut')\
+ last_adh_year = Adhesion.objects.all().order_by('annee_debut') \
.reverse().first()
return last_adh_year.adherent
return queryset
@@ -70,17 +62,20 @@ class UserAdmin(VersionAdmin, BaseUserAdmin):
"""
Get current membership year and check if user is there
"""
- last_adh_year = Adhesion.objects.all().order_by('annee_debut')\
+ last_adh_year = Adhesion.objects.all().order_by('annee_debut') \
.reverse().first()
return last_adh_year and obj in last_adh_year.adherent.all()
is_adherent.boolean = True
is_adherent.short_description = _('is adherent')
+ # TODO {% if not user.is_adherent and perms.users.add_user %}
+ # {% url 'users:adherer' user.id %}
+ # TODO {% if perms.media.add_emprunt %}
+ # {% url 'media:add-emprunt' user.id %}">
+
admin.site.register(User, UserAdmin)
admin.site.register(Request, RequestAdmin)
-admin.site.register(ListRight, ListRightAdmin)
-admin.site.register(Right, RightAdmin)
admin.site.register(Adhesion, AdhesionAdmin)
admin.site.register(Clef, ClefAdmin)
diff --git a/users/models.py b/users/models.py
index bb921bd..8d771f6 100644
--- a/users/models.py
+++ b/users/models.py
@@ -41,14 +41,6 @@ class User(AbstractUser):
REQUIRED_FIELDS = ['first_name', 'last_name', 'email']
- def has_perms(self, perms, obj=None):
- for perm in perms:
- try:
- Right.objects.get(user=self, right__listright=perm)
- return True
- except Right.DoesNotExist:
- return False
-
@property
def is_adherent(self):
last_adh_year = Adhesion.objects.all().order_by(
diff --git a/users/templates/users/profil.html b/users/templates/users/profil.html
deleted file mode 100644
index 709b605..0000000
--- a/users/templates/users/profil.html
+++ /dev/null
@@ -1,96 +0,0 @@
-{% extends "base.html" %}
-{% comment %}
-SPDX-License-Identifier: GPL-3.0-or-later
-{% endcomment %}
-
-{% load bootstrap3 %}
-
-{% block title %}Profil{% endblock %}
-
-{% block content %}
-
Compte
-
-
-
-
-
-
- Prénom |
- {{ user.first_name }} |
- Nom |
- {{ user.last_name }} |
-
-
- Pseudo |
- {{ user.username }} |
- E-mail |
- {{ user.email }} |
-
-
- Commentaire |
- {{ user.comment }} |
- Date d'inscription |
- {{ user.date_joined }} |
-
-
- Adresse |
- {{ user.address }} |
- Telephone |
- {{ user.telephone }} |
-
-
- Emprunts maximums autorisés |
- {{ user.maxemprunt }} |
- Droits |
- {% if list_droits %}
- {% for droit in list_droits %}{{ droit.right }}{% if list_droits|length != forloop.counter %} -
- {% endif %} {% endfor %} |
- {% else %}
- Aucun |
- {% endif %}
-
-
- Statut |
- {% if user.is_active %}
- Actif |
- {% else %}
- Désactivé |
- {% endif %}
- Dernière connexion |
- {{ user.last_login }} |
-
-
- Adherent pour l'année en cours |
- {% if user.is_adherent %}
- Oui |
- {% else %}
- Non |
- {% endif %}
- {% if not user.is_adherent and is_bureau %}
- |
- Adhérer |
- {% endif %}
-
-
-
Emprunts
- {% if is_perm or is_bureau %}
-
- {% endif %}
- {% if emprunts_list %}
- {% include "media/aff_emprunts.html" with emprunts_list=emprunts_list %}
- {% else %}
-
Aucun emprunt
- {% endif %}
-{% endblock %}
-
diff --git a/users/templates/users/user.html b/users/templates/users/user.html
index 66cd359..195f057 100644
--- a/users/templates/users/user.html
+++ b/users/templates/users/user.html
@@ -10,6 +10,9 @@ SPDX-License-Identifier: GPL-3.0-or-later
{% block content %}
{% bootstrap_form_errors userform %}
+
+ Changer le mot de passe
+