Affichage différent selon les droits.
This commit is contained in:
parent
8a4e51333e
commit
af2220be6b
4 changed files with 12 additions and 4 deletions
|
@ -48,3 +48,6 @@ class Content(models.Model):
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return self.name
|
return self.name
|
||||||
|
|
||||||
|
def manager_right(self):
|
||||||
|
return 'users.manage_' + str(self.school_owner.group.pk)
|
||||||
|
|
|
@ -6,12 +6,14 @@
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
<h2 class="display-5">{{content.name}}</h2>
|
<h2 class="display-5">{{content.name}}</h2>
|
||||||
<p class="lead">Contenu proposé par {{content.school_owner.group.name}}</p>
|
<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="d-flex justify-content-between align-items-center">
|
||||||
<div class="btn-group">
|
<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-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>
|
<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>
|
||||||
</div>
|
</div>
|
||||||
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -5,13 +5,14 @@
|
||||||
<h1>{{object.name}}</h1>
|
<h1>{{object.name}}</h1>
|
||||||
{% if manager_right in perms %}
|
{% if manager_right in perms %}
|
||||||
Numéro de téléphone :
|
Numéro de téléphone :
|
||||||
{% if object.school.phone %}{{object.school.phone}}{%else%}
|
{% if object.school.phone %}{{object.school.phone}}
|
||||||
Non indiqué{%endif%}<br/>
|
|
||||||
{%endif%}
|
|
||||||
<a class="btn btn-primary btn-sm" href="{% url 'users:edit-school-name' object.pk %}">
|
<a class="btn btn-primary btn-sm" href="{% url 'users:edit-school-name' object.pk %}">
|
||||||
<i class="fa fa-edit"></i>
|
<i class="fa fa-edit"></i>
|
||||||
Éditer
|
Éditer
|
||||||
</a>
|
</a>
|
||||||
|
{%else%}
|
||||||
|
Non indiqué{%endif%}<br/>
|
||||||
|
{%endif%}
|
||||||
{% if manager_right in perms %}
|
{% if manager_right in perms %}
|
||||||
<h2>Membres</h2>
|
<h2>Membres</h2>
|
||||||
<table class="table table-striped">
|
<table class="table table-striped">
|
||||||
|
@ -46,10 +47,12 @@ Non indiqué{%endif%}<br/>
|
||||||
</table>
|
</table>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<h2>Contenus</h2>
|
<h2>Contenus</h2>
|
||||||
|
{% if manager_right in perms %}
|
||||||
<a class="btn btn-success btn-sm" href="{% url 'content:content-new' %}">
|
<a class="btn btn-success btn-sm" href="{% url 'content:content-new' %}">
|
||||||
<i class="fa fa-plus"></i>
|
<i class="fa fa-plus"></i>
|
||||||
Ajouter un contenu
|
Ajouter un contenu
|
||||||
</a>
|
</a>
|
||||||
|
{% endif %}
|
||||||
<br />
|
<br />
|
||||||
<br />
|
<br />
|
||||||
<div class="row">
|
<div class="row">
|
||||||
|
|
|
@ -161,7 +161,7 @@ class School(LoginRequiredMixin, PermissionRequiredMixin, DetailView):
|
||||||
context['contents'] = Content.objects.filter(school_owner=self.object.school)
|
context['contents'] = Content.objects.filter(school_owner=self.object.school)
|
||||||
context['school'] = True
|
context['school'] = True
|
||||||
context['members'] = User.objects.filter(userprofile__school=self.object.school)
|
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')
|
context['manager_group'],_ = Group.objects.get_or_create(name=str(self.object.pk)+'_admins')
|
||||||
return context
|
return context
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue