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"
|
default_app_config = "cms.apps.CmsConfig"
|
||||||
|
|
|
@ -117,9 +117,7 @@ class ContactForm(forms.Form):
|
||||||
Spam-resistant contact form.
|
Spam-resistant contact form.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
body = forms.CharField(
|
body = forms.CharField(label=_("Message"), widget=forms.Textarea(), required=False)
|
||||||
label=_("Your message"), widget=forms.Textarea(), required=False
|
|
||||||
)
|
|
||||||
|
|
||||||
def save(self, address):
|
def save(self, address):
|
||||||
"""
|
"""
|
||||||
|
|
Plik binarny nie jest wyświetlany.
|
@ -7,8 +7,8 @@ msgid ""
|
||||||
msgstr ""
|
msgstr ""
|
||||||
"Project-Id-Version: PACKAGE VERSION\n"
|
"Project-Id-Version: PACKAGE VERSION\n"
|
||||||
"Report-Msgid-Bugs-To: \n"
|
"Report-Msgid-Bugs-To: \n"
|
||||||
"POT-Creation-Date: 2022-01-29 13:27+0100\n"
|
"POT-Creation-Date: 2022-12-25 21:40+0100\n"
|
||||||
"PO-Revision-Date: 2022-01-29 13:28+0100\n"
|
"PO-Revision-Date: 2022-12-25 21:41+0100\n"
|
||||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||||
"Language-Team: LANGUAGE <LL@li.org>\n"
|
"Language-Team: LANGUAGE <LL@li.org>\n"
|
||||||
"Language: \n"
|
"Language: \n"
|
||||||
|
@ -21,21 +21,13 @@ msgstr ""
|
||||||
msgid "Content Management System"
|
msgid "Content Management System"
|
||||||
msgstr "Content Beheer"
|
msgstr "Content Beheer"
|
||||||
|
|
||||||
#: forms.py:57
|
#: forms.py:58
|
||||||
msgid "Delete"
|
msgid "Delete"
|
||||||
msgstr "Verwijderen"
|
msgstr "Verwijderen"
|
||||||
|
|
||||||
#: forms.py:115
|
#: forms.py:121
|
||||||
msgid "Your email address"
|
msgid "Message"
|
||||||
msgstr "Uw email adres"
|
msgstr "Bericht"
|
||||||
|
|
||||||
#: forms.py:116 forms.py:118
|
|
||||||
msgid "Your message"
|
|
||||||
msgstr "Uw bericht"
|
|
||||||
|
|
||||||
#: forms.py:132
|
|
||||||
msgid "Contact form"
|
|
||||||
msgstr "Contactformulier"
|
|
||||||
|
|
||||||
#: models.py:22 models.py:39
|
#: models.py:22 models.py:39
|
||||||
msgid "page"
|
msgid "page"
|
||||||
|
|
20
cms/views.py
20
cms/views.py
|
@ -1,14 +1,19 @@
|
||||||
import json
|
import json
|
||||||
|
|
||||||
from django.contrib.auth.mixins import UserPassesTestMixin
|
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.shortcuts import redirect
|
||||||
from django.utils.decorators import method_decorator
|
from django.utils.decorators import method_decorator
|
||||||
from django.views.decorators.cache import never_cache
|
from django.views.decorators.cache import never_cache
|
||||||
from django.views.generic import base, detail, edit
|
from django.views.generic import base, detail, edit
|
||||||
|
|
||||||
from . import registry
|
from . import registry
|
||||||
from .forms import PageForm, SectionForm
|
from .forms import ContactForm, PageForm, SectionForm
|
||||||
|
|
||||||
|
|
||||||
class SectionView:
|
class SectionView:
|
||||||
|
@ -54,6 +59,17 @@ class SectionFormView(SectionView):
|
||||||
return form_class(**kwargs)
|
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):
|
class PageView(detail.DetailView):
|
||||||
"""View of a page with heterogeneous sections"""
|
"""View of a page with heterogeneous sections"""
|
||||||
|
|
||||||
|
|
|
@ -1,39 +1,31 @@
|
||||||
from cms.decorators import section_view
|
from cms.decorators import section_view
|
||||||
from cms.forms import ContactForm
|
from cms.views import ContactSectionFormView, SectionView
|
||||||
from cms.views import SectionFormView, SectionView
|
|
||||||
from django.http import HttpResponse
|
|
||||||
from django.utils.translation import gettext_lazy as _
|
from django.utils.translation import gettext_lazy as _
|
||||||
|
|
||||||
|
|
||||||
@section_view
|
@section_view
|
||||||
class Text(SectionView):
|
class Text(SectionView):
|
||||||
verbose_name = _("Text")
|
verbose_name = _("Text")
|
||||||
fields = ["content"]
|
|
||||||
template_name = "text.html"
|
template_name = "text.html"
|
||||||
|
fields = ["content"]
|
||||||
|
|
||||||
|
|
||||||
@section_view
|
@section_view
|
||||||
class Images(SectionView):
|
class Images(SectionView):
|
||||||
verbose_name = _("Image(s)")
|
verbose_name = _("Image(s)")
|
||||||
fields = ["images"]
|
|
||||||
template_name = "images.html"
|
template_name = "images.html"
|
||||||
|
fields = ["images"]
|
||||||
|
|
||||||
|
|
||||||
@section_view
|
@section_view
|
||||||
class Video(SectionView):
|
class Video(SectionView):
|
||||||
verbose_name = _("Video")
|
verbose_name = _("Video")
|
||||||
fields = ["video"]
|
|
||||||
template_name = "video.html"
|
template_name = "video.html"
|
||||||
|
fields = ["video"]
|
||||||
|
|
||||||
|
|
||||||
@section_view
|
@section_view
|
||||||
class Contact(SectionFormView):
|
class Contact(ContactSectionFormView):
|
||||||
verbose_name = _("Contact")
|
verbose_name = _("Contact")
|
||||||
fields = ["content", "href"]
|
|
||||||
form_class = ContactForm
|
|
||||||
template_name = "contact.html"
|
template_name = "contact.html"
|
||||||
|
fields = ["content", "href"]
|
||||||
def form_valid(self, form):
|
|
||||||
response = HttpResponse(status=302)
|
|
||||||
response["Location"] = form.save(self.object.href)
|
|
||||||
return response
|
|
||||||
|
|
|
@ -1,2 +1,2 @@
|
||||||
[tool.isort]
|
[tool.isort]
|
||||||
line_length = 88
|
profile = "black"
|
||||||
|
|
Ładowanie…
Reference in New Issue