From 485d5eac7d05a620bc167a2ce6d519ad7a4c84a2 Mon Sep 17 00:00:00 2001 From: Horilla Date: Tue, 20 Feb 2024 14:17:21 +0530 Subject: [PATCH] [UPDT] OFFBOARDING: Note section to new design and workflow --- offboarding/models.py | 1 - .../offboarding/note/view_notes.html | 207 ++++++++++++++---- .../templates/offboarding/pipeline/nav.html | 5 + .../templates/offboarding/stage/stages.html | 16 -- .../offboarding/task/table_body.html | 11 +- offboarding/urls.py | 7 +- offboarding/views.py | 90 +++++--- 7 files changed, 243 insertions(+), 94 deletions(-) diff --git a/offboarding/models.py b/offboarding/models.py index 85c5b06d5..18b7977dd 100644 --- a/offboarding/models.py +++ b/offboarding/models.py @@ -295,7 +295,6 @@ class OffboardingNote(models.Model): attachments = models.ManyToManyField( OffboardingStageMultipleFile, blank=True, editable=False ) - title = models.CharField(max_length=20, null=True) description = models.TextField(null=True, blank=True,max_length=255) note_by = models.ForeignKey( Employee, on_delete=models.SET_NULL, null=True, editable=False diff --git a/offboarding/templates/offboarding/note/view_notes.html b/offboarding/templates/offboarding/note/view_notes.html index 31dda1b4a..3ba0e1fc0 100644 --- a/offboarding/templates/offboarding/note/view_notes.html +++ b/offboarding/templates/offboarding/note/view_notes.html @@ -1,43 +1,174 @@ {% load i18n static %} - - - {% trans 'Add note' %} - -
    - {% for note in employee.offboardingnote_set.all %} -
  1. - {{ note.title }} - {{ note.description }} -
    - {% for attachment in note.attachments.all %} - - {% endfor %} +{% if messages %} +
    + {% for message in messages %} +
    {{ message }}
    + {% endfor %} +
    + +{% endif %} -
    - {% csrf_token %} - - - -
    -
    - - {% trans 'by' %} - - {{ note.note_by.get_full_name }} @{{ note.stage_id }} - -
    -
    -
    -
  2. - {% endfor %} -
\ No newline at end of file +
+ + + + {{employee}}'s {% trans "Notes" %} +
+ +
+ {% csrf_token %} + +
+ + +
+ + +
+ +{% if employee.offboardingnote_set.all %} +
    + {% for note in employee.offboardingnote_set.all %} +
  1. + {{ note.description }} + + + + +
    + {% for file in note.attachments.all %} + + {% endfor %} + +
    + {% csrf_token %} + + + +
    +
    + + {% trans 'by' %} + + {{ note.updated_by }} @ {{note.stage_id }} + {% trans "stage" %} + +
    +
    +
    +
  2. + + {% endfor %} +
+{% else %} +
+
+
+ {% trans "No notes have been added for this employee" %} + +
+
+
+{% endif %} + + + + + + + \ No newline at end of file diff --git a/offboarding/templates/offboarding/pipeline/nav.html b/offboarding/templates/offboarding/pipeline/nav.html index 7e9afe53b..7c9e677ee 100644 --- a/offboarding/templates/offboarding/pipeline/nav.html +++ b/offboarding/templates/offboarding/pipeline/nav.html @@ -33,3 +33,8 @@
+
+ +
+
+
diff --git a/offboarding/templates/offboarding/stage/stages.html b/offboarding/templates/offboarding/stage/stages.html index 19854f0e4..7a8f00241 100644 --- a/offboarding/templates/offboarding/stage/stages.html +++ b/offboarding/templates/offboarding/stage/stages.html @@ -8,22 +8,6 @@
{% include "offboarding/stage/offboarding_body.html" %}
-
-
- - - - {% trans "Notes" %} -
-
-
-
- """ - ) + messages.success(request, _("Note added successfully")) + return redirect("view-offboarding-note", employee_id=employee.id) return render( - request, "offboarding/note/form.html", {"form": form, "employee": employee} + request, + "offboarding/note/view_notes.html", + { + "form": form, + "employee": employee, + }, ) +@login_required +@manager_can_enter(perm="offboarding.delete_offboardingNote") +def offboarding_note_delete(request, note_id): + """ + This method is used to delete the offboarding note + """ + try: + note = OffboardingNote.objects.get(id=note_id) + employee = note.employee_id.id + note.delete() + messages.success(request, _("Note deleted")) + except OffboardingNote.DoesNotExist: + messages.error(request, _("Note not found.")) + + return redirect("view-offboarding-note", employee_id=employee) + + @login_required @permission_required("offboarding.delete_offboardingnote") def delete_attachment(request): @@ -521,10 +542,17 @@ def task_assign(request): offboarding = employees.first().stage_id.offboarding_id stage_forms = {} stage_forms[str(offboarding.id)] = StageSelectForm(offboarding=offboarding) + groups = pipeline_grouper({}, [task.stage_id.offboarding_id]) + for item in groups: + setattr(item["offboarding"], "stages", item["stages"]) return render( request, "offboarding/stage/offboarding_body.html", - {"offboarding": offboarding, "stage_forms": stage_forms}, + { + "offboarding": groups[0], + "stage_forms": stage_forms, + "response_message": _("Task Assigned"), + }, )