Remove references to old announcement models and remove the model definitions
- Legacy-Id: 6767
This commit is contained in:
parent
2cf72aa9e5
commit
35939cc20c
|
@ -1,88 +1 @@
|
|||
# Copyright The IETF Trust 2007, All Rights Reserved
|
||||
|
||||
from django.db import models
|
||||
from django.conf import settings
|
||||
from ietf.idtracker.models import PersonOrOrgInfo, ChairsHistory
|
||||
#from django.contrib.auth.models import Permission
|
||||
|
||||
# I don't know why the IETF database mostly stores times
|
||||
# as char(N) instead of TIME. Until it's important, let's
|
||||
# keep them as char here too.
|
||||
|
||||
# email is not used; the announced_from text is Foo Bar <foo@bar.com>
|
||||
class AnnouncedFrom(models.Model):
|
||||
announced_from_id = models.AutoField(primary_key=True)
|
||||
announced_from = models.CharField(blank=True, max_length=255, db_column='announced_from_value')
|
||||
email = models.CharField(blank=True, max_length=255, db_column='announced_from_email', editable=False)
|
||||
#permission = models.ManyToManyField(Permission, limit_choices_to={'codename__endswith':'announcedfromperm'}, verbose_name='Permission Required', blank=True)
|
||||
def __str__(self):
|
||||
return self.announced_from
|
||||
class Meta:
|
||||
db_table = 'announced_from'
|
||||
#permissions = (
|
||||
# ("ietf_chair_announcedfromperm", "Can send messages from IETF Chair"),
|
||||
# ("iab_chair_announcedfromperm", "Can send messages from IAB Chair"),
|
||||
# ("iad_announcedfromperm", "Can send messages from IAD"),
|
||||
# ("ietf_execdir_announcedfromperm", "Can send messages from IETF Executive Director"),
|
||||
# ("other_announcedfromperm", "Can send announcements from others"),
|
||||
#)
|
||||
|
||||
class AnnouncedTo(models.Model):
|
||||
announced_to_id = models.AutoField(primary_key=True)
|
||||
announced_to = models.CharField(blank=True, max_length=255, db_column='announced_to_value')
|
||||
email = models.CharField(blank=True, max_length=255, db_column='announced_to_email')
|
||||
def __str__(self):
|
||||
return self.announced_to
|
||||
class Meta:
|
||||
db_table = 'announced_to'
|
||||
|
||||
class Announcement(models.Model):
|
||||
announcement_id = models.AutoField(primary_key=True)
|
||||
announced_by = models.ForeignKey(PersonOrOrgInfo, db_column='announced_by')
|
||||
announced_date = models.DateField(null=True, blank=True)
|
||||
announced_time = models.CharField(blank=True, max_length=20)
|
||||
text = models.TextField(blank=True, db_column='announcement_text')
|
||||
announced_from = models.ForeignKey(AnnouncedFrom)
|
||||
cc = models.CharField(blank=True, null=True, max_length=255)
|
||||
subject = models.CharField(blank=True, max_length=255)
|
||||
extra = models.TextField(blank=True,null=True)
|
||||
announced_to = models.ForeignKey(AnnouncedTo)
|
||||
nomcom = models.NullBooleanField()
|
||||
nomcom_chair = models.ForeignKey(ChairsHistory, null=True, blank=True)
|
||||
manually_added = models.BooleanField(db_column='manualy_added')
|
||||
other_val = models.CharField(blank=True, null=True, max_length=255)
|
||||
def __str__(self):
|
||||
return "Announcement from %s to %s on %s %s" % (self.announced_from, self.announced_to, self.announced_date, self.announced_time)
|
||||
def from_name(self):
|
||||
if self.announced_from_id == 99:
|
||||
return self.other_val
|
||||
if self.announced_from_id == 18: # sigh hardcoding
|
||||
return self.nomcom_chair.person
|
||||
return self.announced_from
|
||||
class Meta:
|
||||
db_table = 'announcements'
|
||||
|
||||
class ScheduledAnnouncement(models.Model):
|
||||
mail_sent = models.BooleanField()
|
||||
to_be_sent_date = models.DateField(null=True, blank=True)
|
||||
to_be_sent_time = models.CharField(blank=True, null=True, max_length=50)
|
||||
scheduled_by = models.CharField(blank=True, max_length=100)
|
||||
scheduled_date = models.DateField(null=True, blank=True)
|
||||
scheduled_time = models.CharField(blank=True, max_length=50)
|
||||
subject = models.CharField(blank=True, max_length=255)
|
||||
to_val = models.CharField(blank=True, max_length=255)
|
||||
from_val = models.CharField(blank=True, max_length=255)
|
||||
cc_val = models.TextField(blank=True,null=True)
|
||||
body = models.TextField(blank=True)
|
||||
actual_sent_date = models.DateField(null=True, blank=True)
|
||||
actual_sent_time = models.CharField(blank=True, max_length=50) # should be time, but database contains oddities
|
||||
first_q = models.IntegerField(null=True, blank=True)
|
||||
second_q = models.IntegerField(null=True, blank=True)
|
||||
note = models.TextField(blank=True,null=True)
|
||||
content_type = models.CharField(blank=True, max_length=255)
|
||||
replyto = models.CharField(blank=True, null=True, max_length=255)
|
||||
bcc_val = models.CharField(blank=True, null=True, max_length=255)
|
||||
def __str__(self):
|
||||
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)
|
||||
class Meta:
|
||||
db_table = 'scheduled_announcements'
|
||||
|
|
|
@ -2,15 +2,12 @@
|
|||
|
||||
from django.conf import settings
|
||||
from django.contrib.sitemaps import Sitemap
|
||||
from ietf.announcements.models import Announcement
|
||||
from ietf.message.models import Message
|
||||
|
||||
class NOMCOMAnnouncementsMap(Sitemap):
|
||||
changefreq = "never"
|
||||
def items(self):
|
||||
if settings.USE_DB_REDESIGN_PROXY_CLASSES:
|
||||
return Message.objects.filter(related_groups__acronym__startswith="nomcom").exclude(related_groups__acronym="nomcom").order_by('-time')
|
||||
return Announcement.objects.all().filter(nomcom=True)
|
||||
return Message.objects.filter(related_groups__acronym__startswith="nomcom").exclude(related_groups__acronym="nomcom").order_by('-time')
|
||||
def location(self, obj):
|
||||
return "/ann/nomcom/%d/" % obj.id
|
||||
def lastmod(self, obj):
|
||||
|
|
|
@ -7,8 +7,6 @@ from ietf.utils.test_data import make_test_data
|
|||
from ietf.utils.mail import outbox
|
||||
from ietf.utils import TestCase
|
||||
|
||||
from ietf.announcements.models import ScheduledAnnouncement
|
||||
|
||||
from ietf.message.models import Message, SendQueue
|
||||
from ietf.person.models import Person
|
||||
|
||||
|
@ -22,54 +20,6 @@ class AnnouncementsUrlTestCase(SimpleUrlTestCase):
|
|||
return content
|
||||
|
||||
class SendScheduledAnnouncementsTestCase(TestCase):
|
||||
def test_send_plain_announcement(self):
|
||||
a = ScheduledAnnouncement.objects.create(
|
||||
mail_sent=False,
|
||||
subject="This is a test",
|
||||
to_val="test@example.com",
|
||||
from_val="testmonkey@example.com",
|
||||
cc_val="cc.a@example.com, cc.b@example.com",
|
||||
bcc_val="bcc@example.com",
|
||||
body="Hello World!",
|
||||
content_type="",
|
||||
)
|
||||
|
||||
mailbox_before = len(outbox)
|
||||
|
||||
from ietf.announcements.send_scheduled import send_scheduled_announcement
|
||||
send_scheduled_announcement(a)
|
||||
|
||||
self.assertEquals(len(outbox), mailbox_before + 1)
|
||||
self.assertTrue("This is a test" in outbox[-1]["Subject"])
|
||||
self.assertTrue(ScheduledAnnouncement.objects.get(id=a.id).mail_sent)
|
||||
|
||||
def test_send_mime_announcement(self):
|
||||
a = ScheduledAnnouncement.objects.create(
|
||||
mail_sent=False,
|
||||
subject="This is a test",
|
||||
to_val="test@example.com",
|
||||
from_val="testmonkey@example.com",
|
||||
cc_val="cc.a@example.com, cc.b@example.com",
|
||||
bcc_val="bcc@example.com",
|
||||
body='--NextPart\r\n\r\nA New Internet-Draft is available from the on-line Internet-Drafts directories.\r\n--NextPart\r\nContent-Type: Message/External-body;\r\n\tname="draft-huang-behave-bih-01.txt";\r\n\tsite="ftp.ietf.org";\r\n\taccess-type="anon-ftp";\r\n\tdirectory="internet-drafts"\r\n\r\nContent-Type: text/plain\r\nContent-ID: <2010-07-30001541.I-D@ietf.org>\r\n\r\n--NextPart--',
|
||||
content_type='Multipart/Mixed; Boundary="NextPart"',
|
||||
)
|
||||
|
||||
mailbox_before = len(outbox)
|
||||
|
||||
from ietf.announcements.send_scheduled import send_scheduled_announcement
|
||||
send_scheduled_announcement(a)
|
||||
|
||||
self.assertEquals(len(outbox), mailbox_before + 1)
|
||||
self.assertTrue("This is a test" in outbox[-1]["Subject"])
|
||||
self.assertTrue("--NextPart" in outbox[-1].as_string())
|
||||
self.assertTrue(ScheduledAnnouncement.objects.get(id=a.id).mail_sent)
|
||||
|
||||
|
||||
class SendScheduledAnnouncementsTestCaseREDESIGN(TestCase):
|
||||
# See ietf.utils.test_utils.TestCase for the use of perma_fixtures vs. fixtures
|
||||
perma_fixtures = ["names"]
|
||||
|
||||
def test_send_plain_announcement(self):
|
||||
make_test_data()
|
||||
|
||||
|
@ -128,6 +78,3 @@ class SendScheduledAnnouncementsTestCaseREDESIGN(TestCase):
|
|||
self.assertTrue("This is a test" in outbox[-1]["Subject"])
|
||||
self.assertTrue("--NextPart" in outbox[-1].as_string())
|
||||
self.assertTrue(SendQueue.objects.get(id=q.id).sent_at)
|
||||
|
||||
if settings.USE_DB_REDESIGN_PROXY_CLASSES:
|
||||
SendScheduledAnnouncementsTestCase = SendScheduledAnnouncementsTestCaseREDESIGN
|
||||
|
|
|
@ -1,16 +1,10 @@
|
|||
# Copyright The IETF Trust 2007, All Rights Reserved
|
||||
|
||||
from django.conf.urls.defaults import patterns
|
||||
from ietf.announcements.models import Announcement
|
||||
|
||||
from django.conf import settings
|
||||
|
||||
nomcom_dict = {
|
||||
'queryset': Announcement.objects.all().filter(nomcom=True)
|
||||
}
|
||||
|
||||
urlpatterns = patterns('',
|
||||
# (r'^nomcom/$', 'django.views.generic.simple.redirect_to', {'url': 'http://www.ietf.org/nomcom/index.html'} ),
|
||||
(r'^nomcom/$', 'ietf.announcements.views.nomcom'),
|
||||
(r'^nomcom/(?P<object_id>\d+)/$', 'ietf.announcements.views.message_detail') if settings.USE_DB_REDESIGN_PROXY_CLASSES else (r'^nomcom/(?P<object_id>\d+)/$', 'django.views.generic.list_detail.object_detail', nomcom_dict)
|
||||
(r'^nomcom/(?P<object_id>\d+)/$', 'ietf.announcements.views.message_detail'))
|
||||
)
|
||||
|
|
|
@ -1,42 +1,18 @@
|
|||
# Copyright The IETF Trust 2007, All Rights Reserved
|
||||
|
||||
import re
|
||||
|
||||
from django.views.generic.simple import direct_to_template
|
||||
from django.shortcuts import get_object_or_404
|
||||
from django.conf import settings
|
||||
from django.db.models import Q
|
||||
|
||||
import re
|
||||
|
||||
from ietf.idtracker.models import ChairsHistory
|
||||
from ietf.idtracker.models import Role
|
||||
from ietf.announcements.models import Announcement
|
||||
from ietf.group.models import Group, GroupEvent
|
||||
from ietf.message.models import Message
|
||||
|
||||
def nomcom(request):
|
||||
curr_chair = (ChairsHistory.objects.
|
||||
get(chair_type=Role.NOMCOM_CHAIR, present_chair='1'))
|
||||
|
||||
all_chairs = (ChairsHistory.objects.all().
|
||||
filter(chair_type='3',start_year__gt = 2003).
|
||||
order_by('-start_year'))
|
||||
|
||||
nomcom_announcements = Announcement.objects.all().filter(nomcom=1)
|
||||
|
||||
regimes = []
|
||||
|
||||
for chair in all_chairs:
|
||||
chair_announcements = (nomcom_announcements.filter(nomcom_chair=chair).
|
||||
order_by('-announced_date','-announced_time'))
|
||||
regimes = regimes + [{'chair': chair,
|
||||
'announcements' : chair_announcements }]
|
||||
|
||||
return direct_to_template(request,
|
||||
"announcements/nomcom.html",
|
||||
{ 'curr_chair' : curr_chair,
|
||||
'regimes' : regimes })
|
||||
|
||||
def nomcomREDESIGN(request):
|
||||
address_re = re.compile("<.*>")
|
||||
|
||||
nomcoms = list(Group.objects.filter(acronym__startswith="nomcom").exclude(name="nomcom"))
|
||||
|
@ -69,11 +45,6 @@ def nomcomREDESIGN(request):
|
|||
"announcements/nomcomREDESIGN.html",
|
||||
{ 'curr_chair' : regimes[0]["chair"],
|
||||
'regimes' : regimes })
|
||||
|
||||
|
||||
if settings.USE_DB_REDESIGN_PROXY_CLASSES:
|
||||
nomcom = nomcomREDESIGN
|
||||
|
||||
|
||||
def message_detail(request, object_id):
|
||||
# restrict to nomcom announcements for the time being
|
||||
|
|
|
@ -10,7 +10,6 @@ management.setup_environ(settings)
|
|||
syslog.openlog(os.path.basename(__file__), syslog.LOG_PID, syslog.LOG_USER)
|
||||
|
||||
|
||||
from ietf.announcements.models import ScheduledAnnouncement
|
||||
from ietf.announcements.send_scheduled import *
|
||||
from django.db.models import Q
|
||||
|
||||
|
@ -25,27 +24,15 @@ mode = sys.argv[1]
|
|||
|
||||
now = datetime.datetime.now()
|
||||
|
||||
if settings.USE_DB_REDESIGN_PROXY_CLASSES:
|
||||
from ietf.announcements.models import SendQueue
|
||||
announcements = SendQueue.objects.filter(sent_at=None)
|
||||
if mode == "rsync":
|
||||
announcements = announcements.filter(send_at=None)
|
||||
elif mode == "specific":
|
||||
announcements = announcements.exclude(send_at=None).filter(send_at__lte=now)
|
||||
else:
|
||||
announcements = ScheduledAnnouncement.objects.filter(mail_sent=False)
|
||||
if mode == "rsync":
|
||||
# include bogus 0000-00-00 entries
|
||||
announcements = announcements.filter(Q(to_be_sent_date=None) | Q(to_be_sent_date__lte=datetime.date.min))
|
||||
elif mode == "specific":
|
||||
# exclude null/bogus entries
|
||||
announcements = announcements.exclude(Q(to_be_sent_date=None) | Q(to_be_sent_date__lte=datetime.date.min))
|
||||
from ietf.message.models import SendQueue
|
||||
needs_sending = SendQueue.objects.filter(sent_at=None).select_related("message")
|
||||
if mode == "rsync":
|
||||
needs_sending = needs_sending.filter(send_at=None)
|
||||
elif mode == "specific":
|
||||
needs_sending = needs_sending.exclude(send_at=None).filter(send_at__lte=now)
|
||||
|
||||
announcements = announcements.filter(to_be_sent_date__lte=now.date(),
|
||||
to_be_sent_time__lte=now.time())
|
||||
|
||||
for announcement in announcements:
|
||||
send_scheduled_announcement(announcement)
|
||||
for s in needs_sending:
|
||||
send_scheduled_announcement(s)
|
||||
|
||||
subject = announcement.message.subject if settings.USE_DB_REDESIGN_PROXY_CLASSES else announcement.subject
|
||||
syslog.syslog(u'Sent scheduled announcement %s "%s"' % (announcement.id, subject))
|
||||
subject = s.message.subject
|
||||
syslog.syslog(u'Sent scheduled announcement %s "%s"' % (s.id, subject))
|
||||
|
|
|
@ -135,7 +135,6 @@ def get_to_choices():
|
|||
# ---------------------------------------------
|
||||
# Select Choices
|
||||
# ---------------------------------------------
|
||||
#TO_CHOICES = tuple(AnnouncedTo.objects.values_list('announced_to_id','announced_to'))
|
||||
TO_CHOICES = get_to_choices()
|
||||
#FROM_CHOICES = get_from_choices()
|
||||
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
from django.db import models
|
||||
from ietf.announcements.models import AnnouncedTo
|
||||
#from ietf.message.models import Message
|
||||
from ietf.group.models import Group, Role
|
||||
|
|
Loading…
Reference in a new issue