TailorDev Contact Documentation

Similar documents
Django MFA Documentation

django simple pagination Documentation

alphafilter Documentation

django-messages Documentation

DJOAuth2 Documentation

MIT AITI Python Software Development Lab DJ1:

django-contact-form Documentation

django-cas Documentation

django-stored-messages Documentation

django-avatar Documentation

django-xross Documentation

django-responsive2 Documentation

django-avatar Documentation

django-oscar-paypal Documentation

Django Extra Views Documentation

A Sample Approach to your Project

django-private-chat Documentation

django-amp-tools Documentation Release latest

django-notifier Documentation

django-baton Documentation

SagePay payment gateway package for django-oscar Documentation

django-dajax Documentation

django-intranet Documentation

South Africa Templates.

Nuit Documentation. Release Ben Cardy

Django urls Django Girls Tutorial

django-allauth-2fa Documentation

Webdev: Building Django Apps. Ryan Fox Andrew Glassman MKE Python

django-inplaceedit Documentation

django-baton Documentation

wagtailmenus Documentation

Gargoyle Documentation

django-geoip Documentation

CIS192 Python Programming

wagtail-robots Documentation

django-renderit Documentation

Django AdminLTE 2 Documentation

Bricks Documentation. Release 1.0. Germano Guerrini

Django File Picker Documentation

django-cms-search Documentation

Djam Documentation. Release Participatory Culture Foundation

Bambu API Documentation

Django PAM Documentation

django_podcasting Documentation

kiss.py Documentation

django-mama-cas Documentation

Django: Views, Templates, and Sessions

django-revproxy Documentation

wagtailmenus Documentation

kaleo Documentation Release 1.5 Eldarion

django-ad-code Documentation

django-facetools Documentation

Django Forme Documentation

Django-CSP Documentation

MapEntity Documentation

Django_template3d Documentation

Django Part II SPARCS 11 undead. Greatly Inspired by SPARCS 10 hodduc

Django OAuth Toolkit Documentation

Django Wordpress API Documentation

django-oauth2-provider Documentation

LECTURE 14. Web Frameworks

django-bootstrap3 Documentation

Release Joris Beckers

Django Generic Ratings Documentation

Django IPRestrict Documentation

Quick housekeeping Last Two Homeworks Extra Credit for demoing project prototypes Reminder about Project Deadlines/specifics Class on April 12th Resul

django-sticky-uploads Documentation

django-intercom Documentation

django-embed-video Documentation

webkitpony Documentation

Building a Django Twilio Programmable Chat Application

HOW TO FLASK. And a very short intro to web development and databases

django cms Documentation

django-osm-field Release 0.3.1

Django. Jinja2. Aymeric Augustin DjangoCong 2016

django-dajaxice Documentation

django-teamwork Documentation

django-openid Documentation

django-embed-video Documentation

django-templation Documentation

django-simple-sms Documentation

CIS192 Python Programming

django-generic-filters Documentation

Django EL(Endless) Pagination Documentation

django-users2 Documentation

django-flickr Documentation

Django File Picker Documentation

open-helpdesk Documentation

micawber Documentation

Easy-select2 Documentation

django-sendgrid-events Documentation

Django Debug Toolbar Documentation

django-dynamic-db-router Documentation

Without Django. applying django principles to non django projects

Django with Python Course Catalog

fragapy Documentation

mozilla-django-oidc Documentation

Asynchronous WebSockets using Django

django-subdomains Documentation

Tangent MicroServices Documentation

Transcription:

TailorDev Contact Documentation Release 0.3 Julien Maupetit November 06, 2013

Contents 1 Django TailorDev Contact 3 1.1 Dependencies............................................... 3 1.2 Installation................................................ 3 1.3 Configuration............................................... 3 1.4 Urls.................................................... 4 1.5 Templates................................................. 5 1.6 Running the Tests............................................ 6 i

ii

TailorDev Contact Documentation, Release 0.3 Contents: Contents 1

TailorDev Contact Documentation, Release 0.3 2 Contents

