ojuso-map/apps/map/views.py

36 lines
1020 B
Python
Raw Normal View History

from django.views.generic import DetailView
from django.views.generic.base import TemplateView
from django.views.generic.edit import FormView
from django.contrib.auth.mixins import LoginRequiredMixin
from .models import CaseStudy
from .forms import ShortCaseStudyForm, LongCaseStudyForm
2017-06-16 16:06:22 +00:00
class Map(TemplateView):
template_name = "map/index.html"
2017-06-16 16:06:22 +00:00
class Create(LoginRequiredMixin, TemplateView):
template_name = "map/how_much_time.html"
2017-06-16 16:06:22 +00:00
class BaseForm(LoginRequiredMixin, FormView):
"""This is the base class for the short and long forms. It handles any shared logic between the two subclasses."""
template_name = 'map/form.html'
class ShortForm(BaseForm):
"""Here, we use the short version of the form."""
form_class = ShortCaseStudyForm
class LongForm(BaseForm):
"""Here, we use the long version of the form."""
form_class = LongCaseStudyForm
class CaseStudyDetail(DetailView):
template_name = "map/detail.html"
model = CaseStudy
context_object_name = "case_study"