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." %}
-
-
-
+
+

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

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

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

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

+
{% 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 @@
-