Compare commits
3 Commits
2889b10e0d
...
09fad6a2de
Author | SHA1 | Date | |
---|---|---|---|
|
09fad6a2de | ||
|
1ff02c30a6 | ||
|
1d4be22da5 |
@ -26,7 +26,6 @@ class NewPaymentForm(BaseModalForm):
|
||||
label=_("Amount"),
|
||||
label_suffix=_(""),
|
||||
help_text=_("Amount in Euro"),
|
||||
localize=True,
|
||||
)
|
||||
due = forms.DateField(
|
||||
label=_("Due on"),
|
||||
@ -49,6 +48,7 @@ class NewPaymentForm(BaseModalForm):
|
||||
)
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
self.template = "modal/modal_form.html"
|
||||
super().__init__(*args, **kwargs)
|
||||
self.intervention = self.instance
|
||||
self.form_title = _("Payment")
|
||||
|
@ -125,9 +125,9 @@ def new_payment_view(request: HttpRequest, intervention_id: str):
|
||||
Returns:
|
||||
|
||||
"""
|
||||
template = "modal/modal_form.html"
|
||||
intervention = get_object_or_404(Intervention, id=intervention_id)
|
||||
form = NewPaymentForm(request.POST or None, instance=intervention, user=request.user)
|
||||
template = form.template
|
||||
if request.method == "POST":
|
||||
if form.is_valid():
|
||||
payment = form.save()
|
||||
@ -163,9 +163,9 @@ def payment_remove_view(request: HttpRequest, id: str):
|
||||
Returns:
|
||||
|
||||
"""
|
||||
template = "modal/modal_form.html"
|
||||
payment = get_object_or_404(Payment, id=id)
|
||||
form = RemoveModalForm(request.POST or None, instance=payment, user=request.user)
|
||||
template = form.template
|
||||
if request.method == "POST":
|
||||
if form.is_valid():
|
||||
form.save()
|
||||
|
@ -1,328 +0,0 @@
|
||||
{% extends 'base.html' %}
|
||||
{% load i18n l10n static fontawesome_5 humanize %}
|
||||
|
||||
{% block head %}
|
||||
|
||||
{% endblock %}
|
||||
|
||||
{% block body %}
|
||||
|
||||
<div id="detail-header" class="row">
|
||||
<div class="col-sm-12 col-md-12 col-lg-6">
|
||||
<h3>{% trans 'Intervention' %} {{intervention.identifier}}</h3>
|
||||
</div>
|
||||
<div class="col-sm-12 col-md-12 col-lg-6">
|
||||
<div class="d-flex justify-content-end">
|
||||
<a href="{% url 'home' %}" class="mr-2">
|
||||
<button class="btn btn-default" title="{% trans 'Open in LANIS' %}">
|
||||
LANIS
|
||||
</button>
|
||||
</a>
|
||||
<a href="{% url 'home' %}" class="mr-2">
|
||||
<button class="btn btn-default" title="{% trans 'Public report' %}">
|
||||
{% fa5_icon 'file-alt' %}
|
||||
</button>
|
||||
</a>
|
||||
{% if has_access %}
|
||||
<a href="{% url 'home' %}" class="mr-2">
|
||||
<button class="btn btn-default" title="{% trans 'Share' %}">
|
||||
{% fa5_icon 'share-alt' %}
|
||||
</button>
|
||||
</a>
|
||||
<a href="{% url 'home' %}" class="mr-2">
|
||||
<button class="btn btn-default" title="{% trans 'Run check' %}">
|
||||
{% fa5_icon 'star' %}
|
||||
</button>
|
||||
</a>
|
||||
<a href="{% url 'home' %}" class="mr-2">
|
||||
<button class="btn btn-default" title="{% trans 'Record' %}">
|
||||
{% fa5_icon 'bookmark' %}
|
||||
</button>
|
||||
</a>
|
||||
<a href="{% url 'home' %}" class="mr-2">
|
||||
<button class="btn btn-default" title="{% trans 'Edit' %}">
|
||||
{% fa5_icon 'edit' %}
|
||||
</button>
|
||||
</a>
|
||||
<a href="{% url 'home' %}" class="mr-2">
|
||||
<button class="btn btn-default" title="{% trans 'Delete' %}">
|
||||
{% fa5_icon 'trash' %}
|
||||
</button>
|
||||
</a>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<hr>
|
||||
<div id="data" class="row">
|
||||
<div class="col-sm-12 col-md-12 col-lg-6">
|
||||
<div class="table-container">
|
||||
<table class="table table-hover">
|
||||
<tr>
|
||||
<th class="w-25" scope="row">{% trans 'Title' %}</th>
|
||||
<td class="align-middle">{{intervention.title}}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">{% trans 'Process type' %}</th>
|
||||
<td class="align-middle">{{intervention.process_type|default_if_none:""}}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">{% trans 'Law' %}</th>
|
||||
<td class="align-middle">{{intervention.law|default_if_none:""}}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">{% trans 'Registration office' %}</th>
|
||||
<td class="align-middle">{{intervention.registration_office|default_if_none:""}}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">{% trans 'Registration office file number' %}</th>
|
||||
<td class="align-middle">{{intervention.registration_file_number|default_if_none:""}}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">{% trans 'Conservation office' %}</th>
|
||||
<td class="align-middle">{{intervention.conservation_office|default_if_none:""}}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">{% trans 'Conversation office file number' %}</th>
|
||||
<td class="align-middle">{{intervention.conservation_file_number|default_if_none:""}}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">{% trans 'Intervention handler' %}</th>
|
||||
<td class="align-middle">{{intervention.handler|default_if_none:""}}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">{% trans 'Checked' %}</th>
|
||||
<td class="align-middle">
|
||||
{% if intervention.checked_on is None %}
|
||||
<span>
|
||||
{% fa5_icon 'star' 'far' %}
|
||||
</span>
|
||||
{% else %}
|
||||
<span class="check-star">
|
||||
{% fa5_icon 'star' %}
|
||||
</span>
|
||||
{% endif %}
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">{% trans 'Recorded' %}</th>
|
||||
<td class="align-middle">
|
||||
{% if intervention.recorded_on is None %}
|
||||
<span>
|
||||
{% fa5_icon 'bookmark' 'far' %}
|
||||
</span>
|
||||
{% else %}
|
||||
<span class="registered-bookmark">
|
||||
{% fa5_icon 'bookmark' %}
|
||||
</span>
|
||||
{% endif %}
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">{% trans 'Registration date' %}</th>
|
||||
<td class="align-middle">{{intervention.registration_date|default_if_none:""}}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">{% trans 'Binding on' %}</th>
|
||||
<td class="align-middle">{{intervention.binding_on|default_if_none:""}}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">{% trans 'Last modified' %}</th>
|
||||
<td class="align-middle">
|
||||
{{intervention.created_on|default_if_none:""|naturalday}}
|
||||
<br>
|
||||
{% trans 'by' %}
|
||||
{{intervention.created_by|default_if_none:""}}
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-sm-12 col-md-12 col-lg-6">
|
||||
{% if geom_form.area == 0 %}
|
||||
<div class="alert alert-info">{% trans 'No geometry added, yet.' %}</div>
|
||||
{% endif %}
|
||||
{{geom_form.media}}
|
||||
{{geom_form.geom}}
|
||||
</div>
|
||||
</div>
|
||||
<hr>
|
||||
|
||||
<div id="related-objects" class="row">
|
||||
<div class="col-sm-12 col-md-12 col-lg-6">
|
||||
<div id="related-compensations" class="card">
|
||||
<div class="card-header rlp-r">
|
||||
<div class="row">
|
||||
<div class="col-sm-6">
|
||||
<h5>
|
||||
<span class="badge badge-light">{{intervention.compensations.count}}</span>
|
||||
{% trans 'Compensations' %}
|
||||
</h5>
|
||||
</div>
|
||||
<div class="col-sm-6">
|
||||
<div class="d-flex justify-content-end">
|
||||
<a href="{% url 'compensation:new' %}" title="{% trans 'Add new compensation' %}">
|
||||
<button class="btn btn-outline-default">
|
||||
{% fa5_icon 'plus' %}
|
||||
{% fa5_icon 'leaf' %}
|
||||
</button>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card-body scroll-300">
|
||||
<table class="table table-hover">
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="col">
|
||||
{% trans 'Identifier' %}
|
||||
</th>
|
||||
<th scope="col">
|
||||
{% trans 'Title' %}
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for comp in intervention.compensations.all %}
|
||||
<tr>
|
||||
<td class="align-middle">
|
||||
<a href="{% url 'compensation:open' comp.id %}">
|
||||
{{ comp.identifier }}
|
||||
</a>
|
||||
</td>
|
||||
<td class="align-middle">{{ comp.title }}</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-sm-12 col-md-12 col-lg-6">
|
||||
<div id="related-payments" class="card">
|
||||
<div class="card-header rlp-r">
|
||||
<div class="row">
|
||||
<div class="col-sm-6">
|
||||
<h5>
|
||||
<span class="badge badge-light">{{intervention.payments.count}}</span>
|
||||
{% trans 'Payments' %}
|
||||
</h5>
|
||||
</div>
|
||||
<div class="col-sm-6">
|
||||
<div class="d-flex justify-content-end">
|
||||
<button class="btn btn-outline-default btn-modal" data-form-url="{% url 'compensation:pay-new' intervention.id %}" title="{% trans 'Add new payment' %}">
|
||||
{% fa5_icon 'plus' %}
|
||||
{% fa5_icon 'money-bill-wave' %}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card-body scroll-300">
|
||||
<table class="table table-hover">
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="col">
|
||||
{% trans 'Amount' %}
|
||||
</th>
|
||||
<th scope="col">
|
||||
{% trans 'Due on' %}
|
||||
</th>
|
||||
<th scope="col">
|
||||
{% trans 'Transfer comment' %}
|
||||
</th>
|
||||
<th scope="col">
|
||||
{% trans 'Action' %}
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for pay in intervention.payments.all %}
|
||||
<tr>
|
||||
<td class="align-middle">
|
||||
<a href="{% url 'compensation:pay-open' pay.id %}">
|
||||
{{ pay.amount|floatformat:2 }} €
|
||||
</a>
|
||||
</td>
|
||||
<td class="align-middle">{{ pay.due_on }}</td>
|
||||
<td class="align-middle">{{ pay.comment }}</td>
|
||||
<td>
|
||||
<button data-form-url="{% url 'compensation:pay-remove' pay.id %}" class="btn btn-default btn-modal" title="{% trans 'Remove payment' %}">
|
||||
{% fa5_icon 'trash' %}
|
||||
</button>
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="related-documents" class="row">
|
||||
<div class="col-sm-12 col-md-12 col-lg-6">
|
||||
<div class="card">
|
||||
<div class="card-header rlp-r">
|
||||
<div class="row">
|
||||
<div class="col-sm-6">
|
||||
<h5>
|
||||
<span class="badge badge-light">{{intervention.documents.count}}</span>
|
||||
{% trans 'Documents' %}
|
||||
</h5>
|
||||
</div>
|
||||
<div class="col-sm-6">
|
||||
<div class="d-flex justify-content-end">
|
||||
<a href="{% url 'doc-new' %}" title="{% trans 'Add new document' %}">
|
||||
<button class="btn btn-outline-default ">
|
||||
{% fa5_icon 'plus' %}
|
||||
{% fa5_icon 'file' %}
|
||||
</button>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card-body scroll-300">
|
||||
<table class="table table-hover">
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="col">
|
||||
{% trans 'Title' %}
|
||||
</th>
|
||||
<th scope="col">
|
||||
{% trans 'Comment' %}
|
||||
</th>
|
||||
<th scope="col">
|
||||
{% trans 'Action' %}
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for doc in intervention.documents.all %}
|
||||
<tr>
|
||||
<td class="align-middle">
|
||||
<a href="{% url 'doc-open' doc.id %}">
|
||||
{{ doc.title }}
|
||||
</a>
|
||||
</td>
|
||||
<td class="align-middle">{{ doc.comment }}</td>
|
||||
<td>
|
||||
<button data-form-url="{% url 'doc-remove' doc.id %}" class="btn btn-default btn-modal" title="{% trans 'Remove document' %}">
|
||||
{% fa5_icon 'trash' %}
|
||||
</button>
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{% with 'btn-modal' as btn_class %}
|
||||
{% include 'modal/modal_form_script.html' %}
|
||||
{% endwith %}
|
||||
|
||||
{% endblock %}
|
@ -0,0 +1,59 @@
|
||||
{% load i18n l10n fontawesome_5 %}
|
||||
<div id="related-documents" class="row">
|
||||
<div class="col-sm-12 col-md-12 col-lg-6">
|
||||
<div class="card">
|
||||
<div class="card-header rlp-r">
|
||||
<div class="row">
|
||||
<div class="col-sm-6">
|
||||
<h5>
|
||||
<span class="badge badge-light">{{intervention.documents.count}}</span>
|
||||
{% trans 'Documents' %}
|
||||
</h5>
|
||||
</div>
|
||||
<div class="col-sm-6">
|
||||
<div class="d-flex justify-content-end">
|
||||
<button class="btn btn-outline-default btn-modal" data-form-url="{% url 'intervention:new-doc' intervention.id %}" title="{% trans 'Add new document' %}">
|
||||
{% fa5_icon 'plus' %}
|
||||
{% fa5_icon 'file' %}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card-body scroll-300">
|
||||
<table class="table table-hover">
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="col">
|
||||
{% trans 'Title' %}
|
||||
</th>
|
||||
<th scope="col">
|
||||
{% trans 'Comment' %}
|
||||
</th>
|
||||
<th scope="col">
|
||||
{% trans 'Action' %}
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for doc in intervention.documents.all %}
|
||||
<tr>
|
||||
<td class="align-middle">
|
||||
<a href="{% url 'doc-open' doc.id %}">
|
||||
{{ doc.title }}
|
||||
</a>
|
||||
</td>
|
||||
<td class="align-middle">{{ doc.comment }}</td>
|
||||
<td>
|
||||
<button data-form-url="{% url 'doc-remove' doc.id %}" class="btn btn-default btn-modal" title="{% trans 'Remove document' %}">
|
||||
{% fa5_icon 'trash' %}
|
||||
</button>
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
113
intervention/templates/intervention/detail/related-objects.html
Normal file
113
intervention/templates/intervention/detail/related-objects.html
Normal file
@ -0,0 +1,113 @@
|
||||
{% load i18n l10n fontawesome_5 %}
|
||||
<div id="related-objects" class="row">
|
||||
<div class="col-sm-12 col-md-12 col-lg-6">
|
||||
<div id="related-compensations" class="card">
|
||||
<div class="card-header rlp-r">
|
||||
<div class="row">
|
||||
<div class="col-sm-6">
|
||||
<h5>
|
||||
<span class="badge badge-light">{{intervention.compensations.count}}</span>
|
||||
{% trans 'Compensations' %}
|
||||
</h5>
|
||||
</div>
|
||||
<div class="col-sm-6">
|
||||
<div class="d-flex justify-content-end">
|
||||
<a href="{% url 'compensation:new' %}" title="{% trans 'Add new compensation' %}">
|
||||
<button class="btn btn-outline-default">
|
||||
{% fa5_icon 'plus' %}
|
||||
{% fa5_icon 'leaf' %}
|
||||
</button>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card-body scroll-300">
|
||||
<table class="table table-hover">
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="col">
|
||||
{% trans 'Identifier' %}
|
||||
</th>
|
||||
<th scope="col">
|
||||
{% trans 'Title' %}
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for comp in intervention.compensations.all %}
|
||||
<tr>
|
||||
<td class="align-middle">
|
||||
<a href="{% url 'compensation:open' comp.id %}">
|
||||
{{ comp.identifier }}
|
||||
</a>
|
||||
</td>
|
||||
<td class="align-middle">{{ comp.title }}</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-sm-12 col-md-12 col-lg-6">
|
||||
<div id="related-payments" class="card">
|
||||
<div class="card-header rlp-r">
|
||||
<div class="row">
|
||||
<div class="col-sm-6">
|
||||
<h5>
|
||||
<span class="badge badge-light">{{intervention.payments.count}}</span>
|
||||
{% trans 'Payments' %}
|
||||
</h5>
|
||||
</div>
|
||||
<div class="col-sm-6">
|
||||
<div class="d-flex justify-content-end">
|
||||
<button class="btn btn-outline-default btn-modal" data-form-url="{% url 'compensation:pay-new' intervention.id %}" title="{% trans 'Add new payment' %}">
|
||||
{% fa5_icon 'plus' %}
|
||||
{% fa5_icon 'money-bill-wave' %}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card-body scroll-300">
|
||||
<table class="table table-hover">
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="col">
|
||||
{% trans 'Amount' %}
|
||||
</th>
|
||||
<th scope="col">
|
||||
{% trans 'Due on' %}
|
||||
</th>
|
||||
<th scope="col">
|
||||
{% trans 'Transfer comment' %}
|
||||
</th>
|
||||
<th scope="col">
|
||||
{% trans 'Action' %}
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for pay in intervention.payments.all %}
|
||||
<tr>
|
||||
<td class="align-middle">
|
||||
<a href="{% url 'compensation:pay-open' pay.id %}">
|
||||
{{ pay.amount|floatformat:2 }} €
|
||||
</a>
|
||||
</td>
|
||||
<td class="align-middle">{{ pay.due_on }}</td>
|
||||
<td class="align-middle">{{ pay.comment }}</td>
|
||||
<td>
|
||||
<button data-form-url="{% url 'compensation:pay-remove' pay.id %}" class="btn btn-default btn-modal" title="{% trans 'Remove payment' %}">
|
||||
{% fa5_icon 'trash' %}
|
||||
</button>
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
159
intervention/templates/intervention/detail/view.html
Normal file
159
intervention/templates/intervention/detail/view.html
Normal file
@ -0,0 +1,159 @@
|
||||
{% extends 'base.html' %}
|
||||
{% load i18n l10n static fontawesome_5 humanize %}
|
||||
|
||||
{% block head %}
|
||||
|
||||
{% endblock %}
|
||||
|
||||
{% block body %}
|
||||
|
||||
<div id="detail-header" class="row">
|
||||
<div class="col-sm-12 col-md-12 col-lg-6">
|
||||
<h3>{% trans 'Intervention' %} {{intervention.identifier}}</h3>
|
||||
</div>
|
||||
<div class="col-sm-12 col-md-12 col-lg-6">
|
||||
<div class="d-flex justify-content-end">
|
||||
<a href="{% url 'home' %}" class="mr-2">
|
||||
<button class="btn btn-default" title="{% trans 'Open in LANIS' %}">
|
||||
LANIS
|
||||
</button>
|
||||
</a>
|
||||
<a href="{% url 'home' %}" class="mr-2">
|
||||
<button class="btn btn-default" title="{% trans 'Public report' %}">
|
||||
{% fa5_icon 'file-alt' %}
|
||||
</button>
|
||||
</a>
|
||||
{% if has_access %}
|
||||
<a href="{% url 'home' %}" class="mr-2">
|
||||
<button class="btn btn-default" title="{% trans 'Share' %}">
|
||||
{% fa5_icon 'share-alt' %}
|
||||
</button>
|
||||
</a>
|
||||
<a href="{% url 'home' %}" class="mr-2">
|
||||
<button class="btn btn-default" title="{% trans 'Run check' %}">
|
||||
{% fa5_icon 'star' %}
|
||||
</button>
|
||||
</a>
|
||||
<a href="{% url 'home' %}" class="mr-2">
|
||||
<button class="btn btn-default" title="{% trans 'Record' %}">
|
||||
{% fa5_icon 'bookmark' %}
|
||||
</button>
|
||||
</a>
|
||||
<a href="{% url 'home' %}" class="mr-2">
|
||||
<button class="btn btn-default" title="{% trans 'Edit' %}">
|
||||
{% fa5_icon 'edit' %}
|
||||
</button>
|
||||
</a>
|
||||
<a href="{% url 'home' %}" class="mr-2">
|
||||
<button class="btn btn-default" title="{% trans 'Delete' %}">
|
||||
{% fa5_icon 'trash' %}
|
||||
</button>
|
||||
</a>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<hr>
|
||||
<div id="data" class="row">
|
||||
<div class="col-sm-12 col-md-12 col-lg-6">
|
||||
<div class="table-container">
|
||||
<table class="table table-hover">
|
||||
<tr>
|
||||
<th class="w-25" scope="row">{% trans 'Title' %}</th>
|
||||
<td class="align-middle">{{intervention.title}}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">{% trans 'Process type' %}</th>
|
||||
<td class="align-middle">{{intervention.process_type|default_if_none:""}}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">{% trans 'Law' %}</th>
|
||||
<td class="align-middle">{{intervention.law|default_if_none:""}}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">{% trans 'Registration office' %}</th>
|
||||
<td class="align-middle">{{intervention.registration_office|default_if_none:""}}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">{% trans 'Registration office file number' %}</th>
|
||||
<td class="align-middle">{{intervention.registration_file_number|default_if_none:""}}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">{% trans 'Conservation office' %}</th>
|
||||
<td class="align-middle">{{intervention.conservation_office|default_if_none:""}}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">{% trans 'Conversation office file number' %}</th>
|
||||
<td class="align-middle">{{intervention.conservation_file_number|default_if_none:""}}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">{% trans 'Intervention handler' %}</th>
|
||||
<td class="align-middle">{{intervention.handler|default_if_none:""}}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">{% trans 'Checked' %}</th>
|
||||
<td class="align-middle">
|
||||
{% if intervention.checked_on is None %}
|
||||
<span>
|
||||
{% fa5_icon 'star' 'far' %}
|
||||
</span>
|
||||
{% else %}
|
||||
<span class="check-star">
|
||||
{% fa5_icon 'star' %}
|
||||
</span>
|
||||
{% endif %}
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">{% trans 'Recorded' %}</th>
|
||||
<td class="align-middle">
|
||||
{% if intervention.recorded_on is None %}
|
||||
<span>
|
||||
{% fa5_icon 'bookmark' 'far' %}
|
||||
</span>
|
||||
{% else %}
|
||||
<span class="registered-bookmark">
|
||||
{% fa5_icon 'bookmark' %}
|
||||
</span>
|
||||
{% endif %}
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">{% trans 'Registration date' %}</th>
|
||||
<td class="align-middle">{{intervention.registration_date|default_if_none:""}}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">{% trans 'Binding on' %}</th>
|
||||
<td class="align-middle">{{intervention.binding_on|default_if_none:""}}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">{% trans 'Last modified' %}</th>
|
||||
<td class="align-middle">
|
||||
{{intervention.created_on|default_if_none:""|naturalday}}
|
||||
<br>
|
||||
{% trans 'by' %}
|
||||
{{intervention.created_by|default_if_none:""}}
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-sm-12 col-md-12 col-lg-6">
|
||||
{% if geom_form.area == 0 %}
|
||||
<div class="alert alert-info">{% trans 'No geometry added, yet.' %}</div>
|
||||
{% endif %}
|
||||
{{geom_form.media}}
|
||||
{{geom_form.geom}}
|
||||
</div>
|
||||
</div>
|
||||
<hr>
|
||||
|
||||
{% include 'intervention/detail/related-objects.html' %}
|
||||
{% include 'intervention/detail/related-documents.html' %}
|
||||
|
||||
|
||||
{% with 'btn-modal' as btn_class %}
|
||||
{% include 'modal/modal_form_script.html' %}
|
||||
{% endwith %}
|
||||
|
||||
{% endblock %}
|
@ -7,12 +7,13 @@ Created on: 30.11.20
|
||||
"""
|
||||
from django.urls import path
|
||||
|
||||
from intervention.views import index_view, new_view, open_view, edit_view, remove_view
|
||||
from intervention.views import index_view, new_view, open_view, edit_view, remove_view, new_document_view
|
||||
|
||||
app_name = "intervention"
|
||||
urlpatterns = [
|
||||
path("", index_view, name="index"),
|
||||
path('new/', new_view, name='new'),
|
||||
path('<id>/document/new/', new_document_view, name='new-doc'),
|
||||
path('<id>', open_view, name='open'),
|
||||
path('<id>/edit', edit_view, name='edit'),
|
||||
path('<id>/remove', remove_view, name='remove'),
|
||||
|
@ -9,7 +9,7 @@ from intervention.models import Intervention
|
||||
from intervention.tables import InterventionTable
|
||||
from konova.contexts import BaseContext
|
||||
from konova.decorators import *
|
||||
from konova.forms import RemoveForm, SimpleGeomForm
|
||||
from konova.forms import RemoveForm, SimpleGeomForm, NewDocumentForm
|
||||
|
||||
|
||||
@login_required
|
||||
@ -73,6 +73,44 @@ def new_view(request: HttpRequest):
|
||||
return render(request, template, context)
|
||||
|
||||
|
||||
@login_required
|
||||
def new_document_view(request: HttpRequest, id: str):
|
||||
""" Renders a form for uploading new documents
|
||||
|
||||
Args:
|
||||
request (HttpRequest): The incoming request
|
||||
id (str): The intervention's id to which the new document will be related
|
||||
Returns:
|
||||
|
||||
"""
|
||||
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,
|
||||
_("There was an error on this form.")
|
||||
)
|
||||
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
|
||||
|
||||
|
||||
@login_required
|
||||
def open_view(request: HttpRequest, id: str):
|
||||
""" Renders a detail view for viewing an intervention's data
|
||||
@ -84,7 +122,7 @@ def open_view(request: HttpRequest, id: str):
|
||||
Returns:
|
||||
|
||||
"""
|
||||
template = "intervention/detail-view.html"
|
||||
template = "intervention/detail/view.html"
|
||||
intervention = get_object_or_404(Intervention, id=id)
|
||||
has_access = intervention.has_access(user=request.user)
|
||||
|
||||
|
@ -13,19 +13,24 @@ from django import forms
|
||||
from django.contrib.auth.models import User
|
||||
from django.contrib.gis.forms import GeometryField, OSMWidget
|
||||
from django.contrib.gis.geos import Polygon
|
||||
from django.db import transaction
|
||||
from django.utils import timezone
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
|
||||
from konova.models import Document
|
||||
|
||||
|
||||
class BaseForm(forms.Form):
|
||||
"""
|
||||
Basic form for that holds attributes needed in all other forms
|
||||
"""
|
||||
template = None
|
||||
action_url = None
|
||||
form_title = None
|
||||
cancel_redirect = None
|
||||
form_caption = None
|
||||
instance = None # The data holding model object
|
||||
form_attrs = {} # Holds additional attributes, that can be used in the template
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
self.instance = kwargs.pop("instance", None)
|
||||
@ -152,6 +157,7 @@ class RemoveModalForm(BaseModalForm):
|
||||
)
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
self.template = "modal/modal_form.html"
|
||||
super().__init__(*args, **kwargs)
|
||||
self.form_title = _("Remove")
|
||||
self.form_caption = _("Are you sure?")
|
||||
@ -166,16 +172,67 @@ class RemoveModalForm(BaseModalForm):
|
||||
self.instance.delete()
|
||||
|
||||
|
||||
class RemoveDocumentForm(BaseModalForm):
|
||||
confirm = forms.BooleanField(
|
||||
label=_("Confirm"),
|
||||
class NewDocumentForm(BaseModalForm):
|
||||
""" Modal form for new documents
|
||||
|
||||
"""
|
||||
title = forms.CharField(
|
||||
label=_("Title"),
|
||||
label_suffix=_(""),
|
||||
widget=forms.CheckboxInput(),
|
||||
required=True,
|
||||
max_length=500,
|
||||
)
|
||||
creation_date = forms.DateField(
|
||||
label=_("Created on"),
|
||||
label_suffix=_(""),
|
||||
help_text=_("When has this file been created? Important for photos."),
|
||||
widget=forms.DateInput(
|
||||
attrs={
|
||||
"type": "date",
|
||||
"data-provide": "datepicker",
|
||||
},
|
||||
format="%d.%m.%Y"
|
||||
)
|
||||
)
|
||||
file = forms.FileField(
|
||||
label=_("File"),
|
||||
label_suffix=_(""),
|
||||
help_text=_("Must be smaller than 15 Mb"),
|
||||
widget=forms.FileInput(
|
||||
attrs={
|
||||
"class": "w-75"
|
||||
}
|
||||
)
|
||||
)
|
||||
comment = forms.CharField(
|
||||
required=False,
|
||||
label=_("Comment"),
|
||||
label_suffix=_(""),
|
||||
help_text=_("Additional comment on this file"),
|
||||
widget=forms.Textarea(
|
||||
attrs={
|
||||
"cols": 30,
|
||||
"rows": 5,
|
||||
}
|
||||
)
|
||||
)
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super().__init__(*args, **kwargs)
|
||||
self.instance = kwargs.get("instance", None)
|
||||
self.form_title = _("Remove document")
|
||||
self.form_caption = _("This will remove '{}'. Are you sure?").format(self.instance.title)
|
||||
self.form_title = _("Add new document")
|
||||
self.form_caption = _("")
|
||||
self.template = "modal/modal_form.html"
|
||||
self.form_attrs = {
|
||||
"enctype": "multipart/form-data",
|
||||
}
|
||||
|
||||
def save(self):
|
||||
with transaction.atomic():
|
||||
doc = Document.objects.create(
|
||||
created_by=self.user,
|
||||
title=self.cleaned_data["title"],
|
||||
comment=self.cleaned_data["comment"],
|
||||
document=self.cleaned_data["file"],
|
||||
date_of_creation=self.cleaned_data["creation_date"],
|
||||
)
|
||||
self.instance.documents.add(doc)
|
||||
return doc
|
||||
|
@ -20,7 +20,7 @@ from simple_sso.sso_client.client import Client
|
||||
|
||||
from konova.autocompletes import OrganisationAutocomplete, NonOfficialOrganisationAutocomplete
|
||||
from konova.settings import SSO_SERVER, SSO_PUBLIC_KEY, SSO_PRIVATE_KEY, DEBUG
|
||||
from konova.views import logout_view, home_view, get_document_view, new_document_view, remove_document_view
|
||||
from konova.views import logout_view, home_view, get_document_view, remove_document_view
|
||||
|
||||
sso_client = Client(SSO_SERVER, SSO_PUBLIC_KEY, SSO_PRIVATE_KEY)
|
||||
urlpatterns = [
|
||||
@ -35,9 +35,8 @@ urlpatterns = [
|
||||
path('user/', include("user.urls")),
|
||||
path('news/', include("news.urls")),
|
||||
|
||||
# Documents
|
||||
# Generic documents routes
|
||||
path('document/<id>', get_document_view, name="doc-open"),
|
||||
path('document/new', new_document_view, name="doc-new"),
|
||||
path('document/<id>/remove', remove_document_view, name="doc-remove"),
|
||||
|
||||
# Autocomplete paths
|
||||
|
@ -14,7 +14,7 @@ from django.utils import timezone
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
|
||||
from konova.contexts import BaseContext
|
||||
from konova.forms import RemoveDocumentForm
|
||||
from konova.forms import RemoveModalForm
|
||||
from konova.models import Document
|
||||
from news.models import ServerMessage
|
||||
from konova.settings import SSO_SERVER_BASE
|
||||
@ -84,23 +84,6 @@ def get_document_view(request: HttpRequest, id: str):
|
||||
return FileResponse(doc.document, as_attachment=True)
|
||||
|
||||
|
||||
@login_required
|
||||
def new_document_view(request: HttpRequest):
|
||||
""" Renders a form for uploading new documents
|
||||
|
||||
Args:
|
||||
request (HttpRequest): The incoming request
|
||||
|
||||
Returns:
|
||||
|
||||
"""
|
||||
template = ""
|
||||
# TODO
|
||||
context = {}
|
||||
context = BaseContext(request, context).context
|
||||
return render(request, template, context)
|
||||
|
||||
|
||||
@login_required
|
||||
def remove_document_view(request: HttpRequest, id: str):
|
||||
""" Renders a form for uploading new documents
|
||||
@ -119,10 +102,10 @@ def remove_document_view(request: HttpRequest, id: str):
|
||||
Returns:
|
||||
|
||||
"""
|
||||
template = "modal/modal_form.html"
|
||||
doc = get_object_or_404(Document, id=id)
|
||||
title = doc.title
|
||||
form = RemoveDocumentForm(request.POST or None, instance=doc)
|
||||
form = RemoveModalForm(request.POST or None, instance=doc, user=request.user)
|
||||
template = form.template
|
||||
if request.method == "POST":
|
||||
if form.is_valid():
|
||||
doc.delete()
|
||||
|
@ -5,7 +5,7 @@
|
||||
{% endcomment %}
|
||||
|
||||
|
||||
<form method="post" action="{{form.action_url}}">
|
||||
<form method="post" action="{{form.action_url}}" {% for attr_key, attr_val in form.form_attrs.items %} {{attr_key}}="{{attr_val}}"{% endfor %}>
|
||||
{% csrf_token %}
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title">{{form.form_title}}</h5>
|
||||
|
@ -14,7 +14,7 @@
|
||||
{{ form.form_caption }}
|
||||
</small>
|
||||
{% endif %}
|
||||
<form method="post" action="{{ form.action_url }}">
|
||||
<form method="post" action="{{ form.action_url }}" {% for attr_key, attr_val in form.form_attrs.items %} {{attr_key}}="{{attr_val}}"{% endfor %}>
|
||||
{% csrf_token %}
|
||||
{% include 'table/generic_table_form_body.html' %}
|
||||
<div class="row">
|
||||
|
Loading…
Reference in New Issue
Block a user