diff --git a/helpdesk/forms.py b/helpdesk/forms.py index bf482344c..79bace94c 100644 --- a/helpdesk/forms.py +++ b/helpdesk/forms.py @@ -20,8 +20,10 @@ class YourForm(forms.Form): # Custom validation logic goes here pass """ +from typing import Any from base.forms import ModelForm from base.models import Department, JobPosition +from employee.forms import MultipleFileField from employee.models import Employee from helpdesk.models import Attachment, DepartmentManager, TicketType, FAQ,Ticket, FAQCategory, Comment from django import forms @@ -73,27 +75,15 @@ class TicketForm(ModelForm): context = {"form": self} table_html = render_to_string("attendance_form.html", context) return table_html - -# def get_updated_choices(assigning_type): -# new_choices =[ -# ('', '---------'), -# ] -# if assigning_type: -# if assigning_type == 'department': -# # Retrieve data from the Department model and format it as a list of dictionaries -# departments = Department.objects.values('id', 'department') -# raised_on = [{'id': dept['id'], 'name': dept['department']} for dept in departments] -# elif assigning_type == 'job_position': -# jobpositions = JobPosition.objects.values('id','job_position') -# raised_on = [{'id': job['id'], 'name': job['job_position']} for job in jobpositions] -# elif assigning_type == 'individual': -# employees = Employee.objects.values('id','employee_first_name','employee_last_name') -# raised_on = [{'id': employee['id'], 'name': f"{employee['employee_first_name']} {employee['employee_last_name']}"} for employee in employees] - -# new_choices = [ -# (choice['id'], choice['name']) for choice in raised_on -# ] -# return new_choices + def __init__(self, *args, **kwargs): + super().__init__(*args, **kwargs) + self.fields["attachment"] = MultipleFileField( + label="Attachements", required=False + ) + self.fields["tags"].choices = list(self.fields["tags"].choices) + self.fields["tags"].choices.append(("create_new_tag", "Create new tag")) + self.fields["ticket_type"].choices = list(self.fields["ticket_type"].choices) + self.fields["ticket_type"].choices.append(("create_new_ticket_type", "Create new ticket type")) class TicketTagForm(ModelForm): class Meta: diff --git a/helpdesk/models.py b/helpdesk/models.py index f8b631134..e0b9f1676 100644 --- a/helpdesk/models.py +++ b/helpdesk/models.py @@ -1,9 +1,10 @@ -import datetime +from datetime import datetime import os from django import apps from django.db import models +from django.forms import ValidationError from base.models import Department, JobPosition, Tags - +from django.utils.translation import gettext_lazy as _ from employee.models import Employee from base.models import Company from base.horilla_company_manager import HorillaCompanyManager @@ -93,7 +94,7 @@ class Ticket(models.Model): created_date = models.DateField(auto_now_add=True) resolved_date = models.DateField(blank=True, null=True) assigning_type = models.CharField(choices = MANAGER_TYPES, max_length=100) - raised_on = models.CharField(max_length=100) + raised_on = models.CharField(max_length=100,verbose_name="Forward To") assigned_to = models.ManyToManyField(Employee,blank=True,related_name="ticket_assigned_to") deadline = models.DateField(null=True,blank=True) tags = models.ManyToManyField(Tags,blank=True,related_name="ticket_tags") @@ -108,7 +109,12 @@ class Ticket(models.Model): objects = HorillaCompanyManager( related_company_field="employee_id__employee__work_info__company_id" ) - + def clean(self, *args, **kwargs): + super().clean(*args, **kwargs) + deadline = self.deadline + today = datetime.today().date() + if deadline < today: + raise ValidationError(_("Deadline should be greater than today")) def get_raised_on(self): obj_id = self.raised_on if self.assigning_type == 'department': diff --git a/helpdesk/templates/helpdesk/ticket/ticket_card.html b/helpdesk/templates/helpdesk/ticket/ticket_card.html index 249adf317..f52ab17c4 100644 --- a/helpdesk/templates/helpdesk/ticket/ticket_card.html +++ b/helpdesk/templates/helpdesk/ticket/ticket_card.html @@ -212,27 +212,10 @@ {% else %} -
-
- -

- {% trans "There are no tickets at the moment." %} -

-
-
+
+ Page not found. 404. +
{% trans "There are no tickets at the moment." %}
+
{% endif %} @@ -466,27 +449,10 @@ {% else %} -
-
- -

- {% trans "There are no tickets at the moment." %} -

-
-
+
+ Page not found. 404. +
{% trans "There are no tickets at the moment." %}
+
{% endif %} @@ -703,27 +669,10 @@ {% else %} -
-
- -

