diff --git a/compensation/templates/compensation/detail/compensation/includes/actions.html b/compensation/templates/compensation/detail/compensation/includes/actions.html index d82d8c08..f8a917ee 100644 --- a/compensation/templates/compensation/detail/compensation/includes/actions.html +++ b/compensation/templates/compensation/detail/compensation/includes/actions.html @@ -61,9 +61,12 @@ {{ action.comment }} - + {% if is_default_member and has_access %} - + {% endif %} diff --git a/compensation/urls/compensation.py b/compensation/urls/compensation.py index 9d644e73..3b6a6822 100644 --- a/compensation/urls/compensation.py +++ b/compensation/urls/compensation.py @@ -18,11 +18,15 @@ urlpatterns = [ path('/log', log_view, name='log'), path('/edit', edit_view, name='edit'), path('/remove', remove_view, name='remove'), + path('/state/new', state_new_view, name='new-state'), - path('/action/new', action_new_view, name='new-action'), - path('/state//remove', state_remove_view, name='state-remove'), path('/state//edit', state_edit_view, name='state-edit'), + path('/state//remove', state_remove_view, name='state-remove'), + + path('/action/new', action_new_view, name='new-action'), + path('/action//edit', action_edit_view, name='action-edit'), path('/action//remove', action_remove_view, name='action-remove'), + path('/deadline/new', deadline_new_view, name="new-deadline"), path('/deadline//remove', deadline_remove_view, name='deadline-remove'), path('/report', report_view, name='report'), diff --git a/compensation/views/compensation.py b/compensation/views/compensation.py index 3baf03a8..65d2ebc5 100644 --- a/compensation/views/compensation.py +++ b/compensation/views/compensation.py @@ -7,7 +7,7 @@ from django.utils.translation import gettext_lazy as _ from compensation.forms.forms import NewCompensationForm, EditCompensationForm from compensation.forms.modalForms import NewStateModalForm, NewDeadlineModalForm, NewActionModalForm, \ NewCompensationDocumentModalForm, RemoveCompensationActionModalForm, RemoveCompensationStateModalForm, \ - EditCompensationStateModalForm + EditCompensationStateModalForm, EditCompensationActionModalForm from compensation.models import Compensation, CompensationState, CompensationAction, CompensationDocument from compensation.tables import CompensationTable from intervention.models import Intervention @@ -21,7 +21,7 @@ from konova.utils.generators import generate_qr_code from konova.utils.message_templates import FORM_INVALID, IDENTIFIER_REPLACED, DATA_UNSHARED_EXPLANATION, \ CHECKED_RECORDED_RESET, COMPENSATION_ADDED_TEMPLATE, COMPENSATION_REMOVED_TEMPLATE, DOCUMENT_ADDED, \ COMPENSATION_STATE_REMOVED, COMPENSATION_STATE_ADDED, COMPENSATION_ACTION_REMOVED, COMPENSATION_ACTION_ADDED, \ - DEADLINE_ADDED, DEADLINE_REMOVED, DOCUMENT_EDITED, COMPENSATION_STATE_EDITED + DEADLINE_ADDED, DEADLINE_REMOVED, DOCUMENT_EDITED, COMPENSATION_STATE_EDITED, COMPENSATION_ACTION_EDITED from konova.utils.user_checks import in_group @@ -400,6 +400,30 @@ def action_new_view(request: HttpRequest, id: str): ) +@login_required +@default_group_required +@shared_access_required(Compensation, "id") +def action_edit_view(request: HttpRequest, id: str, action_id: str): + """ Renders a form for editing actions for a compensation + + Args: + request (HttpRequest): The incoming request + id (str): The compensation's id + action_id (str): The action's id + + Returns: + + """ + comp = get_object_or_404(Compensation, id=id) + action = get_object_or_404(CompensationAction, id=action_id) + form = EditCompensationActionModalForm(request.POST or None, instance=comp, action=action, request=request) + return form.process_request( + request, + msg_success=COMPENSATION_ACTION_EDITED, + redirect_url=reverse("compensation:detail", args=(id,)) + "#related_data" + ) + + @login_required @default_group_required @shared_access_required(Compensation, "id")