kopia lustrzana https://github.com/rtts/django-simplecms
Make email subject user-configurable
rodzic
31fd811985
commit
c52be27802
|
@ -5,7 +5,6 @@ Some not-so-simple forms.
|
|||
from urllib.parse import quote
|
||||
|
||||
from django import forms
|
||||
from django.conf import settings
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
|
||||
from . import registry
|
||||
|
@ -131,11 +130,11 @@ class ContactForm(forms.Form):
|
|||
|
||||
body = forms.CharField(label=_("Message"), widget=forms.Textarea(), required=False)
|
||||
|
||||
def save(self, address):
|
||||
def save(self, address, subject):
|
||||
"""
|
||||
Return a mailto: link.
|
||||
"""
|
||||
|
||||
subject = quote(settings.CONTACT_FORM_EMAIL_SUBJECT, safe="")
|
||||
subject = quote(subject, safe="")
|
||||
body = quote(self.cleaned_data.get("body"), safe="")
|
||||
return f"mailto:{address}?subject={subject}&body={body}"
|
||||
|
|
|
@ -55,6 +55,7 @@ class BaseSection(mixins.Numbered, models.Model):
|
|||
help_text=_("Paste a YouTube, Vimeo, or SoundCloud link"),
|
||||
)
|
||||
href = fields.CharField(_("link"), blank=True)
|
||||
subject = fields.CharField(_("subject"), blank=True)
|
||||
|
||||
def number_with_respect_to(self):
|
||||
return self.page.sections.all()
|
||||
|
|
|
@ -25,9 +25,7 @@ MEDIA_URL = "/media/"
|
|||
MEDIA_ROOT = "/srv/" + PROJECT_NAME + "/media"
|
||||
LOGIN_REDIRECT_URL = "/"
|
||||
LOGOUT_REDIRECT_URL = "/"
|
||||
|
||||
if DEBUG:
|
||||
EMAIL_BACKEND = "django.core.mail.backends.console.EmailBackend"
|
||||
CACHE_MIDDLEWARE_SECONDS = 0
|
||||
|
||||
try:
|
||||
|
|
|
@ -48,4 +48,4 @@ class Contact(ContactSectionFormView):
|
|||
|
||||
verbose_name = _("Contact")
|
||||
template_name = "contact.html"
|
||||
fields = ["content", "href"]
|
||||
fields = ["content", "href", "subject"]
|
||||
|
|
Ładowanie…
Reference in New Issue