dirty, ugly but workable
[prawokultury.git] / migdal / settings.py
1 # -*- coding: utf-8 -*-
2 # This file is part of PrawoKultury, licensed under GNU Affero GPLv3 or later.
3 # Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information.
4 #
5 from django.conf import settings
6 from django.utils.translation import ugettext_lazy as _
7 from migdal.helpers import EntryType
8
9
10 def app_setting(global_name, default):
11     try:
12         return getattr(settings, global_name)
13     except AttributeError:
14         return default
15
16 # Types of entries:
17 # (slug, commentable, on main)
18 TYPES = app_setting('MIGDAL_TYPES', (
19             EntryType('news', _('news'), commentable=True, on_main=True),
20             EntryType('publications', _('publications'), commentable=False, on_main=False),
21             EntryType('info', _('info'), commentable=False, on_main=False),
22         ))
23 TYPES_DICT = dict((t.db, t) for t in TYPES)
24 TYPES_ON_MAIN = tuple(t.db for t in TYPES if t.on_main)
25 # FIXME: if only news is on_main, `news/` should either throw 404 or redirect to main
26
27 LANGUAGES = app_setting('MIGDAL_LANGUAGES', settings.LANGUAGES)
28 LANGUAGE_CODE = app_setting('MIGDAL_LANGUAGE_CODE', settings.LANGUAGE_CODE)
29 OBLIGATORY_LANGUAGES = app_setting('MIGDAL_OBLIGATORY', tuple(
30     lang for lang in LANGUAGES if lang[0]==LANGUAGE_CODE))
31 OPTIONAL_LANGUAGES = tuple(lang for lang in LANGUAGES if lang not in OBLIGATORY_LANGUAGES)