mirror of
https://github.com/postgres/pgweb.git
synced 2025-08-01 15:54:53 +00:00

We were already using signals for everything except delete, and even in our old version of django the delete signal exists (it didn't exist when this code was first written). Django doesn't really like models to be OOP like this, so keeping PgModel would cause issues with upcoming changes in django 1.8. Using simple functions is easier, and the actual functionality is replicated straight off.
35 lines
1.2 KiB
Python
35 lines
1.2 KiB
Python
from django.db import models
|
|
from datetime import date
|
|
from pgweb.core.models import Organisation
|
|
|
|
class NewsArticle(models.Model):
|
|
org = models.ForeignKey(Organisation, null=False, blank=False, verbose_name="Organisation", help_text="If no organisations are listed, please check the <a href=\"/account/orglist/\">organisation list</a> and contact the organisation manager or webmaster@postgresql.org if none are listed.")
|
|
approved = models.BooleanField(null=False, blank=False, default=False)
|
|
date = models.DateField(null=False, blank=False, default=date.today)
|
|
title = models.CharField(max_length=200, null=False, blank=False)
|
|
content = models.TextField(null=False, blank=False)
|
|
|
|
send_notification = True
|
|
markdown_fields = ('content',)
|
|
|
|
def purge_urls(self):
|
|
yield '/about/news/%s/' % self.pk
|
|
yield '/about/newsarchive/'
|
|
yield '/news.rss'
|
|
# FIXME: when to expire the front page?
|
|
yield '/$'
|
|
|
|
def __unicode__(self):
|
|
return "%s: %s" % (self.date, self.title)
|
|
|
|
def verify_submitter(self, user):
|
|
return (len(self.org.managers.filter(pk=user.pk)) == 1)
|
|
|
|
def is_migrated(self):
|
|
if self.org.pk == 0:
|
|
return True
|
|
return False
|
|
|
|
class Meta:
|
|
ordering = ('-date',)
|