From: Radek Czajka Date: Mon, 5 Nov 2012 12:44:30 +0000 (+0100) Subject: Use outside packages. X-Git-Url: https://git.mdrn.pl/prawokultury.git/commitdiff_plain/d57cb0586003722ceca5c06519d3225686566a78?page=%7B%7B%20page.previous_page_number%20%7D%7D;q=%7B%7B%20query%20%7D%7D Use outside packages. --- diff --git a/events/__init__.py b/events/__init__.py index 9de4ba2..300aa93 100644 --- a/events/__init__.py +++ b/events/__init__.py @@ -1,4 +1,4 @@ -from prawokultury.helpers import AppSettings +from fnpdjango.utils.app import AppSettings class Settings(AppSettings): diff --git a/events/admin.py b/events/admin.py index f15f554..2d85789 100644 --- a/events/admin.py +++ b/events/admin.py @@ -4,8 +4,8 @@ # from django.conf import settings from django.contrib import admin +from fnpdjango.utils.models.translation import translated_fields from events.models import Event -from migdal.helpers import translated_fields class EventAdmin(admin.ModelAdmin): diff --git a/events/models.py b/events/models.py index d147aeb..1151a11 100644 --- a/events/models.py +++ b/events/models.py @@ -6,7 +6,7 @@ from django.conf import settings from django.core.exceptions import ValidationError from django.db import models from django.utils.translation import ugettext_lazy as _, ugettext -from migdal.helpers import add_translatable +from fnpdjango.utils.models.translation import add_translatable class Event(models.Model): diff --git a/events/search_indexes.py b/events/search_indexes.py index 9977957..48d0a1c 100644 --- a/events/search_indexes.py +++ b/events/search_indexes.py @@ -1,8 +1,8 @@ -from django.conf import settings import datetime +from django.conf import settings from haystack import indexes +from fnpdjango.utils.models.translation import add_translatable_index from events.models import Event -from migdal.helpers import add_translatable_index class EventIndex(indexes.RealTimeSearchIndex, indexes.Indexable): diff --git a/events/templates/events/event_list.html b/events/templates/events/event_list.html index 66c5184..b6dd773 100755 --- a/events/templates/events/event_list.html +++ b/events/templates/events/event_list.html @@ -1,6 +1,6 @@ {% extends "base.html" %} {% load url from future %} -{% load i18n pagination_tags prevnext %} +{% load i18n pagination_tags fnp_prevnext %} {% load events_tags %} {% block "body" %} diff --git a/menu/__init__.py b/menu/__init__.py new file mode 100644 index 0000000..d1daaa0 --- /dev/null +++ b/menu/__init__.py @@ -0,0 +1,8 @@ +from fnpdjango.utils.app import AppSettings + + +class Settings(AppSettings): + MODULE = 'menu_items' + + +app_settings = Settings('MENU') diff --git a/menu/helpers.py b/menu/helpers.py new file mode 100755 index 0000000..e94cbd8 --- /dev/null +++ b/menu/helpers.py @@ -0,0 +1,78 @@ +class MenuItem(object): + html_id = None + + def __init__(self, url, title, html_id=None, more_urls=None): + self.url = url + self.title = title + self.html_id = html_id + self.more_urls = more_urls or set() + + def is_active(self, request, value): + url = request.get_full_path() + return url == str(self.url) or url in set(str(url) for url in self.more_urls) + + 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.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 str(self.url) == request.get_full_path(): + 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) diff --git a/menu/models.py b/menu/models.py new file mode 100644 index 0000000..bebdfaa --- /dev/null +++ b/menu/models.py @@ -0,0 +1,4 @@ +import importlib +from . import app_settings + +items = importlib.import_module(app_settings.MODULE).ITEMS diff --git a/menu/templates/menu/menu.html b/menu/templates/menu/menu.html new file mode 100755 index 0000000..56debe5 --- /dev/null +++ b/menu/templates/menu/menu.html @@ -0,0 +1,7 @@ +{% load i18n %} +{% for item in items %} + + {{ item.get_title }} +{% endfor %} diff --git a/menu/templatetags/__init__.py b/menu/templatetags/__init__.py new file mode 100755 index 0000000..e69de29 diff --git a/menu/templatetags/menu_tags.py b/menu/templatetags/menu_tags.py new file mode 100755 index 0000000..7446cb7 --- /dev/null +++ b/menu/templatetags/menu_tags.py @@ -0,0 +1,14 @@ +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} diff --git a/migdal/__init__.py b/migdal/__init__.py deleted file mode 100644 index 05322b4..0000000 --- a/migdal/__init__.py +++ /dev/null @@ -1,49 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Migdal (מִגְדָּל) is a multilingual blog Django app. - -Author: Radek Czajka -""" -from django.conf import settings -from prawokultury.helpers import AppSettings -from django.utils.translation import ugettext_lazy as _ -from migdal.helpers import EntryType - - -class Settings(AppSettings): - # Types of entries: - # (slug, commentable, on main) - TYPES = ( - EntryType('news', _('news'), commentable=True, on_main=True), - EntryType('publications', _('publications'), commentable=False, on_main=False), - EntryType('info', _('info'), commentable=False, on_main=False), - ) - TYPE_SUBMIT = 'news' - TAXONOMIES = ( - ('topics', _('topics')), - ('types', _('types')), - ) - LAST_COMMENTS = 5 - - TYPES_DICT = None - def _more_TYPES_DICT(self, value): - return dict((t.db, t) for t in self.TYPES) - - TYPES_ON_MAIN = None - def _more_TYPES_ON_MAIN(self, value): - return tuple(t.db for t in self.TYPES if t.on_main) - - OBLIGATORY_LANGUAGES = None - def _more_OBLIGATORY_LANGUAGES(self, value): - return value or tuple(lang for lang in settings.LANGUAGES - if lang[0] == settings.LANGUAGE_CODE) - - OPTIONAL_LANGUAGES = None - def _more_OPTIONAL_LANGUAGES(self, value): - return tuple(lang for lang in settings.LANGUAGES - if lang not in self.OBLIGATORY_LANGUAGES) - -app_settings = Settings('MIGDAL') - - - diff --git a/migdal/admin.py b/migdal/admin.py deleted file mode 100644 index d93a782..0000000 --- a/migdal/admin.py +++ /dev/null @@ -1,69 +0,0 @@ -# -*- coding: utf-8 -*- -# This file is part of PrawoKultury, licensed under GNU Affero GPLv3 or later. -# Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information. -# -from django.conf import settings -from django.contrib import admin -from django.utils.translation import ugettext_lazy as _ -from migdal.models import Category, Entry, Attachment -from migdal import app_settings -from migdal.helpers import translated_fields - - -class AttachmentInline(admin.TabularInline): - model = Attachment - readonly_fields = ['url'] - - -class EntryAdmin(admin.ModelAdmin): - date_hierarchy = 'date' - readonly_fields = ('date', 'changed_at') + translated_fields(('published_at',)) - fieldsets = ( - (None, {'fields': (('type', 'promo'), 'author', 'author_email', 'image', 'date', 'changed_at')}), - ) + tuple( - (ln, {'fields': ( - ('published_%s' % lc), - 'published_at_%s' % lc, - 'title_%s' % lc, - 'slug_%s' % lc, - 'lead_%s' % lc, - 'body_%s' % lc, - )}) - for lc, ln in app_settings.OBLIGATORY_LANGUAGES - ) + tuple( - (ln, {'fields': ( - ('needed_%s' % lc, 'published_%s' % lc), - 'published_at_%s' % lc, - 'title_%s' % lc, - 'slug_%s' % lc, - 'lead_%s' % lc, - 'body_%s' % lc, - )}) - for lc, ln in app_settings.OPTIONAL_LANGUAGES - ) + ( - (_('Categories'), {'fields': ('categories',)}), - ) - prepopulated_fields = dict([ - ("slug_%s" % lang_code, ("title_%s" % lang_code,)) - for lang_code, lang_name in settings.LANGUAGES - ]) - - list_display = translated_fields(('title',), app_settings.OBLIGATORY_LANGUAGES - ) + ('type', 'date', 'author', 'promo' - ) + translated_fields(('published',) - ) + translated_fields(('needed',), app_settings.OPTIONAL_LANGUAGES) - list_filter = ('type', 'promo') + translated_fields(('published',) - ) + translated_fields(('needed',), app_settings.OPTIONAL_LANGUAGES) - inlines = (AttachmentInline,) - - -class CategoryAdmin(admin.ModelAdmin): - list_display = translated_fields(('title', 'slug')) + ('taxonomy',) - prepopulated_fields = dict([ - ("slug_%s" % lang_code, ("title_%s" % lang_code,)) - for lang_code, lang_name in settings.LANGUAGES - ]) - - -admin.site.register(Entry, EntryAdmin) -admin.site.register(Category, CategoryAdmin) diff --git a/migdal/api.py b/migdal/api.py deleted file mode 100644 index fffbff8..0000000 --- a/migdal/api.py +++ /dev/null @@ -1,27 +0,0 @@ -# -*- coding: utf-8 -*- -# This file is part of PrawoKultury, licensed under GNU Affero GPLv3 or later. -# Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information. -# -from itertools import chain -from migdal.models import Entry -from migdal import app_settings -from django.utils.translation import get_language - - -def entry_list(entry_type=None, category=None, promobox=False): - lang = get_language() - object_list = Entry.objects.filter(**{"published_%s" % lang: True} - ).order_by('-published_at_%s' % lang) - if entry_type: - object_list = object_list.filter(type=entry_type.db) - else: - object_list = object_list.filter(type__in=[t.db for t in app_settings.TYPES if t.on_main]) - if category: - object_list = object_list.filter(categories=category) - - if promobox: - promo = list(object_list.filter(promo=True)[:promobox]) - #object_list = object_list.exclude(pk__in=[p.pk for p in promo]) - object_list.promobox = promo - - return object_list diff --git a/migdal/feeds.py b/migdal/feeds.py deleted file mode 100644 index 33e9e0b..0000000 --- a/migdal/feeds.py +++ /dev/null @@ -1,56 +0,0 @@ -# -*- coding: utf-8 -*- -# This file is part of PrawoKultury, licensed under GNU Affero GPLv3 or later. -# Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information. -# -from django.contrib.syndication.views import Feed -from django.core.urlresolvers import reverse -from django.shortcuts import get_object_or_404 -from django.utils.translation import ugettext as _, string_concat -from migdal import api -from migdal.models import Category -from migdal import app_settings - - -class EntriesFeed(Feed): - def get_object(self, request, type_db=None, category_slug=None): - lang = request.LANGUAGE_CODE - if category_slug: - category = get_object_or_404(Category, **{'slug_%s' % lang: category_slug}) - else: - category = None - if type_db: - entry_type = app_settings.TYPES_DICT[type_db] - else: - entry_type = None - return {'entry_type': entry_type, 'category': category} - - def title(self, obj): - t = "Prawo kultury, " + _("latest") + " " - if obj['entry_type']: - t += unicode(obj['entry_type'].slug) - else: - t += _("entries") - if obj['category']: - t += " " + _("in category") + " " + obj['category'].title - return t - - def link(self, obj): - if obj['category']: - return reverse('migdal_category', args=[obj['category'].slug]) - if obj['entry_type']: - return reverse('migdal_entry_list_%s' % obj['entry_type'].db) - return reverse('migdal_main') - - def items(self, obj): - return api.entry_list(**obj) - - def item_title(self, item): - return item.title - - def item_description(self, item): - return item.lead - image = item.image.url if item.image else "/static/img/square-logo.png" - return string_concat("" % image, item.lead) - - def item_pubdate(self, item): - return item.published_at diff --git a/migdal/fields.py b/migdal/fields.py deleted file mode 100755 index 843c44e..0000000 --- a/migdal/fields.py +++ /dev/null @@ -1,25 +0,0 @@ -# -*- coding: utf-8 -*- -# This file is part of PrawoKultury, licensed under GNU Affero GPLv3 or later. -# Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information. -# -from django.db import models - -class SlugNullField(models.SlugField): - description = "SlugField that stores NULL instead of blank value." - - def to_python(self, value, **kwargs): - value = super(SlugNullField, self).to_python(value, **kwargs) - return value if value is not None else u"" - - def get_prep_value(self, value, **kwargs): - value = super(SlugNullField, self).get_prep_value(value, **kwargs) - return value or None - - -try: - # check for south - from south.modelsinspector import add_introspection_rules -except ImportError: - pass -else: - add_introspection_rules([], ["^migdal\.fields\.SlugNullField"]) diff --git a/migdal/forms.py b/migdal/forms.py deleted file mode 100644 index 140b5fe..0000000 --- a/migdal/forms.py +++ /dev/null @@ -1,61 +0,0 @@ -# -*- coding: utf-8 -*- -# This file is part of PrawoKultury, licensed under GNU Affero GPLv3 or later. -# Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information. -# -from django import forms -from django.utils.translation import ugettext_lazy as _, get_language -from migdal.models import Entry -from migdal import app_settings -from slughifi import slughifi -from django.core.mail import mail_managers -from django import template - - -def get_submit_form(*args, **kwargs): - lang = get_language() - - class SubmitForm(forms.ModelForm): - class Meta: - model = Entry - fields = ['title_%s' % lang, 'lead_%s' % lang, - 'author', 'author_email', 'categories'] - required = ['title_%s' % lang] - - def __init__(self, *args, **kwargs): - super(SubmitForm, self).__init__(*args, **kwargs) - title = self.fields['title_%s' % lang] - title.required = True - title.label = _('Title') - lead = self.fields['lead_%s' % lang] - lead.required = True - lead.label = _('Content') - - def clean(self): - data = super(SubmitForm, self).clean() - data['type'] = app_settings.TYPE_SUBMIT - orig_slug = slughifi(data.get('title_%s' % lang, '')) - slug = orig_slug - number = 2 - while Entry.objects.filter(**{'slug_%s' % lang: slug}).exists(): - slug = "%s-%s" % (orig_slug, number) - number += 1 - data['slug_%s' % lang] = slug - self.cleaned_data = data - return data - - def save(self, *args, **kwargs): - entry = super(SubmitForm, self).save(commit=False) - # Something's wrong with markup fields, they choke on None here. - for f in 'lead_en', 'lead_pl', 'body_en', 'body_pl': - if getattr(entry, f) is None: - setattr(entry, f, '') - for f in 'slug_%s' % lang, 'type': - setattr(entry, f, self.cleaned_data[f]) - entry.save() - entry = super(SubmitForm, self).save(*args, **kwargs) - mail_managers(u"Nowy wpis", - template.loader.get_template( - 'migdal/mail/manager_new_entry.txt').render( - template.Context({'object': entry}))) - - return SubmitForm(*args, **kwargs) \ No newline at end of file diff --git a/migdal/helpers.py b/migdal/helpers.py deleted file mode 100644 index 8a6513d..0000000 --- a/migdal/helpers.py +++ /dev/null @@ -1,97 +0,0 @@ -# -*- coding: utf-8 -*- -# This file is part of PrawoKultury, licensed under GNU Affero GPLv3 or later. -# Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information. -# -from collections import namedtuple -from copy import copy -import re -from django.conf import settings -from django.conf.urls import patterns -from django.core.urlresolvers import LocaleRegexURLResolver -from django.utils.translation import get_language, string_concat - - -class EntryType(namedtuple('EntryType', 'db slug commentable on_main')): - __slots__ = () - def __unicode__(self): - return unicode(self.slug) - - -def field_getter(name): - @property - def getter(self): - val = getattr(self, "%s_%s" % (name, get_language()), None) - if not val: - val = getattr(self, "%s_%s" % (name, settings.LANGUAGE_CODE)) - return val - return getter - - -def add_translatable(model, fields, languages=None): - """Adds some translatable fields to a model, and a getter.""" - if languages is None: - languages = settings.LANGUAGES - for name, field in fields.items(): - for lang_code, lang_name in languages: - new_field = copy(field) - if field.verbose_name: - new_field.verbose_name = string_concat(field.verbose_name, ' [%s]' % lang_code) - new_field.contribute_to_class(model, "%s_%s" % (name, lang_code)) - setattr(model, name, field_getter(name)) - # add setter? - - -class MyLocaleRegexURLResolver(LocaleRegexURLResolver): - """ - A URL resolver that always matches the active language code as URL prefix. - - Rather than taking a regex argument, we just override the ``regex`` - function to always return the active language-code as regex. - """ - @property - def regex(self): - language_code = get_language() - if language_code == settings.LANGUAGE_CODE: - return re.compile('') - if language_code not in self._regex_dict: - regex_compiled = re.compile('^%s/' % language_code, re.UNICODE) - self._regex_dict[language_code] = regex_compiled - return self._regex_dict[language_code] - - -def i18n_patterns(prefix, *args): - """ - Adds the language code prefix to every URL pattern within this - function. This may only be used in the root URLconf, not in an included - URLconf. - - """ - pattern_list = patterns(prefix, *args) - if not settings.USE_I18N: - return pattern_list - return pattern_list + [MyLocaleRegexURLResolver(pattern_list)] - - -def add_translatable_index(index_class, fields, languages=None): - """Adds some translatable fields to a search index, and a getter.""" - if languages is None: - languages = settings.LANGUAGES - for name, field in fields.items(): - for lang_code, lang_name in languages: - new_field = copy(field) - fname = "%s_%s" % (name, lang_code) - new_field.index_fieldname = new_field.index_fieldname \ - and "%s_%s" % (new_field.index_fieldname, lang_code) \ - or fname - new_field.model_attr = new_field.model_attr \ - and "%s_%s" % (new_field.model_attr, lang_code) \ - or fname - setattr(index_class, fname, new_field) - index_class.fields[fname] = new_field - - -def translated_fields(field_names, languages=settings.LANGUAGES): - return tuple("%s_%s" % (field_name, lang_code) - for field_name in field_names - for lang_code, lang_name in languages - ) diff --git a/migdal/locale/pl/LC_MESSAGES/django.mo b/migdal/locale/pl/LC_MESSAGES/django.mo deleted file mode 100644 index f222f82..0000000 Binary files a/migdal/locale/pl/LC_MESSAGES/django.mo and /dev/null differ diff --git a/migdal/locale/pl/LC_MESSAGES/django.po b/migdal/locale/pl/LC_MESSAGES/django.po deleted file mode 100644 index 8347953..0000000 --- a/migdal/locale/pl/LC_MESSAGES/django.po +++ /dev/null @@ -1,317 +0,0 @@ -# SOME DESCRIPTIVE TITLE. -# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER -# This file is distributed under the same license as the PACKAGE package. -# FIRST AUTHOR , YEAR. -# -msgid "" -msgstr "" -"Project-Id-Version: django-migdal 0.1\n" -"Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2012-10-04 12:58+0200\n" -"PO-Revision-Date: 2012-10-04 12:58+0100\n" -"Last-Translator: Radek Czajka \n" -"Language-Team: FNP \n" -"Language: Polish\n" -"MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=UTF-8\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" -"X-Poedit-Language: Polish\n" - -#: __init__.py:17 -msgid "news" -msgstr "newsy" - -#: __init__.py:18 -msgid "publications" -msgstr "publikacje" - -#: __init__.py:19 -msgid "info" -msgstr "info" - -#: __init__.py:23 -msgid "topics" -msgstr "tematy" - -#: __init__.py:24 -msgid "types" -msgstr "rodzaje" - -#: admin.py:44 -msgid "Categories" -msgstr "Kategorie" - -#: feeds.py:28 -msgid "latest" -msgstr "ostatnie" - -#: feeds.py:32 -#: models.py:56 -msgid "entries" -msgstr "wpisy" - -#: feeds.py:34 -msgid "in category" -msgstr "w kategorii" - -#: forms.py:28 -msgid "Title" -msgstr "Tytuł" - -#: forms.py:31 -msgid "Content" -msgstr "Treść" - -#: models.py:20 -msgid "taxonomy" -msgstr "taksonomia" - -#: models.py:24 -msgid "category" -msgstr "kategoria" - -#: models.py:25 -#: models.py:52 -#: urls.py:41 -#: urls.py:43 -msgid "categories" -msgstr "kategorie" - -#: models.py:45 -msgid "created at" -msgstr "data utworzenia" - -#: models.py:46 -msgid "changed at" -msgstr "data ostatniej zmiany" - -#: models.py:47 -msgid "author" -msgstr "autor" - -#: models.py:48 -msgid "author email" -msgstr "e-mail autora" - -#: models.py:49 -msgid "Used only to display gravatar and send notifications." -msgstr "Używany tylko do wyświetlenia gravatara i wysyłania powiadomień." - -#: models.py:50 -msgid "image" -msgstr "obrazek" - -#: models.py:51 -msgid "promoted" -msgstr "promowane" - -#: models.py:55 -msgid "entry" -msgstr "wpis" - -#: models.py:80 -#, python-format -msgid "Published entry should have a slug in relevant language (%s)." -msgstr "Opublikowany wpis powinien mieć slug w odpowiednim języku (%s)." - -#: models.py:99 -#, python-format -msgid "Your story has been published at %s." -msgstr "Twój wpis został opublikowany na stronie %s." - -#: models.py:105 -msgid "needed" -msgstr "potrzebne" - -#: models.py:106 -msgid "Unneeded" -msgstr "Niepotrzebne" - -#: models.py:106 -msgid "Needed" -msgstr "Potrzebne" - -#: models.py:106 -msgid "Done" -msgstr "Ukończone" - -#: models.py:112 -msgid "title" -msgstr "tytuł" - -#: models.py:113 -msgid "lead" -msgstr "lead" - -#: models.py:114 -#: models.py:116 -msgid "Use Textile syntax." -msgstr "Włączona składnia Textile." - -#: models.py:115 -msgid "body" -msgstr "treść" - -#: models.py:117 -msgid "published" -msgstr "opublikowane" - -#: models.py:118 -msgid "published at" -msgstr "data publikacji" - -#: models.py:123 -msgid "file" -msgstr "plik" - -#: models.py:141 -#, python-format -msgid "New comment under your story at %s." -msgstr "Nowy komentarz pod Twoim wpisem na stronie %s." - -#: urls.py:38 -#: urls.py:39 -msgid "submit" -msgstr "wyslij" - -#: urls.py:39 -msgid "thanks" -msgstr "dzieki" - -#: urls.py:45 -msgid "search" -msgstr "szukaj" - -#: templates/comments/form.html:3 -msgid "Add comment" -msgstr "Dodaj komentarz" - -#: templates/comments/form.html:24 -msgid "Post" -msgstr "Wyślij" - -#: templates/comments/form.html:25 -msgid "Preview" -msgstr "Podgląd" - -#: templates/comments/migdal/entry/list.html:5 -msgid "Comments" -msgstr "Komentarze" - -#: templates/comments/migdal/entry/preview.html:26 -msgid "Preview your comment" -msgstr "Podgląd komentarza" - -#: templates/migdal/entry/entry_detail.html:27 -msgid "This entry hasn't been published yet." -msgstr "Ten wpis nie został jeszcze opublikowany." - -#: templates/migdal/entry/entry_list.html:22 -msgid "Category" -msgstr "Kategoria" - -#: templates/migdal/entry/entry_list.html:55 -msgid "Submit a new story, create Culture's Right with us!" -msgstr "Dodaj nowy wpis, twórz Prawo Kultury razem z nami!" - -#: templates/migdal/entry/entry_short.html:19 -#, python-format -msgid "%(c)s comment" -msgid_plural "%(c)s comments" -msgstr[0] "%(c)s komentarz" -msgstr[1] "%(c)s komentarze" -msgstr[2] "%(c)s komentarzy" - -#: templates/migdal/entry/entry_short.html:24 -msgid "read more" -msgstr "czytaj więcej" - -#: templates/migdal/entry/submit.html:7 -msgid "Submit new story" -msgstr "Dodaj nowy wpis" - -#: templates/migdal/entry/submit.html:9 -msgid "" -"\n" -"By submitting a story here, you agree to publish it under the terms of the\n" -"Creative Commons Attribution-Share Alike\n" -"free license." -msgstr "" -"\n" -"Dodając wpis, zgadzasz się najego publikację na warunkach wolnej licencji\n" -"Creative Commons Uznanie autorstwa – Na tych samych warunkach." - -#: templates/migdal/entry/submit.html:14 -msgid "" -"Stories are moderated, so please be\n" -"patient, you'll be notified when it's published." -msgstr "Wpisy są moderowane. Bądź cierpliwy, otrzymasz powiadomienie o publikacji." - -#: templates/migdal/entry/submit.html:21 -msgid "Submit" -msgstr "Wyślij" - -#: templates/migdal/entry/submit_thanks.html:6 -msgid "Thanks for submitting" -msgstr "Dziękujemy za zgłoszenie" - -#: templates/migdal/entry/submit_thanks.html:9 -msgid "" -"\n" -"Thank you for submitting this new story, it's waiting for moderation.\n" -"If you provided an email, we'll inform you about changes in it's status\n" -"and comments.\n" -msgstr "" -"\n" -"Dziękujemy za dodanie nowego wpisu, teraz czeka on na moderację. Jeśli podano adres e-mail, będziemy Cię informowali o zmianach statusu i komentarzach\n" - -#: templates/search/search.html:9 -msgid "Search results" -msgstr "Wyniki wyszukiwania" - -#: templates/search/search.html:18 -msgid "No results found." -msgstr "Brak wyników." - -#: templates/search/search.html:25 -msgid "previous" -msgstr "poprzednie" - -#: templates/search/search.html:28 -msgid "next" -msgstr "następne" - -#: templatetags/migdal_tags.py:128 -msgid "Publications" -msgstr "Publikacje" - -#: templatetags/migdal_tags.py:129 -msgid "Events" -msgstr "Wydarzenia" - -#: templatetags/migdal_tags.py:131 -msgid "Positions" -msgstr "Stanowiska" - -#~ msgid "Please correct the error below" - -#~ msgid_plural "Please correct the errors below" -#~ msgstr[0] "Proszę poprawić poniższy błąd" -#~ msgstr[1] "Proszę poprawić poniższe błędy" -#~ msgstr[2] "Proszę poprawić poniższe błędy" - -#~ msgid "and" -#~ msgstr "i" - -#~ msgid "Post your comment" -#~ msgstr "Wyślij komentarz" - -#~ msgid "or make changes" -#~ msgstr "lub zmień" - -#~ msgid "Latest news" -#~ msgstr "Ostatnie newsy" - -#~ msgid "Submit a new story." -#~ msgstr "Przyślij nowego newsa." diff --git a/migdal/middleware.py b/migdal/middleware.py deleted file mode 100644 index 7153562..0000000 --- a/migdal/middleware.py +++ /dev/null @@ -1,26 +0,0 @@ -# -*- coding: utf-8 -*- -# This file is part of PrawoKultury, licensed under GNU Affero GPLv3 or later. -# Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information. -# -from django.utils import translation -from django.conf import settings -from django.http import Http404 - - -class URLLocaleMiddleware(object): - """Decides which translation to use, based on path only.""" - - def process_request(self, request): - language = translation.get_language_from_path(request.path_info) - if language == settings.LANGUAGE_CODE: - raise Http404 - if language: - translation.activate(language) - request.LANGUAGE_CODE = translation.get_language() - - def process_response(self, request, response): - language = translation.get_language() - translation.deactivate() - if 'Content-Language' not in response: - response['Content-Language'] = language - return response diff --git a/migdal/migrations/0001_initial.py b/migdal/migrations/0001_initial.py deleted file mode 100644 index 3af9e00..0000000 --- a/migdal/migrations/0001_initial.py +++ /dev/null @@ -1,130 +0,0 @@ -# -*- coding: utf-8 -*- -import datetime -from south.db import db -from south.v2 import SchemaMigration -from django.db import models - - -class Migration(SchemaMigration): - - def forwards(self, orm): - # Adding model 'Category' - db.create_table('migdal_category', ( - ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)), - ('slug_pl', self.gf('django.db.models.fields.SlugField')(unique=True, max_length=50)), - ('slug_en', self.gf('django.db.models.fields.SlugField')(unique=True, max_length=50)), - ('title_pl', self.gf('django.db.models.fields.CharField')(unique=True, max_length=64, db_index=True)), - ('title_en', self.gf('django.db.models.fields.CharField')(unique=True, max_length=64, db_index=True)), - )) - db.send_create_signal('migdal', ['Category']) - - # Adding model 'Entry' - db.create_table('migdal_entry', ( - ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)), - ('type', self.gf('django.db.models.fields.CharField')(max_length=16, db_index=True)), - ('date', self.gf('django.db.models.fields.DateTimeField')(auto_now_add=True, db_index=True, blank=True)), - ('author', self.gf('django.db.models.fields.CharField')(max_length=128)), - ('author_email', self.gf('django.db.models.fields.EmailField')(max_length=128, null=True, blank=True)), - ('image', self.gf('django.db.models.fields.files.ImageField')(max_length=100, null=True, blank=True)), - ('promo', self.gf('django.db.models.fields.BooleanField')(default=False)), - ('slug_pl', self.gf('django.db.models.fields.SlugField')(unique=True, max_length=50)), - ('title_pl', self.gf('django.db.models.fields.CharField')(max_length=255)), - ('lead_pl', self.gf('markupfield.fields.MarkupField')(rendered_field=True)), - ('lead_pl_markup_type', self.gf('django.db.models.fields.CharField')(default='textile_pl', max_length=30)), - ('_lead_pl_rendered', self.gf('django.db.models.fields.TextField')()), - ('slug_en', self.gf('django.db.models.fields.SlugField')(max_length=50, unique=True, null=True, blank=True)), - ('title_en', self.gf('django.db.models.fields.CharField')(max_length=255, null=True, blank=True)), - ('lead_en', self.gf('markupfield.fields.MarkupField')(null=True, rendered_field=True, blank=True)), - ('needed_en', self.gf('django.db.models.fields.CharField')(default='n', max_length=1, db_index=True)), - ('lead_en_markup_type', self.gf('django.db.models.fields.CharField')(default='textile_pl', max_length=30, blank=True)), - ('_lead_en_rendered', self.gf('django.db.models.fields.TextField')()), - ('body_pl', self.gf('markupfield.fields.MarkupField')(null=True, rendered_field=True, blank=True)), - ('body_en', self.gf('markupfield.fields.MarkupField')(null=True, rendered_field=True, blank=True)), - ('body_pl_markup_type', self.gf('django.db.models.fields.CharField')(default='textile_pl', max_length=30, blank=True)), - ('body_en_markup_type', self.gf('django.db.models.fields.CharField')(default='textile_pl', max_length=30, blank=True)), - ('published_pl', self.gf('django.db.models.fields.BooleanField')(default=False)), - ('published_en', self.gf('django.db.models.fields.BooleanField')(default=False)), - ('_body_pl_rendered', self.gf('django.db.models.fields.TextField')()), - ('_body_en_rendered', self.gf('django.db.models.fields.TextField')()), - )) - db.send_create_signal('migdal', ['Entry']) - - # Adding M2M table for field categories on 'Entry' - db.create_table('migdal_entry_categories', ( - ('id', models.AutoField(verbose_name='ID', primary_key=True, auto_created=True)), - ('entry', models.ForeignKey(orm['migdal.entry'], null=False)), - ('category', models.ForeignKey(orm['migdal.category'], null=False)) - )) - db.create_unique('migdal_entry_categories', ['entry_id', 'category_id']) - - # Adding model 'Attachment' - db.create_table('migdal_attachment', ( - ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)), - ('file', self.gf('django.db.models.fields.files.FileField')(max_length=100)), - ('entry', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['migdal.Entry'])), - )) - db.send_create_signal('migdal', ['Attachment']) - - - def backwards(self, orm): - # Deleting model 'Category' - db.delete_table('migdal_category') - - # Deleting model 'Entry' - db.delete_table('migdal_entry') - - # Removing M2M table for field categories on 'Entry' - db.delete_table('migdal_entry_categories') - - # Deleting model 'Attachment' - db.delete_table('migdal_attachment') - - - models = { - 'migdal.attachment': { - 'Meta': {'object_name': 'Attachment'}, - 'entry': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['migdal.Entry']"}), - 'file': ('django.db.models.fields.files.FileField', [], {'max_length': '100'}), - 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}) - }, - 'migdal.category': { - 'Meta': {'object_name': 'Category'}, - 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), - 'slug_en': ('django.db.models.fields.SlugField', [], {'unique': 'True', 'max_length': '50'}), - 'slug_pl': ('django.db.models.fields.SlugField', [], {'unique': 'True', 'max_length': '50'}), - 'title_en': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '64', 'db_index': 'True'}), - 'title_pl': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '64', 'db_index': 'True'}) - }, - 'migdal.entry': { - 'Meta': {'ordering': "['-date']", 'object_name': 'Entry'}, - '_body_en_rendered': ('django.db.models.fields.TextField', [], {}), - '_body_pl_rendered': ('django.db.models.fields.TextField', [], {}), - '_lead_en_rendered': ('django.db.models.fields.TextField', [], {}), - '_lead_pl_rendered': ('django.db.models.fields.TextField', [], {}), - 'author': ('django.db.models.fields.CharField', [], {'max_length': '128'}), - 'author_email': ('django.db.models.fields.EmailField', [], {'max_length': '128', 'null': 'True', 'blank': 'True'}), - 'body_en': ('markupfield.fields.MarkupField', [], {'null': 'True', 'rendered_field': 'True', 'blank': 'True'}), - 'body_en_markup_type': ('django.db.models.fields.CharField', [], {'default': "'textile_pl'", 'max_length': '30', 'blank': 'True'}), - 'body_pl': ('markupfield.fields.MarkupField', [], {'null': 'True', 'rendered_field': 'True', 'blank': 'True'}), - 'body_pl_markup_type': ('django.db.models.fields.CharField', [], {'default': "'textile_pl'", 'max_length': '30', 'blank': 'True'}), - 'categories': ('django.db.models.fields.related.ManyToManyField', [], {'symmetrical': 'False', 'to': "orm['migdal.Category']", 'null': 'True', 'blank': 'True'}), - 'date': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'db_index': 'True', 'blank': 'True'}), - 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), - 'image': ('django.db.models.fields.files.ImageField', [], {'max_length': '100', 'null': 'True', 'blank': 'True'}), - 'lead_en': ('markupfield.fields.MarkupField', [], {'null': 'True', 'rendered_field': 'True', 'blank': 'True'}), - 'lead_en_markup_type': ('django.db.models.fields.CharField', [], {'default': "'textile_pl'", 'max_length': '30', 'blank': 'True'}), - 'lead_pl': ('markupfield.fields.MarkupField', [], {'rendered_field': 'True'}), - 'lead_pl_markup_type': ('django.db.models.fields.CharField', [], {'default': "'textile_pl'", 'max_length': '30'}), - 'needed_en': ('django.db.models.fields.CharField', [], {'default': "'n'", 'max_length': '1', 'db_index': 'True'}), - 'promo': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), - 'published_en': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), - 'published_pl': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), - 'slug_en': ('django.db.models.fields.SlugField', [], {'max_length': '50', 'unique': 'True', 'null': 'True', 'blank': 'True'}), - 'slug_pl': ('django.db.models.fields.SlugField', [], {'unique': 'True', 'max_length': '50'}), - 'title_en': ('django.db.models.fields.CharField', [], {'max_length': '255', 'null': 'True', 'blank': 'True'}), - 'title_pl': ('django.db.models.fields.CharField', [], {'max_length': '255'}), - 'type': ('django.db.models.fields.CharField', [], {'max_length': '16', 'db_index': 'True'}) - } - } - - complete_apps = ['migdal'] \ No newline at end of file diff --git a/migdal/migrations/0002_auto__chg_field_entry_slug_pl__chg_field_entry_title_pl__chg_field_ent.py b/migdal/migrations/0002_auto__chg_field_entry_slug_pl__chg_field_entry_title_pl__chg_field_ent.py deleted file mode 100644 index 1caced4..0000000 --- a/migdal/migrations/0002_auto__chg_field_entry_slug_pl__chg_field_entry_title_pl__chg_field_ent.py +++ /dev/null @@ -1,79 +0,0 @@ -# -*- coding: utf-8 -*- -import datetime -from south.db import db -from south.v2 import SchemaMigration -from django.db import models - - -class Migration(SchemaMigration): - - def forwards(self, orm): - - # Changing field 'Entry.slug_pl' - db.alter_column('migdal_entry', 'slug_pl', self.gf('django.db.models.fields.SlugField')(max_length=50, unique=True, null=True)) - - # Changing field 'Entry.title_pl' - db.alter_column('migdal_entry', 'title_pl', self.gf('django.db.models.fields.CharField')(max_length=255, null=True)) - - # Changing field 'Entry.lead_pl' - db.alter_column('migdal_entry', 'lead_pl', self.gf('markupfield.fields.MarkupField')(null=True, rendered_field=True)) - - def backwards(self, orm): - - # Changing field 'Entry.slug_pl' - db.alter_column('migdal_entry', 'slug_pl', self.gf('django.db.models.fields.SlugField')(default='', max_length=50, unique=True)) - - # Changing field 'Entry.title_pl' - db.alter_column('migdal_entry', 'title_pl', self.gf('django.db.models.fields.CharField')(default='', max_length=255)) - - # Changing field 'Entry.lead_pl' - db.alter_column('migdal_entry', 'lead_pl', self.gf('markupfield.fields.MarkupField')(default='', rendered_field=True)) - - models = { - 'migdal.attachment': { - 'Meta': {'object_name': 'Attachment'}, - 'entry': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['migdal.Entry']"}), - 'file': ('django.db.models.fields.files.FileField', [], {'max_length': '100'}), - 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}) - }, - 'migdal.category': { - 'Meta': {'object_name': 'Category'}, - 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), - 'slug_en': ('django.db.models.fields.SlugField', [], {'unique': 'True', 'max_length': '50'}), - 'slug_pl': ('django.db.models.fields.SlugField', [], {'unique': 'True', 'max_length': '50'}), - 'title_en': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '64', 'db_index': 'True'}), - 'title_pl': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '64', 'db_index': 'True'}) - }, - 'migdal.entry': { - 'Meta': {'ordering': "['-date']", 'object_name': 'Entry'}, - '_body_en_rendered': ('django.db.models.fields.TextField', [], {}), - '_body_pl_rendered': ('django.db.models.fields.TextField', [], {}), - '_lead_en_rendered': ('django.db.models.fields.TextField', [], {}), - '_lead_pl_rendered': ('django.db.models.fields.TextField', [], {}), - 'author': ('django.db.models.fields.CharField', [], {'max_length': '128'}), - 'author_email': ('django.db.models.fields.EmailField', [], {'max_length': '128', 'null': 'True', 'blank': 'True'}), - 'body_en': ('markupfield.fields.MarkupField', [], {'null': 'True', 'rendered_field': 'True', 'blank': 'True'}), - 'body_en_markup_type': ('django.db.models.fields.CharField', [], {'default': "'textile_pl'", 'max_length': '30', 'blank': 'True'}), - 'body_pl': ('markupfield.fields.MarkupField', [], {'null': 'True', 'rendered_field': 'True', 'blank': 'True'}), - 'body_pl_markup_type': ('django.db.models.fields.CharField', [], {'default': "'textile_pl'", 'max_length': '30', 'blank': 'True'}), - 'categories': ('django.db.models.fields.related.ManyToManyField', [], {'symmetrical': 'False', 'to': "orm['migdal.Category']", 'null': 'True', 'blank': 'True'}), - 'date': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'db_index': 'True', 'blank': 'True'}), - 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), - 'image': ('django.db.models.fields.files.ImageField', [], {'max_length': '100', 'null': 'True', 'blank': 'True'}), - 'lead_en': ('markupfield.fields.MarkupField', [], {'null': 'True', 'rendered_field': 'True', 'blank': 'True'}), - 'lead_en_markup_type': ('django.db.models.fields.CharField', [], {'default': "'textile_pl'", 'max_length': '30', 'blank': 'True'}), - 'lead_pl': ('markupfield.fields.MarkupField', [], {'null': 'True', 'rendered_field': 'True', 'blank': 'True'}), - 'lead_pl_markup_type': ('django.db.models.fields.CharField', [], {'default': "'textile_pl'", 'max_length': '30', 'blank': 'True'}), - 'needed_en': ('django.db.models.fields.CharField', [], {'default': "'n'", 'max_length': '1', 'db_index': 'True'}), - 'promo': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), - 'published_en': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), - 'published_pl': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), - 'slug_en': ('django.db.models.fields.SlugField', [], {'max_length': '50', 'unique': 'True', 'null': 'True', 'blank': 'True'}), - 'slug_pl': ('django.db.models.fields.SlugField', [], {'max_length': '50', 'unique': 'True', 'null': 'True', 'blank': 'True'}), - 'title_en': ('django.db.models.fields.CharField', [], {'max_length': '255', 'null': 'True', 'blank': 'True'}), - 'title_pl': ('django.db.models.fields.CharField', [], {'max_length': '255', 'null': 'True', 'blank': 'True'}), - 'type': ('django.db.models.fields.CharField', [], {'max_length': '16', 'db_index': 'True'}) - } - } - - complete_apps = ['migdal'] \ No newline at end of file diff --git a/migdal/migrations/0003_auto__add_field_category_taxonomy.py b/migdal/migrations/0003_auto__add_field_category_taxonomy.py deleted file mode 100644 index 7368441..0000000 --- a/migdal/migrations/0003_auto__add_field_category_taxonomy.py +++ /dev/null @@ -1,70 +0,0 @@ -# -*- coding: utf-8 -*- -import datetime -from south.db import db -from south.v2 import SchemaMigration -from django.db import models - - -class Migration(SchemaMigration): - - def forwards(self, orm): - # Adding field 'Category.taxonomy' - db.add_column('migdal_category', 'taxonomy', - self.gf('django.db.models.fields.CharField')(default='topics', max_length=32), - keep_default=False) - - - def backwards(self, orm): - # Deleting field 'Category.taxonomy' - db.delete_column('migdal_category', 'taxonomy') - - - models = { - 'migdal.attachment': { - 'Meta': {'object_name': 'Attachment'}, - 'entry': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['migdal.Entry']"}), - 'file': ('django.db.models.fields.files.FileField', [], {'max_length': '100'}), - 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}) - }, - 'migdal.category': { - 'Meta': {'object_name': 'Category'}, - 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), - 'slug_en': ('django.db.models.fields.SlugField', [], {'unique': 'True', 'max_length': '50'}), - 'slug_pl': ('django.db.models.fields.SlugField', [], {'unique': 'True', 'max_length': '50'}), - 'taxonomy': ('django.db.models.fields.CharField', [], {'max_length': '32'}), - 'title_en': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '64', 'db_index': 'True'}), - 'title_pl': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '64', 'db_index': 'True'}) - }, - 'migdal.entry': { - 'Meta': {'ordering': "['-date']", 'object_name': 'Entry'}, - '_body_en_rendered': ('django.db.models.fields.TextField', [], {}), - '_body_pl_rendered': ('django.db.models.fields.TextField', [], {}), - '_lead_en_rendered': ('django.db.models.fields.TextField', [], {}), - '_lead_pl_rendered': ('django.db.models.fields.TextField', [], {}), - 'author': ('django.db.models.fields.CharField', [], {'max_length': '128'}), - 'author_email': ('django.db.models.fields.EmailField', [], {'max_length': '128', 'null': 'True', 'blank': 'True'}), - 'body_en': ('markupfield.fields.MarkupField', [], {'null': 'True', 'rendered_field': 'True', 'blank': 'True'}), - 'body_en_markup_type': ('django.db.models.fields.CharField', [], {'default': "'textile_pl'", 'max_length': '30', 'blank': 'True'}), - 'body_pl': ('markupfield.fields.MarkupField', [], {'null': 'True', 'rendered_field': 'True', 'blank': 'True'}), - 'body_pl_markup_type': ('django.db.models.fields.CharField', [], {'default': "'textile_pl'", 'max_length': '30', 'blank': 'True'}), - 'categories': ('django.db.models.fields.related.ManyToManyField', [], {'symmetrical': 'False', 'to': "orm['migdal.Category']", 'null': 'True', 'blank': 'True'}), - 'date': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'db_index': 'True', 'blank': 'True'}), - 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), - 'image': ('django.db.models.fields.files.ImageField', [], {'max_length': '100', 'null': 'True', 'blank': 'True'}), - 'lead_en': ('markupfield.fields.MarkupField', [], {'null': 'True', 'rendered_field': 'True', 'blank': 'True'}), - 'lead_en_markup_type': ('django.db.models.fields.CharField', [], {'default': "'textile_pl'", 'max_length': '30', 'blank': 'True'}), - 'lead_pl': ('markupfield.fields.MarkupField', [], {'null': 'True', 'rendered_field': 'True', 'blank': 'True'}), - 'lead_pl_markup_type': ('django.db.models.fields.CharField', [], {'default': "'textile_pl'", 'max_length': '30', 'blank': 'True'}), - 'needed_en': ('django.db.models.fields.CharField', [], {'default': "'n'", 'max_length': '1', 'db_index': 'True'}), - 'promo': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), - 'published_en': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), - 'published_pl': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), - 'slug_en': ('django.db.models.fields.SlugField', [], {'max_length': '50', 'unique': 'True', 'null': 'True', 'blank': 'True'}), - 'slug_pl': ('django.db.models.fields.SlugField', [], {'max_length': '50', 'unique': 'True', 'null': 'True', 'blank': 'True'}), - 'title_en': ('django.db.models.fields.CharField', [], {'max_length': '255', 'null': 'True', 'blank': 'True'}), - 'title_pl': ('django.db.models.fields.CharField', [], {'max_length': '255', 'null': 'True', 'blank': 'True'}), - 'type': ('django.db.models.fields.CharField', [], {'max_length': '16', 'db_index': 'True'}) - } - } - - complete_apps = ['migdal'] \ No newline at end of file diff --git a/migdal/migrations/0004_auto__chg_field_entry_slug_pl__chg_field_entry_slug_en.py b/migdal/migrations/0004_auto__chg_field_entry_slug_pl__chg_field_entry_slug_en.py deleted file mode 100644 index a546e52..0000000 --- a/migdal/migrations/0004_auto__chg_field_entry_slug_pl__chg_field_entry_slug_en.py +++ /dev/null @@ -1,74 +0,0 @@ -# -*- coding: utf-8 -*- -import datetime -from south.db import db -from south.v2 import SchemaMigration -from django.db import models - - -class Migration(SchemaMigration): - - def forwards(self, orm): - - # Changing field 'Entry.slug_pl' - db.alter_column('migdal_entry', 'slug_pl', self.gf('migdal.fields.SlugNullField')(max_length=50, unique=True, null=True)) - - # Changing field 'Entry.slug_en' - db.alter_column('migdal_entry', 'slug_en', self.gf('migdal.fields.SlugNullField')(max_length=50, unique=True, null=True)) - - def backwards(self, orm): - - # Changing field 'Entry.slug_pl' - db.alter_column('migdal_entry', 'slug_pl', self.gf('django.db.models.fields.SlugField')(unique=True, max_length=50, null=True)) - - # Changing field 'Entry.slug_en' - db.alter_column('migdal_entry', 'slug_en', self.gf('django.db.models.fields.SlugField')(unique=True, max_length=50, null=True)) - - models = { - 'migdal.attachment': { - 'Meta': {'object_name': 'Attachment'}, - 'entry': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['migdal.Entry']"}), - 'file': ('django.db.models.fields.files.FileField', [], {'max_length': '100'}), - 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}) - }, - 'migdal.category': { - 'Meta': {'object_name': 'Category'}, - 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), - 'slug_en': ('django.db.models.fields.SlugField', [], {'unique': 'True', 'max_length': '50'}), - 'slug_pl': ('django.db.models.fields.SlugField', [], {'unique': 'True', 'max_length': '50'}), - 'taxonomy': ('django.db.models.fields.CharField', [], {'max_length': '32'}), - 'title_en': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '64', 'db_index': 'True'}), - 'title_pl': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '64', 'db_index': 'True'}) - }, - 'migdal.entry': { - 'Meta': {'ordering': "['-date']", 'object_name': 'Entry'}, - '_body_en_rendered': ('django.db.models.fields.TextField', [], {}), - '_body_pl_rendered': ('django.db.models.fields.TextField', [], {}), - '_lead_en_rendered': ('django.db.models.fields.TextField', [], {}), - '_lead_pl_rendered': ('django.db.models.fields.TextField', [], {}), - 'author': ('django.db.models.fields.CharField', [], {'max_length': '128'}), - 'author_email': ('django.db.models.fields.EmailField', [], {'max_length': '128', 'null': 'True', 'blank': 'True'}), - 'body_en': ('markupfield.fields.MarkupField', [], {'null': 'True', 'rendered_field': 'True', 'blank': 'True'}), - 'body_en_markup_type': ('django.db.models.fields.CharField', [], {'default': "'textile_pl'", 'max_length': '30', 'blank': 'True'}), - 'body_pl': ('markupfield.fields.MarkupField', [], {'null': 'True', 'rendered_field': 'True', 'blank': 'True'}), - 'body_pl_markup_type': ('django.db.models.fields.CharField', [], {'default': "'textile_pl'", 'max_length': '30', 'blank': 'True'}), - 'categories': ('django.db.models.fields.related.ManyToManyField', [], {'symmetrical': 'False', 'to': "orm['migdal.Category']", 'null': 'True', 'blank': 'True'}), - 'date': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'db_index': 'True', 'blank': 'True'}), - 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), - 'image': ('django.db.models.fields.files.ImageField', [], {'max_length': '100', 'null': 'True', 'blank': 'True'}), - 'lead_en': ('markupfield.fields.MarkupField', [], {'null': 'True', 'rendered_field': 'True', 'blank': 'True'}), - 'lead_en_markup_type': ('django.db.models.fields.CharField', [], {'default': "'textile_pl'", 'max_length': '30', 'blank': 'True'}), - 'lead_pl': ('markupfield.fields.MarkupField', [], {'null': 'True', 'rendered_field': 'True', 'blank': 'True'}), - 'lead_pl_markup_type': ('django.db.models.fields.CharField', [], {'default': "'textile_pl'", 'max_length': '30', 'blank': 'True'}), - 'needed_en': ('django.db.models.fields.CharField', [], {'default': "'n'", 'max_length': '1', 'db_index': 'True'}), - 'promo': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), - 'published_en': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), - 'published_pl': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), - 'slug_en': ('migdal.fields.SlugNullField', [], {'max_length': '50', 'unique': 'True', 'null': 'True', 'blank': 'True'}), - 'slug_pl': ('migdal.fields.SlugNullField', [], {'max_length': '50', 'unique': 'True', 'null': 'True', 'blank': 'True'}), - 'title_en': ('django.db.models.fields.CharField', [], {'max_length': '255', 'null': 'True', 'blank': 'True'}), - 'title_pl': ('django.db.models.fields.CharField', [], {'max_length': '255', 'null': 'True', 'blank': 'True'}), - 'type': ('django.db.models.fields.CharField', [], {'max_length': '16', 'db_index': 'True'}) - } - } - - complete_apps = ['migdal'] \ No newline at end of file diff --git a/migdal/migrations/0005_auto__add_field_entry_changed_at__add_field_entry_published_at_pl__add.py b/migdal/migrations/0005_auto__add_field_entry_changed_at__add_field_entry_published_at_pl__add.py deleted file mode 100644 index f8e8ee8..0000000 --- a/migdal/migrations/0005_auto__add_field_entry_changed_at__add_field_entry_published_at_pl__add.py +++ /dev/null @@ -1,99 +0,0 @@ -# -*- coding: utf-8 -*- -import datetime -from south.db import db -from south.v2 import SchemaMigration -from django.db import models - - -class Migration(SchemaMigration): - - def forwards(self, orm): - # Adding field 'Entry.changed_at' - db.add_column('migdal_entry', 'changed_at', - self.gf('django.db.models.fields.DateTimeField')(auto_now=True, default=datetime.datetime(2000, 1, 1, 0, 0), db_index=True, blank=True), - keep_default=False) - - # Adding field 'Entry.published_at_pl' - db.add_column('migdal_entry', 'published_at_pl', - self.gf('django.db.models.fields.DateTimeField')(null=True, blank=True), - keep_default=False) - - # Adding field 'Entry.published_at_en' - db.add_column('migdal_entry', 'published_at_en', - self.gf('django.db.models.fields.DateTimeField')(null=True, blank=True), - keep_default=False) - - if not db.dry_run: - for entry in orm['migdal.Entry'].objects.all(): - update_info = {} - if entry.published_pl: - update_info['published_at_pl'] = entry.date - if entry.published_en: - update_info['published_at_en'] = entry.date - update_info['changed_at'] = entry.date - orm['migdal.Entry'].objects.filter(pk=entry.pk).update(**update_info) - - - def backwards(self, orm): - # Deleting field 'Entry.changed_at' - db.delete_column('migdal_entry', 'changed_at') - - # Deleting field 'Entry.published_at_pl' - db.delete_column('migdal_entry', 'published_at_pl') - - # Deleting field 'Entry.published_at_en' - db.delete_column('migdal_entry', 'published_at_en') - - - models = { - 'migdal.attachment': { - 'Meta': {'object_name': 'Attachment'}, - 'entry': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['migdal.Entry']"}), - 'file': ('django.db.models.fields.files.FileField', [], {'max_length': '100'}), - 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}) - }, - 'migdal.category': { - 'Meta': {'object_name': 'Category'}, - 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), - 'slug_en': ('django.db.models.fields.SlugField', [], {'unique': 'True', 'max_length': '50'}), - 'slug_pl': ('django.db.models.fields.SlugField', [], {'unique': 'True', 'max_length': '50'}), - 'taxonomy': ('django.db.models.fields.CharField', [], {'max_length': '32'}), - 'title_en': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '64', 'db_index': 'True'}), - 'title_pl': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '64', 'db_index': 'True'}) - }, - 'migdal.entry': { - 'Meta': {'ordering': "['-date']", 'object_name': 'Entry'}, - '_body_en_rendered': ('django.db.models.fields.TextField', [], {}), - '_body_pl_rendered': ('django.db.models.fields.TextField', [], {}), - '_lead_en_rendered': ('django.db.models.fields.TextField', [], {}), - '_lead_pl_rendered': ('django.db.models.fields.TextField', [], {}), - 'author': ('django.db.models.fields.CharField', [], {'max_length': '128'}), - 'author_email': ('django.db.models.fields.EmailField', [], {'max_length': '128', 'null': 'True', 'blank': 'True'}), - 'body_en': ('markupfield.fields.MarkupField', [], {'null': 'True', 'rendered_field': 'True', 'blank': 'True'}), - 'body_en_markup_type': ('django.db.models.fields.CharField', [], {'default': "'textile_pl'", 'max_length': '30', 'blank': 'True'}), - 'body_pl': ('markupfield.fields.MarkupField', [], {'null': 'True', 'rendered_field': 'True', 'blank': 'True'}), - 'body_pl_markup_type': ('django.db.models.fields.CharField', [], {'default': "'textile_pl'", 'max_length': '30', 'blank': 'True'}), - 'categories': ('django.db.models.fields.related.ManyToManyField', [], {'symmetrical': 'False', 'to': "orm['migdal.Category']", 'null': 'True', 'blank': 'True'}), - 'changed_at': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'db_index': 'True', 'blank': 'True'}), - 'date': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'db_index': 'True', 'blank': 'True'}), - 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), - 'image': ('django.db.models.fields.files.ImageField', [], {'max_length': '100', 'null': 'True', 'blank': 'True'}), - 'lead_en': ('markupfield.fields.MarkupField', [], {'null': 'True', 'rendered_field': 'True', 'blank': 'True'}), - 'lead_en_markup_type': ('django.db.models.fields.CharField', [], {'default': "'textile_pl'", 'max_length': '30', 'blank': 'True'}), - 'lead_pl': ('markupfield.fields.MarkupField', [], {'null': 'True', 'rendered_field': 'True', 'blank': 'True'}), - 'lead_pl_markup_type': ('django.db.models.fields.CharField', [], {'default': "'textile_pl'", 'max_length': '30', 'blank': 'True'}), - 'needed_en': ('django.db.models.fields.CharField', [], {'default': "'n'", 'max_length': '1', 'db_index': 'True'}), - 'promo': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), - 'published_at_en': ('django.db.models.fields.DateTimeField', [], {'null': 'True', 'blank': 'True'}), - 'published_at_pl': ('django.db.models.fields.DateTimeField', [], {'null': 'True', 'blank': 'True'}), - 'published_en': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), - 'published_pl': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), - 'slug_en': ('migdal.fields.SlugNullField', [], {'max_length': '50', 'unique': 'True', 'null': 'True', 'blank': 'True'}), - 'slug_pl': ('migdal.fields.SlugNullField', [], {'max_length': '50', 'unique': 'True', 'null': 'True', 'blank': 'True'}), - 'title_en': ('django.db.models.fields.CharField', [], {'max_length': '255', 'null': 'True', 'blank': 'True'}), - 'title_pl': ('django.db.models.fields.CharField', [], {'max_length': '255', 'null': 'True', 'blank': 'True'}), - 'type': ('django.db.models.fields.CharField', [], {'max_length': '16', 'db_index': 'True'}) - } - } - - complete_apps = ['migdal'] \ No newline at end of file diff --git a/migdal/migrations/__init__.py b/migdal/migrations/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/migdal/models.py b/migdal/models.py deleted file mode 100644 index c15432d..0000000 --- a/migdal/models.py +++ /dev/null @@ -1,143 +0,0 @@ -# -*- coding: utf-8 -*- -# This file is part of PrawoKultury, licensed under GNU Affero GPLv3 or later. -# Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information. -# -from datetime import datetime -from django.conf import settings -from django.contrib.sites.models import Site -from django.core.exceptions import ValidationError -from django.core.mail import send_mail -from django.db import models -from django.template import loader, Context -from django.utils.translation import get_language, ugettext_lazy as _, ugettext -from django_comments_xtd.models import XtdComment -from markupfield.fields import MarkupField -from migdal import app_settings -from migdal.helpers import add_translatable -from migdal.fields import SlugNullField - -class Category(models.Model): - taxonomy = models.CharField(_('taxonomy'), max_length=32, - choices=app_settings.TAXONOMIES) - - class Meta: - verbose_name = _('category') - verbose_name_plural = _('categories') - - def __unicode__(self): - return self.title - - @models.permalink - def get_absolute_url(self): - return ('migdal_category', [self.slug]) - - -add_translatable(Category, { - 'title': models.CharField(max_length=64, unique=True, db_index=True), - 'slug': models.SlugField(unique=True, db_index=True), -}) - - -class Entry(models.Model): - type = models.CharField(max_length=16, - choices=((t.db, t.slug) for t in app_settings.TYPES), - db_index=True) - date = models.DateTimeField(_('created at'), auto_now_add=True, db_index=True) - changed_at = models.DateTimeField(_('changed at'), auto_now=True, db_index=True) - author = models.CharField(_('author'), max_length=128) - author_email = models.EmailField(_('author email'), max_length=128, null=True, blank=True, - help_text=_('Used only to display gravatar and send notifications.')) - image = models.ImageField(_('image'), upload_to='entry/image/', null=True, blank=True) - promo = models.BooleanField(_('promoted'), default=False) - categories = models.ManyToManyField(Category, null=True, blank=True, verbose_name=_('categories')) - - class Meta: - verbose_name = _('entry') - verbose_name_plural = _('entries') - ordering = ['-date'] - - def __unicode__(self): - return self.title - - def save(self, *args, **kwargs): - published_now = False - for lc, ln in settings.LANGUAGES: - if (getattr(self, "published_%s" % lc) - and getattr(self, "published_at_%s" % lc) is None): - setattr(self, "published_at_%s" % lc, datetime.now()) - published_now = True - super(Entry, self).save(*args, **kwargs) - if published_now: - self.notify_author_published() - - def clean(self): - for lc, ln in settings.LANGUAGES: - if (getattr(self, "published_%s" % lc) and - not getattr(self, "slug_%s" % lc)): - raise ValidationError( - ugettext("Published entry should have a slug in relevant language (%s).") % lc) - - @models.permalink - def get_absolute_url(self): - return ('migdal_entry_%s' % self.type, [self.slug]) - - def get_type(self): - return dict(app_settings.TYPES_DICT)[self.type] - - def notify_author_published(self): - if not self.author_email: - return - site = Site.objects.get_current() - mail_text = loader.get_template('migdal/mail/published.txt').render( - Context({ - 'entry': self, - 'site': site, - })) - send_mail( - ugettext(u'Your story has been published at %s.') % site.domain, - mail_text, settings.SERVER_EMAIL, [self.author_email] - ) - - -add_translatable(Entry, languages=app_settings.OPTIONAL_LANGUAGES, fields={ - 'needed': models.CharField(_('needed'), max_length=1, db_index=True, choices=( - ('n', _('Unneeded')), ('w', _('Needed')), ('y', _('Done'))), - default='n'), -}) - -add_translatable(Entry, { - 'slug': SlugNullField(unique=True, db_index=True, null=True, blank=True), - 'title': models.CharField(_('title'), max_length=255, null=True, blank=True), - 'lead': MarkupField(_('lead'), markup_type='textile_pl', null=True, blank=True, - help_text=_('Use Textile syntax.')), - 'body': MarkupField(_('body'), markup_type='textile_pl', null=True, blank=True, - help_text=_('Use Textile syntax.')), - 'published': models.BooleanField(_('published'), default=False), - 'published_at': models.DateTimeField(_('published at'), null=True, blank=True), -}) - - -class Attachment(models.Model): - file = models.FileField(_('file'), upload_to='entry/attach/') - entry = models.ForeignKey(Entry) - - def url(self): - return self.file.url if self.file else '' - - - -def notify_new_comment(sender, instance, created, **kwargs): - if (created and isinstance(instance.content_object, Entry) and - instance.content_object.author_email): - site = Site.objects.get_current() - mail_text = loader.get_template('migdal/mail/new_comment.txt').render( - Context({ - 'comment': instance, - 'site': site, - })) - send_mail( - ugettext(u'New comment under your story at %s.') % site.domain, - mail_text, settings.SERVER_EMAIL, - [instance.content_object.author_email] - ) -models.signals.post_save.connect(notify_new_comment, sender=XtdComment) \ No newline at end of file diff --git a/migdal/search_indexes.py b/migdal/search_indexes.py deleted file mode 100644 index 4257483..0000000 --- a/migdal/search_indexes.py +++ /dev/null @@ -1,27 +0,0 @@ -from django.conf import settings -import datetime -from haystack import indexes -from migdal.models import Entry -from migdal.helpers import add_translatable_index - - -class EntryIndex(indexes.RealTimeSearchIndex, indexes.Indexable): - date = indexes.DateTimeField(indexed=True, model_attr="date") - author = indexes.CharField(model_attr="author") - - def get_model(self): - return Entry - - def index_queryset(self): - """Used when the entire index for model is updated.""" - return self.get_model().objects.all() # filter(date__lte=datetime.datetime.now()) - - -add_translatable_index(EntryIndex, { - 'title': indexes.CharField(null=True), - 'lead': indexes.CharField(null=True), - 'body': indexes.CharField(null=True) - }) - - -getattr(EntryIndex, "body_%s" % settings.LANGUAGE_CODE).document = True diff --git a/migdal/templates/comments/form.html b/migdal/templates/comments/form.html deleted file mode 100755 index 341750f..0000000 --- a/migdal/templates/comments/form.html +++ /dev/null @@ -1,29 +0,0 @@ -{% load comments i18n %} -
-

