no functional changes
Formatting updated to pep8
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
from ckeditor_uploader.widgets import CKEditorUploadingWidget
|
||||
from ckeditor_uploader.widgets import CKEditorUploadingWidget
|
||||
from django import forms
|
||||
|
||||
from .models import Post, Event, News, FetMeeting
|
||||
@@ -8,49 +8,52 @@ class MyPostForm(forms.ModelForm):
|
||||
class Meta:
|
||||
model = Post
|
||||
fields = ['title', 'subtitle', 'tags', 'image', 'body', 'slug', 'author']
|
||||
|
||||
|
||||
widgets = {'body': CKEditorUploadingWidget(config_name='default')}
|
||||
|
||||
class Media:
|
||||
js = (
|
||||
'js/auto_slug.js', # automatic slag completion via ajax
|
||||
'js/tag_completion.js', # to get a list for tag autocompletion via ajax
|
||||
'js/auto_slug.js', # automatic slag completion via ajax
|
||||
'js/tag_completion.js', # to get a list for tag autocompletion via ajax
|
||||
)
|
||||
|
||||
|
||||
class MyNewsForm(MyPostForm):
|
||||
class Meta:
|
||||
model = News
|
||||
fields = ['title', 'subtitle', 'tags', 'image', 'body', 'slug', 'author']
|
||||
|
||||
|
||||
widgets = {'body': CKEditorUploadingWidget(config_name='default')}
|
||||
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super().__init__(*args, **kwargs) # to get the self.fields set
|
||||
super().__init__(*args, **kwargs) # to get the self.fields set
|
||||
|
||||
|
||||
class MyEventForm(MyPostForm):
|
||||
class Meta:
|
||||
model = Event
|
||||
fields = ['title', 'subtitle', 'tags', 'image', 'body',
|
||||
'event_start', 'event_end', 'event_place', 'slug', 'author']
|
||||
|
||||
|
||||
widgets = {'body': CKEditorUploadingWidget(config_name='default')}
|
||||
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super().__init__(*args, **kwargs) # to get the self.fields set
|
||||
super().__init__(*args, **kwargs) # to get the self.fields set
|
||||
|
||||
self.fields['event_start'].required = True
|
||||
self.fields['event_end'].required = True
|
||||
|
||||
|
||||
if 'event_place' in self.fields:
|
||||
self.fields['event_place'].required = True
|
||||
|
||||
|
||||
class MyFetMeetingForm(MyEventForm):
|
||||
class Meta:
|
||||
model = FetMeeting
|
||||
fields = ['event_start', 'event_end', 'tags']
|
||||
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super().__init__(*args, **kwargs) # to get the self.fields set
|
||||
super().__init__(*args, **kwargs) # to get the self.fields set
|
||||
|
||||
self.fields['event_start'].required = True
|
||||
self.fields['event_end'].required = False
|
||||
self.fields['event_end'].required = False
|
||||
|
||||
Reference in New Issue
Block a user