mirror of
https://gitlab2.federez.net/re2o/re2o
synced 2024-12-26 00:43:46 +00:00
Déplace une partie des vérif dans views pour alléger le template
This commit is contained in:
parent
c5e7431e1a
commit
67b271008b
3 changed files with 63 additions and 83 deletions
|
@ -36,76 +36,51 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
<th></th>
|
<th></th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
{% for revision in revisions_list %}
|
{% for rev in reversions_list %}
|
||||||
{% for reversion in revision.revision.version_set.all %}
|
<tr>
|
||||||
{% if reversion.content_type.name in 'ban,whitelist,user,vente,interface'|slice:',' %}
|
<td>{{ rev.datetime }}</td>
|
||||||
<tr>
|
{% if rev.rev.content_type.name == 'ban' %}
|
||||||
<td>{{ revision.datetime }}</td>
|
<td>
|
||||||
{% if reversion.content_type.name == 'ban' %}
|
{{ rev.username }} a banni
|
||||||
<td>
|
<a href="{% url 'users:profil' rev.rev.object.user_id %}">{{ rev.rev.object.user.get_username }}</a>
|
||||||
{% if revision.revision.user.et_username %}
|
(<i>{{ rev.rev.object.raison }}</i>)
|
||||||
{{ revision.revision.user.get_username }}
|
</td>
|
||||||
{% else %}
|
{% elif rev.rev.content_type.name == 'whitelist' %}
|
||||||
?
|
<td>
|
||||||
{% endif %}
|
{{ rev.username }} a autorisé gracieusement
|
||||||
a banni
|
<a href="{% url 'users:profil' rev.rev.object.user_id %}">{{ rev.rev.object.user.get_username }}</a>
|
||||||
<a href="{% url 'users:profil' reversion.object.user_id %}">{{ reversion.object.user.get_username }}</a>
|
(<i>{{ rev.rev.object.raison }}</i>)
|
||||||
(<i>{{ reversion.object.raison }}</i>)
|
</td>
|
||||||
</td>
|
{% elif rev.rev.content_type.name == 'user' %}
|
||||||
{% elif reversion.content_type.name == 'whitelist' %}
|
<td>
|
||||||
<td>
|
{{ rev.username }} a ajouté
|
||||||
{% if revision.revision.user.get_username %}
|
<a href="{% url 'users:profil' rev.rev.object.id %}">{{ rev.rev.object.get_username }}</a>
|
||||||
{{ revision.revision.user.get_username }}
|
</td>
|
||||||
{% else %}
|
{% elif rev.rev.content_type.name == 'vente' %}
|
||||||
?
|
<td>
|
||||||
{% endif %}
|
<a href="{% url 'users:profil' rev.rev.object.facture.user_id %}">{{ rev.rev.object.facture.user.get_username }}</a>
|
||||||
a autorisé gracieusement
|
a acheté {{ rev.rev.object.number }}x {{ rev.rev.object.name }}
|
||||||
<a href="{% url 'users:profil' reversion.object.user_id %}">{{ reversion.object.user.get_username }}</a>
|
{% if rev.rev.object.iscotisation %}
|
||||||
(<i>{{ reversion.object.raison }}</i>)
|
(<i>+{{ rev.rev.object.duration }} mois</i>)
|
||||||
</td>
|
{% endif %}
|
||||||
{% elif reversion.content_type.name == 'user' %}
|
</td>
|
||||||
<td>
|
{% elif rev.rev.content_type.name == 'interface' %}
|
||||||
{% if revision.revision.user.get_username %}
|
<td>
|
||||||
{{ revision.revision.user.get_username }}
|
{{ rev.username }} a ajouté une interface à
|
||||||
{% else %}
|
<a href="{% url 'users:profil' rev.rev.object.machine.user_id %}">{{ rev.rev.object.machine.user.get_username }}</a>
|
||||||
?
|
(<i>MAC : {{ rev.rev.object.mac_bare }}</i>)
|
||||||
{% endif %}
|
</td>
|
||||||
a ajouté
|
{% endif %}
|
||||||
<a href="{% url 'users:profil' reversion.object.id %}">{{ reversion.object.get_username }}</a>
|
{% if is_bureau %}
|
||||||
</td>
|
<td>
|
||||||
{% elif reversion.content_type.name == 'vente' %}
|
<a class="btn btn-danger btn-sm" role="button" href="{% url 'logs:revert-action' rev.id %}">
|
||||||
<td>
|
<i class="glyphicon glyphicon-remove"></i>
|
||||||
<a href="{% url 'users:profil' reversion.object.facture.user_id %}">{{ reversion.object.facture.user.get_username }}</a>
|
Annuler
|
||||||
a acheté
|
</a>
|
||||||
{{ reversion.object.number }}x {{ reversion.object.name }}
|
</td>
|
||||||
{% if reversion.object.iscotisation %}
|
{% endif %}
|
||||||
(<i>+{{ reversion.object.duration }} mois</i>)
|
</tr>
|
||||||
{% endif %}
|
{% endfor %}
|
||||||
</td>
|
|
||||||
{% elif reversion.content_type.name == 'interface' %}
|
|
||||||
<td>
|
|
||||||
{% if revision.revision.user.get_username %}
|
|
||||||
{{ revision.revision.user.get_username }}
|
|
||||||
{% else %}
|
|
||||||
?
|
|
||||||
{% endif %}
|
|
||||||
a ajouté une interface à
|
|
||||||
<a href="{% url 'users:profil' reversion.object.machine.user_id %}">{{ reversion.object.machine.user.get_username }}</a>
|
|
||||||
(<i>MAC : {{ reversion.object.mac_bare }}</i>)
|
|
||||||
</td>
|
|
||||||
{% endif %}
|
|
||||||
{% if is_bureau %}
|
|
||||||
<td>
|
|
||||||
<a class="btn btn-danger btn-sm" role="button" href="{% url 'logs:revert-action' revision.revision.id %}">
|
|
||||||
<i class="glyphicon glyphicon-remove"></i>
|
|
||||||
Annuler
|
|
||||||
</a>
|
|
||||||
</td>
|
|
||||||
{% endif %}
|
|
||||||
</tr>
|
|
||||||
{% endif %}
|
|
||||||
{% endfor %}
|
|
||||||
{% endfor %}
|
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -29,7 +29,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<h2>Actions effectuées</h2>
|
<h2>Actions effectuées</h2>
|
||||||
{% include "logs/aff_summary.html" with revisions_list=revisions_list %}
|
{% include "logs/aff_summary.html" with reversions_list=reversions_list %}
|
||||||
<br />
|
<br />
|
||||||
<br />
|
<br />
|
||||||
<br />
|
<br />
|
||||||
|
|
|
@ -70,26 +70,31 @@ def index(request):
|
||||||
options, created = GeneralOption.objects.get_or_create()
|
options, created = GeneralOption.objects.get_or_create()
|
||||||
pagination_number = options.pagination_number
|
pagination_number = options.pagination_number
|
||||||
|
|
||||||
revisions_not_filtered = Revision.objects.all().order_by('date_created').reverse().select_related('user').prefetch_related('version_set__object')
|
revisions = Revision.objects.all().order_by('date_created').reverse().select_related('user').prefetch_related('version_set__object')
|
||||||
revisions = []
|
reversions = []
|
||||||
for revision in revisions_not_filtered :
|
for revision in revisions :
|
||||||
reversions = revision.version_set.all()
|
for reversion in revision.version_set.all() :
|
||||||
for reversion in reversions :
|
if reversion.content_type.name in ['ban', 'whitelist', 'vente', 'cotisation', 'interface', 'user'] :
|
||||||
if reversion.content_type.name in ['ban', 'whitelist', 'vente', 'cotisation', 'interface', 'machine', 'user'] :
|
reversions.append(
|
||||||
revisions.append( {'datetime':revision.date_created.strftime('%d/%m/%y %H:%M:%S'), 'revision':revision } )
|
{'id' : revision.id,
|
||||||
|
'datetime': revision.date_created.strftime('%d/%m/%y %H:%M:%S'),
|
||||||
|
'username': revision.user.get_username() if revision.user else '?',
|
||||||
|
'user_id': revision.user_id,
|
||||||
|
'rev': reversion }
|
||||||
|
)
|
||||||
break
|
break
|
||||||
|
|
||||||
paginator = Paginator(revisions, pagination_number)
|
paginator = Paginator(reversions, pagination_number)
|
||||||
page = request.GET.get('page')
|
page = request.GET.get('page')
|
||||||
try:
|
try:
|
||||||
revisions = paginator.page(page)
|
reversions = paginator.page(page)
|
||||||
except PageNotAnInteger:
|
except PageNotAnInteger:
|
||||||
# If page is not an integer, deliver first page.
|
# If page is not an integer, deliver first page.
|
||||||
revisions = paginator.page(1)
|
reversions = paginator.page(1)
|
||||||
except EmptyPage:
|
except EmptyPage:
|
||||||
# If page is out of range (e.g. 9999), deliver last page of results.
|
# If page is out of range (e.g. 9999), deliver last page of results.
|
||||||
revisions = paginator.page(paginator.num_pages)
|
reversions = paginator.page(paginator.num_pages)
|
||||||
return render(request, 'logs/index.html', {'revisions_list': revisions})
|
return render(request, 'logs/index.html', {'reversions_list': reversions})
|
||||||
|
|
||||||
@login_required
|
@login_required
|
||||||
@permission_required('cableur')
|
@permission_required('cableur')
|
||||||
|
|
Loading…
Reference in a new issue