- {% trans "There are no tickets at the moment." %} -

-
-
+
+ Page not found. 404. +
{% trans "There are no tickets at the moment." %}
+
{% endif %} diff --git a/helpdesk/templates/helpdesk/ticket/ticket_detail.html b/helpdesk/templates/helpdesk/ticket/ticket_detail.html index f64f9ebfe..8b013f4b0 100644 --- a/helpdesk/templates/helpdesk/ticket/ticket_detail.html +++ b/helpdesk/templates/helpdesk/ticket/ticket_detail.html @@ -29,7 +29,13 @@

{{ticket.title}}

- {% for status in ticket_status %} @@ -273,11 +279,17 @@ {% trans "Priority" %} {% if ticket.priority == 'high' %} - + + + {% elif ticket.priority == 'medium' %} - + + + {% elif ticket.priority == 'low' %} - + + + {% endif %} @@ -311,7 +323,7 @@
- {% trans "Raised on" %} + {% trans "Forward to" %} {% if perms.helpdesk.changeticket or request.user.employee_get == ticket.employee_id %}
+ +
@@ -447,9 +461,9 @@
+ \ No newline at end of file diff --git a/helpdesk/templates/helpdesk/ticket/ticket_group.html b/helpdesk/templates/helpdesk/ticket/ticket_group.html index 5aa12ab50..0089f439f 100644 --- a/helpdesk/templates/helpdesk/ticket/ticket_group.html +++ b/helpdesk/templates/helpdesk/ticket/ticket_group.html @@ -43,16 +43,17 @@
{% trans "Title" %}
{% trans "Owner" %}
{% trans "Type" %}
-
{% trans "Raised on" %}
+
{% trans "Forward to" %}
{% trans "Assigned to" %}
{% trans "Status" %}
+
{% trans "Priority" %}
{% trans "Tags" %}
{% trans "Actions" %}
{% for ticket in my_ticket_list.list %} -
+
{{ticket.get_raised_on}}
{{ticket.assigned_to.all|join:" , "}}
{{ticket.get_status_display}}
+
+ {% if ticket.priority == 'high' %} + + + + {% elif ticket.priority == 'medium' %} + + + + {% elif ticket.priority == 'low' %} + + + + {% endif %} +
{{ticket.tags.all|join:" , "}}
@@ -201,27 +217,10 @@
{% else %} -
-
- -

- {% trans "There are no tickets at the moment." %} -

-
-
+
+ Page not found. 404. +
{% trans "There are no tickets at the moment." %}
+
{% endif %}
@@ -264,16 +263,17 @@
{% trans "Title" %}
{% trans "Owner" %}
{% trans "Type" %}
-
{% trans "Raised on" %}
+
{% trans "Forward to" %}
{% trans "Assigned to" %}
{% trans "Status" %}
+
{% trans "Priority" %}
{% trans "Tags" %}
{% trans "Actions" %}
{% for ticket in allocated_tickets_list.list %} -
+
{{ticket.get_raised_on}}
{{ticket.assigned_to.all|join:" , "}}
{{ticket.get_status_display}}
+
+ {% if ticket.priority == 'high' %} + + + + {% elif ticket.priority == 'medium' %} + + + + {% elif ticket.priority == 'low' %} + + + + {% endif %} +
{{ticket.tags.all|join:" , "}}
@@ -422,27 +437,10 @@
{% else %} -
-
- -

- {% trans "There are no tickets at the moment." %} -

-
-
+
+ Page not found. 404. +
{% trans "There are no tickets at the moment." %}
+
{% endif %}
@@ -484,16 +482,17 @@
{% trans "Title" %}
{% trans "Owner" %}
{% trans "Type" %}
-
{% trans "Raised on" %}
+
{% trans "Forward to" %}
{% trans "Assigned to" %}
{% trans "Status" %}
+
{% trans "Priority" %}
{% trans "Tags" %}
{% trans "Actions" %}
{% for ticket in all_tickets_list.list %} -
+
{{ticket.get_raised_on}}
{{ticket.assigned_to.all|join:" , "}}
{{ticket.get_status_display}}
+
+ {% if ticket.priority == 'high' %} + + + + {% elif ticket.priority == 'medium' %} + + + + {% elif ticket.priority == 'low' %} + + + + {% endif %} +
{{ticket.tags.all|join:" , "}}
@@ -642,27 +656,10 @@
{% else %} -
-
- -

- {% trans "There are no tickets at the moment." %} -