{% trans "Add comment" %}

-
{% csrf_token %} - {% if next %}{% endif %} - {% for field in form %} - {% if field.is_hidden %} - {{ field }} - {% endif %} - {% endfor %} - - {% for field in form %} - {% if not field.is_hidden %} - - - {% endif %} - {% endfor %} - -
{{ field.label_tag }} - - {% if field.errors %}

{{ field.errors }}

{% endif %} - {{ field }} -
- - -
-
-
diff --git a/migdal/templates/comments/migdal/entry/list.html b/migdal/templates/comments/migdal/entry/list.html deleted file mode 100755 index 9f7241b..0000000 --- a/migdal/templates/comments/migdal/entry/list.html +++ /dev/null @@ -1,26 +0,0 @@ -{% load i18n %} -{% load gravatar %} -{% load markup_tags %} - -

{% trans "Comments" %}

-
- {% for comment in comment_list %} -
- Avatar -
-
- {% if comment.url %} - - {% endif %} - {{ comment.name }} - {% if comment.url %} - - {% endif %} -
-
{{ comment.submit_date }}
-
-
{{ comment.comment|textile_restricted_pl }}
-
- {% endfor %} -
-
\ No newline at end of file diff --git a/migdal/templates/comments/migdal/entry/preview.html b/migdal/templates/comments/migdal/entry/preview.html deleted file mode 100755 index 6d2b5ff..0000000 --- a/migdal/templates/comments/migdal/entry/preview.html +++ /dev/null @@ -1,45 +0,0 @@ -{% extends "base.html" %} -{% load comments gravatar i18n %} -{% load migdal_tags markup_tags %} - - -{% block "main_menu" %} - {% main_menu 'object' entry %} -{% endblock "main_menu" %} - - -{% block "body" %} - -
-
- -{% entry_begin form.target_object 1 %} -
-{{ form.target_object.body }} -
- -{% if form.target_object.get_type.commentable %} -
- - {% render_comment_list for form.target_object %} - -

