models.py 1.63 KB
Newer Older
1 2
from django.db import models
from django.contrib.auth.models import User
okhin's avatar
okhin committed
3 4
from ckeditor.fields import RichTextField

5
from picampaign.contact.models import Contact
6 7 8 9 10 11


class Organization(models.Model):
    id = models.AutoField(primary_key=True)
    name = models.CharField(max_length=64)
    sip_key = models.CharField(max_length=255)
12
    users = models.ManyToManyField(User, blank=True,
13
                                   related_name='organizations')
okhin's avatar
okhin committed
14
    description = RichTextField(blank=True)
15
    logo = models.ImageField(upload_to='organization/logos/', blank=True)
16
    website = models.URLField(blank=True)
17

18
    def __str__(self):
19
        return self.name
20 21


22 23 24 25 26
class GroupType(models.Model):
    id = models.AutoField(primary_key=True)
    organization = models.ForeignKey(Organization)
    name = models.CharField(max_length=64)

27
    def __str__(self):
28 29 30
        return self.name


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

okhin's avatar
okhin committed
41 42 43
    def organization(self):
        return self.type.organization

44
    def __str__(self):
45
        return self.name
46 47 48 49 50


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

53
    def __str__(self):
54
        return self.name