mirror of
https://gitlab2.federez.net/re2o/re2o
synced 2024-11-26 06:32:26 +00:00
Calcul la date dans views pour affichage plus condensé + préfiltre les révisions
Si quelqu'un sait faire le préfiltre avec des request de type .filter je suis preneur. J'ai peur que la solution actuelle soit lente pour un grand nombre d'event (tous parsés) Mais de toute façon le filtre est obligé d'être dans views
This commit is contained in:
parent
2797ec29b6
commit
8e974cc82d
2 changed files with 17 additions and 8 deletions
|
@ -37,24 +37,24 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
{% for revision in revisions_list %}
|
{% for revision in revisions_list %}
|
||||||
{% for reversion in revision.version_set.all %}
|
{% for reversion in revision.revision.version_set.all %}
|
||||||
{% if reversion.content_type.name in 'ban,whitelist,user,vente,interface'|slice:',' %}
|
{% if reversion.content_type.name in 'ban,whitelist,user,vente,interface'|slice:',' %}
|
||||||
<tr>
|
<tr>
|
||||||
<td>{{ revision.date_created }}</td>
|
<td>{{ revision.datetime }}</td>
|
||||||
{% if reversion.content_type.name == 'ban' %}
|
{% if reversion.content_type.name == 'ban' %}
|
||||||
<td>{{ revision.user.get_username }} a banni <a href="{% url 'users:profil' reversion.object.user_id %}">{{ reversion.object.user.get_username }}</a> (<i>{{ reversion.object.raison }}</i>)</td>
|
<td>{{ revision.revision.user.get_username }} a banni <a href="{% url 'users:profil' reversion.object.user_id %}">{{ reversion.object.user.get_username }}</a> (<i>{{ reversion.object.raison }}</i>)</td>
|
||||||
{% elif reversion.content_type.name == 'whitelist' %}
|
{% elif reversion.content_type.name == 'whitelist' %}
|
||||||
<td>{{ revision.user.get_username }} a autorisé gracieusement <a href="{% url 'users:profil' reversion.object.user_id %}">{{ reversion.object.user.get_username }}</a> (<i>{{ reversion.object.raison }}</i>)</td>
|
<td>{{ revision.revision.user.get_username }} a autorisé gracieusement <a href="{% url 'users:profil' reversion.object.user_id %}">{{ reversion.object.user.get_username }}</a> (<i>{{ reversion.object.raison }}</i>)</td>
|
||||||
{% elif reversion.content_type.name == 'user' %}
|
{% elif reversion.content_type.name == 'user' %}
|
||||||
<td>{{ revision.user.get_username }} a ajouté <a href="{% url 'users:profil' reversion.object.id %}">{{ reversion.object.get_username }}</a></td>
|
<td>{{ revision.revision.user.get_username }} a ajouté <a href="{% url 'users:profil' reversion.object.id %}">{{ reversion.object.get_username }}</a></td>
|
||||||
{% elif reversion.content_type.name == 'vente' %}
|
{% elif reversion.content_type.name == 'vente' %}
|
||||||
<td><a href="{% url 'users:profil' reversion.object.facture.user_id %}">{{ reversion.object.facture.user.get_username }}</a> a acheté {{ reversion.object.number }}x {{ reversion.object.name }}{% if reversion.object.iscotisation %} (<i>+{{ reversion.object.duration }} mois</i>){% endif %}</td>
|
<td><a href="{% url 'users:profil' reversion.object.facture.user_id %}">{{ reversion.object.facture.user.get_username }}</a> a acheté {{ reversion.object.number }}x {{ reversion.object.name }}{% if reversion.object.iscotisation %} (<i>+{{ reversion.object.duration }} mois</i>){% endif %}</td>
|
||||||
{% elif reversion.content_type.name == 'interface' %}
|
{% elif reversion.content_type.name == 'interface' %}
|
||||||
<td>{{ revision.user.get_username }} 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>
|
<td>{{ revision.revision.user.get_username }} 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 %}
|
{% endif %}
|
||||||
{% if is_bureau %}
|
{% if is_bureau %}
|
||||||
<td>
|
<td>
|
||||||
<a class="btn btn-danger btn-sm" role="button" href="{% url 'logs:revert-action' revision.id %}">
|
<a class="btn btn-danger btn-sm" role="button" href="{% url 'logs:revert-action' revision.revision.id %}">
|
||||||
<i class="glyphicon glyphicon-remove"></i>
|
<i class="glyphicon glyphicon-remove"></i>
|
||||||
Annuler
|
Annuler
|
||||||
</a>
|
</a>
|
||||||
|
|
|
@ -69,7 +69,16 @@ def form(ctx, template, request):
|
||||||
def index(request):
|
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 = Revision.objects.all().order_by('date_created').reverse().select_related('user').prefetch_related('version_set__object')
|
|
||||||
|
revisions_not_filtered = Revision.objects.all().order_by('date_created').reverse().select_related('user').prefetch_related('version_set__object')
|
||||||
|
revisions = []
|
||||||
|
for revision in revisions_not_filtered :
|
||||||
|
reversions = revision.version_set.all()
|
||||||
|
for reversion in reversions :
|
||||||
|
if reversion.content_type.name in ['ban', 'whitelist', 'vente', 'cotisation', 'interface', 'machine', 'user'] :
|
||||||
|
revisions.append( {'datetime':revision.date_created.strftime('%d/%m/%y %H:%M:%S'), 'revision':revision } )
|
||||||
|
break
|
||||||
|
|
||||||
paginator = Paginator(revisions, pagination_number)
|
paginator = Paginator(revisions, pagination_number)
|
||||||
page = request.GET.get('page')
|
page = request.GET.get('page')
|
||||||
try:
|
try:
|
||||||
|
|
Loading…
Reference in a new issue