models.py 1.49 KB
Newer Older
1 2
from django.db import models
from django.contrib.auth.models import User
3
from picampaign.contact.models import Contact
4 5 6 7 8 9


class Organization(models.Model):
    id = models.AutoField(primary_key=True)
    name = models.CharField(max_length=64)
    sip_key = models.CharField(max_length=255)
10
    users = models.ManyToManyField(User, blank=True,
11
                                   related_name='organizations')
12 13
    description = models.TextField(blank=True)
    logo = models.ImageField(upload_to='organization/logos/', blank=True)
14

15
    def __str__(self):
16
        return self.name
17 18


19 20 21 22 23
class GroupType(models.Model):
    id = models.AutoField(primary_key=True)
    organization = models.ForeignKey(Organization)
    name = models.CharField(max_length=64)

24
    def __str__(self):
25 26 27
        return self.name


28 29 30
class Group(models.Model):
    """Group model to qualify contacts"""
    id = models.AutoField(primary_key=True)
31
    #organization = models.ForeignKey(Organization)
32
    name = models.CharField(max_length=64)
33
    type = models.ForeignKey(GroupType, blank=True, null=True)
34
    media = models.CharField(max_length=255, blank=True)
35
    contacts = models.ManyToManyField(Contact, blank=True,
36
                                      related_name='groups')
37

38
    def __str__(self):
39
        return self.name
40 41 42 43 44


class FeedbackCategory(models.Model):
    id = models.AutoField(primary_key=True)
    name = models.CharField(max_length=64)
45
    organization = models.ForeignKey(Organization)
46

47
    def __str__(self):
48
        return self.name