mirror of
https://github.com/ae-utbm/sith.git
synced 2025-07-11 04:19:25 +00:00
Refactor page view with Django's black magic powered DetailView&co
This commit is contained in:
@ -56,42 +56,3 @@ class UserEditForm(UserChangeForm):
|
||||
"""We never handle password in this form"""
|
||||
return
|
||||
|
||||
|
||||
class PagePropForm(forms.ModelForm):
|
||||
error_css_class = 'error'
|
||||
required_css_class = 'required'
|
||||
parent = forms.ModelChoiceField(queryset=Page.objects.all())
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(PagePropForm, self).__init__(*args, **kwargs)
|
||||
self.fields['parent'].required = False
|
||||
|
||||
class Meta:
|
||||
model = Page
|
||||
fields = ['parent', 'name', 'owner_group', 'edit_group', 'view_group']
|
||||
|
||||
def save(self, commit=True):
|
||||
page = super(PagePropForm, self).save(commit=False)
|
||||
if commit:
|
||||
page.save()
|
||||
return page
|
||||
|
||||
|
||||
class PageEditForm(forms.ModelForm):
|
||||
error_css_class = 'error'
|
||||
required_css_class = 'required'
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(PageEditForm, self).__init__(*args, **kwargs)
|
||||
|
||||
class Meta:
|
||||
model = Page
|
||||
fields = ['title', 'content', ]
|
||||
|
||||
def save(self, commit=True):
|
||||
page = super(PageEditForm, self).save(commit=False)
|
||||
if commit:
|
||||
page.save()
|
||||
return page
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user