Created
June 20, 2012 10:57
-
-
Save mjtamlyn/2959354 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] |
It does have a content type, it's at the bottom of the models file. You
create forms through the admin interface and integrate them through the
content type.
Regarding pip: I'll have to roll a release!
…On Jun 20, 2012 1:19 PM, "Marc Tamlyn" < ***@***.***> wrote:
Yeah I looked at that for about half an hour and couldn't see how to make
it do what I needed. Also it didn't have a content type or app content to
go with it, whereas this already had the handling. That and I couldn't pip
install it :(
---
Reply to this email directly or view it on GitHub:
https://gist.github.com/2959354
Ah, that wasn't obvious. It needed a bit of docs to explain how the email/action stuff worked too.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Yeah I looked at that for about half an hour and couldn't see how to make it do what I needed. Also it didn't have a content type or app content to go with it, whereas this already had the handling. That and I couldn't pip install it :(