-
-
Save pije76/3974817 to your computer and use it in GitHub Desktop.
Multi-contact form (FeinCMS content type)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.db import models | |
from django.utils.text import ugettext_lazy as _ | |
from .contact_form_amended import ContactForm, ContactFormContent | |
class MultiContactFormContent(ContactFormContent): | |
FORM_CLASSES = {'simple-contact': ContactForm} | |
FORM_CHOICES = (('simple-contact', _('Simple contact form')),) | |
class Meta(ContactFormContent.Meta): | |
abstract = True | |
@classmethod | |
def initialize_type(cls, forms=None): | |
if forms: | |
cls.FORM_CLASSES = dict([(f[0], f[2]) for f in forms]) | |
cls.FORM_CHOICES = [(f[0], f[1]) for f in forms] | |
cls.add_to_class('form', models.CharField(max_length=200, choices=cls.FORM_CHOICES)) | |
def get_email_template_names(self): | |
return [ | |
'context/contactform/%s-email.txt' % self.form, | |
'content/contactform/email.txt', | |
] | |
def get_form_class(self): | |
return self.FORM_CLASSES[self.form] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment