Browse files

Initial commit.

  • Loading branch information...
0 parents commit 89197810be5770bdc059037c68556c52535c7334 Christian Neumann committed Feb 16, 2012
14 .gitignore
@@ -0,0 +1,14 @@
+Kotti.db
+kotti_contactform.egg-info/
+bin/
+develop-eggs/
+dist/
+eggs/
+include/
+lib/
+*.pyc
+*.pt.py
+.coverage
+.installed.cfg
+coverage-*
+nose-*
22 development.ini
@@ -0,0 +1,22 @@
+[app:main]
+use = egg:kotti
+pyramid.reload_templates = true
+pyramid.debug_authorization = false
+pyramid.debug_notfound = false
+pyramid.debug_routematch = false
+pyramid.debug_templates = true
+pyramid.default_locale_name = en
+pyramid.includes = pyramid_debugtoolbar
+ pyramid_tm
+sqlalchemy.url = sqlite:///%(here)s/Kotti.db
+
+kotti.site_title = Kotti with contact forms
+kotti.secret = qwerty
+
+# kotti_calendar specific configuration:
+kotti.configurators = kotti_contactform.kotti_configure
+
+[server:main]
+use = egg:Paste#http
+host = 0.0.0.0
+port = 6543
3 kotti_contactform/__init__.py
@@ -0,0 +1,3 @@
+def kotti_configure(settings):
+ settings['kotti.includes'] += ' kotti_contactform.views'
+ settings['kotti.available_types'] += ' kotti_contactform.resources.ContactForm'
28 kotti_contactform/resources.py
@@ -0,0 +1,28 @@
+from sqlalchemy import Table
+from sqlalchemy import Column
+from sqlalchemy import ForeignKey
+from sqlalchemy import Integer
+from sqlalchemy import String
+from sqlalchemy.orm import mapper
+from kotti import metadata
+from kotti.resources import Content
+
+class ContactForm(Content):
+ type_info = Content.type_info.copy(
+ name=u'ContactForm',
+ add_view=u'add_contactform',
+ addable_to=[u'Document'],
+ )
+
+ def __init__(self, recipient=u"", **kwargs):
+ super(ContactForm, self).__init__(**kwargs)
+ self.recipient = recipient
+
+contactforms = Table(
+ 'contact_forms', metadata,
+ Column('id', Integer, ForeignKey('contents.id'), primary_key=True),
+ Column('recipient', String, nullable=False),
+)
+
+mapper(ContactForm, contactforms, inherits=Content,
+ polymorphic_identity='contact_form')
35 kotti_contactform/templates/contactform-view.pt
@@ -0,0 +1,35 @@
+<!DOCTYPE html>
+<html xmlns="http://www.w3.org/1999/xhtml"
+ xml:lang="en"
+ xmlns:tal="http://xml.zope.org/namespaces/tal"
+ metal:use-macro="api.macro('kotti:templates/view/master.pt')">
+
+ <head tal:omit-tag="" metal:fill-slot="head-more">
+<!-- <link rel="stylesheet" href="${request.static_url('kotti_contactform:static/style.css')}" type="text/css" /> -->
+ <more tal:omit-tag="" metal:define-slot="head"></more>
+ </head>
+
+ <article metal:fill-slot="content" class="contactform-view content">
+ <h1>${api.context.title}</h1>
+ <p class="description">
+ ${api.context.description}
+ </p>
+ <div class="row">
+ <div class="span4">
+ Contact
+ </div>
+ <div class="span4">
+ <form method="POST" action="${request.url}" class="well">
+ <label for="email">Ihre E-Mail Adresse:</label>
+ <input id="email" name="email" type="text" />
+ <label for="subject">Betreff:</label>
+ <input id="subject" name="subjectl" type="text" />
+ <label for="message">Nachricht:</label>
+ <textarea id="message" name="message"></textarea>
+ <br />
+ <button class="btn" name="send-contactform">Senden</button>
+ </form>
+ </div>
+ </div>
+ </article>
+</html>
53 kotti_contactform/views.py
@@ -0,0 +1,53 @@
+import colander
+from kotti.views.edit import ContentSchema
+from kotti.views.edit import generic_edit
+from kotti.views.edit import generic_add
+from kotti.views.util import ensure_view_selector
+from kotti.views.util import template_api
+
+from kotti_contactform.resources import ContactForm
+
+class ContactFormSchema(ContentSchema):
+ recipient = colander.SchemaNode(colander.String())
+
+@ensure_view_selector
+def edit_contactform(context, request):
+ return generic_edit(context, request, ContactFormSchema())
+
+def add_contactform(context, request):
+ return generic_add(context, request, ContactFormSchema(), ContactForm, u'contactform')
+
+def view_contactform(context, request):
+ return {
+ 'api': template_api(context, request),
+ }
+
+def includeme_edit(config):
+ config.add_view(
+ edit_contactform,
+ context=ContactForm,
+ name='edit',
+ permission='edit',
+ renderer='kotti:templates/edit/node.pt',
+ )
+
+ config.add_view(
+ add_contactform,
+ name=ContactForm.type_info.add_view,
+ permission='add',
+ renderer='kotti:templates/edit/node.pt',
+ )
+
+def includeme_view(config):
+ config.add_view(
+ view_contactform,
+ context=ContactForm,
+ name='view',
+ permission='view',
+ renderer='templates/contactform-view.pt',
+ )
+ config.add_static_view('static-kotti_contactform', 'kotti_contactform:static')
+
+def includeme(config):
+ includeme_edit(config)
+ includeme_view(config)
3 setup.cfg
@@ -0,0 +1,3 @@
+[egg_info]
+tag_build = dev
+tag_svn_revision = true
34 setup.py
@@ -0,0 +1,34 @@
+from setuptools import setup, find_packages
+import sys, os
+
+version = '0.1'
+
+setup(name='kotti_contactform',
+ version=version,
+ description="Simple contact form for Kotti sites",
+ long_description="""\
+This is an extension to Kotti that allows to add simple contact forms to your website.""",
+ classifiers=[
+ "Development Status :: 3 - Alpha",
+ "Programming Language :: Python",
+ "Framework :: Pylons",
+ "Topic :: Internet :: WWW/HTTP",
+ "Topic :: Internet :: WWW/HTTP :: Dynamic Content",
+ "Topic :: Internet :: WWW/HTTP :: WSGI :: Application",
+ "License :: OSI Approved :: BSD License",
+ ],
+ keywords='kotti contact form',
+ author='Christian Neumann',
+ author_email='christian@datenkarussell.de',
+ url='http://pypi.python.org/pypi/kotti_contactform',
+ license='BSD License',
+ packages=find_packages(exclude=['ez_setup', 'examples', 'tests']),
+ include_package_data=True,
+ zip_safe=False,
+ install_requires=[
+ 'Kotti',
+ ],
+ entry_points="""
+ # -*- Entry points: -*-
+ """,
+ )

0 comments on commit 8919781

Please sign in to comment.