Rename view classes to have more descriptive names

This commit is contained in:
Anna Sidwell 2019-03-04 19:57:47 +00:00
parent c41141fea6
commit 07f9bed096
2 changed files with 16 additions and 15 deletions

View File

@ -9,17 +9,19 @@ from . import views
urlpatterns = [
url(r'^$', RedirectView.as_view(url=reverse_lazy('map')), name='index'),
url(r'^case-study/create/?$', views.Create.as_view(), name="create"),
url(r'^case-study/create/short/?$', views.ShortForm.as_view(), name='short-form'),
url(r'^case-study/create/long/?$', views.LongForm.as_view(), name='long-form'),
url(r'^case-study/create/poi/?$', views.PointOfInterest.as_view(), name='point-of-interest-form'),
url(r'^case-study/create/success/?$', views.FormSuccess.as_view(), name='form-success'),
url(r'^case-study/draft/?$', views.Drafts.as_view(), name='drafts'),
url(r'^case-study/(?P<slug>[-\w]+)/?$', views.CaseStudyDetail.as_view(), name='detail'),
url(r'^case-study/create/?$', views.CreateCaseStudySelector.as_view(), name="create"),
url(r'^case-study/create/short/?$', views.CreateShortCaseStudy.as_view(), name='short-form'),
url(r'^case-study/create/long/?$', views.CreateLongCaseStudy.as_view(), name='long-form'),
url(r'^case-study/create/poi/?$', views.CreatePointOfInterest.as_view(), name='point-of-interest-form'),
url(r'^case-study/create/success/?$', views.CreateCaseStudySuccess.as_view(), name='form-success'),
url(r'^case-study/edit/(?P<pk>[\d]+)/?$', views.EditCaseStudy.as_view(), name='edit'),
# View case studies
url(r'^case-study/(?P<slug>[-\w]+)/?$', views.ViewCaseStudyDetail.as_view(), name='detail'),
url(r'^map/?$', views.Map.as_view(), name='map'),
# API
url(r'^case-study/draft/?$', views.DraftsAPI.as_view(), name='drafts'),
url(r'^jsi18n/$', JavaScriptCatalog.as_view(), name='javascript-catalogue'),
url(r'^srs-autocomplete/$', views.SpatialRefSysAutocomplete.as_view(), name='srs-autocomplete'),
]

View File

@ -36,11 +36,11 @@ class Map(TemplateView):
template_name = "map/index.html"
class Create(LoginRequiredMixin, TemplateView):
class CreateCaseStudySelector(LoginRequiredMixin, TemplateView):
template_name = "map/form-selector.html"
class PointOfInterest(LoginRequiredMixin, CreateView):
class CreatePointOfInterest(LoginRequiredMixin, CreateView):
"""View for base case study form."""
template_name = 'map/form-poi.html'
success_url = '/case-study/create/success/'
@ -123,27 +123,26 @@ class BaseCreateForm(LoginRequiredMixin, FilesHandlerMixin, CreateView):
delete_user_draft(self.request.user)
class ShortForm(BaseCreateForm):
class CreateShortCaseStudy(BaseCreateForm):
"""View for short version of case study form."""
form_class = ShortCaseStudyForm
class LongForm(BaseCreateForm):
class CreateLongCaseStudy(BaseCreateForm):
"""View for long version of case study form."""
form_class = LongCaseStudyForm
class FormSuccess(TemplateView):
class CreateCaseStudySuccess(TemplateView):
template_name = 'map/form-success.html'
class CaseStudyDetail(DetailView):
class ViewCaseStudyDetail(DetailView):
template_name = "map/detail.html"
model = CaseStudy
context_object_name = "case_study"
class BaseEditForm(LoginRequiredMixin, FilesHandlerMixin, UpdateView):
"""View for base case study form."""
template_name = 'map/form-case_study.html'
@ -168,7 +167,7 @@ class SpatialRefSysAutocomplete(autocomplete.Select2QuerySetView):
return qs
class Drafts(LoginRequiredMixin, View):
class DraftsAPI(LoginRequiredMixin, View):
"""Retrieve or save a draft."""
def get_object(self, request):