Browse files

Readying for PyPI

  • Loading branch information...
1 parent 851e3fe commit 7639f18ef48a9381c2d8ab3fc61050e4a338d983 @maccesch committed Sep 2, 2010
View
4 MANIFEST.in
@@ -1,2 +1,2 @@
-recursive-include cmsplugin_contact/locale *.mo
-graft cmsplugin_contact/templates
+recursive-include cmsplugin-contact/locale *.mo
+graft cmsplugin-contact/templates
View
8 README.rst
@@ -30,6 +30,14 @@ Both libraries can be installed by ``easy_install`` or ``pip``.
Installation
============
+From PyPI
+---------
+
+You can simply type into a terminal ``pip install cmsplugin-contact`` or ``easy_install cmsplugin-contact``.
+
+Manual Download
+---------------
+
Unzip the file you downloaded. Then go in your terminal and ``cd`` into the unpacked folder. Then type ``python setup.py install`` in your terminal.
Put "cmsplugin_contact" in your ``INSTALLED_APPS`` section in settings.py. Don't forget to syncdb your database.
View
0 cmsplugin_contact/__init__.py
No changes.
View
80 cmsplugin_contact/admin.py
@@ -1,80 +0,0 @@
-from django.forms import ModelForm, Field, CharField
-from django.forms.util import ErrorList
-from django.core.exceptions import ValidationError
-from django.contrib.sites.models import Site
-from django.conf import settings
-from django.utils.translation import ugettext_lazy as _
-
-from models import Contact
-
-class KeyField(CharField):
- def validate(self, value):
- # valdates always. validation is done in the form (see below)
- pass
-
-class ContactAdminForm(ModelForm):
- akismet_api_key = KeyField(max_length=255, label=_("Akismet API Key"), help_text=_('Get a Wordpress Key from http://akismet.com/'))
-
- recaptcha_public_key = KeyField(max_length=255, label=_("ReCAPTCHA Public Key"), help_text=_('Get this from http://www.google.com/recaptcha'))
- recaptcha_private_key = KeyField(max_length=255, label=_("ReCAPTCHA Private Key"), help_text=_('Get this from http://www.google.com/recaptcha'))
-
- class Meta:
- model = Contact
-
-
- def _add_error(self, field_name, error):
- if not field_name in self._errors:
- self._errors[field_name] = ErrorList()
- self._errors[field_name].append(error)
-
- def _check_akismet(self):
- def add_error(error):
- self._add_error('akismet_api_key', error)
-
- try:
- from akismet import Akismet
- except ImportError:
- self._add_error('spam_protection_method', _('Akismet library is not installed. Use "easy_install akismet" or "pip install akismet".'))
-
- api_key = self.cleaned_data['akismet_api_key']
- if not api_key:
- add_error(Field.default_error_messages['required'])
- else:
- ak = Akismet(
- key = api_key,
- blog_url = 'http://%s/' % Site.objects.get(pk=settings.SITE_ID).domain
- )
- if not ak.verify_key():
- add_error(_('The API Key is not valid.'))
-
-
- def _check_recaptcha(self):
-
- try:
- from recaptcha.client import captcha as recaptcha
- except ImportError:
- self._add_error('spam_protection_method', _('ReCAPTCHA library is not installed. Use "easy_install recaptcha-client" or "pip install recaptcha-client".'))
-
- public_key = self.cleaned_data['recaptcha_public_key']
- private_key = self.cleaned_data['recaptcha_private_key']
-
- if not public_key:
- self._add_error('recaptcha_public_key', Field.default_error_messages['required'])
- if not private_key:
- self._add_error('recaptcha_private_key', Field.default_error_messages['required'])
-
-
- def clean(self):
-
- method = self.cleaned_data['spam_protection_method']
- print "huhu"
- if method == 1:
- # user chose aksimet => akismet api key is required
- self._check_akismet()
- elif method == 2:
- # user chose recaptcha => recaptcha keys are required
- self._check_recaptcha()
-
- return self.cleaned_data
-
-
View
87 cmsplugin_contact/cms_plugins.py
@@ -1,87 +0,0 @@
-from django.utils.translation import ugettext_lazy as _
-from cms.plugin_base import CMSPluginBase
-from cms.plugin_pool import plugin_pool
-from django.template.loader import render_to_string
-from models import Contact
-from forms import AkismetContactForm, RecaptchaContactForm, HoneyPotContactForm
-from django.core.mail import EmailMessage
-from admin import ContactAdminForm
-
-class ContactPlugin(CMSPluginBase):
- model = Contact
- name = _("Contact Form")
- render_template = "cmsplugin_contact/contact.html"
- form = ContactAdminForm
-
- fieldsets = (
- (None, {
- 'fields': ('site_email', 'email_label', 'subject_label', 'content_label', 'thanks', 'submit'),
- }),
- (_('Spam Protection'), {
- 'fields': ('spam_protection_method', 'akismet_api_key', 'recaptcha_public_key', 'recaptcha_private_key', 'recaptcha_theme')
- })
- )
-
- change_form_template = "cmsplugin_contact/admin/plugin_change_form.html"
-
- def create_form(self, instance, request):
- if instance.get_spam_protection_method_display() == 'Akismet':
- AkismetContactForm.aksimet_api_key = instance.aksimet_api_key
- FormClass = AkismetContactForm
- elif instance.get_spam_protection_method_display() == 'ReCAPTCHA':
- RecaptchaContactForm.recaptcha_public_key = instance.recaptcha_public_key
- RecaptchaContactForm.recaptcha_private_key = instance.recaptcha_private_key
- RecaptchaContactForm.recaptcha_theme = instance.recaptcha_theme
- FormClass = RecaptchaContactForm
- else:
- FormClass = HoneyPotContactForm
-
- if request.method == "POST":
- return FormClass(request, data=request.POST)
- else:
- return FormClass(request)
-
-
- def send(self, form, site_email):
- subject = form.cleaned_data['subject']
- if not subject:
- subject = _('No subject')
- email_message = EmailMessage(
- subject,
- render_to_string("cmsplugin_contact/email.txt", {
- 'data': form.cleaned_data,
- }),
- site_email,
- [site_email],
- headers = {
- 'Reply-To': form.cleaned_data['email']
- },)
- email_message.send(fail_silently=True)
-
- def render(self, context, instance, placeholder):
- request = context['request']
-
- form = self.create_form(instance, request)
-
- if request.method == "POST" and form.is_valid():
- self.send(form, instance.site_email)
- context.update( {
- 'contact': instance,
- })
- else:
- context.update({
- 'contact': instance,
- 'form': form,
- })
-
- return context
-
- def render_change_form(self, request, context, add=False, change=False, form_url='', obj=None):
- context.update({
- 'spam_protection_method': obj.spam_protection_method if obj else 0
- })
-
- return super(ContactPlugin, self).render_change_form(request, context, add, change, form_url, obj)
-
-
-plugin_pool.register_plugin(ContactPlugin)
View
30 cmsplugin_contact/forms.py
@@ -1,30 +0,0 @@
-from django import forms
-#import settings
-from stopspam.forms import HoneyPotForm, RecaptchaForm, AkismetForm
-
-class HoneyPotContactForm(HoneyPotForm):
- email = forms.EmailField()
- subject = forms.CharField(required=False)
- content = forms.CharField(widget=forms.Textarea())
-
-
-class AkismetContactForm(AkismetForm):
- akismet_fields = {
- 'comment_author_email': 'email',
- 'comment_content': 'content'
- }
- email = forms.EmailField()
- subject = forms.CharField(required=False)
- content = forms.CharField(widget=forms.Textarea())
-
- akismet_api_key = None
-
-
-class RecaptchaContactForm(RecaptchaForm):
- email = forms.EmailField()
- subject = forms.CharField(required=False)
- content = forms.CharField(widget=forms.Textarea())
-
- recaptcha_public_key = None
- recaptcha_private_key = None
- recaptcha_theme = None
View
BIN cmsplugin_contact/locale/de/LC_MESSAGES/django.mo
Binary file not shown.
View
154 cmsplugin_contact/locale/de/LC_MESSAGES/django.po
@@ -1,154 +0,0 @@
-# SOME DESCRIPTIVE TITLE.
-# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
-# This file is distributed under the same license as the PACKAGE package.
-# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
-#
-#, fuzzy
-msgid ""
-msgstr ""
-"Project-Id-Version: PACKAGE VERSION\n"
-"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2010-09-01 18:46+0200\n"
-"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
-"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
-"Language-Team: LANGUAGE <LL@li.org>\n"
-"MIME-Version: 1.0\n"
-"Content-Type: text/plain; charset=UTF-8\n"
-"Content-Transfer-Encoding: 8bit\n"
-"Plural-Forms: nplurals=2; plural=(n != 1)\n"
-
-#: admin.py:16
-msgid "Akismet API Key"
-msgstr ""
-
-#: admin.py:16
-msgid "Get a Wordpress Key from http://akismet.com/"
-msgstr "Wordpress Key von http://akismet.com/"
-
-#: admin.py:18
-msgid "ReCAPTCHA Public Key"
-msgstr ""
-
-#: admin.py:18 admin.py:19
-msgid "Get this from http://www.google.com/recaptcha"
-msgstr "Erhältlich von http://www.google.com/recaptcha"
-
-#: admin.py:19
-msgid "ReCAPTCHA Private Key"
-msgstr ""
-
-#: admin.py:37
-msgid ""
-"Akismet library is not installed. Use \"easy_install akismet\" or \"pip "
-"install akismet\"."
-msgstr ""
-"Die Akismet Bibliothek ist nicht installiert. Zum installieren: "
-"\"easy_install akismet\" oder \"pip install akismet\""
-
-#: admin.py:48
-msgid "The API Key is not valid."
-msgstr "Der API Key ist ungültig."
-
-#: admin.py:56
-msgid ""
-"ReCAPTCHA library is not installed. Use \"easy_install recaptcha-client\" or "
-"\"pip install recaptcha-client\"."
-msgstr ""
-"Die ReCAPTCHA Bibliothek ist nicht installiert. Zum installieren: "
-"\"easy_install recaptcha-client\" oder \"pip install recaptcha-client\""
-
-#: cms_plugins.py:12
-msgid "Contact Form"
-msgstr "Kontaktformular"
-
-#: cms_plugins.py:20
-msgid "Spam Protection"
-msgstr "Spamschutz"
-
-#: cms_plugins.py:48
-msgid "No subject"
-msgstr "Kein Betreff"
-
-#: models.py:20
-msgid "Email recipient"
-msgstr "E-Mail Empfänger"
-
-#: models.py:21
-msgid "Email sender label"
-msgstr "E-Mail Absender Beschriftung"
-
-#: models.py:21
-msgid "Your email address"
-msgstr "Ihre E-Mail Adresse"
-
-#: models.py:22
-msgid "Subject label"
-msgstr "Betreff Beschriftung"
-
-#: models.py:22
-msgid "Subject"
-msgstr "Betreff"
-
-#: models.py:23
-msgid "Message content label"
-msgstr "Nachrichteninhalt Beschriftung"
-
-#: models.py:23
-msgid "Message"
-msgstr "Nachricht"
-
-#: models.py:24
-msgid "Thanks message"
-msgstr "Dankesnachricht"
-
-#: models.py:24
-msgid "Message displayed on successful submit"
-msgstr "Nachricht nach erfolgreichem Absenden"
-
-#: models.py:24
-msgid "Thank you for your message."
-msgstr "Vielen Dank für Ihre Nachricht."
-
-#: models.py:25
-msgid "Submit button value"
-msgstr "Senden Button Beschriftung"
-
-#: models.py:25
-msgid "Submit"
-msgstr "Senden"
-
-#: models.py:27
-msgid "Spam protection method"
-msgstr "Spamschutzmethode"
-
-#: models.py:33
-msgid "ReCAPTCHA theme"
-msgstr "ReCAPTCHA Theme"
-
-#: templates/cmsplugin_contact/contact.html:40
-msgid "Incorrect please try again"
-msgstr "Eingabe nicht korrekt, bitte erneut versuchen"
-
-#: templates/cmsplugin_contact/contact.html:43
-msgid "Enter the words above:"
-msgstr "Obige Wörter eingeben:"
-
-#: templates/cmsplugin_contact/contact.html:44
-msgid "Enter the numbers you hear:"
-msgstr "Die gehörten Zahlen eingeben:"
-
-#: templates/cmsplugin_contact/contact.html:49
-msgid "Get another CAPTCHA"
-msgstr "Anderes CAPTCHA"
-
-#: templates/cmsplugin_contact/contact.html:50
-msgid "Get an audio CAPTCHA"
-msgstr "Audio CAPTCHA"
-
-#: templates/cmsplugin_contact/contact.html:51
-msgid "Get an image CAPTCHA"
-msgstr "Bild CAPTCHA"
-
-#: templates/cmsplugin_contact/contact.html:53
-msgid "Help"
-msgstr "Hilfe"
View
36 cmsplugin_contact/models.py
@@ -1,36 +0,0 @@
-from django.db import models
-from django.utils.translation import ugettext_lazy as _
-from cms.models.pluginmodel import CMSPlugin
-
-class Contact(CMSPlugin):
- SPAM_PROTECTION_CHOICES = (
- (0, 'Honeypot'),
- (1, 'Akismet'),
- (2, 'ReCAPTCHA'),
- )
-
- THEME_CHOICES = (
- ('clean', 'Clean'),
- ('red', 'Red'),
- ('white', 'White'),
- ('blackglass', 'Black Glass'),
- ('custom', 'Custom'),
- )
-
- site_email = models.EmailField(_('Email recipient'))
- 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)
- 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)
-
- akismet_api_key = models.CharField(max_length=255, blank=True)
-
- recaptcha_public_key = models.CharField(max_length=255, blank=True)
- recaptcha_private_key = models.CharField(max_length=255, blank=True)
- recaptcha_theme = models.CharField(max_length=20, choices=THEME_CHOICES, default='clean', verbose_name=_('ReCAPTCHA theme'))
-
- def __unicode__(self):
- return self.site_email
View
64 cmsplugin_contact/templates/cmsplugin_contact/admin/plugin_change_form.html
@@ -1,64 +0,0 @@
-{% extends "admin/cms/page/plugin_change_form.html" %}
-
-{% block extrahead %}{{ block.super }}
-<script type="text/javascript">
-//<![CDATA[
-(function($) {
- function updateVisibility(class_prefix) {
- $('div.spam_protection_method').parent().children('.form-row').each(function(index, row) {
- var visible = false;
- $.each($(row).attr('class').split(/\s+/), function(index, class) {
- if (class == 'spam_protection_method' || class.indexOf(class_prefix) >= 0) {
- visible = true;
- }
- });
- if (visible) {
- $(row).css('display', 'block');
- } else {
- $(row).css('display', 'none');
- }
- });
- }
-
- $(document).ready(function(){
-
- $('#id_spam_protection_method').change(function() {
- var curOption = $('#id_spam_protection_method :selected');
- updateVisibility(curOption.html().toLowerCase());
- });
- });
-})(jQuery);
-//]]>
-</script>
-
-{% endblock extrahead %}
-
-{% block extrastyle %}{{ block.super }}
-<style type="text/css">
- div.form-row label {
- width: 14em;
- }
- form .aligned p.help {
- padding-left: 48px;
- margin-left: 13em;
- }
-
- {% if spam_protection_method != 1 %}
- div.form-row.akismet_api_key {
- display: none;
- }
- {% endif %}
-
- {% if spam_protection_method != 2 %}
- div.form-row.recaptcha_public_key {
- display: none;
- }
- div.form-row.recaptcha_private_key {
- display: none;
- }
- div.form-row.recaptcha_theme {
- display: none;
- }
- {% endif %}
-</style>
-{% endblock extrastyle %}
View
82 cmsplugin_contact/templates/cmsplugin_contact/contact.html
@@ -1,82 +0,0 @@
-{% load i18n %}
-
-{% if form %}
- <form action='' method="POST">
- <p {% if form.email.errors %}class="error"{% endif %}>
- <label>{{ contact.email_label }}</label>
- {{ form.email }}
- {% if form.email.errors %}
- {% for error in form.email.errors %}
- <span class="error_msg">{{ error }}</span>
- {% endfor %}
- {% endif %}
- </p>
- <p {% if form.subject.errors %}class="error"{% endif %}>
- <label>{{ contact.subject_label }}</label>
- {{ form.subject }}
- {% if form.subject.errors %}
- {% for error in form.subject.errors %}
- <span class="error_msg">{{ error }}</span>
- {% endfor %}
- {% endif %}
- </p>
- <p {% if form.content.errors %}class="error"{% endif %}>
- <label>{{ contact.content_label }}</label>
- {{ form.content }}
- {% if form.content.errors %}
- {% for error in form.content.errors %}
- <span class="error_msg">{{ error }}</span>
- {% endfor %}
- {% endif %}
- </p>
- {% if form.recaptcha_challenge_field %}
- {% autoescape off %}
- <p {% if form.recaptcha_response_fiel.errors %}class="error"{% endif %}>
- {{ form.recaptcha_challenge_field }}
- {% if form.recaptcha_theme == "custom" %}
- <div id="recaptcha_widget" style="display:none">
-
- <div id="recaptcha_image"></div>
- <span class="recaptcha_only_if_incorrect_sol error_msg">{% trans "Incorrect please try again" %}</span>
-
- <label>
- <span class="recaptcha_only_if_image">{% trans "Enter the words above:" %}</span>
- <span class="recaptcha_only_if_audio">{% trans "Enter the numbers you hear:" %}</span>
- </label>
-
- <input type="text" id="recaptcha_response_field" name="recaptcha_response_field" />
-
- <div><a href="javascript:Recaptcha.reload()">{% trans "Get another CAPTCHA" %}</a></div>
- <div class="recaptcha_only_if_image"><a href="javascript:Recaptcha.switch_type('audio')">{% trans "Get an audio CAPTCHA" %}</a></div>
- <div class="recaptcha_only_if_audio"><a href="javascript:Recaptcha.switch_type('image')">{% trans "Get an image CAPTCHA" %}</a></div>
-
- <div><a href="javascript:Recaptcha.showhelp()">{% trans "Help" %}</a>
-
- </div>
- {% endif %}
-
- {{ form.recaptcha_response_field }}
- {% if form.recaptcha_response_field.errors %}
- {% for error in form.recaptcha_response_field.errors %}
- <span class="error_msg">{% trans error %}</span>
- {% endfor %}
- {% endif %}
- </p>
- {% endautoescape %}
- {% endif %}
-
- {% if form.accept_terms %}
- {% autoescape off %}
- {{ form.accept_terms }}
- {% endautoescape %}
- {% endif %}
- <p>
- <input type="submit" {% if contact.submit %}value="{{ contact.submit }}"{% endif %}>
- </p>
-
- {% csrf_token %}
- </form>
-
-{% else %}
- <h2>{{ contact.thanks }}</h2>
-{% endif %}
View
1 cmsplugin_contact/templates/cmsplugin_contact/email.txt
@@ -1 +0,0 @@
-{{ data.content }}
View
2 setup.py
@@ -6,7 +6,7 @@
description='Contact form plugin for Django CMS with spam protection and i18n',
author='Maccesch',
author_email='maccesch@gmail.com',
- url='http://github.com/maccesch/cmsplugin_contact',
+ url='http://github.com/maccesch/cmsplugin-contact',
packages=find_packages(),
keywords='contact form django cms django-cms spam protection email',
classifiers=[

0 comments on commit 7639f18

Please sign in to comment.