django-simplecms/example/views.py

40 wiersze
943 B
Python
Czysty Zwykły widok Historia

from cms.decorators import section_view
from cms.forms import ContactForm
2021-07-03 23:59:48 +00:00
from cms.views import SectionFormView, SectionView
from django.http import HttpResponse
from django.utils.translation import gettext_lazy as _
2021-07-03 23:59:48 +00:00
@section_view
class Text(SectionView):
2021-07-03 23:59:48 +00:00
verbose_name = _("Text")
fields = ["content"]
template_name = "text.html"
@section_view
class Images(SectionView):
2021-07-03 23:59:48 +00:00
verbose_name = _("Image(s)")
fields = ["images"]
template_name = "images.html"
@section_view
class Video(SectionView):
2021-07-03 23:59:48 +00:00
verbose_name = _("Video")
fields = ["video"]
template_name = "video.html"
@section_view
class Contact(SectionFormView):
2021-07-03 23:59:48 +00:00
verbose_name = _("Contact")
fields = ["content", "href"]
form_class = ContactForm
2021-07-03 23:59:48 +00:00
template_name = "contact.html"
def form_valid(self, form):
response = HttpResponse(status=302)
response["Location"] = form.save(self.object.href)
return response