Compensation detail view

* adds compensation detail view (WIP)
* adds includes dir for related objects, similar to interventions
* adds functionality for
   * adding/removing before_states
   * adding/removing after_states
   * adding/removing deadlines
   * adding/removing documents
* refactors usage of BaseModalForm
   * holds now process_request() in base class for generic usage anywhere
* adds __str__() method for some models
* compensation__action is blank=True now
* renamed tooltips
* adds new routes for state/deadline/document handling inside of compensation/urls.py
* adds precalculation of before/after_states for detail view, so users will see directly if there are missing states
* removes unnecessary link for intervention detail payment
* adds missing tooltips for check and record icon on detail views
* refactors DeadlineTypeEnum into DeadlineType in konova/models.py, just as the django 3.x documentation suggests for model enumerations
* UuidModel id field is not editable anymore in the admin interface
* adds/updates translations
This commit is contained in:
mipel
2021-08-03 13:13:01 +02:00
parent a06b532108
commit 881edaeba6
22 changed files with 1010 additions and 236 deletions

View File

@@ -132,12 +132,12 @@ class InterventionTable(BaseTable):
"""
html = ""
checked = value is not None
tooltip = _("Not registered yet")
tooltip = _("Not recorded yet")
if checked:
value = value.timestamp
value = localtime(value)
on = value.strftime(DEFAULT_DATE_TIME_FORMAT)
tooltip = _("Registered on {} by {}").format(on, record.recorded.user)
tooltip = _("Recorded on {} by {}").format(on, record.recorded.user)
html += self.render_bookmark(
tooltip=tooltip,
icn_filled=checked,

View File

@@ -42,9 +42,7 @@
{% for pay in intervention.payments.all %}
<tr>
<td class="align-middle">
<a href="{% url 'compensation:pay-open' pay.id %}">
{{ pay.amount|floatformat:2 }} €
</a>
{{ pay.amount|floatformat:2 }} €
</td>
<td class="align-middle">{{ pay.due_on }}</td>
<td class="align-middle">{{ pay.comment }}</td>

View File

@@ -110,7 +110,7 @@
<th scope="row">{% trans 'Recorded' %}</th>
<td class="align-middle">
{% if intervention.recorded is None %}
<span>
<span title="{% trans 'Not recorded yet' %}">
{% fa5_icon 'bookmark' 'far' %}
</span>
{% else %}

View File

@@ -10,7 +10,6 @@ from intervention.tables import InterventionTable
from konova.contexts import BaseContext
from konova.decorators import *
from konova.forms import SimpleGeomForm, NewDocumentForm, RemoveModalForm
from konova.utils.message_templates import FORM_INVALID
from konova.utils.user_checks import in_group
@@ -89,30 +88,7 @@ def new_document_view(request: HttpRequest, id: str):
"""
intervention = get_object_or_404(Intervention, id=id)
form = NewDocumentForm(request.POST or None, request.FILES or None, instance=intervention, user=request.user)
template = form.template
if request.method == "POST":
if form.is_valid():
doc = form.save()
messages.success(
request,
_("Document '{}' added").format(doc.title)
)
return redirect(request.META.get("HTTP_REFERER", "home"))
else:
messages.info(
request,
FORM_INVALID
)
return redirect(request.META.get("HTTP_REFERER", "home"))
elif request.method == "GET":
context = {
"form": form
}
context = BaseContext(request, context).context
return render(request, template, context)
else:
raise NotImplementedError
return form.process_request(request)
@login_required