|
|
|
@ -90,8 +90,11 @@ class BlogForm(forms.Form): |
|
|
|
|
|
|
|
|
|
|
|
class NewsForm(BlogForm): |
|
|
|
class NewsForm(BlogForm): |
|
|
|
type = Article.news |
|
|
|
type = Article.news |
|
|
|
exposition = forms.ModelChoiceField(label = u'Выставка', required=False, queryset=Exposition.objects.all()) |
|
|
|
exposition = forms.CharField(label=u'Выставка', widget=forms.HiddenInput(), required=False) |
|
|
|
conference = forms.ModelChoiceField(label = u'Конференция', required=False, queryset=Conference.objects.all()) |
|
|
|
conference = forms.CharField(label=u'Конференция', widget=forms.HiddenInput(), required=False) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#exposition = forms.ModelChoiceField(label = u'Выставка', required=False, queryset=Exposition.objects.all()) |
|
|
|
|
|
|
|
#conference = forms.ModelChoiceField(label = u'Конференция', required=False, queryset=Conference.objects.all()) |
|
|
|
|
|
|
|
|
|
|
|
def save(self, author, article=None): |
|
|
|
def save(self, author, article=None): |
|
|
|
article = super(NewsForm, self).save(author, article) |
|
|
|
article = super(NewsForm, self).save(author, article) |
|
|
|
@ -102,6 +105,24 @@ class NewsForm(BlogForm): |
|
|
|
article.save() |
|
|
|
article.save() |
|
|
|
return article |
|
|
|
return article |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def clean_exposition(self): |
|
|
|
|
|
|
|
id = self.cleaned_data['exposition'] |
|
|
|
|
|
|
|
if not id: |
|
|
|
|
|
|
|
return None |
|
|
|
|
|
|
|
try: |
|
|
|
|
|
|
|
return Exposition.objects.get(id=id) |
|
|
|
|
|
|
|
except Exposition.DoesNotExist: |
|
|
|
|
|
|
|
return None |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def clean_conference(self): |
|
|
|
|
|
|
|
id = self.cleaned_data['conference'] |
|
|
|
|
|
|
|
if not id: |
|
|
|
|
|
|
|
return None |
|
|
|
|
|
|
|
try: |
|
|
|
|
|
|
|
return Conference.objects.get(id=id) |
|
|
|
|
|
|
|
except Conference.DoesNotExist: |
|
|
|
|
|
|
|
return None |
|
|
|
|
|
|
|
|
|
|
|
class ArticleForm(forms.Form): |
|
|
|
class ArticleForm(forms.Form): |
|
|
|
""" |
|
|
|
""" |
|
|
|
Create Article form for creating conference |
|
|
|
Create Article form for creating conference |
|
|
|
|