cas
[prawokultury.git] / migdal / __init__.py
1 # -*- coding: utf-8 -*-
2 """
3 Migdal (מִגְדָּל) is a multilingual blog Django app.
4
5 Author: Radek Czajka <radoslaw.czajka@nowoczesnapolska.org.pl>
6 """
7 from django.conf import settings
8 from prawokultury.helpers import AppSettings
9 from django.utils.translation import ugettext_lazy as _
10 from migdal.helpers import EntryType
11
12
13 class Settings(AppSettings):
14     # Types of entries:
15     # (slug, commentable, on main)
16     TYPES = (
17             EntryType('news', _('news'), commentable=True, on_main=True),
18             EntryType('publications', _('publications'), commentable=False, on_main=False),
19             EntryType('info', _('info'), commentable=False, on_main=False),
20         )
21     TYPE_SUBMIT = 'news'
22     TAXONOMIES = (
23         ('topics', _('topics')),
24         ('types', _('types')),
25     )
26     LAST_COMMENTS = 5
27
28     TYPES_DICT = None
29     def _more_TYPES_DICT(self, value):
30         return dict((t.db, t) for t in self.TYPES)
31
32     TYPES_ON_MAIN = None
33     def _more_TYPES_ON_MAIN(self, value):
34         return tuple(t.db for t in self.TYPES if t.on_main)
35
36     OBLIGATORY_LANGUAGES = None
37     def _more_OBLIGATORY_LANGUAGES(self, value):
38         return value or tuple(lang for lang in settings.LANGUAGES
39                         if lang[0] == settings.LANGUAGE_CODE)
40
41     OPTIONAL_LANGUAGES = None
42     def _more_OPTIONAL_LANGUAGES(self, value):
43         return tuple(lang for lang in settings.LANGUAGES
44                         if lang not in self.OBLIGATORY_LANGUAGES)
45
46 app_settings = Settings('MIGDAL')
47
48
49