@@ -34,7 +34,7 @@
|
||||
{% trans 'Comment' %}
|
||||
</th>
|
||||
{% if is_default_member and has_access %}
|
||||
<th scope="col">
|
||||
<th class="w-10" scope="col">
|
||||
<span class="float-right">
|
||||
{% trans 'Action' %}
|
||||
</span>
|
||||
|
||||
@@ -34,7 +34,7 @@
|
||||
{% trans 'Comment' %}
|
||||
</th>
|
||||
{% if is_default_member and has_access %}
|
||||
<th scope="col">
|
||||
<th class="w-10" scope="col">
|
||||
<span class="float-right">
|
||||
{% trans 'Action' %}
|
||||
</span>
|
||||
|
||||
@@ -34,7 +34,7 @@
|
||||
{% trans 'Comment' %}
|
||||
</th>
|
||||
{% if is_default_member and has_access %}
|
||||
<th scope="col">
|
||||
<th class="w-10" scope="col">
|
||||
<span class="float-right">
|
||||
{% trans 'Action' %}
|
||||
</span>
|
||||
@@ -60,9 +60,12 @@
|
||||
{{ action.comment }}
|
||||
</div>
|
||||
</td>
|
||||
<td class="">
|
||||
<td class="align-middle float-right">
|
||||
{% if is_default_member and has_access %}
|
||||
<button data-form-url="{% url 'compensation:acc:action-remove' obj.id action.id %}" class="btn btn-default btn-modal float-right" title="{% trans 'Remove action' %}">
|
||||
<button data-form-url="{% url 'compensation:acc:action-edit' obj.id action.id %}" class="btn btn-default btn-modal" title="{% trans 'Edit action' %}">
|
||||
{% fa5_icon 'edit' %}
|
||||
</button>
|
||||
<button data-form-url="{% url 'compensation:acc:action-remove' obj.id action.id %}" class="btn btn-default btn-modal" title="{% trans 'Remove action' %}">
|
||||
{% fa5_icon 'trash' %}
|
||||
</button>
|
||||
{% endif %}
|
||||
|
||||
@@ -44,12 +44,17 @@ class EcoAccountViewTestCase(CompensationViewTestCase):
|
||||
self.edit_url = reverse("compensation:acc:edit", args=(self.eco_account.id,))
|
||||
self.remove_url = reverse("compensation:acc:remove", args=(self.eco_account.id,))
|
||||
self.report_url = reverse("compensation:acc:report", args=(self.eco_account.id,))
|
||||
|
||||
self.state_new_url = reverse("compensation:acc:new-state", args=(self.eco_account.id,))
|
||||
self.state_edit_url = reverse("compensation:acc:state-edit", args=(self.eco_account.id, self.comp_state.id))
|
||||
self.state_remove_url = reverse("compensation:acc:state-remove", args=(self.eco_account.id, self.comp_state.id,))
|
||||
|
||||
self.action_new_url = reverse("compensation:acc:new-action", args=(self.eco_account.id,))
|
||||
self.action_edit_url = reverse("compensation:acc:action-edit", args=(self.eco_account.id, self.comp_action.id))
|
||||
self.action_remove_url = reverse("compensation:acc:action-remove", args=(self.eco_account.id, self.comp_action.id,))
|
||||
|
||||
self.deadline_new_url = reverse("compensation:acc:new-deadline", args=(self.eco_account.id,))
|
||||
self.new_doc_url = reverse("compensation:acc:new-doc", args=(self.eco_account.id,))
|
||||
self.state_remove_url = reverse("compensation:acc:state-remove", args=(self.eco_account.id, self.comp_state.id,))
|
||||
self.action_remove_url = reverse("compensation:acc:action-remove", args=(self.eco_account.id, self.comp_action.id,))
|
||||
|
||||
def test_logged_in_no_groups_shared(self):
|
||||
""" Check correct status code for all requests
|
||||
@@ -78,10 +83,12 @@ class EcoAccountViewTestCase(CompensationViewTestCase):
|
||||
self.edit_url,
|
||||
self.remove_url,
|
||||
self.state_new_url,
|
||||
self.action_new_url,
|
||||
self.deadline_new_url,
|
||||
self.state_edit_url,
|
||||
self.state_remove_url,
|
||||
self.action_new_url,
|
||||
self.action_edit_url,
|
||||
self.action_remove_url,
|
||||
self.deadline_new_url,
|
||||
self.new_doc_url,
|
||||
]
|
||||
|
||||
@@ -115,10 +122,12 @@ class EcoAccountViewTestCase(CompensationViewTestCase):
|
||||
self.edit_url,
|
||||
self.remove_url,
|
||||
self.state_new_url,
|
||||
self.action_new_url,
|
||||
self.deadline_new_url,
|
||||
self.state_edit_url,
|
||||
self.state_remove_url,
|
||||
self.action_new_url,
|
||||
self.action_edit_url,
|
||||
self.action_remove_url,
|
||||
self.deadline_new_url,
|
||||
self.new_doc_url,
|
||||
]
|
||||
|
||||
@@ -149,11 +158,13 @@ class EcoAccountViewTestCase(CompensationViewTestCase):
|
||||
self.new_id_url,
|
||||
self.edit_url,
|
||||
self.state_new_url,
|
||||
self.action_new_url,
|
||||
self.deadline_new_url,
|
||||
self.state_edit_url,
|
||||
self.state_remove_url,
|
||||
self.action_new_url,
|
||||
self.action_edit_url,
|
||||
self.action_remove_url,
|
||||
self.new_doc_url,
|
||||
self.deadline_new_url,
|
||||
self.log_url,
|
||||
self.remove_url,
|
||||
]
|
||||
@@ -184,13 +195,15 @@ class EcoAccountViewTestCase(CompensationViewTestCase):
|
||||
fail_urls = [
|
||||
self.edit_url,
|
||||
self.state_new_url,
|
||||
self.action_new_url,
|
||||
self.deadline_new_url,
|
||||
self.state_edit_url,
|
||||
self.state_remove_url,
|
||||
self.action_new_url,
|
||||
self.action_edit_url,
|
||||
self.action_remove_url,
|
||||
self.new_doc_url,
|
||||
self.log_url,
|
||||
self.remove_url,
|
||||
self.deadline_new_url,
|
||||
]
|
||||
self.assert_url_fail(client, fail_urls)
|
||||
self.assert_url_success(client, success_urls)
|
||||
|
||||
@@ -19,11 +19,15 @@ urlpatterns = [
|
||||
path('<id>/report', report_view, name='report'),
|
||||
path('<id>/edit', edit_view, name='edit'),
|
||||
path('<id>/remove', remove_view, name='remove'),
|
||||
|
||||
path('<id>/state/new', state_new_view, name='new-state'),
|
||||
path('<id>/action/new', action_new_view, name='new-action'),
|
||||
path('<id>/state/<state_id>/remove', state_remove_view, name='state-remove'),
|
||||
path('<id>/state/<state_id>/edit', state_edit_view, name='state-edit'),
|
||||
path('<id>/state/<state_id>/remove', state_remove_view, name='state-remove'),
|
||||
|
||||
path('<id>/action/new', action_new_view, name='new-action'),
|
||||
path('<id>/action/<action_id>/edit', action_edit_view, name='action-edit'),
|
||||
path('<id>/action/<action_id>/remove', action_remove_view, name='action-remove'),
|
||||
|
||||
path('<id>/deadline/<deadline_id>/remove', deadline_remove_view, name='deadline-remove'),
|
||||
path('<id>/deadline/new', deadline_new_view, name="new-deadline"),
|
||||
path('<id>/share/<token>', share_view, name='share'),
|
||||
|
||||
@@ -17,7 +17,7 @@ from django.shortcuts import render, get_object_or_404, redirect
|
||||
from compensation.forms.forms import NewEcoAccountForm, EditEcoAccountForm
|
||||
from compensation.forms.modalForms import NewStateModalForm, NewActionModalForm, NewDeadlineModalForm, \
|
||||
NewEcoAccountDocumentModalForm, RemoveCompensationActionModalForm, RemoveCompensationStateModalForm, \
|
||||
EditCompensationStateModalForm
|
||||
EditCompensationStateModalForm, EditCompensationActionModalForm
|
||||
from compensation.models import EcoAccount, EcoAccountDocument, CompensationState, CompensationAction
|
||||
from compensation.tables import EcoAccountTable
|
||||
from intervention.forms.modalForms import NewDeductionModalForm, ShareModalForm, RemoveEcoAccountDeductionModalForm, \
|
||||
@@ -35,7 +35,7 @@ from konova.utils.generators import generate_qr_code
|
||||
from konova.utils.message_templates import IDENTIFIER_REPLACED, FORM_INVALID, DATA_UNSHARED, DATA_UNSHARED_EXPLANATION, \
|
||||
CANCEL_ACC_RECORDED_OR_DEDUCTED, DEDUCTION_REMOVED, DEDUCTION_ADDED, DOCUMENT_ADDED, COMPENSATION_STATE_REMOVED, \
|
||||
COMPENSATION_STATE_ADDED, COMPENSATION_ACTION_REMOVED, COMPENSATION_ACTION_ADDED, DEADLINE_ADDED, DEADLINE_REMOVED, \
|
||||
DEDUCTION_EDITED, DOCUMENT_EDITED, COMPENSATION_STATE_EDITED
|
||||
DEDUCTION_EDITED, DOCUMENT_EDITED, COMPENSATION_STATE_EDITED, COMPENSATION_ACTION_EDITED
|
||||
from konova.utils.user_checks import in_group
|
||||
|
||||
|
||||
@@ -491,6 +491,30 @@ def action_remove_view(request: HttpRequest, id: str, action_id: str):
|
||||
)
|
||||
|
||||
|
||||
@login_required
|
||||
@default_group_required
|
||||
@shared_access_required(EcoAccount, "id")
|
||||
def action_edit_view(request: HttpRequest, id: str, action_id: str):
|
||||
""" Renders a form for editing a compensation action
|
||||
|
||||
Args:
|
||||
request (HttpRequest): The incoming request
|
||||
id (str): The compensation's id
|
||||
id (str): The action's id
|
||||
|
||||
Returns:
|
||||
|
||||
"""
|
||||
acc = get_object_or_404(EcoAccount, id=id)
|
||||
action = get_object_or_404(CompensationAction, id=action_id)
|
||||
form = EditCompensationActionModalForm(request.POST or None, instance=acc, action=action, request=request)
|
||||
return form.process_request(
|
||||
request,
|
||||
msg_success=COMPENSATION_ACTION_EDITED,
|
||||
redirect_url=reverse("compensation:acc:detail", args=(id,)) + "#related_data"
|
||||
)
|
||||
|
||||
|
||||
@login_required
|
||||
@default_group_required
|
||||
@shared_access_required(EcoAccount, "id")
|
||||
|
||||
Reference in New Issue
Block a user