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

Clean up the whitespace in the primary Python / HTML files in order to make it easier to apply changes going forward.
21 lines
732 B
Python
21 lines
732 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', )
|