|
1 | | -# Copyright The IETF Trust 2007, All Rights Reserved |
2 | | - |
3 | 1 | from django.db import models |
4 | | -from django.conf import settings |
5 | | -from ietf.idtracker.models import PersonOrOrgInfo, ChairsHistory |
6 | | -#from django.contrib.auth.models import Permission |
7 | | - |
8 | | -# I don't know why the IETF database mostly stores times |
9 | | -# as char(N) instead of TIME. Until it's important, let's |
10 | | -# keep them as char here too. |
11 | | - |
12 | | -# email is not used; the announced_from text is Foo Bar <foo@bar.com> |
13 | | -class AnnouncedFrom(models.Model): |
14 | | - announced_from_id = models.AutoField(primary_key=True) |
15 | | - announced_from = models.CharField(blank=True, max_length=255, db_column='announced_from_value') |
16 | | - email = models.CharField(blank=True, max_length=255, db_column='announced_from_email', editable=False) |
17 | | - #permission = models.ManyToManyField(Permission, limit_choices_to={'codename__endswith':'announcedfromperm'}, verbose_name='Permission Required', blank=True) |
18 | | - def __str__(self): |
19 | | - return self.announced_from |
20 | | - class Meta: |
21 | | - db_table = 'announced_from' |
22 | | - #permissions = ( |
23 | | - # ("ietf_chair_announcedfromperm", "Can send messages from IETF Chair"), |
24 | | - # ("iab_chair_announcedfromperm", "Can send messages from IAB Chair"), |
25 | | - # ("iad_announcedfromperm", "Can send messages from IAD"), |
26 | | - # ("ietf_execdir_announcedfromperm", "Can send messages from IETF Executive Director"), |
27 | | - # ("other_announcedfromperm", "Can send announcements from others"), |
28 | | - #) |
29 | | - |
30 | | -class AnnouncedTo(models.Model): |
31 | | - announced_to_id = models.AutoField(primary_key=True) |
32 | | - announced_to = models.CharField(blank=True, max_length=255, db_column='announced_to_value') |
33 | | - email = models.CharField(blank=True, max_length=255, db_column='announced_to_email') |
34 | | - def __str__(self): |
35 | | - return self.announced_to |
36 | | - class Meta: |
37 | | - db_table = 'announced_to' |
38 | | - |
39 | | -class Announcement(models.Model): |
40 | | - announcement_id = models.AutoField(primary_key=True) |
41 | | - announced_by = models.ForeignKey(PersonOrOrgInfo, db_column='announced_by') |
42 | | - announced_date = models.DateField(null=True, blank=True) |
43 | | - announced_time = models.CharField(blank=True, max_length=20) |
44 | | - text = models.TextField(blank=True, db_column='announcement_text') |
45 | | - announced_from = models.ForeignKey(AnnouncedFrom) |
46 | | - cc = models.CharField(blank=True, null=True, max_length=255) |
47 | | - subject = models.CharField(blank=True, max_length=255) |
48 | | - extra = models.TextField(blank=True,null=True) |
49 | | - announced_to = models.ForeignKey(AnnouncedTo) |
50 | | - nomcom = models.NullBooleanField() |
51 | | - nomcom_chair = models.ForeignKey(ChairsHistory, null=True, blank=True) |
52 | | - manually_added = models.BooleanField(db_column='manualy_added') |
53 | | - other_val = models.CharField(blank=True, null=True, max_length=255) |
54 | | - def __str__(self): |
55 | | - return "Announcement from %s to %s on %s %s" % (self.announced_from, self.announced_to, self.announced_date, self.announced_time) |
56 | | - def from_name(self): |
57 | | - if self.announced_from_id == 99: |
58 | | - return self.other_val |
59 | | - if self.announced_from_id == 18: # sigh hardcoding |
60 | | - return self.nomcom_chair.person |
61 | | - return self.announced_from |
62 | | - class Meta: |
63 | | - db_table = 'announcements' |
64 | | - |
65 | | -class ScheduledAnnouncement(models.Model): |
66 | | - mail_sent = models.BooleanField() |
67 | | - to_be_sent_date = models.DateField(null=True, blank=True) |
68 | | - to_be_sent_time = models.CharField(blank=True, null=True, max_length=50) |
69 | | - scheduled_by = models.CharField(blank=True, max_length=100) |
70 | | - scheduled_date = models.DateField(null=True, blank=True) |
71 | | - scheduled_time = models.CharField(blank=True, max_length=50) |
72 | | - subject = models.CharField(blank=True, max_length=255) |
73 | | - to_val = models.CharField(blank=True, max_length=255) |
74 | | - from_val = models.CharField(blank=True, max_length=255) |
75 | | - cc_val = models.TextField(blank=True,null=True) |
76 | | - body = models.TextField(blank=True) |
77 | | - actual_sent_date = models.DateField(null=True, blank=True) |
78 | | - actual_sent_time = models.CharField(blank=True, max_length=50) # should be time, but database contains oddities |
79 | | - first_q = models.IntegerField(null=True, blank=True) |
80 | | - second_q = models.IntegerField(null=True, blank=True) |
81 | | - note = models.TextField(blank=True,null=True) |
82 | | - content_type = models.CharField(blank=True, max_length=255) |
83 | | - replyto = models.CharField(blank=True, null=True, max_length=255) |
84 | | - bcc_val = models.CharField(blank=True, null=True, max_length=255) |
85 | | - def __str__(self): |
86 | | - return "Scheduled Announcement from %s to %s on %s %s" % (self.from_val, self.to_val, self.to_be_sent_date, self.to_be_sent_time) |
87 | | - class Meta: |
88 | | - db_table = 'scheduled_announcements' |
0 commit comments