register = template.Library()
-def do_get_chunk(parser, token):
- # split_contents() knows not to split quoted strings.
- tokens = token.split_contents()
- if len(tokens) < 2 or len(tokens) > 3:
- raise template.TemplateSyntaxError, "%r tag should have either 2 or 3 arguments" % (tokens[0],)
- if len(tokens) == 2:
- tag_name, key = tokens
- cache_time = 0
- if len(tokens) == 3:
- tag_name, key, cache_time = tokens
- # Check to see if the key is properly double/single quoted
- if not (key[0] == key[-1] and key[0] in ('"', "'")):
- raise template.TemplateSyntaxError, "%r tag's argument should be in quotes" % tag_name
- # Send key without quotes and caching time
- return ChunkNode(key[1:-1], cache_time)
-
-
-class ChunkNode(template.Node):
- def __init__(self, key, cache_time=0):
- self.key = key
- self.cache_time = cache_time
-
- def render(self, context):
- try:
- cache_key = 'chunk_' + self.key
- c = cache.get(cache_key)
- if c is None:
- c = Chunk.objects.get(key=self.key)
- cache.set(cache_key, c, int(self.cache_time))
- content = c.content
- except Chunk.DoesNotExist:
- n = Chunk(key=self.key)
- n.save()
- return ''
- return content
-
-register.tag('chunk', do_get_chunk)
+@register.simple_tag
+def chunk(key, cache_time=0):
+ try:
+ cache_key = 'chunk_' + key
+ c = cache.get(cache_key)
+ if c is None:
+ c = Chunk.objects.get(key=key)
+ cache.set(cache_key, c, int(cache_time))
+ content = c.content
+ except Chunk.DoesNotExist:
+ n = Chunk(key=key)
+ n.save()
+ return ''
+ return content
+@register.simple_tag
def attachment(key, cache_time=0):
try:
cache_key = 'attachment_' + key
except Attachment.DoesNotExist:
return ''
-register.simple_tag(attachment)
from django import forms
from django.template.loader import render_to_string
from django.template import RequestContext
+from django.utils.translation import ugettext_lazy as _
from .models import Attachment, Contact
class ContactForm(forms.Form):
"""Subclass and define some fields."""
__metaclass__ = ContactFormMeta
+
+ form_tag = None
+ title = _('Contact form')
+ submit_label = _('Submit')
+
required_css_class = 'required'
contact = forms.CharField(max_length=128)
- form_tag = None
def save(self, request):
body = {}
{% extends "base.html" %}
-{% load i18n %}
+{% load i18n chunks %}
{% block "body" %}
- <h1>{% block contact_form_title %}{% trans "Contact form" %}{% endblock %}</h1>
+ <h1>{% block contact_form_title %}{{ form.title }}{% endblock %}</h1>
<div class="form-info">
{% block contact_form_description %}
+ {% chunk "contact_form "|add:form.form_tag %}
{% endblock %}
</div>
{% csrf_token %}
<table>
{{ form.as_table }}
- <tr><td></td><td><button>{% block contact_form_submit %}{% trans "Submit" %}{% endblock %}</button></td></tr>
+ <tr><td></td><td><button>{% block contact_form_submit %}{{ form.submit_label }}{% endblock %}</button></td></tr>
</table>
</form>
class RegistrationForm(ContactForm):
form_tag = 'register'
+ title = _('Registration form')
+
name = forms.CharField(label=_('Name'), max_length=128)
contact = forms.EmailField(label=_('E-mail'), max_length=128)
organization = forms.CharField(label=_('Organization'),
max_length=256, required=False)
+ title = forms.CharField(label=_('Title of presentation'),
+ max_length=256, required=False)
presentation = forms.FileField(label=_('Presentation'),
required=False)
summary = forms.CharField(label=_('Summary'),
msgstr ""
"Project-Id-Version: prawokultury\n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2012-10-10 12:41+0200\n"
-"PO-Revision-Date: 2012-10-10 12:42+0100\n"
+"POT-Creation-Date: 2012-10-11 12:45+0200\n"
+"PO-Revision-Date: 2012-10-11 13:03+0100\n"
"Last-Translator: Radek Czajka <radoslaw.czajka@nowoczesnapolska.org.pl>\n"
"Language-Team: FNP <fundacja@nowoczesnapolska.org.pl>\n"
"Language: \n"
"Plural-Forms: nplurals=3; plural=(n==1 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2)\n"
#: contact_forms.py:8
+msgid "Registration form"
+msgstr "Formularz rejestracyjny"
+
+#: contact_forms.py:10
msgid "Name"
msgstr "Imię i nazwisko"
-#: contact_forms.py:9
+#: contact_forms.py:11
+msgid "E-mail"
+msgstr "E-mail"
+
+#: contact_forms.py:12
msgid "Organization"
msgstr "Organizacja"
-#: contact_forms.py:10
-msgid "Summary"
-msgstr "Podsumowanie prezentacji"
+#: contact_forms.py:14
+msgid "Title of presentation"
+msgstr "Tytuł prezentacji"
-#: contact_forms.py:11
+#: contact_forms.py:16
msgid "Presentation"
msgstr "Prezentacja"
+#: contact_forms.py:18
+msgid "Summary"
+msgstr "Podsumowanie prezentacji"
+
#: menu_items.py:22
msgid "Form"
msgstr "Formularz"
msgid "CopyCamp"
msgstr "CopyCamp"
-#: templates/base.html:41
+#: templates/base.html:42
msgid "Search"
msgstr "Szukaj"
-#: templates/base.html:84
+#: templates/base.html:85
msgid "If not explicitly stated otherwise, all texts are licensed under the <a href='http://creativecommons.org/licenses/by-sa/3.0/'>Creative Commons Attribution-Share Alike</a> free license."
msgstr "Jeśli nie oznaczono inaczej, wszystkie teksty są objęte wolną licencją <a href='http://creativecommons.org/licenses/by-sa/3.0/deed.pl'>Creative Commons Uznanie autorstwa – Na tych samych warunkach</a>."
-#: templates/contact/register/form.html:4
-msgid "Registration form"
-msgstr "Formularz rejestracyjny"
-
#~ msgid "events"
#~ msgstr "wydarzenia"
+++ /dev/null
-{% extends "contact/form.html" %}
-{% load i18n %}
-{% load chunks %}
-
-{% block contact_form_title %}{% trans "Registration form" %}{% endblock %}
-
-{% block contact_form_description %}
- {% chunk "formularz rejestracyjny" %}
-{% endblock %}