-
-
+
+ Page not found. 404. +
{% trans "There are no tickets at the moment." %}
+
{% endif %}
diff --git a/helpdesk/templates/helpdesk/ticket/ticket_list.html b/helpdesk/templates/helpdesk/ticket/ticket_list.html index e2c965ec8..4644c2270 100644 --- a/helpdesk/templates/helpdesk/ticket/ticket_list.html +++ b/helpdesk/templates/helpdesk/ticket/ticket_list.html @@ -20,21 +20,23 @@
{% trans "Title" %}
{% trans "Owner" %}
{% trans "Type" %}
-
{% trans "Raised on" %}
+
{% trans "Forward to" %}
{% trans "Assigned to" %}
{% trans "Status" %}
+
{% trans "Priority" %}
{% trans "Tags" %}
{% trans "Actions" %}
{% for ticket in my_tickets %} -
+
{{ticket.get_raised_on}}
{{ticket.assigned_to.all|join:" , "}}
{{ticket.get_status_display}}
+
+ {% if ticket.priority == 'high' %} + + + + {% elif ticket.priority == 'medium' %} + + + + {% elif ticket.priority == 'low' %} + + + + {% endif %} +
+
{{ticket.tags.all|join:" , "}}
@@ -172,27 +190,10 @@
{% else %} -
-
- -

- {% trans "There are no tickets at the moment." %} -

-
-
+
+ Page not found. 404. +
{% trans "There are no tickets at the moment." %}
+
{% endif %}
@@ -215,9 +216,10 @@
{% trans "Title" %}
{% trans "Owner" %}
{% trans "Type" %}
-
{% trans "Raised on" %}
+
{% trans "Forward to" %}
{% trans "Assigned to" %}
{% trans "Status" %}
+
{% trans "Priority" %}
{% trans "Tags" %}
{% trans "Actions" %}
@@ -225,12 +227,13 @@
{% for ticket in allocated_tickets %} -
+
{{ticket.get_raised_on}}
{{ticket.assigned_to.all|join:" , "}}
{{ticket.get_status_display}}
+
+ {% if ticket.priority == 'high' %} + + + + {% elif ticket.priority == 'medium' %} + + + + {% elif ticket.priority == 'low' %} + + + + {% endif %} +
{{ticket.tags.all|join:" , "}}
@@ -390,27 +408,10 @@
{% else %} -
-
- -

- {% trans "There are no tickets at the moment." %} -

-
-
+
+ Page not found. 404. +
{% trans "There are no tickets at the moment." %}
+
{% endif %}
@@ -433,21 +434,23 @@
{% trans "Title" %}
{% trans "Owner" %}
{% trans "Type" %}
-
{% trans "Raised on" %}
+
{% trans "Forward to" %}
{% trans "Assigned to" %}
{% trans "Status" %}
+
{% trans "Priority" %}
{% trans "Tags" %}
{% trans "Actions" %}
{% for ticket in all_tickets %} -
+
{{ticket.get_raised_on}}
{{ticket.assigned_to.all|join:" , "}}
{{ticket.get_status_display}}
+
+ {% if ticket.priority == 'high' %} + + + + {% elif ticket.priority == 'medium' %} + + + + {% elif ticket.priority == 'low' %} + + + + {% endif %} +
{{ticket.tags.all|join:" , "}}
@@ -584,27 +602,10 @@
{% else %} -
-
- -

- {% trans "There are no tickets at the moment." %} -

