attachment.file.save(value.name, value)
attachment.save()
+ site = Site.objects.get_current()
dictionary = {
'form_tag': self.form_tag,
- 'site': Site.objects.get_current(),
+ 'site_name': site.name,
+ 'site_domain': site.domain,
'contact': contact,
- 'admin_url': '',
}
context = RequestContext(request)
mail_managers_subject = render_to_string([
'contact/mail_body.txt',
], dictionary, context)
send_mail(mail_subject, mail_body,
- 'no-reply@%s' % dictionary['site'].domain,
+ 'no-reply@%s' % site.domain,
[contact.contact],
fail_silently=True)
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2012-10-08 16:48+0200\n"
-"PO-Revision-Date: 2012-10-08 16:51+0100\n"
+"POT-Creation-Date: 2012-10-10 13:12+0200\n"
+"PO-Revision-Date: 2012-10-10 13:12+0100\n"
"Last-Translator: Radek Czajka <radoslaw.czajka@nowoczesnapolska.org.pl>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"Language: \n"
#: templates/contact/mail_body.txt:2
#: templates/contact/mail_subject.txt:1
#, python-format
-msgid "Thank you for contacting us at %(site.name)s."
-msgstr "Dziękujemy za skontaktowanie się z nami na stronie %(site.name)s."
+msgid "Thank you for contacting us at %(site_name)s."
+msgstr "Dziękujemy za skontaktowanie się z nami na stronie %(site_name)s."
#: templates/contact/mail_body.txt:3
msgid "Your submission has been referred to the project coordinator."
{% block contact_form_description %}
{% endblock %}
- <form method="POST" action="." enctype="multipart/form-data">
+ <form method="POST" action="." enctype="multipart/form-data" class="submit-form">
{% csrf_token %}
<table>
{{ form.as_table }}
{% load i18n %}
-{% blocktrans %}Thank you for contacting us at {{ site.name }}.{% endblocktrans %}
+{% blocktrans %}Thank you for contacting us at {{ site_name }}.{% endblocktrans %}
{% trans "Your submission has been referred to the project coordinator." %}
--
-Wypełniono formularz {{ form_tag }} na stronie {{ site.name }}.
+{% load url from future %}Wypełniono formularz {{ form_tag }} na stronie {{ site_name }}.
-http://{{ site.domain }}{{ admin_url }}
+http://{{ site_domain }}{% url 'admin:contact_contact_change' contact.pk %}
{{ contact.body }}
-Wypełniono formularz {{ form_tag }} na stronie {{ site.name }}.
\ No newline at end of file
+Wypełniono formularz {{ form_tag }} na stronie {{ site_name }}.
\ No newline at end of file
-{% load i18n %}{% blocktrans %}Thank you for contacting us at {{ site.name }}.{% endblocktrans %}
\ No newline at end of file
+{% load i18n %}{% blocktrans %}Thank you for contacting us at {{ site_name }}.{% endblocktrans %}
\ No newline at end of file
--- /dev/null
+{% load i18n fnp_lang %}
+{% for lc, ln in languages %}
+ {% if lc != request.LANGUAGE_CODE %}
+ <a href="{{ request|get_here_url:lc }}">{{ lc }}</a>
+ {% endif %}
+{% endfor %}
\ No newline at end of file
--- /dev/null
+from django.conf import settings
+from django.core.urlresolvers import resolve, reverse
+from django import template
+from django.utils import translation
+from ..utils.views import get_current_object
+
+register = template.Library()
+
+
+@register.inclusion_tag('fnpdjango/lang_switcher.html', takes_context=True)
+def lang_switcher(context):
+ """Context-aware language switcher.
+
+ Use ..utils.views.set_current_object to provide the context.
+ """
+ request = context['request']
+ obj = get_current_object(request)
+ languages = settings.LANGUAGES
+ if hasattr(obj, 'get_available_languages'):
+ available_languages = set(obj.get_available_languages())
+ languages = [lang for lang in languages if lang[0] in available_languages]
+ return {
+ 'request': request,
+ 'languages': languages,
+ }
+
+
+@register.filter
+def get_here_url(request, lang):
+ obj = get_current_object(request, for_url=True)
+ if hasattr(obj, 'get_absolute_url'):
+ with translation.override(lang):
+ url = obj.get_absolute_url()
+ else:
+ match = resolve(request.get_full_path())
+ view = match.url_name
+ if view is None:
+ view = match.func
+ if lang is None:
+ lang = translation.get_language()
+ with translation.override(lang):
+ url = reverse(view, args=match.args, kwargs=match.kwargs)
+ return url
+
+
return response
else:
return HttpResponseRedirect(url)
+
+
+def set_current_object(request, obj, in_url=True):
+ request.CURRENT_OBJECT = obj
+ request.CURRENT_OBJECT_IN_URL = in_url
+
+
+def get_current_object(request, for_url=False):
+ if for_url and not getattr(request, 'CURRENT_OBJECT_IN_URL', True):
+ return None
+ return getattr(request, 'CURRENT_OBJECT', None)
--- /dev/null
+from fnpdjango.utils.app import AppSettings
+
+
+class Settings(AppSettings):
+ MODULE = 'menu_items'
+
+
+app_settings = Settings('MENU')
--- /dev/null
+class MenuItem(object):
+ html_id = None
+
+ def __init__(self, url, title, html_id=None):
+ self.url = url
+ self.title = title
+ self.html_id = html_id
+
+ def is_active(self, request, value):
+ return request.get_full_path() == str(self.url)
+
+ def check_active(self, request, value):
+ self.active = self.is_active(request, value)
+
+ def get_url(self):
+ return self.url
+
+ def get_title(self):
+ return self.title
+
+
+class ObjectMenuItem(MenuItem):
+ """Menu item corresponding to an object.
+
+ If no url or title is provided, get_absolute_url and __unicode__ are used.
+ You can also provide a reverse lookup dictionary, as in {model: field_name}.
+ """
+ def __init__(self, obj, url=None, rev_lookups=None, title=None, html_id=None):
+ super(ObjectMenuItem, self).__init__(url=url, title=title, html_id=html_id)
+ self.obj = obj
+ self.rev_lookups = rev_lookups
+
+ def get_title(self):
+ return self.title or unicode(self.obj)
+
+ @property
+ def get_url(self):
+ return self.url or self.get_obj().get_absolute_url()
+
+ def is_active(self, request, value):
+ if value == self.obj:
+ return True
+ if self.rev_lookups:
+ for model, manager in self.rev_lookups.items():
+ if (isinstance(value, model) and
+ self.obj in getattr(value, manager).all()):
+ return True
+ return False
+
+
+class ModelMenuItem(MenuItem):
+ """Menu item corresponding to a model, optionally filtered by some fields."""
+
+ def __init__(self, model, url, field_lookups=None, title=None, html_id=None):
+ if title is None:
+ title = unicode(model)
+ super(ModelMenuItem, self).__init__(title=title, url=url, html_id=html_id)
+ self.model = model
+ self.field_lookups = field_lookups
+
+ def is_active(self, request, value):
+ if value == self.model and not self.field_lookups:
+ return True
+ if isinstance(value, self.model) and self.field_lookups:
+ lookups_ok = True
+ for field, lookup in self.field_lookups.items():
+ if getattr(value, field) != lookup:
+ lookups_ok = False
+ if lookups_ok:
+ return True
+ return False
+
+ def get_title(self):
+ return self.title or unicode(self.model)
--- /dev/null
+import importlib
+from . import app_settings
+
+items = importlib.import_module(app_settings.MODULE).ITEMS
--- /dev/null
+{% load i18n %}
+{% for item in items %}
+ <li{% if item.active %}
+ class="active"{%endif %} {% if item.html_id %}
+ id="{{ item.html_id}}"{% endif %}>
+ <a href="{{ item.get_url }}">{{ item.get_title }}</a></li>
+{% endfor %}
--- /dev/null
+from django import template
+from fnpdjango.utils.views import get_current_object
+from ..models import items
+
+register = template.Library()
+
+
+@register.inclusion_tag('menu/menu.html', takes_context=True)
+def main_menu(context):
+ request = context['request']
+ obj = get_current_object(request)
+ for item in items:
+ item.check_active(request, obj)
+ return {'items': items}
)
LAST_COMMENTS = 5
- MENU = []
+ MAIN_PAGE_ENTRY = None
TYPES_DICT = None
def _more_TYPES_DICT(self, value):
{% endspaceless %}{% endblock %}
-{% block "main_menu" %}
- {% main_menu 'object' entry %}
-{% endblock "main_menu" %}
-
-
{% block "body" %}
{% if not entry.published %}
{% load migdal_tags %}
-{% block "main_menu" %}
- {% if category %}
- {% main_menu 'object' category %}
- {% elif entry_type %}
- {% main_menu 'entry_type' entry_type.db %}
- {% else %}
- {{ block.super }}
- {% endif %}
-{% endblock "main_menu" %}
-
-
{% block "body" %}
{% if category %}
+++ /dev/null
-{% load i18n %}
-{% for item in items %}
- <li{% if item.active %}
- class="active"{%endif %} {% if item.html_id %}
- id="{{ item.html_id}}"{% endif %}>
- <a href="{{ item.url }}">{{ item.title }}</a></li>
-{% endfor %}
{% load url from future %}
{% load i18n %}
{% load migdal_tags %}
-{% load events_tags %}
+{#% load events_tags %#}
{% block "body" %}
{% for result in page.object_list %}
{% if result.model_name == "entry" %}
{% entry_short result.object %}
- {% elif result.model_name == "event" %}
- {% event_short result.object %}
+ {#% elif result.model_name == "event" %#}
+ {#% event_short result.object %#}
{% endif %}
{% empty %}
<p>{% trans "No results found." %}</p>
#
from django_comments_xtd.models import XtdComment
from django.contrib import comments
-from django.core.urlresolvers import reverse
from django import template
from migdal import app_settings
from migdal.models import Category, Entry
'form': comments.get_form()(entry),
'next': entry.get_absolute_url(),
}
-
-
-class MenuItem(object):
- html_id = None
-
- def __init__(self, title, url, html_id=None):
- self.title = title
- self.url = url
- self.html_id = html_id
-
- def check_active(self, chooser, value):
- self.active = chooser == 'url' and value == self.url
-
-
-class ModelMenuItem(object):
- def __init__(self, obj, title=None, html_id=None):
- self.obj = obj
- self.title = title or unicode(obj)
- self.url = obj.get_absolute_url()
- self.html_id = html_id
-
- def check_active(self, chooser, value):
- self.active = (chooser == 'object' and value == self.obj or
- chooser == 'objects' and self.obj in value)
-
-class CategoryMenuItem(ModelMenuItem):
- def check_active(self, chooser, value):
- super(CategoryMenuItem, self).check_active(chooser, value)
- self.active = (self.active or
- (chooser == 'object' and isinstance(value, Entry) and
- self.obj in value.categories.all()))
-
-
-class EntryTypeMenuItem(object):
- def __init__(self, title, type_, html_id=None):
- self.type = type_
- self.title = title
- self.url = reverse('migdal_entry_list_%s' % type_)
- self.html_id = html_id
-
- def check_active(self, chooser, value):
- self.active = (chooser == 'object' and isinstance(value, Entry)
- and value.type == self.type or
- chooser == 'entry_type' and value == self.type)
-
-@register.inclusion_tag('migdal/menu.html', takes_context=True)
-def main_menu(context, chooser=None, value=None):
- items = [
- #ModelMenuItem(Entry.objects.get(slug_pl='o-nas')),
- #MenuItem(_(u'Events'), reverse('events')),
- ]
- # TODO: context-aware language switcher
- if context['request'].LANGUAGE_CODE == 'pl':
- items.append(MenuItem(u'en', '/en/', html_id='item-lang'))
- else:
- items.append(MenuItem(u'pl', '/', html_id='item-lang'))
- for item in items:
- item.check_active(chooser, value)
- return {'items': items}
urlpatterns = i18n_patterns('',
# main page
- url(r'^$', 'migdal.views.entry_list', name='migdal_main'),
+ url(r'^$', 'migdal.views.main', name='migdal_main'),
url(r'^rss.xml$', feeds.EntriesFeed(), name='migdal_main_feed'),
# submit new entry
url(string_concat(r'^', _('submit'), r'/$'), 'migdal.views.submit', name='migdal_submit'),
#
from django.shortcuts import get_object_or_404, render, redirect
from django.utils.translation import get_language
+from fnpdjango.utils.views import set_current_object
from migdal import api
from migdal.forms import get_submit_form
from migdal.models import Category, Entry
from haystack.views import SearchView
+def main(request):
+ if app_settings.MAIN_PAGE_ENTRY is not None:
+ main_entry = Entry.objects.get(**app_settings.MAIN_PAGE_ENTRY)
+ return entry(request, entry=main_entry)
+ else:
+ return entry_list(request)
+
+
def entry_list(request, type_db=None, category_slug=None):
lang = request.LANGUAGE_CODE
templates = ["migdal/entry/entry_list.html"]
else:
category = None
+ if category:
+ set_current_object(request, category)
+
promobox = 5 if entry_type is None and category is None else None
object_list = api.entry_list(entry_type=entry_type, category=category,
})
-def entry(request, type_db, slug):
- lang = request.LANGUAGE_CODE
- args = {'type': type_db, 'slug_%s' % lang: slug}
- if not request.user.has_perm('migdal.change_entry'):
- args['published_%s' % lang] = True
- entry = get_object_or_404(Entry, **args)
+def entry(request, type_db=None, slug=None, entry=None):
+ if entry is None:
+ lang = request.LANGUAGE_CODE
+ args = {'type': type_db, 'slug_%s' % lang: slug}
+ entry = get_object_or_404(Entry, **args)
+ if request.user.has_perm('migdal.change_entry') or not entry.published:
+ raise Http404
+ set_current_object(request, entry, in_url=slug is not None)
templates = ["migdal/entry/entry_detail.html"]
- if type_db is not None:
+ if entry.type is not None:
templates = ["migdal/entry/%s/entry_detail.html" % type_db] + templates
return render(request, templates, {'entry': entry})
class RegistrationForm(ContactForm):
form_tag = 'register'
name = forms.CharField(label=_('Name'), max_length=128)
- organization = forms.CharField(label=_('Organization'), max_length=128)
- summary = forms.CharField(label=_('Summary'), widget=forms.Textarea)
- presentation = forms.FileField(label=_('Presentation'))
+ contact = forms.EmailField(label=_('E-mail'), max_length=128)
+ organization = forms.CharField(label=_('Organization'),
+ max_length=256, required=False)
+ presentation = forms.FileField(label=_('Presentation'),
+ required=False)
+ summary = forms.CharField(label=_('Summary'),
+ widget=forms.Textarea, required=False)
msgstr ""
"Project-Id-Version: prawokultury\n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2012-08-30 11:15+0200\n"
-"PO-Revision-Date: 2012-08-30 11:15+0100\n"
+"POT-Creation-Date: 2012-10-10 12:41+0200\n"
+"PO-Revision-Date: 2012-10-10 12:42+0100\n"
"Last-Translator: Radek Czajka <radoslaw.czajka@nowoczesnapolska.org.pl>\n"
"Language-Team: FNP <fundacja@nowoczesnapolska.org.pl>\n"
"Language: \n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=3; plural=(n==1 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2)\n"
-#: urls.py:23
-msgid "events"
-msgstr "wydarzenia"
+#: contact_forms.py:8
+msgid "Name"
+msgstr "Imię i nazwisko"
-#: templates/404.html:5
-msgid "Page not found."
-msgstr "Strona nie znaleziona."
+#: contact_forms.py:9
+msgid "Organization"
+msgstr "Organizacja"
+
+#: contact_forms.py:10
+msgid "Summary"
+msgstr "Podsumowanie prezentacji"
+
+#: contact_forms.py:11
+msgid "Presentation"
+msgstr "Prezentacja"
-#: templates/404.html:10
+#: menu_items.py:22
+msgid "Form"
+msgstr "Formularz"
+
+#: templates/404.html:5
+#: templates/404.html.py:10
msgid "Page not found"
msgstr "Strona nie znaleziona"
msgid "The page you were looking for doesn't exist."
msgstr "Strona, której szukasz, nie istnieje."
-#: templates/base.html:8
-#: templates/base.html.py:13
-#: templates/base.html:14
-#: templates/base.html.py:25
-#: templates/base.html:73
-msgid "Culture's right"
-msgstr "Prawo kultury"
+#: templates/base.html:26
+msgid "CopyCamp"
+msgstr "CopyCamp"
-#: templates/base.html:30
-msgid "Organizer"
-msgstr "Organizator"
+#: templates/base.html:41
+msgid "Search"
+msgstr "Szukaj"
-#: templates/base.html:33
-msgid "Modern Poland Foundation"
-msgstr "Fundacja Nowoczesna Polska"
+#: templates/base.html:84
+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/base.html:35
-msgid "Sponsor"
-msgstr "Wspierane przez"
+#: templates/contact/register/form.html:4
+msgid "Registration form"
+msgstr "Formularz rejestracyjny"
-#: templates/base.html:38
-msgid "Trust for Civil Society in Central and Eastern Europe"
-msgstr ""
+#~ msgid "events"
+#~ msgstr "wydarzenia"
-#: templates/base.html:47
-msgid "Search"
-msgstr "Szukaj"
+#~ msgid "Page not found."
+#~ msgstr "Strona nie znaleziona."
-#: templates/base.html:62
-msgid "Upcoming events"
-msgstr "Nadchodzące wydarzenia"
+#~ msgid "Culture's right"
+#~ msgstr "Prawo kultury"
-#: templates/base.html:77
-msgid "Latest comments"
-msgstr "Ostatnie komentarze"
+#~ msgid "Modern Poland Foundation"
+#~ msgstr "Fundacja Nowoczesna Polska"
-#: templates/base.html:105
-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>."
+#~ msgid "Sponsor"
+#~ msgstr "Wspierane przez"
+
+#~ msgid "Upcoming events"
+#~ msgstr "Nadchodzące wydarzenia"
+
+#~ msgid "Latest comments"
+#~ msgstr "Ostatnie komentarze"
+
+#~ msgid "Share on Facebook"
+#~ msgstr "Podziel się na Facebooku"
+
+#~ msgid "Share on Google+"
+#~ msgstr "Podziel się na Google+"
+
+#~ msgid "Share on Twitter"
+#~ msgstr "Podziel się na Twitterze"
+
+#~ msgid "Share on NK.pl"
+#~ msgstr "Podziel się na NK.pl"
+
+#~ msgid "next"
+#~ msgstr "następne"
-#: templates/share.html:5
-#: templates/share.html.py:7
-msgid "Share on Facebook"
-msgstr "Podziel się na Facebooku"
-
-#: templates/share.html:10
-#: templates/share.html.py:12
-msgid "Share on Google+"
-msgstr "Podziel się na Google+"
-
-#: templates/share.html:15
-#: templates/share.html.py:17
-msgid "Share on Twitter"
-msgstr "Podziel się na Twitterze"
-
-#: templates/share.html:20
-#: templates/share.html.py:22
-msgid "Share on NK.pl"
-msgstr "Podziel się na NK.pl"
-
-#: templates/prevnext/next.html:13
-msgid "next"
-msgstr "następne"
-
-#: templates/prevnext/previous.html:13
-msgid "previous"
-msgstr "poprzednie"
+#~ msgid "previous"
+#~ msgstr "poprzednie"
#~ msgid "About us"
#~ msgstr "O nas"
--- /dev/null
+from migdal.models import Entry
+from menu.helpers import ObjectMenuItem, MenuItem
+from django.core.urlresolvers import reverse_lazy
+from django.utils.translation import ugettext_lazy as _
+
+
+ITEMS = []
+
+def add_entry(**qs):
+ try:
+ entry = Entry.objects.get(**qs)
+ except Entry.DoesNotExist:
+ return
+ if not entry.published:
+ return
+ ITEMS.append(ObjectMenuItem(entry))
+
+add_entry(slug_pl='co')
+add_entry(slug_pl='gdzie')
+add_entry(slug_pl='program')
+add_entry(slug_pl='media')
+ITEMS.append(MenuItem(reverse_lazy('contact_form', args=['register']), _('Form')))
+add_entry(slug_pl='materialy')
+add_entry(slug_pl='kontakt')
'fnpdjango',
#'events',
+ 'menu',
'migdal',
'contact',
+ 'sponsors',
'gravatar',
'south',
'django.contrib.comments',
)
MIGDAL_TAXONOMIES = ()
+MIGDAL_MAIN_PAGE_ENTRY = {'slug_pl': 'jakies-info'}
CONTACT_FORMS_MODULE = 'prawokultury.contact_forms'
+MENU_MODULE = 'prawokultury.menu_items'
+
# Use Nginx's X-accel when serving files with helpers.serve_file().
# See http://wiki.nginx.org/X-accel
X_ACCEL_REDIRECT = False
+
font-size: 1.1em; }
.submit-form .helptext a {
color: #363A3B; }
+ .submit-form .required label {
+ font-weight: bold; }
+ .submit-form .required label:before {
+ content: '* '; }
color: #363A3B;
}
}
+
+ .required label {
+ font-weight: bold;
+ }
+ .required label:before {
+ content: '* ';
+ }
}
<!DOCTYPE html>
{% load url from future %}
{% load i18n static %}
-{% load fnp_common migdal_tags fnp_share %}
+{% load fnp_common migdal_tags fnp_share fnp_lang menu_tags %}
+{% load sponsor_tags %}
{% load compressed %}
<html prefix="og: http://ogp.me/ns#">
<head>
</div>
<div class="bar-right">
<div class="social">
- <a href="{% url 'contact_form' 'register' %}">register!</a>
{% url 'migdal_main' as main_url %}
{% share main_url "CopyCamp" "big" %}
</div>
<div id="menu-bar">
<div class="bar-right">
- <form id="search-form" method="GET" action="{% url 'search' %}"><input name="q" /><button>
+ <!--form id="search-form" method="GET" action="{% url 'search' %}"><input name="q" /><button>
<img src="{% static "img/search.png" %}" alt="{% trans "Search" %}" />
- </button></form>
+ </button></form-->
</div>
<ul id="menu" class="bar-left">
{% block "main_menu" %}
- {% main_menu 'url' request.get_full_path %}
+ {% main_menu %}
{% endblock %}
+ <li id="item-lang">{% lang_switcher %}</li>
</ul>
<div style="clear: both;"></div>
</div>
<div id="sidebar" class="bar-right">
{% block "sidebar" %}
<div class="sidebar-box">
- (Sponsorzy)
+ {% sponsor_page 'main' %}
</div>
{% endblock %}
</div>
(r'^accounts/login/$', 'django_cas.views.login'),
(r'^accounts/logout/$', 'django_cas.views.logout'),
) + i18n_patterns('',
- url(string_concat(r'^', _('events'), r'/'), include('events.urls')),
+ #url(string_concat(r'^', _('events'), r'/'), include('events.urls')),
url(r'^comments/', include('django_comments_xtd.urls')),
url(r'^contact/', include('contact.urls')),
) + migdal_urlpatterns
-e git+https://github.com/toastdriven/django-haystack.git@master#egg=django-haystack
pysolr
piwik
+
+-e git+https://github.com/fnp/django-sponsors.git@master#egg=django-sponsors