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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user