diff --git a/models.py b/models.py index 45848b8e..9c043dd2 100644 --- a/models.py +++ b/models.py @@ -99,9 +99,18 @@ class Ticket(models.Model): (CLOSED_STATUS, 'Closed'), ) + PRIORITY_CHOICES = ( + (1, '1 (Critical)'), + (2, '2 (High)'), + (3, '3 (Normal)'), + (4, '4 (Low)'), + (5, '5 (Very Low)'), + ) + title = models.CharField(maxlength=200) queue = models.ForeignKey(Queue) - created = models.DateTimeField(auto_now_add=True) + created = models.DateTimeField(blank=True) + modified = models.DateTimeField(blank=True) submitter_email = models.EmailField(blank=True, null=True, help_text='The submitter will receive an email for all public follow-ups left for this task.') assigned_to = models.ForeignKey(User, related_name='assigned_to', blank=True, null=True) status = models.IntegerField(choices=STATUS_CHOICES, default=OPEN_STATUS) @@ -109,6 +118,8 @@ class Ticket(models.Model): description = models.TextField(blank=True, null=True) resolution = models.TextField(blank=True, null=True) + priority = models.IntegerField(choices=PRIORITY_CHOICES, default=3, blank=3) + def _get_assigned_to(self): """ Custom property to allow us to easily print 'Unassigned' if a ticket has no owner, or the users name if it's assigned. If the user @@ -148,6 +159,11 @@ class Ticket(models.Model): if not self.id: # This is a new ticket as no ID yet exists. self.created = datetime.now() + + if not self.priority: + self.priority = 3 + + self.modified = datetime.now() super(Ticket, self).save() @@ -181,6 +197,13 @@ class FollowUp(models.Model): def __unicode__(self): return '%s' % self.title + + def save(self): + t = self.ticket + t.modified = datetime.now() + t.save() + super(FollowUp, self).save() + class TicketChange(models.Model): """ For each FollowUp, any changes to the parent ticket (eg Title, Priority, etc) are tracked here for display purposes. diff --git a/scripts/get_email.py b/scripts/get_email.py index dca1f5ff..7642c2ea 100644 --- a/scripts/get_email.py +++ b/scripts/get_email.py @@ -93,6 +93,16 @@ def ticket_from_message(message, queue): except: ticket = None + priority = 3 + + smtp_priority = message.get('priority', '') + smtp_importance = message.get('importance', '') + + high_priority_types = ('high', 'important', '1', 'urgent') + + if smtp_priority in high_priority_types or smtp_importance in high_priority_types: + priority = 2 + if ticket == None: t = Ticket( title=subject, @@ -100,6 +110,7 @@ def ticket_from_message(message, queue): submitter_email=sender_email, created=now, description=body, + priority=priority, ) t.save() diff --git a/templates/helpdesk/dashboard.html b/templates/helpdesk/dashboard.html index 6dfeee68..43787db7 100644 --- a/templates/helpdesk/dashboard.html +++ b/templates/helpdesk/dashboard.html @@ -23,11 +23,11 @@ $(document).ready(function() {