Skip to content

Instantly share code, notes, and snippets.

@pije76
Forked from mjtamlyn/multi_contact_form.py
Created October 24, 2012 09:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pije76/3944958 to your computer and use it in GitHub Desktop.
Save pije76/3944958 to your computer and use it in GitHub Desktop.
Multi-contact form (FeinCMS content type)
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