From af2220be6b1190baf43dda34b408a4f470906d0f Mon Sep 17 00:00:00 2001 From: Klafyvel Date: Fri, 2 Mar 2018 10:28:31 +0100 Subject: [PATCH] =?UTF-8?q?Affichage=20diff=C3=A9rent=20selon=20les=20droi?= =?UTF-8?q?ts.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- content/models.py | 3 +++ content/templates/content/content.html | 2 ++ users/templates/users/school.html | 9 ++++++--- users/views.py | 2 +- 4 files changed, 12 insertions(+), 4 deletions(-) diff --git a/content/models.py b/content/models.py index 99a61f4..6c5b204 100644 --- a/content/models.py +++ b/content/models.py @@ -48,3 +48,6 @@ class Content(models.Model): def __str__(self): return self.name + + def manager_right(self): + return 'users.manage_' + str(self.school_owner.group.pk) diff --git a/content/templates/content/content.html b/content/templates/content/content.html index 3f86de4..3785644 100644 --- a/content/templates/content/content.html +++ b/content/templates/content/content.html @@ -6,12 +6,14 @@

{{content.name}}

Contenu proposé par {{content.school_owner.group.name}}

+ {% if content.manager_right in perms %} + {% endif %}
diff --git a/users/templates/users/school.html b/users/templates/users/school.html index 79d7a88..e76fd7f 100644 --- a/users/templates/users/school.html +++ b/users/templates/users/school.html @@ -5,13 +5,14 @@

{{object.name}}

{% if manager_right in perms %} Numéro de téléphone : -{% if object.school.phone %}{{object.school.phone}}{%else%} -Non indiqué{%endif%}
-{%endif%} +{% if object.school.phone %}{{object.school.phone}} Éditer +{%else%} +Non indiqué{%endif%}
+{%endif%} {% if manager_right in perms %}

Membres

@@ -46,10 +47,12 @@ Non indiqué{%endif%}
{% endif %}

Contenus

+{% if manager_right in perms %} Ajouter un contenu +{% endif %}

diff --git a/users/views.py b/users/views.py index b9ad3f9..a939e8f 100644 --- a/users/views.py +++ b/users/views.py @@ -161,7 +161,7 @@ class School(LoginRequiredMixin, PermissionRequiredMixin, DetailView): context['contents'] = Content.objects.filter(school_owner=self.object.school) context['school'] = True context['members'] = User.objects.filter(userprofile__school=self.object.school) - context['manager_right'] = 'auth.manage_' + str(self.object.pk) + context['manager_right'] = 'users.manage_' + str(self.object.pk) context['manager_group'],_ = Group.objects.get_or_create(name=str(self.object.pk)+'_admins') return context