-
-
+
+ Page not found. 404. +
{% trans "There are no tickets at the moment." %}
+
{% endif %}
diff --git a/helpdesk/templates/helpdesk/ticket/ticket_view.html b/helpdesk/templates/helpdesk/ticket/ticket_view.html index ccab77fe5..ed752cbb0 100644 --- a/helpdesk/templates/helpdesk/ticket/ticket_view.html +++ b/helpdesk/templates/helpdesk/ticket/ticket_view.html @@ -131,7 +131,7 @@ {% trans "My Tickets" %}
  • - {% trans "Allocated Tickets" %} + {% trans "Suggested Tickets" %}
  • {% if request.user|is_reportingmanager %}
  • @@ -232,6 +232,57 @@ $(".ticket-view-type").attr("hx-vals", hxVals); }); }); + function saveTag(){ + var title=$('#id_tag_title').val() + var color = $("#id_tag_color").val() + var is_active = $("#id_tag_is_active").val() + $.ajax({ + type: "post", + url: `/helpdesk/ticket-create-tag`, + data: { + csrfmiddlewaretoken: getCookie("csrftoken"), + "title": title, + "color":color, + "is_active":is_active, + }, + success: function (response) { + if (response.errors === "no_error") { + var newOption = $('').val(response.tag_id).text(response.title) + $("#createTagModal").removeClass("oh-modal--show"); + $("#id_tags option[value='create_new_tag']").before(newOption); + $("#id_tags option[value='create_new_tag']").prop('selected',false) + {% comment %} updateTag() {% endcomment %} + } + } + }); + } + function saveTicketType(){ + var title=$('#id_ticket_type_title').val() + var type = $("#id_type").val() + var prefix = $("#id_prefix").val() + var is_active = $("#id_ticket_type_is_active").val() + $.ajax({ + type: "post", + url: "{% url 'ticket-type-create' %}?ajax=True", + data: { + csrfmiddlewaretoken: getCookie("csrftoken"), + "title": title, + "type":type, + 'prefix':prefix, + "is_active":is_active, + }, + success: function (response) { + if (response.errors === "no_error") { + var newOption = $('').val(response.ticket_id).text(response.title) + $("#createTicketTypeModal").removeClass("oh-modal--show"); + $("#id_ticket_type option[value='create_new_ticket_type']").before(newOption); + $("#id_ticket_type option[value='create_new_ticket_type']").prop('selected',false) + {% comment %} updateTag() {% endcomment %} + } + } + }); + } + {% endblock %} \ No newline at end of file diff --git a/helpdesk/views.py b/helpdesk/views.py index ee64fb4dc..b246c2768 100644 --- a/helpdesk/views.py +++ b/helpdesk/views.py @@ -9,7 +9,7 @@ from base.methods import filtersubordinates, get_key_instances, get_pagination from base.models import Department, JobPosition, Tags from employee.models import Employee from helpdesk.filter import FAQCategoryFilter, FAQFilter,TicketFilter, TicketReGroup -from helpdesk.forms import AttachmentForm, CommentForm, DepartmentManagerCreateForm, FAQCategoryForm, FAQForm,TicketForm, TicketRaisedOnForm, TicketTagForm ,TicketAssigneesForm +from helpdesk.forms import AttachmentForm, CommentForm, DepartmentManagerCreateForm, FAQCategoryForm, FAQForm,TicketForm, TicketRaisedOnForm, TicketTagForm ,TicketAssigneesForm, TicketTypeForm from django.utils.translation import gettext as _ from django.contrib import messages from django.db.models import ProtectedError @@ -402,9 +402,13 @@ def ticket_create(request): status = request.GET.get('status') form = TicketForm(initial={'status':status}) if request.method == "POST": - form = TicketForm(request.POST) - if form.is_valid(): + form = TicketForm(request.POST,request.FILES) + if form.is_valid(): ticket = form.save() + attachments = form.files.getlist('attachment') + for attachment in attachments: + attachment_instance= Attachment(file=attachment,ticket=ticket) + attachment_instance.save() mail_thread = TicketSendThread(request, ticket, type="create") mail_thread.start() messages.success( @@ -431,6 +435,7 @@ def ticket_create(request): return HttpResponse("") context = { 'form': form, + 't_type_form':TicketTypeForm(), } return render(request, "helpdesk/ticket/ticket_form.html", context) @@ -452,9 +457,13 @@ def ticket_update(request,ticket_id): ticket = Ticket.objects.get(id=ticket_id) form = TicketForm(instance=ticket) if request.method == "POST": - form = TicketForm(request.POST,instance=ticket) + form = TicketForm(request.POST,request.FILES,instance=ticket) if form.is_valid(): - form.save() + ticket = form.save() + attachments = form.files.getlist('attachment') + for attachment in attachments: + attachment_instance= Attachment(file=attachment,ticket=ticket) + attachment_instance.save() messages.success( request, _('The Ticket updated successfully.') ) @@ -729,8 +738,11 @@ def ticket_detail(request,ticket_id,**kwargs): context=context ) @login_required -@owner_can_enter("perms.helpdesk.helpdesk_changeticket", Ticket) +# @owner_can_enter("perms.helpdesk.helpdesk_changeticket", Ticket) def ticket_update_tag(request): + """ + method to update the tags of ticket + """ data = request.GET ticket = Ticket.objects.get(id=data['ticketId']) tagids = data.getlist('selectedValues[]') @@ -807,6 +819,7 @@ def create_tag(request): """ This is an ajax method to return json response to create tag in the change tag form. """ + if request.method == "POST": form = TagsForm(request.POST) diff --git a/static/images/ui/orange_star.png b/static/images/ui/orange_star.png new file mode 100644 index 000000000..529d2b4fe Binary files /dev/null and b/static/images/ui/orange_star.png differ diff --git a/static/images/ui/star.png b/static/images/ui/star.png new file mode 100644 index 000000000..97b0aa893 Binary files /dev/null and b/static/images/ui/star.png differ