Intervention Detail View
* adds (WIP) detail view for interventions * renames typo in conservations_file_number to conservation_file_number * adds simple has_access check for intervention objects for given users * renames occurences of "Registered" to "Recorded" (verzeichnen) * adds an informing message for detail view of intervention objects which are not editable for a user * adds GeometryAdmin * adds fallback DEFAULT_SRID for Geometry model * adds translations
This commit is contained in:
@@ -25,7 +25,7 @@ class Intervention(BaseObject):
|
||||
registration_office = models.ForeignKey(Organisation, on_delete=models.SET_NULL, null=True, related_name="+")
|
||||
registration_file_number = models.CharField(max_length=1000, blank=True, null=True)
|
||||
conservation_office = models.ForeignKey(Organisation, on_delete=models.SET_NULL, null=True, related_name="+")
|
||||
conservations_file_number = models.CharField(max_length=1000, blank=True, null=True)
|
||||
conservation_file_number = models.CharField(max_length=1000, blank=True, null=True)
|
||||
|
||||
process_type = models.CharField(max_length=500, null=True, blank=True)
|
||||
law = models.CharField(max_length=500, null=True, blank=True)
|
||||
@@ -107,4 +107,17 @@ class Intervention(BaseObject):
|
||||
while Intervention.objects.filter(identifier=new_id).exists():
|
||||
new_id = self._generate_new_identifier()
|
||||
self.identifier = new_id
|
||||
super().save(*args, **kwargs)
|
||||
super().save(*args, **kwargs)
|
||||
|
||||
def has_access(self, user: User):
|
||||
""" Access check
|
||||
|
||||
Checks whether a given user has access to this intervention
|
||||
|
||||
Args:
|
||||
user ():
|
||||
|
||||
Returns:
|
||||
|
||||
"""
|
||||
return self.users.filter(username=user.username).exists()
|
||||
|
||||
@@ -36,7 +36,7 @@ class InterventionTable(BaseTable):
|
||||
accessor="checked_on",
|
||||
)
|
||||
r = tables.Column(
|
||||
verbose_name=_("Registered"),
|
||||
verbose_name=_("Recorded"),
|
||||
orderable=True,
|
||||
empty_values=[],
|
||||
accessor="recorded_on",
|
||||
|
||||
121
intervention/templates/intervention/detail-view.html
Normal file
121
intervention/templates/intervention/detail-view.html
Normal file
@@ -0,0 +1,121 @@
|
||||
{% extends 'base.html' %}
|
||||
{% load i18n static fontawesome_5 %}
|
||||
|
||||
{% 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>
|
||||
{% if has_access %}
|
||||
<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 '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 '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:""}}
|
||||
<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">
|
||||
{{geom_form.media}}
|
||||
{{geom_form.geom}}
|
||||
</div>
|
||||
</div>
|
||||
<div id="related-objects" class="row"></div>
|
||||
|
||||
{% endblock %}
|
||||
@@ -1,47 +0,0 @@
|
||||
{% extends 'base.html' %}
|
||||
{% load i18n static %}
|
||||
|
||||
{% block body %}
|
||||
<div class="rows">
|
||||
<div class="columns">
|
||||
<div class="large-10 column">
|
||||
<h3>{% trans 'Intervention' %}: {{ intervention.title }}</h3>
|
||||
</div>
|
||||
<div class="large-2 column">
|
||||
<a href="{% url 'intervention:edit' intervention.id %}">
|
||||
<button class="button small" role="button" value="{% trans 'Edit' %}"><i class='fas fa-edit'></i> {% trans 'Edit' %}</button>
|
||||
</a>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<hr>
|
||||
{% comment %}
|
||||
form.media needs to be loaded to ensure the openlayers client will be loaded properly
|
||||
{% endcomment %}
|
||||
{{ form.media }}
|
||||
<div class="columns">
|
||||
<div class="small-6 columns">
|
||||
<table>
|
||||
<tbody>
|
||||
{% for field in form %}
|
||||
{% if field != form.geometry %}
|
||||
<tr title="{{ field.help_text }}" class="{% if field.errors %}error{% endif %}">
|
||||
<th scope="row" class="small-3">
|
||||
<div>{{ field.label }}</div>
|
||||
<small>{{ field.help_text }}</small>
|
||||
</th>
|
||||
<td class="small-12">
|
||||
{{ field }}
|
||||
</td>
|
||||
</tr>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<div class="small-6 columns">
|
||||
{{ form.geometry }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
||||
@@ -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
|
||||
from konova.forms import RemoveForm, SimpleGeomForm
|
||||
|
||||
|
||||
@login_required
|
||||
@@ -75,7 +75,7 @@ def new_view(request: HttpRequest):
|
||||
|
||||
@login_required
|
||||
def open_view(request: HttpRequest, id: str):
|
||||
""" Renders a view for viewing an intervention's data
|
||||
""" Renders a detail view for viewing an intervention's data
|
||||
|
||||
Args:
|
||||
request (HttpRequest): The incoming request
|
||||
@@ -84,12 +84,21 @@ def open_view(request: HttpRequest, id: str):
|
||||
Returns:
|
||||
|
||||
"""
|
||||
template = "intervention/open.html"
|
||||
template = "intervention/detail-view.html"
|
||||
intervention = get_object_or_404(Intervention, id=id)
|
||||
form = OpenInterventionForm(instance=intervention)
|
||||
has_access = intervention.has_access(user=request.user)
|
||||
|
||||
if not has_access:
|
||||
messages.info(request, _("Remember: This data has not been shared with you, yet. This means you can only read but can not edit or perform any actions like running a check or recording."))
|
||||
|
||||
geom_form = SimpleGeomForm(
|
||||
instance=intervention
|
||||
)
|
||||
|
||||
context = {
|
||||
"intervention": intervention,
|
||||
"form": form,
|
||||
"has_access": has_access,
|
||||
"geom_form": geom_form,
|
||||
}
|
||||
context = BaseContext(request, context).context
|
||||
return render(request, template, context)
|
||||
|
||||
Reference in New Issue
Block a user