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