{% trans "Preview your comment" %}

-
- -
- Avatar -
-
{{ form.name.value }}
-
-
{{ comment|textile_restricted_pl }}
-
-
- - {% include "comments/form.html" %} - -
-{% endif %} -
-
- -{% endblock %} diff --git a/migdal/templates/django_comments_xtd/email_followup_comment.html b/migdal/templates/django_comments_xtd/email_followup_comment.html deleted file mode 100644 index 2e5e858..0000000 --- a/migdal/templates/django_comments_xtd/email_followup_comment.html +++ /dev/null @@ -1,19 +0,0 @@ -{% load i18n %} -

{{ user_name }},

- -

Pojawił się nowy komentarz w wątku z Twoim udziałem.

- -

-{% language 'pl' %} - „{{ content_object.title }}” -{% endlanguage %} -

- -

{{ comment.name }}, {{ comment.submit_date|date:"SHORT_DATE_FORMAT" }}:

-
-{{ comment.comment }} -
- -

--
-{{ site }} -

diff --git a/migdal/templates/django_comments_xtd/email_followup_comment.txt b/migdal/templates/django_comments_xtd/email_followup_comment.txt deleted file mode 100755 index 834c60e..0000000 --- a/migdal/templates/django_comments_xtd/email_followup_comment.txt +++ /dev/null @@ -1,15 +0,0 @@ -{% load i18n %}{{ user_name }}, - -Pojawił się nowy komentarz w wątku z Twoim udziałem. - -{% language 'pl' %}„{{ content_object.title }}” -http://{{ site.domain }}{{ content_object.get_absolute_url }}{% endlanguage %} - - -{{ comment.name }}, {{ comment.submit_date|date:"SHORT_DATE_FORMAT" }}: --------- -{{ comment.comment }} - - --- -{{ site }} diff --git a/migdal/templates/migdal/categories.html b/migdal/templates/migdal/categories.html deleted file mode 100755 index 75c0805..0000000 --- a/migdal/templates/migdal/categories.html +++ /dev/null @@ -1,7 +0,0 @@ -
    - {% for cat in object_list %} -
  • - {{ cat }} -
  • - {% endfor %} -
