* adds modal_generic.html template for generic usage
* adds M2M field log to BaseObject
* adds show log button to controls.html
* adds logging on adding related objects
* adds render log table using generic modal
* adds tooltip to missing values in detail views
* adds/updates translations
This commit is contained in:
mipel
2021-08-05 12:54:28 +02:00
parent f69d98460f
commit 5efa755188
18 changed files with 368 additions and 146 deletions

View File

@@ -133,12 +133,7 @@ class NewInterventionForm(BaseForm):
created=action,
)
intervention.save()
for doc in documents:
doc_obj = Document()
doc_obj.file = doc
# ToDo Add functionality for other attributes
doc_obj.save()
intervention.documents.add(doc_obj)
intervention.log.add(action)
return intervention
@@ -201,12 +196,12 @@ class EditInterventionForm(NewInterventionForm):
self.instance.geometry = geometry
self.instance.save()
for doc in documents:
doc_obj = Document()
doc_obj.document = doc
# ToDo Add functionality for other attributes
doc_obj.save()
self.instance.documents.add(doc_obj)
user_action = UserActionLogEntry.objects.create(
user=self.user,
action=UserAction.EDITED
)
self.instance.log.add(user_action)
return self.instance
@@ -364,10 +359,14 @@ class NewRevocationForm(BaseModalForm):
def save(self):
with transaction.atomic():
user_action = UserActionLogEntry.objects.create(
created_action = UserActionLogEntry.objects.create(
user=self.user,
action=UserAction.CREATED
)
edited_action = UserActionLogEntry.objects.create(
user=self.user,
action=UserAction.EDITED
)
document = Document.objects.create(
title="revocation_of_{}".format(self.instance.identifier),
date_of_creation=self.cleaned_data["date"],
@@ -378,8 +377,9 @@ class NewRevocationForm(BaseModalForm):
date=self.cleaned_data["date"],
comment=self.cleaned_data["comment"],
document=document,
created=user_action,
created=created_action,
)
self.instance.log.add(edited_action)
self.instance.legal.revocation = revocation
self.instance.legal.save()
return revocation
@@ -421,4 +421,5 @@ class RunCheckForm(BaseModalForm):
if self.instance.checked:
self.instance.checked.delete()
self.instance.checked = user_action
self.instance.save()
self.instance.log.add(user_action)
self.instance.save()

View File

@@ -17,7 +17,7 @@ from konova.models import BaseObject, Geometry, UuidModel, BaseResource
from konova.utils import generators
from konova.utils.generators import generate_random_string
from organisation.models import Organisation
from user.models import UserActionLogEntry, UserAction
from user.models import UserActionLogEntry
class ResponsibilityData(UuidModel):
@@ -123,7 +123,7 @@ class Intervention(BaseObject):
next_version = models.ForeignKey("Intervention", null=True, blank=True, on_delete=models.DO_NOTHING)
# Users having access on this object
users = models.ManyToManyField(User)
users = models.ManyToManyField(User, help_text="Users having access (data shared with)")
access_token = models.CharField(
max_length=255,
null=True,

View File

@@ -27,15 +27,18 @@
</button>
</a>
{% endif %}
{% if is_default_member %}
<a href="{% url 'home' %}" class="mr-2">
<button class="btn btn-default" title="{% trans 'Edit' %}">
{% fa5_icon 'edit' %}
{% if is_default_member %}
<a href="{% url 'home' %}" class="mr-2">
<button class="btn btn-default" title="{% trans 'Edit' %}">
{% fa5_icon 'edit' %}
</button>
</a>
<button class="btn btn-default btn-modal mr-2" data-form-url="{% url 'intervention:log' intervention.id %}" title="{% trans 'Show log' %}">
{% fa5_icon 'history' %}
</button>
</a>
<button class="btn btn-default btn-modal" data-form-url="{% url 'intervention:remove' intervention.id %}" title="{% trans 'Delete' %}">
{% fa5_icon 'trash' %}
</button>
{% endif %}
<button class="btn btn-default btn-modal" data-form-url="{% url 'intervention:remove' intervention.id %}" title="{% trans 'Delete' %}">
{% fa5_icon 'trash' %}
</button>
{% endif %}
{% endif %}
</div>

View File

@@ -20,15 +20,15 @@
<div class="col-sm-12 col-md-12 col-lg-6">
<div class="table-container">
<table class="table table-hover">
<tr {% if not intervention.title %}class="alert alert-danger"{% endif %}>
<tr {% if not intervention.title %}class="alert alert-danger" title="{% trans 'Missing' %}" {% endif %}>
<th class="w-25" scope="row">{% trans 'Title' %}</th>
<td class="align-middle">{{intervention.title|default_if_none:""}}</td>
</tr>
<tr {% if not intervention.legal.process_type %}class="alert alert-danger"{% endif %}>
<tr {% if not intervention.legal.process_type %}class="alert alert-danger" title="{% trans 'Missing' %}" {% endif %}>
<th scope="row">{% trans 'Process type' %}</th>
<td class="align-middle">{{intervention.legal.process_type|default_if_none:""}}</td>
</tr>
<tr {% if not intervention.legal.law %}class="alert alert-danger"{% endif %}>
<tr {% if not intervention.legal.law %}class="alert alert-danger" title="{% trans 'Missing' %}" {% endif %}>
<th scope="row">{% trans 'Law' %}</th>
<td class="align-middle">{{intervention.legal.law|default_if_none:""}}</td>
</tr>
@@ -36,7 +36,7 @@
<th scope="row">{% trans 'Registration office' %}</th>
<td class="align-middle">{{intervention.responsible.registration_office|default_if_none:""}}</td>
</tr>
<tr {% if not intervention.responsible.registration_file_number %}class="alert alert-danger"{% endif %}>
<tr {% if not intervention.responsible.registration_file_number %}class="alert alert-danger" title="{% trans 'Missing' %}" {% endif %}>
<th scope="row">{% trans 'Registration office file number' %}</th>
<td class="align-middle">{{intervention.responsible.registration_file_number|default_if_none:""}}</td>
</tr>
@@ -48,7 +48,7 @@
<th scope="row">{% trans 'Conversation office file number' %}</th>
<td class="align-middle">{{intervention.responsible.conservation_file_number|default_if_none:""}}</td>
</tr>
<tr {% if not intervention.responsible.handler %}class="alert alert-danger"{% endif %}>
<tr {% if not intervention.responsible.handler %}class="alert alert-danger" title="{% trans 'Missing' %}" {% endif %}>
<th scope="row">{% trans 'Intervention handler' %}</th>
<td class="align-middle">{{intervention.responsible.handler|default_if_none:""}}</td>
</tr>
@@ -80,15 +80,15 @@
{% endif %}
</td>
</tr>
<tr {% if not intervention.legal.registration_date %}class="alert alert-danger"{% endif %}>
<tr {% if not intervention.legal.registration_date %}class="alert alert-danger" title="{% trans 'Missing' %}" {% endif %}>
<th scope="row">{% trans 'Registration date' %}</th>
<td class="align-middle">{{intervention.legal.registration_date|default_if_none:""}}</td>
</tr>
<tr {% if not intervention.legal.binding_date %}class="alert alert-danger"{% endif %}>
<tr {% if not intervention.legal.binding_date %}class="alert alert-danger" title="{% trans 'Missing' %}" {% endif %}>
<th scope="row">{% trans 'Binding on' %}</th>
<td class="align-middle">{{intervention.legal.binding_date|default_if_none:""}}</td>
</tr>
<tr {% if intervention.legal.revocation %}class="alert alert-danger"{% endif %}>
<tr {% if intervention.legal.revocation %}class="alert alert-danger" title="{% trans 'Missing' %}" {% endif %}>
<th scope="row">{% trans 'Revocation' %}</th>
<td class="align-middle">{{intervention.legal.revocation.date|naturalday|default_if_none:""}}</td>
</tr>

View File

@@ -8,7 +8,7 @@ Created on: 30.11.20
from django.urls import path
from intervention.views import index_view, new_view, open_view, edit_view, remove_view, new_document_view, share_view, \
create_share_view, remove_revocation_view, new_revocation_view, run_check_view
create_share_view, remove_revocation_view, new_revocation_view, run_check_view, log_view
app_name = "intervention"
urlpatterns = [
@@ -16,6 +16,7 @@ urlpatterns = [
path('new/', new_view, name='new'),
path('<id>/document/new/', new_document_view, name='new-doc'),
path('<id>', open_view, name='open'),
path('<id>/log', log_view, name='log'),
path('<id>/edit', edit_view, name='edit'),
path('<id>/remove', remove_view, name='remove'),
path('<id>/share/<token>', share_view, name='share'),

View File

@@ -370,3 +370,25 @@ def new_revocation_view(request: HttpRequest, id: str):
raise NotImplementedError
@login_required
def log_view(request: HttpRequest, id: str):
""" Renders a log view using modal
Args:
request (HttpRequest): The incoming request
id (str): The compensation's id
Returns:
"""
intervention = get_object_or_404(Intervention, id=id)
template = "modal/modal_generic.html"
body_template = "log.html"
context = {
"modal_body_template": body_template,
"log": intervention.log.all().order_by("-timestamp"),
"modal_title": _("Log"),
}
context = BaseContext(request, context).context
return render(request, template, context)