Unverified Commit 0b6b5506 authored by Marco Marinello's avatar Marco Marinello
Browse files

Add unicode compatibility, strs and set closed_by to optional

parent 92e6549e
......@@ -3,8 +3,10 @@ from datetime import datetime
from django.db import models
from django.contrib.auth.models import User
from django.utils.translation import ugettext_lazy as _
from django.utils.encoding import python_2_unicode_compatible
@python_2_unicode_compatible
class Alarm(models.Model):
host = models.ForeignKey('hosts.Computer', related_name='alarms')
definition = models.ForeignKey('AlarmDefinition', related_name='alarms', blank=True)
......@@ -21,6 +23,7 @@ class Alarm(models.Model):
db_table = 'alarms'
@python_2_unicode_compatible
class AlarmDefinition(models.Model):
user = models.ForeignKey(User, related_name='alarm_definitions')
description = models.CharField(max_length=200)
......@@ -35,6 +38,7 @@ class AlarmDefinition(models.Model):
db_table = 'alarm_definition'
@python_2_unicode_compatible
class AlarmDefinitionRun(models.Model):
school = models.ForeignKey('schools.School', related_name='alarm_definition_runs')
definition = models.ForeignKey('AlarmDefinition', related_name='runs')
......@@ -47,6 +51,7 @@ class AlarmDefinitionRun(models.Model):
db_table = 'alarm_definition_run'
@python_2_unicode_compatible
class Ticket(models.Model):
opened = models.DateTimeField(null=True, blank=True)
opened_by = models.ForeignKey(User, related_name='tickets_opened')
......@@ -55,7 +60,10 @@ class Ticket(models.Model):
description = models.CharField(max_length=2000,
verbose_name=_('Problem description'))
closed = models.DateTimeField(default=None, null=True, blank=True)
closed_by = models.ForeignKey(User, related_name='tickets_closed')
closed_by = models.ForeignKey(User, related_name='tickets_closed', null=True, blank=True)
def __str__(self):
return self.ticket_for
class Meta:
db_table = 'ticket'
......@@ -76,11 +84,15 @@ class Ticket(models.Model):
return True if self.closed else False
@python_2_unicode_compatible
class TicketNote(models.Model):
ticket = models.ForeignKey('Ticket', related_name='notes', null=True, blank=True)
user = models.ForeignKey(User, related_name='ticket_notes')
timestamp = models.DateTimeField(null=True, blank=True)
content = models.CharField(max_length=2000, blank=True)
def __str__(self):
return "%s %s" %(self.ticket, _("comment"))
class Meta:
db_table = 'ticket_note'
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment