diff --git a/base/templates/announcement/comment_view.html b/base/templates/announcement/comment_view.html
index adbcd6555..b30f20708 100644
--- a/base/templates/announcement/comment_view.html
+++ b/base/templates/announcement/comment_view.html
@@ -35,7 +35,7 @@
{% csrf_token %}
-
+
@@ -69,7 +69,7 @@
{% if perms.base.delete_announcementcomment or request.user == comment.created_by %}
{% endif %}
@@ -101,19 +101,3 @@
{% endif %}
-
-
diff --git a/base/templates/base/auth/permission_lines.html b/base/templates/base/auth/permission_lines.html
index 95ca441b8..82e6d8ab1 100644
--- a/base/templates/base/auth/permission_lines.html
+++ b/base/templates/base/auth/permission_lines.html
@@ -62,9 +62,6 @@
{% endif %}
{% endif %}
-
- {% if request.user.employee_get == shift_request.employee_id or perms.base.add_shiftrequestcomment or request.user|is_reportingmanager %}
-
- {% endif %}
+
+{% if request.user.employee_get == shift_request.employee_id or perms.base.add_shiftrequestcomment or request.user|is_reportingmanager %}
+
+{% endif %}
{% if comments %}
-
{% endfor %}
{% else %}
-
{% trans "There are no comments to show." %}
-

+
{% trans "There are no comments to show." %}
+
{% endif %}
-
-
-
-
-
-
-
diff --git a/base/templates/work_type_request/htmx/work_type_comment.html b/base/templates/work_type_request/htmx/work_type_comment.html
index 6cb9a3e9e..710174b2f 100644
--- a/base/templates/work_type_request/htmx/work_type_comment.html
+++ b/base/templates/work_type_request/htmx/work_type_comment.html
@@ -1,56 +1,45 @@
{% load i18n static %}
{% load basefilters %}
{% if messages %}
-
- {% for message in messages %}
-
{{ message }}
- {% endfor %}
-
-
+
{% endif %}
-
- {% if request.user.employee_get == work_type_request.employee_id or perms.base.add_worktyperequestcomment or request.user|is_reportingmanager %}
-
- {% endif %}
+
+
+{% endif %}
{% if comments %}
@@ -58,72 +47,48 @@
{% for comment in comments %}
-
{% endfor %}
{% else %}
-
{% trans "There are no comments to show." %}
-

