Affichage de plus d'information sur la page admin

This commit is contained in:
Klafyvel 2018-03-02 10:02:54 +01:00
parent 0c75f32c5f
commit e62359e4fa
2 changed files with 8 additions and 1 deletions

View file

@ -43,12 +43,16 @@
<tr> <tr>
<th>Nom</th> <th>Nom</th>
<th>Nombre de membres</th> <th>Nombre de membres</th>
<th>Nombre de contenus</th>
<th>Nombre de catégories</th>
<th>Numéro de téléphone</th> <th>Numéro de téléphone</th>
<th></th> <th></th>
{% for school in schools %} {% for school in schools %}
<tr> <tr>
<th>{{school.group.name}}</th> <th>{{school.group.name}}</th>
<td>{{school.group.user_set.count}}</td> <td>{{school.group.user_set.count}}</td>
<td>{{school.content_set.count}}</td>
<td>{{school.number_of_categories}}</td>
<td>{{school.phone}}</td> <td>{{school.phone}}</td>
<td><a class="btn btn-outline-primary btn-sm" href="{% url "users:edit-school-name" pk=school.group.pk%}"> <td><a class="btn btn-outline-primary btn-sm" href="{% url "users:edit-school-name" pk=school.group.pk%}">
<i class="fas fa-edit"></i> <i class="fas fa-edit"></i>

View file

@ -36,7 +36,10 @@ class SchoolProfile(models.Model):
return self.group.name return self.group.name
def get_absolute_url(self): def get_absolute_url(self):
return reverse("users:school", kwargs={'pk':self.pk}) return reverse("users:school", kwargs={'pk':self.group.pk})
def number_of_categories(self):
return self.content_set.values('category').distinct().count()
def save(self, *args, **kwargs): def save(self, *args, **kwargs):
viewing_right, _ = Permission.objects.get_or_create( viewing_right, _ = Permission.objects.get_or_create(