|
| 1 | +from django.db import models |
| 2 | +from ietf.idtracker.models import PersonOrOrgInfo, ChairsHistory |
| 3 | + |
| 4 | +# I don't know why the IETF database mostly stores times |
| 5 | +# as char(N) instead of TIME. Until it's important, let's |
| 6 | +# keep them as char here too. |
| 7 | + |
| 8 | +class AnnouncedFrom(models.Model): |
| 9 | + announced_from_id = models.AutoField(primary_key=True) |
| 10 | + announced_from_value = models.CharField(blank=True, maxlength=255) |
| 11 | + announced_from_email = models.CharField(blank=True, maxlength=255) |
| 12 | + def __str__(self): |
| 13 | + return self.announced_from_value |
| 14 | + class Meta: |
| 15 | + db_table = 'announced_from' |
| 16 | + class Admin: |
| 17 | + pass |
| 18 | + |
| 19 | +class AnnouncedTo(models.Model): |
| 20 | + announced_to_id = models.AutoField(primary_key=True) |
| 21 | + announced_to_value = models.CharField(blank=True, maxlength=255) |
| 22 | + announced_to_email = models.CharField(blank=True, maxlength=255) |
| 23 | + def __str__(self): |
| 24 | + return self.announced_to_value |
| 25 | + class Meta: |
| 26 | + db_table = 'announced_to' |
| 27 | + class Admin: |
| 28 | + pass |
| 29 | + |
| 30 | +class Announcement(models.Model): |
| 31 | + announcement_id = models.AutoField(primary_key=True) |
| 32 | + announced_by = models.ForeignKey(PersonOrOrgInfo, raw_id_admin=True, db_column='announced_by') |
| 33 | + announced_date = models.DateField(null=True, blank=True) |
| 34 | + announced_time = models.CharField(blank=True, maxlength=20) |
| 35 | + text = models.TextField(blank=True, db_column='announcement_text') |
| 36 | + announced_from = models.ForeignKey(AnnouncedFrom) |
| 37 | + cc = models.CharField(blank=True, maxlength=255) |
| 38 | + subject = models.CharField(blank=True, maxlength=255) |
| 39 | + extra = models.TextField(blank=True) |
| 40 | + announced_to = models.ForeignKey(AnnouncedTo) |
| 41 | + nomcom = models.BooleanField() |
| 42 | + nomcom_chair_id = models.IntegerField(null=True, blank=True) # ForeignKey to nomcom chairs |
| 43 | + manually_added = models.BooleanField(db_column='manualy_added') |
| 44 | + other_val = models.CharField(blank=True, maxlength=255) |
| 45 | + def __str__(self): |
| 46 | + return "Announcement from %s to %s on %s %s" % (self.announced_from, self.announced_to, self.announced_date, self.announced_time) |
| 47 | + def from_name(self): |
| 48 | + if self.announced_from_id == 99: |
| 49 | + return self.other_val |
| 50 | + if self.announced_from_id == 14: # sigh hardcoding |
| 51 | + return ChairsHistory.objects.all().get(id=self.nomcom_chair_id).person |
| 52 | + return self.announced_from |
| 53 | + class Meta: |
| 54 | + db_table = 'announcements' |
| 55 | + class Admin: |
| 56 | + pass |
| 57 | + |
| 58 | +class ScheduledAnnouncement(models.Model): |
| 59 | + mail_sent = models.BooleanField() |
| 60 | + to_be_sent_date = models.DateField(null=True, blank=True) |
| 61 | + to_be_sent_time = models.CharField(blank=True, maxlength=50) |
| 62 | + scheduled_by = models.CharField(blank=True, maxlength=100) |
| 63 | + scheduled_date = models.DateField(null=True, blank=True) |
| 64 | + scheduled_time = models.CharField(blank=True, maxlength=50) |
| 65 | + subject = models.CharField(blank=True, maxlength=255) |
| 66 | + to_val = models.CharField(blank=True, maxlength=255) |
| 67 | + from_val = models.CharField(blank=True, maxlength=255) |
| 68 | + cc_val = models.TextField(blank=True) |
| 69 | + body = models.TextField(blank=True) |
| 70 | + actual_sent_date = models.DateField(null=True, blank=True) |
| 71 | + actual_sent_time = models.CharField(blank=True, maxlength=50) |
| 72 | + first_q = models.IntegerField(null=True, blank=True) |
| 73 | + second_q = models.IntegerField(null=True, blank=True) |
| 74 | + note = models.TextField(blank=True) |
| 75 | + content_type = models.CharField(blank=True, maxlength=255) |
| 76 | + replyto = models.CharField(blank=True, maxlength=255) |
| 77 | + bcc_val = models.CharField(blank=True, maxlength=255) |
| 78 | + def __str__(self): |
| 79 | + 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) |
| 80 | + class Meta: |
| 81 | + db_table = 'scheduled_announcements' |
| 82 | + class Admin: |
| 83 | + pass |
0 commit comments