Recording data
* adds dynamic icon for recording and unrecording of data * adds record view to intervention and eco accounts * adds quality_check() method for Intervention and EcoAccount class which holds logic for data quality checking * adds UserAction "unrecorded"
This commit is contained in:
@@ -248,6 +248,10 @@ class EcoAccount(AbstractCompensation):
|
||||
y,
|
||||
)
|
||||
|
||||
def quality_check(self) -> (bool, dict):
|
||||
# ToDo
|
||||
pass
|
||||
|
||||
|
||||
class EcoAccountWithdraw(BaseResource):
|
||||
"""
|
||||
|
||||
@@ -13,11 +13,15 @@
|
||||
</a>
|
||||
{% if has_access %}
|
||||
{% if is_ets_member %}
|
||||
<a href="{% url 'home' %}" class="mr-2">
|
||||
<button class="btn btn-default" title="{% trans 'Record' %}">
|
||||
{% fa5_icon 'bookmark' %}
|
||||
</button>
|
||||
</a>
|
||||
{% if obj.recorded %}
|
||||
<button class="btn btn-default btn-modal mr-2" title="{% trans 'Unrecord' %}" data-form-url="{% url 'compensation:acc-record' obj.id %}">
|
||||
{% fa5_icon 'bookmark' 'far' %}
|
||||
</button>
|
||||
{% else %}
|
||||
<button class="btn btn-default btn-modal mr-2" title="{% trans 'Record' %}" data-form-url="{% url 'compensation:acc-record' obj.id %}">
|
||||
{% fa5_icon 'bookmark' %}
|
||||
</button>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
{% if is_default_member %}
|
||||
<a href="{% url 'home' %}" class="mr-2">
|
||||
|
||||
@@ -24,6 +24,7 @@ urlaptterns_eco_acc = [
|
||||
path('acc/new/', eco_account_views.new_view, name='acc-new'),
|
||||
path('acc/<id>', eco_account_views.open_view, name='acc-open'),
|
||||
path('acc/<id>/log', eco_account_views.log_view, name='acc-log'),
|
||||
path('acc/<id>/record', eco_account_views.record_view, name='acc-record'),
|
||||
path('acc/<id>/edit', eco_account_views.edit_view, name='acc-edit'),
|
||||
path('acc/<id>/remove', eco_account_views.remove_view, name='acc-remove'),
|
||||
path('acc/<id>/state/new', eco_account_views.state_new_view, name='acc-new-state'),
|
||||
|
||||
@@ -18,8 +18,8 @@ from compensation.models import EcoAccount
|
||||
from compensation.tables import EcoAccountTable
|
||||
from intervention.forms import NewWithdrawForm
|
||||
from konova.contexts import BaseContext
|
||||
from konova.decorators import any_group_check, default_group_required
|
||||
from konova.forms import RemoveModalForm, SimpleGeomForm, NewDocumentForm
|
||||
from konova.decorators import any_group_check, default_group_required, conservation_office_group_required
|
||||
from konova.forms import RemoveModalForm, SimpleGeomForm, NewDocumentForm, RecordForm
|
||||
from konova.settings import DEFAULT_GROUP, ZB_GROUP, ETS_GROUP
|
||||
from konova.utils.user_checks import in_group
|
||||
|
||||
@@ -188,6 +188,28 @@ def log_view(request: HttpRequest, id: str):
|
||||
return render(request, template, context)
|
||||
|
||||
|
||||
@login_required
|
||||
@conservation_office_group_required
|
||||
def record_view(request: HttpRequest, id:str):
|
||||
""" Renders a modal form for recording an eco account
|
||||
|
||||
Args:
|
||||
request (HttpRequest): The incoming request
|
||||
id (str): The account's id
|
||||
|
||||
Returns:
|
||||
|
||||
"""
|
||||
acc = get_object_or_404(EcoAccount, id=id)
|
||||
form = RecordForm(request.POST or None, instance=acc, user=request.user)
|
||||
msg_succ = _("{} unrecorded") if acc.recorded else _("{} recorded")
|
||||
msg_succ = msg_succ.format(acc.identifier)
|
||||
return form.process_request(
|
||||
request,
|
||||
msg_succ
|
||||
)
|
||||
|
||||
|
||||
@login_required
|
||||
def state_new_view(request: HttpRequest, id: str):
|
||||
""" Renders a form for adding new states for an eco account
|
||||
|
||||
Reference in New Issue
Block a user