#86 Edit actions compensation
* adds support for editing of CompensationAction for compensation * adds buttons and urls
This commit is contained in:
parent
06f81d89c4
commit
8d573e7390
@ -61,9 +61,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:action-remove' obj.id action.id %}" class="btn btn-default btn-modal float-right" title="{% trans 'Remove action' %}">
|
||||
<button data-form-url="{% url 'compensation: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:action-remove' obj.id action.id %}" class="btn btn-default btn-modal" title="{% trans 'Remove action' %}">
|
||||
{% fa5_icon 'trash' %}
|
||||
</button>
|
||||
{% endif %}
|
||||
|
@ -18,11 +18,15 @@ urlpatterns = [
|
||||
path('<id>/log', log_view, name='log'),
|
||||
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/new', deadline_new_view, name="new-deadline"),
|
||||
path('<id>/deadline/<deadline_id>/remove', deadline_remove_view, name='deadline-remove'),
|
||||
path('<id>/report', report_view, name='report'),
|
||||
|
@ -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")
|
||||
|
Loading…
Reference in New Issue
Block a user