+
{% trans "There are no comments to show." %}
+
{% endif %}
-
-
-
-
-
-
-
diff --git a/base/views.py b/base/views.py
index ff3ba68c8..cb3031465 100644
--- a/base/views.py
+++ b/base/views.py
@@ -109,6 +109,7 @@ from base.methods import (
format_date,
get_key_instances,
get_pagination,
+ is_reportingmanager,
sortby,
)
from base.models import (
@@ -4011,7 +4012,7 @@ def shift_request_view(request):
allocated_shift_requests = filtersubordinates(
request,
ShiftRequest.objects.filter(reallocate_to__isnull=False),
- "base.add_shiftrequest",
+ "base.view_shiftrequest",
)
allocated_requests = ShiftRequest.objects.filter(reallocate_to__isnull=False)
if not request.user.has_perm("base.view_shiftrequest"):
@@ -4816,22 +4817,25 @@ def delete_notification(request, id):
"""
This method is used to delete notification
"""
+ script = ""
try:
request.user.notifications.get(id=id).delete()
messages.success(request, _("Notification deleted."))
except Exception as e:
messages.error(request, e)
- notifications = request.user.notifications.all()
- return render(
- request, "notification/all_notifications.html", {"notifications": notifications}
- )
+ if not request.user.notifications.all():
+ script = """"""
+ return HttpResponse(script)
@login_required
def mark_as_read_notification(request, notification_id):
+ script = ""
notification = Notification.objects.get(id=notification_id)
notification.mark_as_read()
- return redirect(notifications)
+ if not request.user.notifications.unread():
+ script = """"""
+ return HttpResponse(script)
@login_required
@@ -5782,26 +5786,27 @@ def view_shift_comment(request, shift_id):
@login_required
-@permission_required("offboarding.delete_offboardingnote")
+@hx_request_required
def delete_shift_comment_file(request):
"""
Used to delete attachment
"""
ids = request.GET.getlist("ids")
- BaserequestFile.objects.filter(id__in=ids).delete()
- messages.success(request, _("File deleted successfully"))
shift_id = request.GET["shift_id"]
- comments = ShiftRequestComment.objects.filter(request_id=shift_id).order_by(
- "-created_at"
- )
- return render(
- request,
- "shift_request/htmx/shift_comment.html",
- {
- "comments": comments,
- "request_id": shift_id,
- },
- )
+ comment_id = request.GET["comment_id"]
+ comment = ShiftRequestComment.find(comment_id)
+ script = ""
+ if (
+ request.user.employee_get == comment.employee_id
+ or request.user.has_perm("base.delete_baserequestfile")
+ or is_reportingmanager(request)
+ ):
+ BaserequestFile.objects.filter(id__in=ids).delete()
+ messages.success(request, _("File deleted successfully"))
+ else:
+ messages.warning(request, _("You don't have permission"))
+ script = f""""""
+ return HttpResponse(script)
@login_required
@@ -5841,24 +5846,27 @@ def view_work_type_comment(request, work_type_id):
@login_required
-@permission_required("offboarding.delete_offboardingnote")
+@hx_request_required
def delete_work_type_comment_file(request):
"""
Used to delete attachment
"""
ids = request.GET.getlist("ids")
- BaserequestFile.objects.filter(id__in=ids).delete()
- messages.success(request, _("File deleted successfully"))
- work_type_id = request.GET["work_type_id"]
- comments = WorkTypeRequestComment.objects.filter(request_id=work_type_id)
- return render(
- request,
- "work_type_request/htmx/work_type_comment.html",
- {
- "comments": comments,
- "request_id": work_type_id,
- },
- )
+ request_id = request.GET["request_id"]
+ comment_id = request.GET["comment_id"]
+ comment = WorkTypeRequestComment.find(comment_id)
+ script = ""
+ if (
+ request.user.employee_get == comment.employee_id
+ or request.user.has_perm("base.delete_baserequestfile")
+ or is_reportingmanager(request)
+ ):
+ BaserequestFile.objects.filter(id__in=ids).delete()
+ messages.success(request, _("File deleted successfully"))
+ else:
+ messages.warning(request, _("You don't have permission"))
+ script = f""""""
+ return HttpResponse(script)
@login_required
@@ -5868,9 +5876,19 @@ def delete_shiftrequest_comment(request, comment_id):
This method is used to delete shift request comments
"""
comment = ShiftRequestComment.find(comment_id)
- comment.delete()
- messages.success(request, _("Comment deleted successfully!"))
- return HttpResponse()
+ request_id = comment.request_id.id
+ script = ""
+ if (
+ request.user.employee_get == comment.employee_id
+ or request.user.has_perm("base.delete_baserequestfile")
+ or is_reportingmanager(request)
+ ):
+ comment.delete()
+ messages.success(request, _("Comment deleted successfully!"))
+ else:
+ messages.warning(request, _("You don't have permission"))
+ script = f""""""
+ return HttpResponse(script)
@login_required
@@ -5997,10 +6015,20 @@ def delete_worktyperequest_comment(request, comment_id):
"""
This method is used to delete Work type request comments
"""
- comment = WorkTypeRequestComment.objects.filter(id=comment_id)
- comment.delete()
- messages.success(request, _("Comment deleted successfully!"))
- return HttpResponse()
+ script = ""
+ comment = WorkTypeRequestComment.find(comment_id)
+ request_id = comment.request_id.id
+ if (
+ request.user.employee_get == comment.employee_id
+ or request.user.has_perm("base.delete_baserequestfile")
+ or is_reportingmanager(request)
+ ):
+ comment.delete()
+ messages.success(request, _("Comment deleted successfully!"))
+ else:
+ messages.warning(request, _("You don't have permission"))
+ script = f""""""
+ return HttpResponse(script)
@login_required
@@ -6026,7 +6054,7 @@ def pagination_settings_view(request):
@login_required
-@permission_required("base.view_actiontype")
+@permission_required("employee.view_actiontype")
def action_type_view(request):
"""
This method is used to show Action Type
@@ -6039,7 +6067,7 @@ def action_type_view(request):
@login_required
@hx_request_required
-@permission_required("base.add_actiontype")
+@permission_required("employee.add_actiontype")
def action_type_create(request):
"""
This method renders form and template to create Action Type
@@ -6053,9 +6081,7 @@ def action_type_create(request):
form.save()
form = ActiontypeForm()
messages.success(request, _("Action has been created successfully!"))
- if dynamic == "None":
- return HttpResponse("")
- else:
+ if dynamic != "None":
url = reverse("create-actions")
instance = Actiontype.objects.all().order_by("-id").first()
mutable_get = request.GET.copy()
@@ -6075,7 +6101,7 @@ def action_type_create(request):
@login_required
@hx_request_required
-@permission_required("base.change_actiontype")
+@permission_required("employee.change_actiontype")
def action_type_update(request, act_id):
"""
This method renders form and template to update Action type
@@ -6084,7 +6110,10 @@ def action_type_update(request, act_id):
form = ActiontypeForm(instance=action)
if action.action_type == "warning":
- if AccountBlockUnblock.objects.first().is_enabled:
+ if (
+ AccountBlockUnblock.objects.first()
+ and AccountBlockUnblock.objects.first().is_enabled
+ ):
form.fields["block_option"].widget = forms.HiddenInput()
if request.method == "POST":
@@ -6096,7 +6125,6 @@ def action_type_update(request, act_id):
form.save()
form = ActiontypeForm()
messages.success(request, _("Action has been updated successfully!"))
- return HttpResponse("")
return render(
request,
"base/action_type/action_type_form.html",
diff --git a/employee/templates/tabs/note_tab.html b/employee/templates/tabs/note_tab.html
index 9cab1d72d..4be186cc2 100644
--- a/employee/templates/tabs/note_tab.html
+++ b/employee/templates/tabs/note_tab.html
@@ -1,295 +1,164 @@
{% load static %}{% load i18n %} {% load basefilters %}
{% if messages %}
-
- {% for message in messages %}
-
- {% endfor %}
-
+
{% endif %}
- {% if notes %}
-
- {% if perms.employee.add_employeenote or request.user|is_reportingmanager %}
-
- {% endif %}
-
-
-{% else %} {% if messages %}
-
- {% for message in messages %}
-
- {% endfor %}
-
-{% endif %}
-
-
-
-
-
-
-

-
- {% trans "No notes have been added for this employee" %}
-
-
-
-{% endif %}
-
-
-
-
-
-
-
-
+
+

+
+ {% trans "No notes have been added for this employee" %}
+
+
+{% endif %}
diff --git a/employee/views.py b/employee/views.py
index 2a9e6c784..e6fb4d85a 100755
--- a/employee/views.py
+++ b/employee/views.py
@@ -3035,16 +3035,13 @@ def employee_note_delete(request, note_id):
note = EmployeeNote.objects.get(id=note_id)
note.delete()
- message = _("Note deleted successfully...")
- return HttpResponse(
- f"
"
- )
+ messages.success(request, _("Note deleted successfully."))
+ return HttpResponse()
@login_required
@hx_request_required
+@manager_can_enter(perm="employee.add_notefiles")
def add_more_employee_files(request, note_id):
"""
This method is used to Add more files to the Employee note.
@@ -3065,6 +3062,8 @@ def add_more_employee_files(request, note_id):
@login_required
+@hx_request_required
+@manager_can_enter(perm="employee.delete_notefiles")
def delete_employee_note_file(request, note_file_id):
"""
This method is used to delete the stage note file
@@ -3072,12 +3071,8 @@ def delete_employee_note_file(request, note_file_id):
id : stage file instance id
"""
file = NoteFiles.objects.get(id=note_file_id)
- notes = file.employeenote_set.all()
- if not request.user.has_perm("employee.delete_notefile"):
- file.employeenote_set.filter(employee_id__employee_user_id=request.user)
- employee_id = notes.first().employee_id.id
file.delete()
- return redirect(f"/employee/note-tab/{employee_id}")
+ return HttpResponse()
@login_required
@@ -3481,7 +3476,6 @@ def employee_tag_create(request):
form.save()
form = EmployeeTagForm()
messages.success(request, _("Tag has been created successfully!"))
- return HttpResponse("")
return render(
request,
"base/employee_tag/employee_tag_form.html",