mirror of
https://github.com/postgres/pgweb.git
synced 2025-08-10 00:42:06 +00:00

Once a twitter account has been registered (using the twitter_register management command), the twitter_post command wills start posting all new news to twitter, once they are approved. It will only post news from the past 7 days to avoid accidentally flooding with old news.
21 lines
741 B
Python
21 lines
741 B
Python
from django import forms
|
|
from django.forms import ValidationError
|
|
|
|
from pgweb.core.models import Organisation
|
|
from models import NewsArticle
|
|
|
|
class NewsArticleForm(forms.ModelForm):
|
|
def __init__(self, *args, **kwargs):
|
|
super(NewsArticleForm, self).__init__(*args, **kwargs)
|
|
def filter_by_user(self, user):
|
|
self.fields['org'].queryset = Organisation.objects.filter(managers=user, approved=True)
|
|
def clean_date(self):
|
|
if self.instance.pk and self.instance.approved:
|
|
if self.cleaned_data['date'] != self.instance.date:
|
|
raise ValidationError("You cannot change the date on an article that has been approved")
|
|
return self.cleaned_data['date']
|
|
|
|
class Meta:
|
|
model = NewsArticle
|
|
exclude = ('submitter', 'approved', 'tweeted')
|