Fixup forms and templates for forms
This commit is contained in:
@ -1,4 +1,5 @@
|
||||
from django import forms
|
||||
from django.urls import reverse
|
||||
from crispy_forms.helper import FormHelper
|
||||
from crispy_forms.layout import Submit
|
||||
from leaflet.forms.widgets import LeafletWidget
|
||||
@ -7,7 +8,7 @@ from .models import CaseStudy
|
||||
|
||||
|
||||
class BaseCaseStudyForm(forms.ModelForm):
|
||||
|
||||
"""Base form class for the CaseStudy model."""
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(BaseCaseStudyForm, self).__init__(*args, **kwargs)
|
||||
self.helper = FormHelper()
|
||||
@ -26,6 +27,12 @@ class BaseCaseStudyForm(forms.ModelForm):
|
||||
|
||||
|
||||
class ShortCaseStudyForm(BaseCaseStudyForm):
|
||||
"""Short version of the CaseStudy form."""
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(ShortCaseStudyForm, self).__init__(*args, **kwargs)
|
||||
self.helper.form_action = reverse('short-form')
|
||||
|
||||
class Meta(BaseCaseStudyForm.Meta):
|
||||
fields = [
|
||||
'entry_name',
|
||||
@ -50,5 +57,10 @@ class ShortCaseStudyForm(BaseCaseStudyForm):
|
||||
|
||||
|
||||
class LongCaseStudyForm(BaseCaseStudyForm):
|
||||
"""Long version of the CaseStudy form."""
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(LongCaseStudyForm, self).__init__(*args, **kwargs)
|
||||
self.helper.form_action = reverse('long-form')
|
||||
|
||||
class Meta(BaseCaseStudyForm.Meta):
|
||||
fields = '__all__'
|
||||
|
Reference in New Issue
Block a user