core/counter: add generic operation logs and implements it for Sellings and Refilling deletions

This commit is contained in:
2019-11-13 23:14:21 +01:00
parent 129f2e53ee
commit e634cda318
13 changed files with 467 additions and 192 deletions

View File

@ -0,0 +1,32 @@
{% extends "core/base.jinja" %}
{% from 'core/macros.jinja' import paginate %}
{% block title %}
{% trans %}Operation logs{% endtrans %}
{% endblock %}
{% block content %}
<table>
<thead>
<tr>
<th>{% trans %}Date{% endtrans %}</th>
<th>{% trans %}Operation type{% endtrans %}</th>
<th>{% trans %}Label{% endtrans %}</th>
<th>{% trans %}Operator{% endtrans %}</th>
</tr>
</thead>
<tbody>
{% for log in object_list %}
<tr>
<td>{{ log.date }} </td>
<td>{{ log.get_operation_type_display() }}</td>
<td>{{ log.label }}</td>
<td>{{ log.operator }}</td>
</tr>
{% endfor %}
</tbody>
</table>
<br>
{{ paginate(page_obj, paginator) }}
{% endblock content %}

View File

@ -2,6 +2,7 @@
#
# Copyright 2016,2017
# - Skia <skia@libskia.so>
# - Sli <antoine@bartuccio.fr>
#
# Ce fichier fait partie du site de l'Association des Étudiants de l'UTBM,
# http://ae.utbm.fr.
@ -33,4 +34,5 @@ urlpatterns = [
DeleteAllForumUserMessagesView.as_view(),
name="delete_forum_messages",
),
re_path(r"^logs$", OperationLogListView.as_view(), name="operation_logs"),
]

View File

@ -25,13 +25,15 @@
from django.utils.translation import ugettext as _
from django.views.generic.edit import FormView
from django.views.generic import ListView
from django.urls import reverse
from django import forms
from django.core.exceptions import PermissionDenied
from ajax_select.fields import AutoCompleteSelectField
from core.models import User
from core.views import CanEditPropMixin
from core.models import User, OperationLog
from counter.models import Customer
from forum.models import ForumMessageMeta
@ -165,3 +167,14 @@ class DeleteAllForumUserMessagesView(FormView):
def get_success_url(self):
return reverse("core:user_profile", kwargs={"user_id": self.user.id})
class OperationLogListView(ListView, CanEditPropMixin):
"""
List all logs
"""
model = OperationLog
template_name = "rootplace/logs.jinja"
ordering = ["-date"]
paginate_by = 100