\ No newline at end of file diff --git a/migdal/templates/migdal/entry/entry_begin.html b/migdal/templates/migdal/entry/entry_begin.html deleted file mode 100755 index 12f49ae..0000000 --- a/migdal/templates/migdal/entry/entry_begin.html +++ /dev/null @@ -1,47 +0,0 @@ -{% load i18n %} -{% load gravatar thumbnail %} - -Avatar -{% if detail %} -

{{ object.title }}

-{% else %} -

{{ object.title }}

-{% endif %} - -
-
{{ object.published_at }}
-
{{ object.author }}
- -{% comment %} -{% if request.LANGUAGE_CODE == 'pl' %} - {% if object.published_en %} - {% language 'en' %} - English version - {% endlanguage %} - {% endif %} -{% elif object.published_pl %} - {% language 'pl' %} - polska wersja - {% endlanguage %} -{% endif %} -{% endcomment %} - -
-{% for category in object.categories.all %} - {% if forloop.counter != 1 %}/{% endif %} - {{ category }} -{% endfor %} -
- -
- -{% if object.image %} - -{% endif %} -
-{{ object.lead }} -
diff --git a/migdal/templates/migdal/entry/entry_detail.html b/migdal/templates/migdal/entry/entry_detail.html deleted file mode 100755 index 5827d08..0000000 --- a/migdal/templates/migdal/entry/entry_detail.html +++ /dev/null @@ -1,57 +0,0 @@ -{% extends "base.html" %} -{% load comments i18n %} -{% load common_tags migdal_tags share %} - - -{% block "titleextra" %}{{ entry.title }} :: {% endblock %} -{% block "ogtitle" %}{{ entry.title }}{% endblock %} -{% block "ogtype" %}article{% endblock %} -{% block "ogdescription"%}{{ entry.lead|striptags|truncatewords:10 }}{% endblock %} -{% block "ogimage" %}{% spaceless %} -{% if entry.image %} - {{ entry.image.url|build_absolute_uri:request }} -{% else %} - {{ block.super }} -{% endif %} -{% endspaceless %}{% endblock %} - - -{% block "main_menu" %} - {% main_menu 'object' entry %} -{% endblock "main_menu" %} - - -{% block "body" %} - -{% if not entry.published %} -

