Commits

Kai Diefenbach committed f0be4d7

Intial import

Comments (0)

Files changed (11)

+syntax: glob
+*.pyc
+*.pyo
+*.DS_Store 
+*.installed.cfg
+*build/
+*dist/
+*.egg-info/
+Introduction
+============
+
+lfc_contact_form is a contact form for LFC.

lfc_contact_form/__init__.py

+# django imports
+from django.utils.translation import ugettext_lazy as _
+
+# lfc imports
+from lfc.utils.registration import register_content_type
+from lfc.utils.registration import unregister_content_type
+from lfc.utils.registration import register_sub_type
+from lfc.utils.registration import register_template
+from lfc.utils.registration import unregister_template
+
+# portlets imports
+from portlets.utils import register_portlet
+from portlets.utils import unregister_portlet
+
+# lfc_contact_form import
+from lfc_contact_form.models import ContactForm
+
+name = "Contact Form"
+description = _(u"Contact form for LFC")
+
+def install():
+    """Installs the lfc_contact_form application.
+    """
+    # Register Templates
+    register_template(name="Contact Form", path="lfc_contact_form/contact_form.html")
+
+    # Register objects
+    register_content_type(ContactForm, name = "Contact", templates=["Contact Form"], default_template="Contact Form", global_addable=True, workflow="Portal")
+    
+def uninstall():
+    """Uninstalls the lfc_contact_form application.
+    """
+    # unregister your stuff here
+    unregister_content_type("ContactForm")
+
+    # Unregister template
+    unregister_template("Contact Form")

lfc_contact_form/admin.py

+from django.contrib import admin
+
+# Add your admin site registrations here, eg.
+# from lfc_contact_form.models import Author
+# admin.site.register(Author)

lfc_contact_form/forms.py

+from django import forms
+from django.utils.translation import ugettext_lazy as _
+
+class ContactForm(forms.Form):
+    name = forms.CharField(label=_(u'Your name'))
+    email = forms.EmailField(label=_(u'Your email address'))
+    message = forms.CharField(label=_(u'Your message'), widget=forms.Textarea())

lfc_contact_form/models.py

+# django imports
+from django import forms
+from django.db import models
+
+# django imports
+from django import forms
+from django import template
+from django.conf import settings
+from django.contrib.auth.models import User
+from django.contrib.contenttypes import generic
+from django.contrib.contenttypes.models import ContentType
+from django.core.cache import cache
+from django.core.urlresolvers import reverse
+from django.db import models
+from django.db.models.signals import post_syncdb
+from django.template import RequestContext
+from django.template.loader import render_to_string
+from django.utils import translation
+from django.utils.translation import ugettext_lazy as _
+
+# lfc imports
+import lfc.utils
+from lfc.models import BaseContent
+
+# lfc_contact_form imports
+from lfc_contact_form.forms import ContactForm as DjangoContactForm
+
+
+class ContactForm(BaseContent):
+    """Contact form for LFC.
+    """
+    text = models.TextField(blank=True)
+    thank_you_message = models.TextField(blank=True)
+
+    def edit_form(self, **kwargs):
+        """Returns the add/edit form of the Blog
+        """
+        return ContactFormForm(**kwargs)
+
+    def render(self, request):
+        """Renders the content of the contact form.
+        """
+        render_context = self.get_render_context(request)
+
+        if request.method == "POST":
+            form = DjangoContactForm(data=request.POST)
+            if form.is_valid():
+                sent = True
+                # send mail
+            else:
+                sent = False
+        else:
+            form = DjangoContactForm()
+            sent = False
+
+        render_context["sent"] = sent
+        render_context["form"] = form
+
+        return self.render_to_string(render_context)
+
+class ContactFormForm(forms.ModelForm):
+    """The add/edit form of the ContactForm content object.
+    """
+    class Meta:
+        model = ContactForm
+        fields = ("title", "display_title", "slug", "description", "text", "thank_you_message")

lfc_contact_form/templates/lfc_contact_form/contact_form.html

+{% extends "lfc/base.html" %}
+{% load portlets_tags %}
+
+{% block section %}contact-form{% endblock %}
+
+{% block content %}
+    {% if self.display_title %}
+        <h1 class="first-heading">{{ self.title }}</h1>
+    {% endif %}
+
+    <div>
+        {{ self.text|safe }}
+    </div>
+    <div>
+        {% if sent %}
+            {{ self.thank_you|safe }}
+        {% else %}
+            <form method="post">
+                {% include "lfc/lfc_form.html" %}
+                <input type="submit" />
+            </form>
+        {% endif %}
+    </div>
+{% endblock %}

lfc_contact_form/tests.py

+from django.test import TestCase
+
+class AppTestCase(TestCase):
+    """Populate this class with unit tests for your application.
+    """
+    def testApp():
+        pass

lfc_contact_form/urls.py

+from django.conf.urls.defaults import *
+
+# URL patterns for lfc_contact_form
+
+urlpatterns = patterns('lfc_contact_form.views',
+  # Add url patterns here
+)

lfc_contact_form/views.py

+# Create your views here.
+from setuptools import setup, find_packages
+import os
+
+version = '1.0'
+
+here = os.path.abspath(os.path.dirname(__file__))
+README = open(os.path.join(here, 'README.txt')).read()
+
+setup(name='lfc-contact-form',
+      version=version,
+      description='Contact Form or LFC',
+      long_description=README,
+      classifiers=[
+          'Development Status :: 4 - Beta',
+          'Environment :: Web Environment',
+          'Framework :: Django',
+          'License :: OSI Approved :: BSD License',
+          'Operating System :: OS Independent',
+          'Programming Language :: Python',
+      ],
+      keywords='django lfc contact form',
+      author='Kai Diefenbach',
+      author_email='kai.diefenbach@iqpp.de',
+      url='http://www.iqpp.de',
+      license='BSD',
+      packages=find_packages(exclude=['ez_setup']),
+      include_package_data=True,
+      zip_safe=False,
+      install_requires=[
+        'setuptools',
+      ],
+      )
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.