RemoveModalForm refactoring
* wraps generic request processing logic into RemoveModalForm * adds delete action to intervention detail compensations.html * fixes rendering of deleted compensations in intervention detail view
This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
<div class="row">
|
||||
<div class="col-sm-6">
|
||||
<h5>
|
||||
<span class="badge badge-light">{{intervention.compensations.count}}</span>
|
||||
<span class="badge badge-light">{{compensations.count}}</span>
|
||||
{% trans 'Compensations' %}
|
||||
</h5>
|
||||
</div>
|
||||
@@ -30,10 +30,13 @@
|
||||
<th scope="col">
|
||||
{% trans 'Title' %}
|
||||
</th>
|
||||
<th scope="col">
|
||||
{% trans 'Action' %}
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for comp in intervention.compensations.all %}
|
||||
{% for comp in compensations %}
|
||||
<tr>
|
||||
<td class="align-middle">
|
||||
<a href="{% url 'compensation:open' comp.id %}">
|
||||
@@ -41,6 +44,11 @@
|
||||
</a>
|
||||
</td>
|
||||
<td class="align-middle">{{ comp.title }}</td>
|
||||
<td>
|
||||
<button data-form-url="{% url 'compensation:remove' comp.id %}" class="btn btn-default btn-modal" title="{% trans 'Remove compensation' %}">
|
||||
{% fa5_icon 'trash' %}
|
||||
</button>
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
|
||||
@@ -124,7 +124,13 @@ def open_view(request: HttpRequest, id: str):
|
||||
|
||||
"""
|
||||
template = "intervention/detail/view.html"
|
||||
|
||||
# Fetch data, filter out deleted related data
|
||||
intervention = get_object_or_404(Intervention, id=id)
|
||||
compensations = intervention.compensations.filter(
|
||||
deleted_on=None,
|
||||
deleted_by=None,
|
||||
)
|
||||
has_access = intervention.has_access(user=request.user)
|
||||
|
||||
geom_form = SimpleGeomForm(
|
||||
@@ -133,6 +139,7 @@ def open_view(request: HttpRequest, id: str):
|
||||
|
||||
context = {
|
||||
"intervention": intervention,
|
||||
"compensations": compensations,
|
||||
"has_access": has_access,
|
||||
"geom_form": geom_form,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user