Affichage différent selon les droits.

This commit is contained in:
Klafyvel 2018-03-02 10:28:31 +01:00
parent 8a4e51333e
commit af2220be6b
4 changed files with 12 additions and 4 deletions

View file

@ -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)

View file

@ -6,12 +6,14 @@
<div class="card-body">
<h2 class="display-5">{{content.name}}</h2>
<p class="lead">Contenu proposé par {{content.school_owner.group.name}}</p>
{% if content.manager_right in perms %}
<div class="d-flex justify-content-between align-items-center">
<div class="btn-group">
<a class="btn btn-sm btn-outline-primary"i href="{% url "content:content-edit" content.pk %}"><i class="fa fa-edit"></i> Éditer</a>
<a class="btn btn-sm btn-outline-danger" href="{% url "content:content-delete" content.pk %}" ><i class="fa fa-trash"></i> Supprimer</a>
</div>
</div>
{% endif %}
</div>
</div>
</div>

View file

@ -5,13 +5,14 @@
<h1>{{object.name}}</h1>
{% if manager_right in perms %}
Numéro de téléphone :
{% if object.school.phone %}{{object.school.phone}}{%else%}
Non indiqué{%endif%}<br/>
{%endif%}
{% if object.school.phone %}{{object.school.phone}}
<a class="btn btn-primary btn-sm" href="{% url 'users:edit-school-name' object.pk %}">
<i class="fa fa-edit"></i>
Éditer
</a>
{%else%}
Non indiqué{%endif%}<br/>
{%endif%}
{% if manager_right in perms %}
<h2>Membres</h2>
<table class="table table-striped">
@ -46,10 +47,12 @@ Non indiqué{%endif%}<br/>
</table>
{% endif %}
<h2>Contenus</h2>
{% if manager_right in perms %}
<a class="btn btn-success btn-sm" href="{% url 'content:content-new' %}">
<i class="fa fa-plus"></i>
Ajouter un contenu
</a>
{% endif %}
<br />
<br />
<div class="row">

View file

@ -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