{% trans "This entry hasn't been published yet." %}

-{% endif %} - -
-
- -{% entry_begin entry 1 %} -
-{{ entry.body }} -
- -
- -
- -
- -
- -{% if entry.get_type.commentable %} - {% render_comment_list for entry %} -
- {% entry_comment_form entry %} -
-{% endif %} -
-
- -{% endblock %} \ No newline at end of file diff --git a/migdal/templates/migdal/entry/entry_list.html b/migdal/templates/migdal/entry/entry_list.html deleted file mode 100755 index eede699..0000000 --- a/migdal/templates/migdal/entry/entry_list.html +++ /dev/null @@ -1,66 +0,0 @@ -{% extends "base.html" %} -{% load url from future %} -{% load i18n %} -{% load pagination_tags prevnext %} -{% 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 %} -

{% trans "Category" %}: {{ category }} - -

-{% elif entry_type %} -

{{ entry_type|capfirst }} - -

-{% endif %} - -{% if object_list.promobox and request.page == 1 %} -
- - -
-
    -{% for object in object_list.promobox %} - {% entry_promobox object forloop.counter %} -{% endfor %} -
-
- -
-{% endif %} - -{% if submit %} - -{% endif %} - - -{% autopaginate object_list 10 %} -{% for object in object_list %} - {% entry_short object %} -{% endfor %} -{% prevnext %} - -{% endblock %} \ No newline at end of file diff --git a/migdal/templates/migdal/entry/entry_promobox.html b/migdal/templates/migdal/entry/entry_promobox.html deleted file mode 100755 index f68b487..0000000 --- a/migdal/templates/migdal/entry/entry_promobox.html +++ /dev/null @@ -1,30 +0,0 @@ -{% load i18n thumbnail %} - - -
  • - - - - -
    -
    -

    {{ object.title }}

    - -
    -{{ object.lead|striptags|truncatewords:8 }} -
    -
    -
    - -
    -
  • diff --git a/migdal/templates/migdal/entry/entry_short.html b/migdal/templates/migdal/entry/entry_short.html deleted file mode 100755 index 31dbf9e..0000000 --- a/migdal/templates/migdal/entry/entry_short.html +++ /dev/null @@ -1,38 +0,0 @@ -{% load i18n %} -{% load comments %} -{% load migdal_tags share %} - - -
    -
    - -{% entry_begin object %} - -
    - -
    -
    - -{% if object.get_type.commentable %} -{% get_comment_count for object as comment_count %} - -{% blocktrans count comment_count as c %}{{c}} comment{% plural %}{{c}} comments{% endblocktrans %} - -{% endif %} - -{% if object.body.raw %} - {% trans "read more" %} -{% endif %} - -
    - - -
    - - - -
    -
    -
    diff --git a/migdal/templates/migdal/entry/info/entry_begin.html b/migdal/templates/migdal/entry/info/entry_begin.html deleted file mode 100755 index e9eae95..0000000 --- a/migdal/templates/migdal/entry/info/entry_begin.html +++ /dev/null @@ -1,38 +0,0 @@ -{% load i18n %} -{% load thumbnail %} - -{% if detail %} -

    {{ object.title }}

    -{% else %} -

    {{ object.title }}

    -{% endif %} - - -{% comment %} -
    -{% if request.LANGUAGE_CODE == 'pl' %} - {% if object.published_en %} - {% language 'en' %} - English version - {% endlanguage %} - {% endif %} -{% elif object.published_pl %} - {{ request.LANGUAGE_CODE }} - {% language 'pl' %} - polska wersja - {% endlanguage %} -{% endif %} -
    -{% endcomment %} - - -{% if object.image %} - -{% endif %} -
    -{{ object.lead }} -
    diff --git a/migdal/templates/migdal/entry/publications/entry_begin.html b/migdal/templates/migdal/entry/publications/entry_begin.html deleted file mode 100755 index e9eae95..0000000 --- a/migdal/templates/migdal/entry/publications/entry_begin.html +++ /dev/null @@ -1,38 +0,0 @@ -{% load i18n %} -{% load thumbnail %} - -{% if detail %} -

    {{ object.title }}

    -{% else %} -

    {{ object.title }}

    -{% endif %} - - -{% comment %} -
    -{% if request.LANGUAGE_CODE == 'pl' %} - {% if object.published_en %} - {% language 'en' %} - English version - {% endlanguage %} - {% endif %} -{% elif object.published_pl %} - {{ request.LANGUAGE_CODE }} - {% language 'pl' %} - polska wersja - {% endlanguage %} -{% endif %} -
    -{% endcomment %} - - -{% if object.image %} - -{% endif %} -
    -{{ object.lead }} -
    diff --git a/migdal/templates/migdal/entry/submit.html b/migdal/templates/migdal/entry/submit.html deleted file mode 100755 index cc376d7..0000000 --- a/migdal/templates/migdal/entry/submit.html +++ /dev/null @@ -1,26 +0,0 @@ -{% extends "base.html" %} -{% load url from future %} -{% load i18n %} - -{% block "body" %} - -

    {% trans "Submit new story" %}

    - -

    {% blocktrans %} -By submitting a story here, you agree to publish it under the terms of the -Creative Commons Attribution-Share Alike -free license.{% endblocktrans %}

    - -

    {% blocktrans %}Stories are moderated, so please be -patient, you'll be notified when it's published.{% endblocktrans %}

    - -
    -{% csrf_token %} - - {{ submit_form.as_table }} - -
    -
    - - -{% endblock %} \ No newline at end of file diff --git a/migdal/templates/migdal/entry/submit_thanks.html b/migdal/templates/migdal/entry/submit_thanks.html deleted file mode 100755 index 99cecaf..0000000 --- a/migdal/templates/migdal/entry/submit_thanks.html +++ /dev/null @@ -1,18 +0,0 @@ -{% extends "base.html" %} -{% load i18n %} - -{% block "body" %} - -

    {% trans "Thanks for submitting" %}

    - -

    -{% blocktrans %} -Thank you for submitting this new story, it's waiting for moderation. -If you provided an email, we'll inform you about changes in it's status -and comments. -{% endblocktrans %} -

    - - - -{% endblock %} \ No newline at end of file diff --git a/migdal/templates/migdal/last_comments.html b/migdal/templates/migdal/last_comments.html deleted file mode 100755 index f26cfea..0000000 --- a/migdal/templates/migdal/last_comments.html +++ /dev/null @@ -1,13 +0,0 @@ -{% load gravatar %} -{% load markup_tags %} - \ No newline at end of file diff --git a/migdal/templates/migdal/mail/manager_new_entry.txt b/migdal/templates/migdal/mail/manager_new_entry.txt deleted file mode 100755 index 59703e2..0000000 --- a/migdal/templates/migdal/mail/manager_new_entry.txt +++ /dev/null @@ -1,14 +0,0 @@ -{% load url from future %}W serwisie pojawił się nowy wpis. -http://localhost:8000{% url 'admin:migdal_entry_change' object.pk %} - -Autor: {{ object.author|default_if_none:"" }} -E-mail: {{ object.author_email|default_if_none:"" }} -Tytuł [pl]: {{ object.title_pl|default_if_none:"" }} -Tytuł [en]: {{ object.title_en|default_if_none:"" }} -Kategorie: {{ object.categories.all|join:", " }} - ---- -{{ object.lead_pl.raw }} ---- -{{ object.lead_en.raw }} ---- \ No newline at end of file diff --git a/migdal/templates/migdal/mail/new_comment.txt b/migdal/templates/migdal/mail/new_comment.txt deleted file mode 100755 index d7074c2..0000000 --- a/migdal/templates/migdal/mail/new_comment.txt +++ /dev/null @@ -1,15 +0,0 @@ -{% load i18n %}{{ comment.content_object.author }}, - -Pod Twoim wpisem pojawił się nowy komentarz. - -{% language 'pl' %}{{ comment.content_object.title }} -http://{{ site.domain }}{{ comment.get_absolute_url }}{% endlanguage %} - - -Autor: {{ comment.name }} - -{{ comment.comment }} - - --- -{{ site }} diff --git a/migdal/templates/migdal/mail/published.txt b/migdal/templates/migdal/mail/published.txt deleted file mode 100755 index b99e1f3..0000000 --- a/migdal/templates/migdal/mail/published.txt +++ /dev/null @@ -1,11 +0,0 @@ -{% load i18n %}{{ entry.author }}, - -Twój wpis został opublikowany: - -{% language 'pl' %}{{ entry.title }} -http://{{ site.domain }}{{ entry.get_absolute_url }}{% endlanguage %} - -Dziękujemy! - --- -{{ site }} diff --git a/migdal/templates/migdal/menu.html b/migdal/templates/migdal/menu.html deleted file mode 100755 index 3fcfef5..0000000 --- a/migdal/templates/migdal/menu.html +++ /dev/null @@ -1,7 +0,0 @@ -{% load i18n %} -{% for item in items %} - - {{ item.title }} -{% endfor %} diff --git a/migdal/templates/search/search.html b/migdal/templates/search/search.html deleted file mode 100644 index 84610ff..0000000 --- a/migdal/templates/search/search.html +++ /dev/null @@ -1,32 +0,0 @@ -{% extends "base.html" %} -{% load url from future %} -{% load i18n %} -{% load migdal_tags %} -{% load events_tags %} - - -{% block "body" %} -

    {% trans "Search results" %}

    - -{% for result in page.object_list %} - {% if result.model_name == "entry" %} - {% entry_short result.object %} - {% elif result.model_name == "event" %} - {% event_short result.object %} - {% endif %} -{% empty %} -

    {% trans "No results found." %}

    -{# Show some example queries to run, maybe query syntax, something else? #} -{% endfor %} - -{% if page.has_previous or page.has_next %} -

    - {% if page.has_previous %} - {% trans "previous" %} - {% endif %} - {% if page.has_next %} - {% trans "next" %} - {% endif %} -{% endif %} - -{% endblock "body" %} diff --git a/migdal/templatetags/__init__.py b/migdal/templatetags/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/migdal/templatetags/migdal_tags.py b/migdal/templatetags/migdal_tags.py deleted file mode 100644 index 380cb56..0000000 --- a/migdal/templatetags/migdal_tags.py +++ /dev/null @@ -1,141 +0,0 @@ -# -*- coding: utf-8 -*- -# This file is part of PrawoKultury, licensed under GNU Affero GPLv3 or later. -# Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information. -# -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 -from django.utils.translation import ugettext_lazy as _ - -register = template.Library() - - -@register.simple_tag(takes_context=True) -def entry_begin(context, entry, detail=False): - t = template.loader.select_template(( - 'migdal/entry/%s/entry_begin.html' % entry.type, - 'migdal/entry/entry_begin.html', - )) - context = { - 'request': context['request'], - 'object': entry, - 'detail': detail, - } - return t.render(template.Context(context)) - - -@register.simple_tag(takes_context=True) -def entry_short(context, entry): - t = template.loader.select_template(( - 'migdal/entry/%s/entry_short.html' % entry.type, - 'migdal/entry/entry_short.html', - )) - context = { - 'request': context['request'], - 'object': entry, - } - return t.render(template.Context(context)) - - -@register.simple_tag(takes_context=True) -def entry_promobox(context, entry, counter): - t = template.loader.select_template(( - 'migdal/entry/%s/entry_promobox.html' % entry.type, - 'migdal/entry/entry_promobox.html', - )) - context = { - 'request': context['request'], - 'object': entry, - 'counter': counter, - } - return t.render(template.Context(context)) - - -@register.inclusion_tag('migdal/categories.html', takes_context=True) -def categories(context, taxonomy): - context = { - 'request': context['request'], - 'object_list': Category.objects.filter(taxonomy=taxonomy - ).exclude(entry__isnull=True) - } - return context - - -@register.inclusion_tag('migdal/last_comments.html') -def last_comments(limit=app_settings.LAST_COMMENTS): - return {'object_list': - XtdComment.objects.filter(is_public=True, is_removed=False).order_by('-submit_date')[:limit]} - - -@register.inclusion_tag(['comments/form.html']) -def entry_comment_form(entry): - return { - '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')), - EntryTypeMenuItem(_(u'Publications'), u'publications'), - MenuItem(_(u'Events'), reverse('events')), - CategoryMenuItem(Category.objects.get(slug_pl='stanowisko'), - title=_('Positions')), - #CategoryMenuItem(Category.objects.get(slug_pl='pierwsza-pomoc'), - # title=_('First aid in copyright')), - ] - #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} diff --git a/migdal/tests.py b/migdal/tests.py deleted file mode 100644 index 501deb7..0000000 --- a/migdal/tests.py +++ /dev/null @@ -1,16 +0,0 @@ -""" -This file demonstrates writing tests using the unittest module. These will pass -when you run "manage.py test". - -Replace this with more appropriate tests for your application. -""" - -from django.test import TestCase - - -class SimpleTest(TestCase): - def test_basic_addition(self): - """ - Tests that 1 + 1 always equals 2. - """ - self.assertEqual(1 + 1, 2) diff --git a/migdal/urls.py b/migdal/urls.py deleted file mode 100644 index c7db6f4..0000000 --- a/migdal/urls.py +++ /dev/null @@ -1,48 +0,0 @@ -# -*- coding: utf-8 -*- -# This file is part of PrawoKultury, licensed under GNU Affero GPLv3 or later. -# Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information. -# -from django.conf.urls import patterns, include, url, handler404 -from django.utils.translation import ugettext_lazy as _ -from django.utils.translation import string_concat -from migdal import feeds, app_settings -from migdal.views import SearchPublishedView -from migdal.helpers import i18n_patterns - -pats = [] -for t in app_settings.TYPES: - pats += [ - # entry list - url(string_concat(r'^', t.slug, r'/$'), - 'migdal.views.entry_list', {'type_db': t.db}, - name='migdal_entry_list_%s' % t.db), - url(string_concat(r'^', t.slug, r'/rss.xml$'), - feeds.EntriesFeed(), {'type_db': t.db}, - name='migdal_entry_list_%s_feed' % t.db), - # single entry - url(string_concat(r'^', t.slug, r'/(?P[^/]+)/$'), - 'migdal.views.entry', {'type_db': t.db}, - name='migdal_entry_%s' % t.db), - ] - - -# Disable en for now. -urlpatterns = patterns('', - url(r'^en/', handler404), -) -urlpatterns += i18n_patterns('', - # main page - url(r'^$', 'migdal.views.entry_list', 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'), - url(string_concat(r'^', _('submit'), r'/', _('thanks'), r'$'), 'migdal.views.submit_thanks', name='migdal_submit_thanks'), - # category - url(string_concat(r'^', _('categories'), r'/(?P[^/]*)/$'), - 'migdal.views.entry_list', name='migdal_category'), - url(string_concat(r'^', _('categories'), r'/(?P[^/]*)/rss.xml$'), - feeds.EntriesFeed(), name='migdal_category_feed'), - url(string_concat(r'^', _('search')), SearchPublishedView(), name='search'), - # type-specific views - *pats -) diff --git a/migdal/views.py b/migdal/views.py deleted file mode 100644 index 84cd6fe..0000000 --- a/migdal/views.py +++ /dev/null @@ -1,90 +0,0 @@ -# -*- coding: utf-8 -*- -# This file is part of PrawoKultury, licensed under GNU Affero GPLv3 or later. -# Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information. -# -from django.shortcuts import get_object_or_404, render, redirect -from django.utils.translation import get_language -from migdal import api -from migdal.forms import get_submit_form -from migdal.models import Category, Entry -from migdal import app_settings -from haystack.views import SearchView - - -def entry_list(request, type_db=None, category_slug=None): - lang = request.LANGUAGE_CODE - templates = ["migdal/entry/entry_list.html"] - - if type_db: - if app_settings.TYPES_ON_MAIN == (type_db,): - return redirect('migdal_main') - entry_type = app_settings.TYPES_DICT[type_db] - templates = ["migdal/entry/%s/entry_list.html" % type_db] + templates - submit = type_db == app_settings.TYPE_SUBMIT - else: - submit = app_settings.TYPES_ON_MAIN == (app_settings.TYPE_SUBMIT,) - entry_type = None - - if category_slug: - category = get_object_or_404(Category, **{'slug_%s' % lang: category_slug}) - else: - category = None - - promobox = 5 if entry_type is None and category is None else None - - object_list = api.entry_list(entry_type=entry_type, category=category, - promobox=promobox) - - return render(request, templates, { - 'object_list': object_list, - 'category': category, - 'entry_type': entry_type, - 'submit': submit, - }) - - -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) - - templates = ["migdal/entry/entry_detail.html"] - if type_db is not None: - templates = ["migdal/entry/%s/entry_detail.html" % type_db] + templates - return render(request, templates, {'entry': entry}) - - -def submit(request): - if request.method == 'POST': - submit_form = get_submit_form(request.POST) - if submit_form.is_valid(): - submit_form.save() - return redirect('migdal_submit_thanks') - else: - submit_form = get_submit_form() - - return render(request, 'migdal/entry/submit.html', { - 'submit_form': submit_form, - }) - -def submit_thanks(request): - return render(request, "migdal/entry/submit_thanks.html") - - -class SearchPublishedView(SearchView): - def __init__(self, *args, **kwargs): - super(SearchPublishedView, self).__init__(*args, **kwargs) - - def get_results(self): - results = super(SearchPublishedView, self).get_results() - lang_code = get_language() - def is_published(entity): - if isinstance(entity, Entry): - return getattr(entity, "published_%s" % lang_code) == True - else: - return True - results = filter(lambda r: is_published(r.object), results) - print results - return results diff --git a/prawokultury/helpers.py b/prawokultury/helpers.py deleted file mode 100644 index 5877e0b..0000000 --- a/prawokultury/helpers.py +++ /dev/null @@ -1,66 +0,0 @@ -# -*- coding: utf-8 -*- -# This file is part of PrawoKultury, licensed under GNU Affero GPLv3 or later. -# Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information. -# -from django.conf import settings -from textile import Textile - - -class TextilePL(Textile): - glyph_defaults = [(name, repl) - for (name, repl) in Textile.glyph_defaults - if name != 'txt_quote_double_open'] - glyph_defaults.append(('txt_quote_double_open', '„')) - - -def textile_pl(text): - return TextilePL().textile(text) - - -def textile_restricted_pl(text): - return TextilePL(restricted=True, lite=True, - noimage=True, auto_link=False).textile( - text, rel='nofollow') - - -class LazyUGettextLazy(): - """You can use it to internationalize strings in settings. - - Just import this class as gettext. - """ - _ = lambda s: s - real = False - - def __init__(self, text): - self.text = text - - def __unicode__(self): - if not self.real: - from django.utils.translation import ugettext_lazy - LazyUGettextLazy._ = staticmethod(ugettext_lazy) - LazyUGettextLazy.real = True - return unicode(self._(self.text)) - - -class AppSettings(object): - """Allows specyfying custom settings for an app, with default values. - - Just subclass, set some properties and instantiate with a prefix. - Getting a SETTING from an instance will check for prefix_SETTING - in project settings if set, else take the default. The value will be - then filtered through _more_SETTING method, if there is one. - - """ - def __init__(self, prefix): - self._prefix = prefix - - def __getattribute__(self, name): - if name.startswith('_'): - return object.__getattribute__(self, name) - value = getattr(settings, - "%s_%s" % (self._prefix, name), - object.__getattribute__(self, name)) - more = "_more_%s" % name - if hasattr(self, more): - value = getattr(self, more)(value) - return value diff --git a/prawokultury/menu_items.py b/prawokultury/menu_items.py new file mode 100644 index 0000000..eb3f766 --- /dev/null +++ b/prawokultury/menu_items.py @@ -0,0 +1,29 @@ +from migdal.models import Category, Entry +from menu.helpers import ObjectMenuItem, MenuItem, ModelMenuItem +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='o-nas') + +ITEMS.append(ModelMenuItem(Entry, reverse_lazy('migdal_entry_list_publications'), + field_lookups={'type': 'publications'}, title=_('Publications'))) + +ITEMS.append(MenuItem(reverse_lazy('events'), _('Events'), + more_urls=(reverse_lazy('events_past'),))) + +ITEMS.append(ObjectMenuItem(Category.objects.get(slug_pl='stanowisko'), + rev_lookups={Entry: 'categories'}, title=_('Positions'))) +#CategoryMenuItem(Category.objects.get(slug_pl='stanowisko'), +# title=_('Positions')), diff --git a/prawokultury/settings.d/10-paths.conf b/prawokultury/settings.d/10-paths.conf old mode 100755 new mode 100644 diff --git a/prawokultury/settings.d/20-basic.conf b/prawokultury/settings.d/20-basic.conf old mode 100755 new mode 100644 diff --git a/prawokultury/settings.d/30-apps.conf b/prawokultury/settings.d/30-apps.conf old mode 100755 new mode 100644 index 8d6bf16..1d0e9b9 --- a/prawokultury/settings.d/30-apps.conf +++ b/prawokultury/settings.d/30-apps.conf @@ -1,5 +1,7 @@ INSTALLED_APPS = ( 'prawokultury', + 'fnpdjango', + 'menu', 'events', 'migdal', diff --git a/prawokultury/settings.d/30-locale.conf b/prawokultury/settings.d/30-locale.conf old mode 100755 new mode 100644 diff --git a/prawokultury/settings.d/35-search.conf b/prawokultury/settings.d/35-search.conf index 62b5799..15667a3 100644 --- a/prawokultury/settings.d/35-search.conf +++ b/prawokultury/settings.d/35-search.conf @@ -5,5 +5,4 @@ HAYSTACK_CONNECTIONS = { }, } -from django.conf import settings -HAYSTACK_DOCUMENT_FIELD = "body_%s" % settings.LANGUAGE_CODE +HAYSTACK_DOCUMENT_FIELD = "body_%s" % LANGUAGE_CODE diff --git a/prawokultury/settings.d/40-auth.conf b/prawokultury/settings.d/40-auth.conf old mode 100755 new mode 100644 diff --git a/prawokultury/settings.d/40-context.conf b/prawokultury/settings.d/40-context.conf old mode 100755 new mode 100644 diff --git a/prawokultury/settings.d/40-logging.conf b/prawokultury/settings.d/40-logging.conf old mode 100755 new mode 100644 diff --git a/prawokultury/settings.d/40-middleware.conf b/prawokultury/settings.d/40-middleware.conf old mode 100755 new mode 100644 index 2b07632..47a889e --- a/prawokultury/settings.d/40-middleware.conf +++ b/prawokultury/settings.d/40-middleware.conf @@ -1,7 +1,7 @@ MIDDLEWARE_CLASSES = ( 'django.contrib.sessions.middleware.SessionMiddleware', #'django.middleware.locale.LocaleMiddleware', - 'migdal.middleware.URLLocaleMiddleware', + 'fnpdjango.middleware.URLLocaleMiddleware', 'django.middleware.common.CommonMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', @@ -19,7 +19,7 @@ MIDDLEWARE_CLASSES += ( # Uncomment the next line for simple clickjacking protection: # 'django.middleware.clickjacking.XFrameOptionsMiddleware', 'pagination.middleware.PaginationMiddleware', - 'realip_middleware.SetRemoteAddrFromXRealIP', + 'fnpdjango.middleware.SetRemoteAddrFromXRealIP', ) diff --git a/prawokultury/settings.d/50-contrib.conf b/prawokultury/settings.d/50-contrib.conf old mode 100755 new mode 100644 index 27a516c..55c9811 --- a/prawokultury/settings.d/50-contrib.conf +++ b/prawokultury/settings.d/50-contrib.conf @@ -1,4 +1,4 @@ -from prawokultury.helpers import textile_pl +from fnpdjango.utils.text.textilepl import textile_pl COMMENTS_APP = "django_comments_xtd" COMMENTS_XTD_CONFIRM_EMAIL = False diff --git a/prawokultury/settings.d/50-static.conf b/prawokultury/settings.d/50-static.conf old mode 100755 new mode 100644 diff --git a/prawokultury/settings.d/60-custom.conf b/prawokultury/settings.d/60-custom.conf old mode 100755 new mode 100644 index e69de29..0f84054 --- a/prawokultury/settings.d/60-custom.conf +++ b/prawokultury/settings.d/60-custom.conf @@ -0,0 +1 @@ +MENU_MODULE = 'prawokultury.menu_items' diff --git a/prawokultury/templates/base.html b/prawokultury/templates/base.html index 0a92ff7..cae698b 100755 --- a/prawokultury/templates/base.html +++ b/prawokultury/templates/base.html @@ -1,7 +1,7 @@ {% load url from future %} {% load i18n static %} -{% load common_tags migdal_tags events_tags share %} +{% load fnp_common menu_tags migdal_tags events_tags fnp_share fnp_lang %} {% load compressed %} @@ -49,8 +49,9 @@

    diff --git a/prawokultury/templates/prevnext/next.html b/prawokultury/templates/prevnext/next.html deleted file mode 100755 index 928011f..0000000 --- a/prawokultury/templates/prevnext/next.html +++ /dev/null @@ -1,16 +0,0 @@ -{% if number or url %} - {% load i18n %} - - {% if title %} - {{ title }} - {% else %} - {% trans "next" %} - {% endif %} - -{% endif %} \ No newline at end of file diff --git a/prawokultury/templates/prevnext/previous.html b/prawokultury/templates/prevnext/previous.html deleted file mode 100755 index 88a656b..0000000 --- a/prawokultury/templates/prevnext/previous.html +++ /dev/null @@ -1,16 +0,0 @@ -{% if number or url %} - {% load i18n %} - - {% if title %} - {{ title }} - {% else %} - {% trans "previous" %} - {% endif %} - -{% endif %} \ No newline at end of file diff --git a/prawokultury/templates/prevnext/prevnext.html b/prawokultury/templates/prevnext/prevnext.html deleted file mode 100755 index 8a5cd04..0000000 --- a/prawokultury/templates/prevnext/prevnext.html +++ /dev/null @@ -1,5 +0,0 @@ -{% load prevnext %} -

    -{% next_page %} -{% previous_page %} -

    \ No newline at end of file diff --git a/prawokultury/templates/share.html b/prawokultury/templates/share.html deleted file mode 100755 index 71b2c0e..0000000 --- a/prawokultury/templates/share.html +++ /dev/null @@ -1,35 +0,0 @@ -{% load i18n common_tags static %} -{% with encoded_url=url|build_absolute_uri:request|urlencode encoded_desc=description|urlencode %} - - - {% trans 'Share on Google+' %} - - - {% trans 'Share on NK.pl' %} -{% comment %} - - {% trans 'Share on Diaspora' %} - - {% trans 'Share on Blip.pl' %} -{% endcomment %} -{% endwith %} \ No newline at end of file diff --git a/prawokultury/templatetags/__init__.py b/prawokultury/templatetags/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/prawokultury/templatetags/common_tags.py b/prawokultury/templatetags/common_tags.py deleted file mode 100755 index ccaf03b..0000000 --- a/prawokultury/templatetags/common_tags.py +++ /dev/null @@ -1,7 +0,0 @@ -from django import template -register = template.Library() - - -@register.filter -def build_absolute_uri(uri, request): - return request.build_absolute_uri(uri) diff --git a/prawokultury/templatetags/markup_tags.py b/prawokultury/templatetags/markup_tags.py deleted file mode 100644 index 9f1117e..0000000 --- a/prawokultury/templatetags/markup_tags.py +++ /dev/null @@ -1,18 +0,0 @@ -# -*- coding: utf-8 -*- -# This file is part of PrawoKultury, licensed under GNU Affero GPLv3 or later. -# Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information. -# -from django import template -from django.utils.safestring import mark_safe -from prawokultury import helpers - -register = template.Library() - - -@register.filter -def textile_pl(node): - return mark_safe(helpers.textile_pl(node)) - -@register.filter -def textile_restricted_pl(node): - return mark_safe(helpers.textile_restricted_pl(node)) diff --git a/prawokultury/templatetags/prevnext.py b/prawokultury/templatetags/prevnext.py deleted file mode 100755 index ec067e7..0000000 --- a/prawokultury/templatetags/prevnext.py +++ /dev/null @@ -1,27 +0,0 @@ -from django.template import Library - -register = Library() - - -@register.inclusion_tag('prevnext/previous.html', takes_context=True) -def previous_page(context, fallback=None, fallback_title=None): - current = context['page_obj'].number - if current > 1: - return {'number': current - 1, 'title': None, 'url': None} - else: - return {'number': None, 'title': fallback_title, 'url': fallback} - - -@register.inclusion_tag('prevnext/next.html', takes_context=True) -def next_page(context, fallback=None, fallback_title=None): - current = context['page_obj'].number - page_range = context['paginator'].page_range - if current < page_range[-1]: - return {'number': current + 1, 'title': None, 'url': None} - else: - return {'number': None, 'title': fallback_title, 'url': fallback} - - -@register.inclusion_tag('prevnext/prevnext.html', takes_context=True) -def prevnext(context): - return context diff --git a/prawokultury/templatetags/share.py b/prawokultury/templatetags/share.py deleted file mode 100755 index ba9a69b..0000000 --- a/prawokultury/templatetags/share.py +++ /dev/null @@ -1,13 +0,0 @@ -from django.template import Library - -register = Library() - - -@register.inclusion_tag('share.html', takes_context=True) -def share(context, url, description, iconset=""): - return { - 'url': url, - 'description': description, - 'iconset': iconset, - 'request': context['request'], - } diff --git a/prawokultury/urls.py b/prawokultury/urls.py index e1fb40b..1e2683b 100644 --- a/prawokultury/urls.py +++ b/prawokultury/urls.py @@ -6,10 +6,10 @@ from django.conf import settings from django.conf.urls import patterns, include, url from django.contrib import admin from django.contrib.staticfiles.urls import staticfiles_urlpatterns -from migdal.helpers import i18n_patterns -from migdal.urls import urlpatterns as migdal_urlpatterns from django.utils.translation import ugettext_lazy as _, string_concat +from fnpdjango.utils.urls import i18n_patterns from events.urls import urlpatterns as events_urlpatterns +from migdal.urls import urlpatterns as migdal_urlpatterns admin.autodiscover() diff --git a/realip_middleware.py b/realip_middleware.py deleted file mode 100755 index 9f97b7f..0000000 --- a/realip_middleware.py +++ /dev/null @@ -1,7 +0,0 @@ -class SetRemoteAddrFromXRealIP(object): - """Sets REMOTE_ADDR from the X-Real-IP header, as set by Nginx.""" - def process_request(self, request): - try: - request.META['REMOTE_ADDR'] = request.META['HTTP_X_REAL_IP'] - except KeyError: - return None diff --git a/requirements.txt b/requirements.txt index 79359e7..5915d22 100644 --- a/requirements.txt +++ b/requirements.txt @@ -6,6 +6,9 @@ PIL sorl-thumbnail>=11.09,<12 django-pagination +-e git+git://github.com/fnp/fnpdjango.git@9a5b05c52311da4f726fec29d8be7d173f695352#egg=fnpdjango +-e git+git://github.com/fnp/django-migdal.git@734cd58d3f12c5397b42c1ae122c947500386014#egg=django-migdal + textile django-markupfield django-gravatar diff --git a/slughifi.py b/slughifi.py deleted file mode 100644 index fe5c9e3..0000000 --- a/slughifi.py +++ /dev/null @@ -1,56 +0,0 @@ -# -*- coding: utf-8 -*- -import re -from types import UnicodeType - -from django.template.defaultfilters import slugify - -# default unicode character mapping ( you may not see some chars, leave as is ) -char_map = {u'À': 'A', u'Á': 'A', u'Â': 'A', u'Ã': 'A', u'Ä': 'Ae', u'Å': 'A', u'Æ': 'A', u'Ā': 'A', u'Ą': 'A', u'Ă': 'A', u'Ç': 'C', u'Ć': 'C', u'Č': 'C', u'Ĉ': 'C', u'Ċ': 'C', u'Ď': 'D', u'Đ': 'D', u'È': 'E', u'É': 'E', u'Ê': 'E', u'Ë': 'E', u'Ē': 'E', u'Ę': 'E', u'Ě': 'E', u'Ĕ': 'E', u'Ė': 'E', u'Ĝ': 'G', u'Ğ': 'G', u'Ġ': 'G', u'Ģ': 'G', u'Ĥ': 'H', u'Ħ': 'H', u'Ì': 'I', u'Í': 'I', u'Î': 'I', u'Ï': 'I', u'Ī': 'I', u'Ĩ': 'I', u'Ĭ': 'I', u'Į': 'I', u'İ': 'I', u'IJ': 'IJ', u'Ĵ': 'J', u'Ķ': 'K', u'Ľ': 'K', u'Ĺ': 'K', u'Ļ': 'K', u'Ŀ': 'K', u'Ł': 'L', u'Ñ': 'N', u'Ń': 'N', u'Ň': 'N', u'Ņ': 'N', u'Ŋ': 'N', u'Ò': 'O', u'Ó': 'O', u'Ô': 'O', u'Õ': 'O', u'Ö': 'Oe', u'Ø': 'O', u'Ō': 'O', u'Ő': 'O', u'Ŏ': 'O', u'Œ': 'OE', u'Ŕ': 'R', u'Ř': 'R', u'Ŗ': 'R', u'Ś': 'S', u'Ş': 'S', u'Ŝ': 'S', u'Ș': 'S', u'Š': 'S', u'Ť': 'T', u'Ţ': 'T', u'Ŧ': 'T', u'Ț': 'T', u'Ù': 'U', u'Ú': 'U', u'Û': 'U', u'Ü': 'Ue', u'Ū': 'U', u'Ů': 'U', u'Ű': 'U', u'Ŭ': 'U', u'Ũ': 'U', u'Ų': 'U', u'Ŵ': 'W', u'Ŷ': 'Y', u'Ÿ': 'Y', u'Ý': 'Y', u'Ź': 'Z', u'Ż': 'Z', u'Ž': 'Z', u'à': 'a', u'á': 'a', u'â': 'a', u'ã': 'a', u'ä': 'ae', u'ā': 'a', u'ą': 'a', u'ă': 'a', u'å': 'a', u'æ': 'ae', u'ç': 'c', u'ć': 'c', u'č': 'c', u'ĉ': 'c', u'ċ': 'c', u'ď': 'd', u'đ': 'd', u'è': 'e', u'é': 'e', u'ê': 'e', u'ë': 'e', u'ē': 'e', u'ę': 'e', u'ě': 'e', u'ĕ': 'e', u'ė': 'e', u'ƒ': 'f', u'ĝ': 'g', u'ğ': 'g', u'ġ': 'g', u'ģ': 'g', u'ĥ': 'h', u'ħ': 'h', u'ì': 'i', u'í': 'i', u'î': 'i', u'ï': 'i', u'ī': 'i', u'ĩ': 'i', u'ĭ': 'i', u'į': 'i', u'ı': 'i', u'ij': 'ij', u'ĵ': 'j', u'ķ': 'k', u'ĸ': 'k', u'ł': 'l', u'ľ': 'l', u'ĺ': 'l', u'ļ': 'l', u'ŀ': 'l', u'ñ': 'n', u'ń': 'n', u'ň': 'n', u'ņ': 'n', u'ʼn': 'n', u'ŋ': 'n', u'ò': 'o', u'ó': 'o', u'ô': 'o', u'õ': 'o', u'ö': 'oe', u'ø': 'o', u'ō': 'o', u'ő': 'o', u'ŏ': 'o', u'œ': 'oe', u'ŕ': 'r', u'ř': 'r', u'ŗ': 'r', u'ś': 's', u'š': 's', u'ť': 't', u'ù': 'u', u'ú': 'u', u'û': 'u', u'ü': 'ue', u'ū': 'u', u'ů': 'u', u'ű': 'u', u'ŭ': 'u', u'ũ': 'u', u'ų': 'u', u'ŵ': 'w', u'ÿ': 'y', u'ý': 'y', u'ŷ': 'y', u'ż': 'z', u'ź': 'z', u'ž': 'z', u'ß': 'ss', u'ſ': 'ss', u'Α': 'A', u'Ά': 'A', u'Ἀ': 'A', u'Ἁ': 'A', u'Ἂ': 'A', u'Ἃ': 'A', u'Ἄ': 'A', u'Ἅ': 'A', u'Ἆ': 'A', u'Ἇ': 'A', u'ᾈ': 'A', u'ᾉ': 'A', u'ᾊ': 'A', u'ᾋ': 'A', u'ᾌ': 'A', u'ᾍ': 'A', u'ᾎ': 'A', u'ᾏ': 'A', u'Ᾰ': 'A', u'Ᾱ': 'A', u'Ὰ': 'A', u'Ά': 'A', u'ᾼ': 'A', u'Β': 'B', u'Γ': 'G', u'Δ': 'D', u'Ε': 'E', u'Έ': 'E', u'Ἐ': 'E', u'Ἑ': 'E', u'Ἒ': 'E', u'Ἓ': 'E', u'Ἔ': 'E', u'Ἕ': 'E', u'Έ': 'E', u'Ὲ': 'E', u'Ζ': 'Z', u'Η': 'I', u'Ή': 'I', u'Ἠ': 'I', u'Ἡ': 'I', u'Ἢ': 'I', u'Ἣ': 'I', u'Ἤ': 'I', u'Ἥ': 'I', u'Ἦ': 'I', u'Ἧ': 'I', u'ᾘ': 'I', u'ᾙ': 'I', u'ᾚ': 'I', u'ᾛ': 'I', u'ᾜ': 'I', u'ᾝ': 'I', u'ᾞ': 'I', u'ᾟ': 'I', u'Ὴ': 'I', u'Ή': 'I', u'ῌ': 'I', u'Θ': 'TH', u'Ι': 'I', u'Ί': 'I', u'Ϊ': 'I', u'Ἰ': 'I', u'Ἱ': 'I', u'Ἲ': 'I', u'Ἳ': 'I', u'Ἴ': 'I', u'Ἵ': 'I', u'Ἶ': 'I', u'Ἷ': 'I', u'Ῐ': 'I', u'Ῑ': 'I', u'Ὶ': 'I', u'Ί': 'I', u'Κ': 'K', u'Λ': 'L', u'Μ': 'M', u'Ν': 'N', u'Ξ': 'KS', u'Ο': 'O', u'Ό': 'O', u'Ὀ': 'O', u'Ὁ': 'O', u'Ὂ': 'O', u'Ὃ': 'O', u'Ὄ': 'O', u'Ὅ': 'O', u'Ὸ': 'O', u'Ό': 'O', u'Π': 'P', u'Ρ': 'R', u'Ῥ': 'R', u'Σ': 'S', u'Τ': 'T', u'Υ': 'Y', u'Ύ': 'Y', u'Ϋ': 'Y', u'Ὑ': 'Y', u'Ὓ': 'Y', u'Ὕ': 'Y', u'Ὗ': 'Y', u'Ῠ': 'Y', u'Ῡ': 'Y', u'Ὺ': 'Y', u'Ύ': 'Y', u'Φ': 'F', u'Χ': 'X', u'Ψ': 'PS', u'Ω': 'O', u'Ώ': 'O', u'Ὠ': 'O', u'Ὡ': 'O', u'Ὢ': 'O', u'Ὣ': 'O', u'Ὤ': 'O', u'Ὥ': 'O', u'Ὦ': 'O', u'Ὧ': 'O', u'ᾨ': 'O', u'ᾩ': 'O', u'ᾪ': 'O', u'ᾫ': 'O', u'ᾬ': 'O', u'ᾭ': 'O', u'ᾮ': 'O', u'ᾯ': 'O', u'Ὼ': 'O', u'Ώ': 'O', u'ῼ': 'O', u'α': 'a', u'ά': 'a', u'ἀ': 'a', u'ἁ': 'a', u'ἂ': 'a', u'ἃ': 'a', u'ἄ': 'a', u'ἅ': 'a', u'ἆ': 'a', u'ἇ': 'a', u'ᾀ': 'a', u'ᾁ': 'a', u'ᾂ': 'a', u'ᾃ': 'a', u'ᾄ': 'a', u'ᾅ': 'a', u'ᾆ': 'a', u'ᾇ': 'a', u'ὰ': 'a', u'ά': 'a', u'ᾰ': 'a', u'ᾱ': 'a', u'ᾲ': 'a', u'ᾳ': 'a', u'ᾴ': 'a', u'ᾶ': 'a', u'ᾷ': 'a', u'β': 'b', u'γ': 'g', u'δ': 'd', u'ε': 'e', u'έ': 'e', u'ἐ': 'e', u'ἑ': 'e', u'ἒ': 'e', u'ἓ': 'e', u'ἔ': 'e', u'ἕ': 'e', u'ὲ': 'e', u'έ': 'e', u'ζ': 'z', u'η': 'i', u'ή': 'i', u'ἠ': 'i', u'ἡ': 'i', u'ἢ': 'i', u'ἣ': 'i', u'ἤ': 'i', u'ἥ': 'i', u'ἦ': 'i', u'ἧ': 'i', u'ᾐ': 'i', u'ᾑ': 'i', u'ᾒ': 'i', u'ᾓ': 'i', u'ᾔ': 'i', u'ᾕ': 'i', u'ᾖ': 'i', u'ᾗ': 'i', u'ὴ': 'i', u'ή': 'i', u'ῂ': 'i', u'ῃ': 'i', u'ῄ': 'i', u'ῆ': 'i', u'ῇ': 'i', u'θ': 'th', u'ι': 'i', u'ί': 'i', u'ϊ': 'i', u'ΐ': 'i', u'ἰ': 'i', u'ἱ': 'i', u'ἲ': 'i', u'ἳ': 'i', u'ἴ': 'i', u'ἵ': 'i', u'ἶ': 'i', u'ἷ': 'i', u'ὶ': 'i', u'ί': 'i', u'ῐ': 'i', u'ῑ': 'i', u'ῒ': 'i', u'ΐ': 'i', u'ῖ': 'i', u'ῗ': 'i', u'κ': 'k', u'λ': 'l', u'μ': 'm', u'ν': 'n', u'ξ': 'ks', u'ο': 'o', u'ό': 'o', u'ὀ': 'o', u'ὁ': 'o', u'ὂ': 'o', u'ὃ': 'o', u'ὄ': 'o', u'ὅ': 'o', u'ὸ': 'o', u'ό': 'o', u'π': 'p', u'ρ': 'r', u'ῤ': 'r', u'ῥ': 'r', u'σ': 's', u'ς': 's', u'τ': 't', u'υ': 'y', u'ύ': 'y', u'ϋ': 'y', u'ΰ': 'y', u'ὐ': 'y', u'ὑ': 'y', u'ὒ': 'y', u'ὓ': 'y', u'ὔ': 'y', u'ὕ': 'y', u'ὖ': 'y', u'ὗ': 'y', u'ὺ': 'y', u'ύ': 'y', u'ῠ': 'y', u'ῡ': 'y', u'ῢ': 'y', u'ΰ': 'y', u'ῦ': 'y', u'ῧ': 'y', u'φ': 'f', u'χ': 'x', u'ψ': 'ps', u'ω': 'o', u'ώ': 'o', u'ὠ': 'o', u'ὡ': 'o', u'ὢ': 'o', u'ὣ': 'o', u'ὤ': 'o', u'ὥ': 'o', u'ὦ': 'o', u'ὧ': 'o', u'ᾠ': 'o', u'ᾡ': 'o', u'ᾢ': 'o', u'ᾣ': 'o', u'ᾤ': 'o', u'ᾥ': 'o', u'ᾦ': 'o', u'ᾧ': 'o', u'ὼ': 'o', u'ώ': 'o', u'ῲ': 'o', u'ῳ': 'o', u'ῴ': 'o', u'ῶ': 'o', u'ῷ': 'o', u'¨': '', u'΅': '', u'᾿': '', u'῾': '', u'῍': '', u'῝': '', u'῎': '', u'῞': '', u'῏': '', u'῟': '', u'῀': '', u'῁': '', u'΄': '', u'΅': '', u'`': '', u'῭': '', u'ͺ': '', u'᾽': '', u'А': 'A', u'Б': 'B', u'В': 'V', u'Г': 'G', u'Д': 'D', u'Е': 'E', u'Ё': 'E', u'Ж': 'ZH', u'З': 'Z', u'И': 'I', u'Й': 'I', u'К': 'K', u'Л': 'L', u'М': 'M', u'Н': 'N', u'О': 'O', u'П': 'P', u'Р': 'R', u'С': 'S', u'Т': 'T', u'У': 'U', u'Ф': 'F', u'Х': 'KH', u'Ц': 'TS', u'Ч': 'CH', u'Ш': 'SH', u'Щ': 'SHCH', u'Ы': 'Y', u'Э': 'E', u'Ю': 'YU', u'Я': 'YA', u'а': 'A', u'б': 'B', u'в': 'V', u'г': 'G', u'д': 'D', u'е': 'E', u'ё': 'E', u'ж': 'ZH', u'з': 'Z', u'и': 'I', u'й': 'I', u'к': 'K', u'л': 'L', u'м': 'M', u'н': 'N', u'о': 'O', u'п': 'P', u'р': 'R', u'с': 'S', u'т': 'T', u'у': 'U', u'ф': 'F', u'х': 'KH', u'ц': 'TS', u'ч': 'CH', u'ш': 'SH', u'щ': 'SHCH', u'ы': 'Y', u'э': 'E', u'ю': 'YU', u'я': 'YA', u'Ъ': '', u'ъ': '', u'Ь': '', u'ь': '', u'ð': 'd', u'Ð': 'D', u'þ': 'th', u'Þ': 'TH', - u'ა': 'a', u'ბ': 'b', u'გ': 'g', u'დ': 'd', u'ე': 'e', u'ვ': 'v', u'ზ': 'z', u'თ': 't', u'ი': 'i', u'კ': 'k', u'ლ': 'l', u'მ': 'm', u'ნ': 'n', u'ო': 'o', u'პ': 'p', u'ჟ': 'zh', u'რ': 'r', u'ს': 's', u'ტ': 't', u'უ': 'u', u'ფ': 'p', u'ქ': 'k', u'ღ': 'gh', u'ყ': 'q', u'შ': 'sh', u'ჩ': 'ch', u'ც': 'ts', u'ძ': 'dz', u'წ': 'ts', u'ჭ': 'ch', u'ხ': 'kh', u'ჯ': 'j', u'ჰ': 'h' } - -def replace_char(m): - char = m.group() - if char_map.has_key(char): - return char_map[char] - else: - return char - -def slughifi(value, do_slugify=True, overwrite_char_map={}): - """ - High Fidelity slugify - slughifi.py, v 0.1 - - Examples : - - >>> text = 'C\'est déjà l\'été.' - - >>> slughifi(text) - 'cest-deja-lete' - - >>> slughifi(text, overwrite_char_map={u'\'': '-',}) - 'c-est-deja-l-ete' - - >>> slughifi(text, do_slugify=False) - "C'est deja l'ete." - - # Normal slugify removes accented characters - >>> slugify(text) - 'cest-dj-lt' - - """ - - # unicodification - if type(value) != UnicodeType: - value = unicode(value, 'utf-8', 'ignore') - - # overwrite chararcter mapping - char_map.update(overwrite_char_map) - - # try to replace chars - value = re.sub('[^a-zA-Z0-9\\s\\-]{1}', replace_char, value) - - # apply django default slugify - if do_slugify: - value = slugify(value) - - return value.encode('ascii', 'ignore') -