Merge branch 'master' into 138_New_map_client
This commit is contained in:
@@ -104,7 +104,7 @@ class EmaTable(BaseTable, TableRenderMixin):
|
||||
|
||||
"""
|
||||
parcels = value.get_underlying_parcels().values_list(
|
||||
"gmrkng",
|
||||
"parcel_group__name",
|
||||
flat=True
|
||||
).distinct()
|
||||
html = render_to_string(
|
||||
@@ -151,9 +151,7 @@ class EmaTable(BaseTable, TableRenderMixin):
|
||||
|
||||
"""
|
||||
html = ""
|
||||
has_access = value.filter(
|
||||
id=self.user.id
|
||||
).exists()
|
||||
has_access = record.is_shared_with(self.user)
|
||||
|
||||
html += self.render_icn(
|
||||
tooltip=_("Full access granted") if has_access else _("Access not granted"),
|
||||
|
||||
@@ -60,14 +60,13 @@
|
||||
<th scope="row">{% trans 'Last modified' %}</th>
|
||||
<td class="align-middle">
|
||||
{% if obj.modified %}
|
||||
{{obj.modified.timestamp|default_if_none:""|naturalday}}
|
||||
{{obj.modified.timestamp|default_if_none:""}}
|
||||
<br>
|
||||
{{obj.modified.user.username}}
|
||||
{% else %}
|
||||
{{obj.created.timestamp|default_if_none:""|naturalday}}
|
||||
{{obj.created.timestamp|default_if_none:""}}
|
||||
<br>
|
||||
{{obj.created.user.username}}
|
||||
|
||||
{% endif %}
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
@@ -43,14 +43,7 @@
|
||||
{% include 'konova/includes/parcels.html' %}
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-sm-6 col-md-6 col-lg-6">
|
||||
<h4>{% trans 'Open in browser' %}</h4>
|
||||
{{ qrcode|safe }}
|
||||
</div>
|
||||
<div class="col-sm-6 col-md-6 col-lg-6">
|
||||
<h4>{% trans 'View in LANIS' %}</h4>
|
||||
{{ qrcode_lanis|safe }}
|
||||
</div>
|
||||
{% include 'konova/includes/report/qrcodes.html' %}
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
@@ -117,6 +117,32 @@ class EmaWorkflowTestCase(BaseWorkflowTestCase):
|
||||
self.assertEqual(pre_edit_log_count + 1, self.ema.log.count())
|
||||
self.assertEqual(self.ema.log.first().action, UserAction.EDITED)
|
||||
|
||||
def test_non_editable_after_recording(self):
|
||||
""" Tests that the EMA can not be edited after being recorded
|
||||
|
||||
User must be redirected to another page
|
||||
|
||||
Returns:
|
||||
|
||||
"""
|
||||
self.superuser.groups.add(self.groups.get(name=ETS_GROUP))
|
||||
self.assertIsNotNone(self.ema)
|
||||
self.ema.share_with_user(self.superuser)
|
||||
self.assertFalse(self.ema.is_recorded)
|
||||
edit_url = reverse("ema:edit", args=(self.ema.id,))
|
||||
response = self.client_user.get(edit_url)
|
||||
has_redirect = response.status_code == 302
|
||||
self.assertFalse(has_redirect)
|
||||
|
||||
self.ema.set_recorded(self.superuser)
|
||||
self.assertTrue(self.ema.is_recorded)
|
||||
|
||||
edit_url = reverse("ema:edit", args=(self.ema.id,))
|
||||
response = self.client_user.get(edit_url)
|
||||
has_redirect = response.status_code == 302
|
||||
self.assertTrue(has_redirect)
|
||||
self.ema.set_unrecorded(self.superuser)
|
||||
|
||||
def test_recordability(self):
|
||||
"""
|
||||
This tests if the recordability of the Ema is triggered by the quality of it's data (e.g. not all fields filled)
|
||||
|
||||
33
ema/views.py
33
ema/views.py
@@ -26,7 +26,7 @@ from konova.utils.generators import generate_qr_code
|
||||
from konova.utils.message_templates import IDENTIFIER_REPLACED, FORM_INVALID, DATA_UNSHARED, DATA_UNSHARED_EXPLANATION, \
|
||||
DOCUMENT_ADDED, COMPENSATION_STATE_REMOVED, COMPENSATION_STATE_ADDED, COMPENSATION_ACTION_REMOVED, \
|
||||
COMPENSATION_ACTION_ADDED, DEADLINE_ADDED, DEADLINE_REMOVED, DOCUMENT_EDITED, COMPENSATION_STATE_EDITED, \
|
||||
COMPENSATION_ACTION_EDITED, DEADLINE_EDITED
|
||||
COMPENSATION_ACTION_EDITED, DEADLINE_EDITED, RECORDED_BLOCKS_EDIT
|
||||
from konova.utils.user_checks import in_group
|
||||
|
||||
|
||||
@@ -213,6 +213,13 @@ def edit_view(request: HttpRequest, id: str):
|
||||
template = "compensation/form/view.html"
|
||||
# Get object from db
|
||||
ema = get_object_or_404(Ema, id=id)
|
||||
if ema.is_recorded:
|
||||
messages.info(
|
||||
request,
|
||||
RECORDED_BLOCKS_EDIT
|
||||
)
|
||||
return redirect("ema:detail", id=id)
|
||||
|
||||
# Create forms, initialize with values from db/from POST request
|
||||
data_form = EditEmaForm(request.POST or None, instance=ema)
|
||||
geom_form = SimpleGeomForm(request.POST or None, read_only=False, instance=ema)
|
||||
@@ -563,14 +570,12 @@ def report_view(request:HttpRequest, id: str):
|
||||
instance=ema,
|
||||
)
|
||||
parcels = ema.get_underlying_parcels()
|
||||
qrcode_img = generate_qr_code(
|
||||
request.build_absolute_uri(reverse("ema:report", args=(id,))),
|
||||
10
|
||||
)
|
||||
qrcode_img_lanis = generate_qr_code(
|
||||
ema.get_LANIS_link(),
|
||||
7
|
||||
)
|
||||
|
||||
qrcode_url = request.build_absolute_uri(reverse("ema:report", args=(id,)))
|
||||
qrcode_img = generate_qr_code(qrcode_url, 10)
|
||||
qrcode_lanis_url = ema.get_LANIS_link()
|
||||
qrcode_img_lanis = generate_qr_code(qrcode_lanis_url, 7)
|
||||
|
||||
# Order states by surface
|
||||
before_states = ema.before_states.all().order_by("-surface").prefetch_related("biotope_type")
|
||||
after_states = ema.after_states.all().order_by("-surface").prefetch_related("biotope_type")
|
||||
@@ -578,8 +583,14 @@ def report_view(request:HttpRequest, id: str):
|
||||
|
||||
context = {
|
||||
"obj": ema,
|
||||
"qrcode": qrcode_img,
|
||||
"qrcode_lanis": qrcode_img_lanis,
|
||||
"qrcode": {
|
||||
"img": qrcode_img,
|
||||
"url": qrcode_url
|
||||
},
|
||||
"qrcode_lanis": {
|
||||
"img": qrcode_img_lanis,
|
||||
"url": qrcode_lanis_url
|
||||
},
|
||||
"has_access": False, # disables action buttons during rendering
|
||||
"before_states": before_states,
|
||||
"after_states": after_states,
|
||||
|
||||
Reference in New Issue
Block a user