Permalink
Browse files

Merge pull request #11 from williambr/master

Change thank you message and fix a typo
  • Loading branch information...
maccesch committed May 15, 2011
2 parents 2ca5ae1 + ad267a3 commit 6397f0f2f30b6fc7e657b86e3ea863d62c70d6d4
@@ -1,11 +1,15 @@
from django.conf import settings
from django.utils.translation import ugettext_lazy as _
from django.forms.fields import CharField
from django.core.mail import EmailMessage
from django.template.loader import render_to_string
from cms.plugin_base import CMSPluginBase
from cms.plugin_pool import plugin_pool
from django.template.loader import render_to_string
from cms.plugins.text.settings import USE_TINYMCE
from cms.plugins.text.widgets.wymeditor_widget import WYMEditor
from models import Contact
from forms import AkismetContactForm, RecaptchaContactForm, HoneyPotContactForm
from django.core.mail import EmailMessage
from admin import ContactAdminForm
class ContactPlugin(CMSPluginBase):
@@ -25,6 +29,46 @@ class ContactPlugin(CMSPluginBase):
change_form_template = "cmsplugin_contact/admin/plugin_change_form.html"
def get_editor_widget(self, request, plugins):
"""
Returns the Django form Widget to be used for
the text area
"""
if USE_TINYMCE and "tinymce" in settings.INSTALLED_APPS:
from cms.plugins.text.widgets.tinymce_widget import TinyMCEEditor
return TinyMCEEditor(installed_plugins=plugins)
else:
return WYMEditor(installed_plugins=plugins)
def get_form_class(self, request, plugins):
"""
Returns a subclass of Form to be used by this plugin
"""
# We avoid mutating the Form declared above by subclassing
class TextPluginForm(self.form):
pass
widget = self.get_editor_widget(request, plugins)
TextPluginForm.declared_fields["thanks"] = CharField(widget=widget, required=False)
return TextPluginForm
def get_form(self, request, obj=None, **kwargs):
plugins = plugin_pool.get_text_enabled_plugins(self.placeholder, self.page)
form = self.get_form_class(request, plugins)
kwargs['form'] = form # override standard form
return super(ContactPlugin, self).get_form(request, obj, **kwargs)
def get_editor_widget(self, request, plugins):
"""
Returns the Django form Widget to be used for
the text area
"""
if USE_TINYMCE and "tinymce" in settings.INSTALLED_APPS:
from cms.plugins.text.widgets.tinymce_widget import TinyMCEEditor
return TinyMCEEditor(installed_plugins=plugins)
else:
return WYMEditor(installed_plugins=plugins)
def create_form(self, instance, request):
if instance.get_spam_protection_method_display() == 'Akismet':
AkismetContactForm.aksimet_api_key = instance.akismet_api_key
@@ -1,16 +1,15 @@
# SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
# Copyright (C) 2011
# This file is distributed under the same license as the PACKAGE package.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
# William Grzybowski <william@agencialivre.com.br> 2011.
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2011-05-15 11:07-0300\n"
"PO-Revision-Date: 2011-05-15 11:14\n"
"Last-Translator: <will@aas.com.br>\n"
"PO-Revision-Date: 2011-05-15 11:54\n"
"Last-Translator: <william@agencialivre.com.br>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
@@ -81,7 +80,7 @@ msgstr "Rótulo de e-mail do remetente"
#: models.py:21
msgid "Your email address"
msgstr "Seu endereçõ de e-mail"
msgstr "Seu endereço de e-mail"
#: models.py:22
msgid "Subject label"
@@ -0,0 +1,73 @@
# encoding: utf-8
import datetime
from south.db import db
from south.v2 import SchemaMigration
from django.db import models
class Migration(SchemaMigration):
def forwards(self, orm):
# Adding model 'Contact'
db.create_table('cmsplugin_contact', (
('cmsplugin_ptr', self.gf('django.db.models.fields.related.OneToOneField')(to=orm['cms.CMSPlugin'], unique=True, primary_key=True)),
('site_email', self.gf('django.db.models.fields.EmailField')(max_length=75)),
('email_label', self.gf('django.db.models.fields.CharField')(default=u'Your email address', max_length=100)),
('subject_label', self.gf('django.db.models.fields.CharField')(default=u'Subject', max_length=200)),
('content_label', self.gf('django.db.models.fields.CharField')(default=u'Message', max_length=100)),
('thanks', self.gf('django.db.models.fields.CharField')(default=u'Thank you for your message.', max_length=200)),
('submit', self.gf('django.db.models.fields.CharField')(default=u'Submit', max_length=30)),
('spam_protection_method', self.gf('django.db.models.fields.SmallIntegerField')(default=0)),
('akismet_api_key', self.gf('django.db.models.fields.CharField')(max_length=255, blank=True)),
('recaptcha_public_key', self.gf('django.db.models.fields.CharField')(max_length=255, blank=True)),
('recaptcha_private_key', self.gf('django.db.models.fields.CharField')(max_length=255, blank=True)),
('recaptcha_theme', self.gf('django.db.models.fields.CharField')(default='clean', max_length=20)),
))
db.send_create_signal('cmsplugin_contact', ['Contact'])
def backwards(self, orm):
# Deleting model 'Contact'
db.delete_table('cmsplugin_contact')
models = {
'cms.cmsplugin': {
'Meta': {'object_name': 'CMSPlugin'},
'creation_date': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'language': ('django.db.models.fields.CharField', [], {'max_length': '15', 'db_index': 'True'}),
'level': ('django.db.models.fields.PositiveIntegerField', [], {'db_index': 'True'}),
'lft': ('django.db.models.fields.PositiveIntegerField', [], {'db_index': 'True'}),
'parent': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['cms.CMSPlugin']", 'null': 'True', 'blank': 'True'}),
'placeholder': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['cms.Placeholder']", 'null': 'True'}),
'plugin_type': ('django.db.models.fields.CharField', [], {'max_length': '50', 'db_index': 'True'}),
'position': ('django.db.models.fields.PositiveSmallIntegerField', [], {'null': 'True', 'blank': 'True'}),
'rght': ('django.db.models.fields.PositiveIntegerField', [], {'db_index': 'True'}),
'tree_id': ('django.db.models.fields.PositiveIntegerField', [], {'db_index': 'True'})
},
'cms.placeholder': {
'Meta': {'object_name': 'Placeholder'},
'default_width': ('django.db.models.fields.PositiveSmallIntegerField', [], {'null': 'True'}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'slot': ('django.db.models.fields.CharField', [], {'max_length': '50', 'db_index': 'True'})
},
'cmsplugin_contact.contact': {
'Meta': {'object_name': 'Contact', 'db_table': "'cmsplugin_contact'", '_ormbases': ['cms.CMSPlugin']},
'akismet_api_key': ('django.db.models.fields.CharField', [], {'max_length': '255', 'blank': 'True'}),
'cmsplugin_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': "orm['cms.CMSPlugin']", 'unique': 'True', 'primary_key': 'True'}),
'content_label': ('django.db.models.fields.CharField', [], {'default': "u'Message'", 'max_length': '100'}),
'email_label': ('django.db.models.fields.CharField', [], {'default': "u'Your email address'", 'max_length': '100'}),
'recaptcha_private_key': ('django.db.models.fields.CharField', [], {'max_length': '255', 'blank': 'True'}),
'recaptcha_public_key': ('django.db.models.fields.CharField', [], {'max_length': '255', 'blank': 'True'}),
'recaptcha_theme': ('django.db.models.fields.CharField', [], {'default': "'clean'", 'max_length': '20'}),
'site_email': ('django.db.models.fields.EmailField', [], {'max_length': '75'}),
'spam_protection_method': ('django.db.models.fields.SmallIntegerField', [], {'default': '0'}),
'subject_label': ('django.db.models.fields.CharField', [], {'default': "u'Subject'", 'max_length': '200'}),
'submit': ('django.db.models.fields.CharField', [], {'default': "u'Submit'", 'max_length': '30'}),
'thanks': ('django.db.models.fields.CharField', [], {'default': "u'Thank you for your message.'", 'max_length': '200'})
}
}
complete_apps = ['cmsplugin_contact']
@@ -0,0 +1,59 @@
# encoding: utf-8
import datetime
from south.db import db
from south.v2 import SchemaMigration
from django.db import models
class Migration(SchemaMigration):
def forwards(self, orm):
# Changing field 'Contact.thanks'
db.alter_column('cmsplugin_contact', 'thanks', self.gf('django.db.models.fields.TextField')(max_length=200))
def backwards(self, orm):
# Changing field 'Contact.thanks'
db.alter_column('cmsplugin_contact', 'thanks', self.gf('django.db.models.fields.CharField')(max_length=200))
models = {
'cms.cmsplugin': {
'Meta': {'object_name': 'CMSPlugin'},
'creation_date': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'language': ('django.db.models.fields.CharField', [], {'max_length': '15', 'db_index': 'True'}),
'level': ('django.db.models.fields.PositiveIntegerField', [], {'db_index': 'True'}),
'lft': ('django.db.models.fields.PositiveIntegerField', [], {'db_index': 'True'}),
'parent': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['cms.CMSPlugin']", 'null': 'True', 'blank': 'True'}),
'placeholder': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['cms.Placeholder']", 'null': 'True'}),
'plugin_type': ('django.db.models.fields.CharField', [], {'max_length': '50', 'db_index': 'True'}),
'position': ('django.db.models.fields.PositiveSmallIntegerField', [], {'null': 'True', 'blank': 'True'}),
'rght': ('django.db.models.fields.PositiveIntegerField', [], {'db_index': 'True'}),
'tree_id': ('django.db.models.fields.PositiveIntegerField', [], {'db_index': 'True'})
},
'cms.placeholder': {
'Meta': {'object_name': 'Placeholder'},
'default_width': ('django.db.models.fields.PositiveSmallIntegerField', [], {'null': 'True'}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'slot': ('django.db.models.fields.CharField', [], {'max_length': '50', 'db_index': 'True'})
},
'cmsplugin_contact.contact': {
'Meta': {'object_name': 'Contact', 'db_table': "'cmsplugin_contact'", '_ormbases': ['cms.CMSPlugin']},
'akismet_api_key': ('django.db.models.fields.CharField', [], {'max_length': '255', 'blank': 'True'}),
'cmsplugin_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': "orm['cms.CMSPlugin']", 'unique': 'True', 'primary_key': 'True'}),
'content_label': ('django.db.models.fields.CharField', [], {'default': "u'Message'", 'max_length': '100'}),
'email_label': ('django.db.models.fields.CharField', [], {'default': "u'Your email address'", 'max_length': '100'}),
'recaptcha_private_key': ('django.db.models.fields.CharField', [], {'max_length': '255', 'blank': 'True'}),
'recaptcha_public_key': ('django.db.models.fields.CharField', [], {'max_length': '255', 'blank': 'True'}),
'recaptcha_theme': ('django.db.models.fields.CharField', [], {'default': "'clean'", 'max_length': '20'}),
'site_email': ('django.db.models.fields.EmailField', [], {'max_length': '75'}),
'spam_protection_method': ('django.db.models.fields.SmallIntegerField', [], {'default': '0'}),
'subject_label': ('django.db.models.fields.CharField', [], {'default': "u'Subject'", 'max_length': '200'}),
'submit': ('django.db.models.fields.CharField', [], {'default': "u'Submit'", 'max_length': '30'}),
'thanks': ('django.db.models.fields.TextField', [], {'default': "u'Thank you for your message.'", 'max_length': '200'})
}
}
complete_apps = ['cmsplugin_contact']
No changes.
@@ -21,7 +21,7 @@ class Contact(CMSPlugin):
email_label = models.CharField(_('Email sender label'), default=_('Your email address'), max_length=100)
subject_label = models.CharField(_('Subject label'), default=_('Subject'), max_length=200)
content_label = models.CharField(_('Message content label'), default=_('Message'), max_length=100)
thanks = models.CharField(verbose_name=_("Thanks message"), help_text=_('Message displayed on successful submit'), default=_('Thank you for your message.'), max_length=200)
thanks = models.TextField(verbose_name=_("Thanks message"), help_text=_('Message displayed on successful submit'), default=_('Thank you for your message.'), max_length=200)
submit = models.CharField(_('Submit button value'), default=_('Submit'), max_length=30)
spam_protection_method = models.SmallIntegerField(verbose_name=_('Spam protection method'), choices=SPAM_PROTECTION_CHOICES, default=0)
@@ -74,5 +74,5 @@
</form>
{% else %}
<h2>{{ contact.thanks }}</h2>
{{ contact.thanks|safe }}
{% endif %}

0 comments on commit 6397f0f

Please sign in to comment.