CHAPTER 1 Django TailorDev Contact A customizable contact form for your django projects. 1.1 Dependencies For now, Django>=1.5 is the only dependency for this project to run on production, with python>=2.6. Currently, this application is not compatible with python 3.3. We are working on it. 1.2 Installation To install TailorDev Contact, use pip: $ pip install django-td-contact If you intend to test or improve this application, first clone this repository and install the local dependencies: $ pip install -r requirements/local.txt 1.3 Configuration Add td_contact and its dependencies to your INSTALLED_APPS: INSTALLED_APPS = (... td_contact,... ) Add td_contact urls to your project url patterns: urlpatterns = patterns(,... url(r ^contact/, include( td_contact.urls )),... ) 3

TailorDev Contact Documentation, Release 0.3 Set your td_contact rules in your settings.py, by adding something like: # Contact form TD_CONTACT_FORM_RULES = { default : { prefix : "[Foo:contact]", subject : "General informations", to : ( contact@foo.com, ceo@foo.com ), }, partner : { prefix : "[Foo:partner]", subject : "Partnership opportunity", to : ( partner@foo.com, ), }, jobs : { prefix : "[Foo:jobs]", subject : "Job opportunity", to : ( jobs@foo.com, ), }, } TD_CONTACT_FORM_RULES is a simple dictionary where each key defines a new rule. Each rule is also a dictionary defining the email prefix & subject and the recipient list. Important note : when a contact form has been successfully filled, the user is redirected to the website home page. Thereby, we use the django messages framework to inform our user of its request status. Remember to enable messages and add something like the following to your base template DOM: {% if messages %} <ul class="messages"> {% for message in messages %} <li data-alert{% if message.tags %} class="message {{ message.tags }}"{% endif %}> {{ message }} <a href="#" class="close"> </a> </li> {% endfor %} </ul> {% endif %} This example works with the zurb foundation framework. Feel free to adapt this for your favorite framework. 1.4 Urls TailorDev Contact form defines 3 urls you may use in your templates: 1.4.1 contact_form_rule This url has been designed to initialize your form with your own rule, e.g.: {% url contact_form_rule jobs %} 1.4.2 user_contact_form_by_slug and user_contact_form_by_pk Depending on your application, people may want to contact a registered user directly and you want an elegant url to point to. To do so, use the user_contact_form_by_slug in your templates, e.g.: 4 Chapter 1. Django TailorDev Contact

TailorDev Contact Documentation, Release 0.3 {% url user_contact_form_by_slug myuser.slug %} Alternatively, use the user_contact_form_by_id in your templates, like: {% url user_contact_form_by_pk myuser.pk %} 1.4.3 contact_form This base url points to your contact form. Nothing more to add. 1.5 Templates 1.5.1 Using the default templates If you want to use our default templates, feel free to do so. But please note that: You should create a base template to inherit from, visible as _layouts/base.html Your form will appear in a content block Two partial templates must be customized contact/partials/contact_recipient.html and contact/partials/aside.html 1.5.2 Using your own template(s) The template-to-override used to render the form is visible as contact/form.html. The core part of the template may looks like: <div class="form_wrapper"> <h1>{% trans "Contact" %}</h1> {% if recipient %} {% include "contact/partials/contact_recipient.html" %} {% endif %} <form action="" method="post" class="custom"> {% csrf_token %} {% for field in form %} {% if field.is_hidden %} {{ field }} {% else %} <div class="field_wrapper"> <div class="field{% if field.field.required %} required{% endif %}"> <label {% if field.errors %}class="error"{% endif %}>{{ field.label }}</label> {{ field }} {% if field.errors %} <small class="error">{{ field.errors }}</small> {% endif %} </div> </div> {% endif %} {% endfor %} 1.5. Templates 5

TailorDev Contact Documentation, Release 0.3 <button type="submit" />{% trans "Send message" %}</button> </form> </div> 1.6 Running the Tests You can run the tests with via: python setup.py test or: python runtests.py 1.6.1 Code coverage To estimate the project coverage: coverage run --source= td_contact runtests.py coverage report -m 6 Chapter 1. Django TailorDev Contact