coding utf-8 from django db import models from service managers import

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# -*- coding: utf-8
from django.db import models
from service.managers import CheckRecords
from django.contrib.auth.models import User
import datetime
class AlertDate(models.Model):
name = models.CharField(max_length=30)
days = models.IntegerField()
def __unicode__(self):
return self.name
class Group(models.Model):
name = models.CharField(max_length=30)
user = models.ManyToManyField(User)
def __unicode__(self):
return self.name
class Service(models.Model):
name = models.CharField(max_length=50)
def __unicode__(self):
return self.name
class Client(models.Model):
name = models.CharField(max_length=50)
def __unicode__(self):
return self.name
class Meta:
ordering = ['name']
class Record(models.Model):
service = models.ForeignKey(Service)
client = models.ForeignKey(Client)
description = models.TextField(blank=True)
information = models.TextField(blank=True)
start_date = models.DateField()
end_date = models.DateField()
alert_group = models.ManyToManyField(Group)
alert = models.ForeignKey(AlertDate)
objects = models.Manager()
check = CheckRecords()
def will_expire(self):
_expirein = self.end_date - datetime.date.today()
return _expirein.days
def __unicode__(self):
return self.description