add contact app + konkurs contact form
[wolnelektury.git] / src / contact / __init__.py
1 # -*- coding: utf-8 -*-
2 """
3 Generic app for creating contact forms.
4
5 0. Add 'contact' to your INSTALLED_APPS and include 'contact.urls' somewhere
6 in your urls.py, like: 
7     url(r'^contact/', 
8         include('contact.urls'))
9
10 1. Migrate.
11
12 2. Create somewhere in your project a module with some subclasses of
13 contact.forms.ContactForm, specyfing form_tag and some fields in each.
14
15 3. Set CONTACT_FORMS_MODULE in your settings to point to the module.
16
17 4. Link to the form with {% url 'contact_form' form_tag %}.
18
19 5. Optionally override some templates in form-specific template directories
20 (/contact/<form_tag>/...).
21
22 6. Receive submitted forms by email and read them in admin.
23
24
25 Example:
26 ========
27
28 settings.py:
29     CONTACT_FORMS_MODULE = 'myproject.contact_forms'
30
31 myproject/contact_forms.py:
32     from django import forms
33     from contact.forms import ContactForm
34     from django.utils.translation import ugettext_lazy as _
35
36     class RegistrationForm(ContactForm):
37         form_tag = 'register'
38         name = forms.CharField(label=_('Name'), max_length=128)
39         presentation = forms.FileField(label=_('Presentation'))
40
41 some_template.html:
42     {% url 'contact:form' 'register' %}
43
44 """
45
46 from fnpdjango.utils.app import AppSettings
47
48
49 class Settings(AppSettings):
50     FORMS_MODULE = "contact_forms"
51
52
53 app_settings = Settings('CONTACT')