Fixup forms and templates for forms

This commit is contained in:
Livvy Mackintosh
2017-10-10 00:58:36 +01:00
parent 8c38748347
commit 52090ec25a
6 changed files with 66 additions and 7 deletions

View File

@ -1,7 +1,8 @@
from django.views.generic import DetailView
from django.views.generic.base import TemplateView
from django.views.generic.edit import FormView
from django.views.generic.edit import CreateView
from django.contrib.auth.mixins import LoginRequiredMixin
from django.urls import reverse
from .models import CaseStudy
from .forms import ShortCaseStudyForm, LongCaseStudyForm
@ -14,21 +15,27 @@ class Create(LoginRequiredMixin, TemplateView):
template_name = "map/how_much_time.html"
class BaseForm(LoginRequiredMixin, FormView):
"""This is the base class for the short and long forms. It handles any shared logic between the two subclasses."""
class BaseForm(LoginRequiredMixin, CreateView):
"""View for base case study form."""
template_name = 'map/form.html'
success_url = '/'
model = CaseStudy
class ShortForm(BaseForm):
"""Here, we use the short version of the form."""
"""View for short version of case study form."""
form_class = ShortCaseStudyForm
class LongForm(BaseForm):
"""Here, we use the long version of the form."""
"""View for long version of case study form."""
form_class = LongCaseStudyForm
class FormSuccess(TemplateView):
template_name = 'map/form-success.html'
class CaseStudyDetail(DetailView):
template_name = "map/detail.html"
model = CaseStudy