kopia lustrzana https://github.com/rtts/django-simplecms
Merry 1.1.1
This release fine-tunes the translations and offers a ready-to-use, spam resistant contact form. Submitting the form will open the user's mail app with an email addressed to the `href` field of the section. This method, although unconventional, has been tested by my mother on several of her devices, which proofs anyone can use it. It couldn't be easier and, best of all, no more spam! \o/main
rodzic
9588d7ac72
commit
94af72cca8
|
@ -1,2 +1,2 @@
|
|||
__version__ = "1.1.0"
|
||||
__version__ = "1.1.1"
|
||||
default_app_config = "cms.apps.CmsConfig"
|
||||
|
|
|
@ -117,9 +117,7 @@ class ContactForm(forms.Form):
|
|||
Spam-resistant contact form.
|
||||
"""
|
||||
|
||||
body = forms.CharField(
|
||||
label=_("Your message"), widget=forms.Textarea(), required=False
|
||||
)
|
||||
body = forms.CharField(label=_("Message"), widget=forms.Textarea(), required=False)
|
||||
|
||||
def save(self, address):
|
||||
"""
|
||||
|
|
Plik binarny nie jest wyświetlany.
|
@ -7,8 +7,8 @@ msgid ""
|
|||
msgstr ""
|
||||
"Project-Id-Version: PACKAGE VERSION\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2022-01-29 13:27+0100\n"
|
||||
"PO-Revision-Date: 2022-01-29 13:28+0100\n"
|
||||
"POT-Creation-Date: 2022-12-25 21:40+0100\n"
|
||||
"PO-Revision-Date: 2022-12-25 21:41+0100\n"
|
||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||
"Language-Team: LANGUAGE <LL@li.org>\n"
|
||||
"Language: \n"
|
||||
|
@ -21,21 +21,13 @@ msgstr ""
|
|||
msgid "Content Management System"
|
||||
msgstr "Content Beheer"
|
||||
|
||||
#: forms.py:57
|
||||
#: forms.py:58
|
||||
msgid "Delete"
|
||||
msgstr "Verwijderen"
|
||||
|
||||
#: forms.py:115
|
||||
msgid "Your email address"
|
||||
msgstr "Uw email adres"
|
||||
|
||||
#: forms.py:116 forms.py:118
|
||||
msgid "Your message"
|
||||
msgstr "Uw bericht"
|
||||
|
||||
#: forms.py:132
|
||||
msgid "Contact form"
|
||||
msgstr "Contactformulier"
|
||||
#: forms.py:121
|
||||
msgid "Message"
|
||||
msgstr "Bericht"
|
||||
|
||||
#: models.py:22 models.py:39
|
||||
msgid "page"
|
||||
|
|
20
cms/views.py
20
cms/views.py
|
@ -1,14 +1,19 @@
|
|||
import json
|
||||
|
||||
from django.contrib.auth.mixins import UserPassesTestMixin
|
||||
from django.http import Http404, HttpResponseBadRequest, HttpResponseRedirect
|
||||
from django.http import (
|
||||
Http404,
|
||||
HttpResponse,
|
||||
HttpResponseBadRequest,
|
||||
HttpResponseRedirect,
|
||||
)
|
||||
from django.shortcuts import redirect
|
||||
from django.utils.decorators import method_decorator
|
||||
from django.views.decorators.cache import never_cache
|
||||
from django.views.generic import base, detail, edit
|
||||
|
||||
from . import registry
|
||||
from .forms import PageForm, SectionForm
|
||||
from .forms import ContactForm, PageForm, SectionForm
|
||||
|
||||
|
||||
class SectionView:
|
||||
|
@ -54,6 +59,17 @@ class SectionFormView(SectionView):
|
|||
return form_class(**kwargs)
|
||||
|
||||
|
||||
class ContactSectionFormView(SectionFormView):
|
||||
"""Contact section with bogus contact form"""
|
||||
|
||||
form_class = ContactForm
|
||||
|
||||
def form_valid(self, form):
|
||||
response = HttpResponse(status=302)
|
||||
response["Location"] = form.save(self.object.href)
|
||||
return response
|
||||
|
||||
|
||||
class PageView(detail.DetailView):
|
||||
"""View of a page with heterogeneous sections"""
|
||||
|
||||
|
|
|
@ -1,39 +1,31 @@
|
|||
from cms.decorators import section_view
|
||||
from cms.forms import ContactForm
|
||||
from cms.views import SectionFormView, SectionView
|
||||
from django.http import HttpResponse
|
||||
from cms.views import ContactSectionFormView, SectionView
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
|
||||
|
||||
@section_view
|
||||
class Text(SectionView):
|
||||
verbose_name = _("Text")
|
||||
fields = ["content"]
|
||||
template_name = "text.html"
|
||||
fields = ["content"]
|
||||
|
||||
|
||||
@section_view
|
||||
class Images(SectionView):
|
||||
verbose_name = _("Image(s)")
|
||||
fields = ["images"]
|
||||
template_name = "images.html"
|
||||
fields = ["images"]
|
||||
|
||||
|
||||
@section_view
|
||||
class Video(SectionView):
|
||||
verbose_name = _("Video")
|
||||
fields = ["video"]
|
||||
template_name = "video.html"
|
||||
fields = ["video"]
|
||||
|
||||
|
||||
@section_view
|
||||
class Contact(SectionFormView):
|
||||
class Contact(ContactSectionFormView):
|
||||
verbose_name = _("Contact")
|
||||
fields = ["content", "href"]
|
||||
form_class = ContactForm
|
||||
template_name = "contact.html"
|
||||
|
||||
def form_valid(self, form):
|
||||
response = HttpResponse(status=302)
|
||||
response["Location"] = form.save(self.object.href)
|
||||
return response
|
||||
fields = ["content", "href"]
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
[tool.isort]
|
||||
line_length = 88
|
||||
profile = "black"
|
||||
|
|
Ładowanie…
Reference in New Issue