[UPDT] LEAVE: Updated restricted leave page to cbv
This commit is contained in:
@@ -297,12 +297,29 @@ class LeaveRequestsDetailView(HorillaDetailedView):
|
||||
(_("Created By"), "created_by"),
|
||||
(_("Description"), "description"),
|
||||
(_("View attachment"), "attachment_action", True),
|
||||
(_("Reason for Rejection"), "rejected_action", True),
|
||||
(_("Reason for Cancellation"), "cancelled_action", True),
|
||||
(_("Multiple Approvals"), "multiple_approval_action", True),
|
||||
]
|
||||
action_method = "leave_requests_detail_view_actions"
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
context = super().get_context_data(**kwargs)
|
||||
body = list(self.body)
|
||||
|
||||
if self.instance.multiple_approvals:
|
||||
insert_index = 7
|
||||
body.insert(
|
||||
insert_index,
|
||||
(_("Multiple Approvals"), "multiple_approval_action", True),
|
||||
)
|
||||
|
||||
if self.instance.reject_reason:
|
||||
insert_index = 8
|
||||
body.insert(
|
||||
insert_index, (_("Reason for Rejection"), "rejected_action", True)
|
||||
)
|
||||
|
||||
context["body"] = body
|
||||
return context
|
||||
|
||||
|
||||
@method_decorator(login_required, name="dispatch")
|
||||
@method_decorator(manager_can_enter("leave.add_leaverequest"), name="dispatch")
|
||||
|
||||
@@ -231,15 +231,18 @@ class MyLeaveRequestDetailView(HorillaDetailedView):
|
||||
"subtitle": "my_leave_request_detail_subtitle",
|
||||
"avatar": "employee_id__get_avatar",
|
||||
}
|
||||
# cols = {
|
||||
# "rejected_action" : 12,
|
||||
# "attachment_action" : 12
|
||||
# }
|
||||
body = [
|
||||
("Leave Type", "leave_type_id"),
|
||||
("Days", "requested_days"),
|
||||
("Start Date", "start_date"),
|
||||
("End Date", "end_date"),
|
||||
("Status", "get_status"),
|
||||
("Status", "get_status_display"),
|
||||
("Description", "description"),
|
||||
("Reason for Rejection", "rejected_action", True),
|
||||
("Reason for Cancellation", "cancelled_action", True),
|
||||
("View attachment", "attachment_action", True),
|
||||
]
|
||||
action_method = "detail_leave_actions"
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
</style>
|
||||
{% if instance.attachment %}
|
||||
<a href="{{instance.attachment.url}}" target="_blank" class="oh-timeoff-modal__download-link">
|
||||
<a href="{{instance.attachment.url}}" target="_blank" class="oh-timeoff-modal__download-link mt-0">
|
||||
<ion-icon class="me-1" name="download-outline"></ion-icon>
|
||||
<span class="oh-timeoff-modal__download-link-text"></span>
|
||||
{% trans "View attachment" %}
|
||||
|
||||
@@ -1,56 +1,41 @@
|
||||
{% load basefilters %}
|
||||
{% load i18n %}
|
||||
{% load basefilters i18n %}
|
||||
|
||||
{% if instance.status == 'requested'%}
|
||||
<a hx-get="{% url 'user-request-update' instance.id %}"
|
||||
hx-target='#genericModalBody'
|
||||
data-toggle="oh-modal-toggle"
|
||||
data-target='#genericModal'
|
||||
class="oh-btn oh-btn--info w-50" title="{% trans 'Edit' %}">
|
||||
<ion-icon name="create-outline"></ion-icon>
|
||||
</a>
|
||||
{% else %}
|
||||
<button class="oh-btn oh-btn--info w-50" disabled><ion-icon name="create-outline" ></ion-icon></button></td>
|
||||
{% endif %}
|
||||
{% if instance.status == 'requested'%}
|
||||
<form hx-confirm="{% trans 'Are you sure you want to delete this leave request?' %}"
|
||||
hx-post="{% url 'user-request-delete' instance.id %}"
|
||||
hx-target="#genericModalBody" style="width: 50%">
|
||||
{% csrf_token %}
|
||||
<button type='submit' class="oh-btn oh-btn--secondary w-100" title="{% trans 'Remove' %}"><ion-icon name="trash-outline"></ion-icon></button>
|
||||
</form>
|
||||
{% else %}
|
||||
<button class="oh-btn oh-btn--secondary w-50" disabled><ion-icon name="trash-outline"></ion-icon></button></td>
|
||||
<a
|
||||
hx-get="{% url 'user-request-update' instance.id %}"
|
||||
hx-target="#genericModalBody"
|
||||
data-toggle="oh-modal-toggle"
|
||||
data-target="#genericModal"
|
||||
class="oh-btn oh-btn--info w-50"
|
||||
title="{% trans 'Edit' %}"
|
||||
>
|
||||
<ion-icon name="create-outline"></ion-icon>
|
||||
{% trans 'Edit' %}
|
||||
</a>
|
||||
{% else %}
|
||||
<button class="oh-btn oh-btn--info w-50" disabled>
|
||||
<ion-icon name="create-outline"></ion-icon>{% trans 'Edit' %}
|
||||
</button>
|
||||
{% endif %}
|
||||
|
||||
|
||||
{% comment %}
|
||||
{% load i18n %}
|
||||
<div class=" {% if instance.status == 'rejected' %} diff-cell{% endif %}" onclick="event.stopPropagation()">
|
||||
{% if instance.status == 'requested'%}
|
||||
<div class="oh-btn-group" >
|
||||
<button class="oh-btn oh-btn--info w-50" title="{% trans 'Edit' %}" data-toggle="oh-modal-toggle"
|
||||
data-target="#genericModal" hx-get="{% url 'user-request-update' instance.id %}?instance_ids={{instance.ordered_ids}}"
|
||||
hx-target="#genericModalBody">
|
||||
<ion-icon name="create-outline"></ion-icon>
|
||||
</button>
|
||||
<a class="oh-btn oh-btn--secondary w-50"
|
||||
title="{% trans 'Delete' %}" id="delete-link"
|
||||
hx-confirm="{% trans 'Are you sure you want to delete this leave request?' %}"
|
||||
hx-post="{% url 'user-request-delete' instance.id %}"
|
||||
hx-target="#deleteleavedata"
|
||||
>
|
||||
<ion-icon name="trash-outline"></ion-icon>
|
||||
</a>
|
||||
</div>
|
||||
{% else %}
|
||||
<div class="oh-btn-group" >
|
||||
<button
|
||||
class="oh-btn oh-btn--info w-50" disabled style="width: 50%">
|
||||
<ion-icon name="create-outline" ></ion-icon>
|
||||
</button></td>
|
||||
<button class="oh-btn oh-btn--secondary w-50" disabled style="width: 50%">
|
||||
<ion-icon name="trash-outline"></ion-icon>
|
||||
</button></td>
|
||||
</div>
|
||||
{% endif %}
|
||||
</div> {% endcomment %}
|
||||
{% if instance.status == 'requested'%}
|
||||
<form
|
||||
hx-confirm="{% trans 'Are you sure you want to delete this leave request?' %}"
|
||||
hx-post="{% url 'user-request-delete' instance.id %}"
|
||||
hx-target="#genericModalBody"
|
||||
style="width: 50%"
|
||||
>
|
||||
{% csrf_token %}
|
||||
<button
|
||||
type="submit"
|
||||
class="oh-btn oh-btn--secondary w-100"
|
||||
title="{% trans 'Remove' %}"
|
||||
>
|
||||
<ion-icon name="trash-outline"></ion-icon> {% trans 'Remove' %}
|
||||
</button>
|
||||
</form>
|
||||
{% else %}
|
||||
<button class="oh-btn oh-btn--secondary w-50" disabled>
|
||||
<ion-icon name="trash-outline"></ion-icon>{% trans 'Remove' %}
|
||||
</button>
|
||||
{% endif %}
|
||||
|
||||
@@ -7,13 +7,20 @@
|
||||
</style>
|
||||
|
||||
{% if instance.reject_reason %}
|
||||
{% if instance.status == "rejected" %}
|
||||
<div class="oh-timeoff-modal__stats w-100 mt-3 p-2 row-status--gray diff-cell">
|
||||
<div class="oh-timeoff-modal__stat">
|
||||
<span class="oh-timeoff-modal__stat-title">{% trans "Reason for Rejection" %}</span>
|
||||
<div class="oh-timeoff-modal__stat-description">{{instance.reject_reason}}</div>
|
||||
</div>
|
||||
</div>
|
||||
{% if instance.status == "rejected" %}
|
||||
<div class="oh-timeoff-modal__stats w-100 p-2 row-status--gray diff-cell">
|
||||
<div class="oh-timeoff-modal__stat">
|
||||
<span class="oh-timeoff-modal__stat-title">{% trans "Reason for Rejection" %}</span>
|
||||
<div class="oh-timeoff-modal__stat-description">{{instance.reject_reason}}</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{% endif %}
|
||||
{% elif instance.status == "cancelled" %}
|
||||
<div class="oh-timeoff-modal__stats w-100 p-2 row-status--gray diff-cell">
|
||||
<div class="oh-timeoff-modal__stat">
|
||||
<span class="oh-timeoff-modal__stat-title">{% trans "Reason for Cancellation" %}</span>
|
||||
<div class="oh-timeoff-modal__stat-description">{{instance.reject_reason}}</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
|
||||
Reference in New Issue
Block a user