OBLIGATORY_LANGUAGES = None
def _more_OPTIONAL_LANGUAGES(self, value):
- return tuple(lang for lang in settings.LANGUAGES if lang not in self.OBLIGATORY_LANGUAGES)
+ if value is None:
+ return tuple(lang for lang in settings.LANGUAGES if lang not in self.OBLIGATORY_LANGUAGES)
+ else:
+ return value
OPTIONAL_LANGUAGES = None
+ def _more_LANGUAGES(self, value):
+ return self.OBLIGATORY_LANGUAGES + self.OPTIONAL_LANGUAGES
+ LANGUAGES = None
+
PUBLISH_DATE_EDITABLE = False
app_settings = Settings('MIGDAL')
return field
date_hierarchy = 'date'
- readonly_fields = ('date', 'changed_at') + translated_fields(('published_at',))
+ readonly_fields = ('date', 'changed_at') + translated_fields(('published_at',), app_settings.LANGUAGES)
if app_settings.PUBLISH_DATE_EDITABLE:
readonly_fields += ('first_published_at',)
_promo_if_necessary = ('promo',) if typ.promotable else ()
)
prepopulated_fields = dict([
("slug_%s" % lang_code, ("title_%s" % lang_code,))
- for lang_code, lang_name in settings.LANGUAGES
+ for lang_code, lang_name in app_settings.LANGUAGES
])
list_display = translated_fields(('title',), app_settings.OBLIGATORY_LANGUAGES) + \
('date', 'author') + \
_promo_if_necessary + \
('in_stream', 'first_published_at',) + \
- translated_fields(('published_at',)) + \
+ translated_fields(('published_at',), app_settings.LANGUAGES) + \
translated_fields(('needed',), app_settings.OPTIONAL_LANGUAGES)
list_filter = _promo_if_necessary + \
- translated_fields(('published',)) + \
+ translated_fields(('published',), app_settings.LANGUAGES) + \
translated_fields(('needed',), app_settings.OPTIONAL_LANGUAGES)
inlines = (PhotoInline, AttachmentInline)
search_fields = ('title_pl', 'title_en')
from migdal.models import Category
class CategoryAdmin(admin.ModelAdmin):
- list_display = translated_fields(('title', 'slug')) + ('taxonomy',)
+ list_display = translated_fields(('title', 'slug'), app_settings.LANGUAGES) + ('taxonomy',)
prepopulated_fields = dict([
("slug_%s" % lang_code, ("title_%s" % lang_code,))
- for lang_code, lang_name in settings.LANGUAGES
+ for lang_code, lang_name in app_settings.LANGUAGES
])
admin.site.register(Category, CategoryAdmin)
return 'migdal_category', [self.slug]
-add_translatable(Category, {
+add_translatable(Category, languages=app_settings.LANGUAGES, fields={
'title': models.CharField(max_length=64, unique=True, db_index=True),
'slug': models.SlugField(unique=True, db_index=True),
})
def save(self, *args, **kwargs):
published_now = False
- for lc, ln in settings.LANGUAGES:
+ for lc, ln in app_settings.LANGUAGES:
if (getattr(self, "published_%s" % lc)
and getattr(self, "published_at_%s" % lc) is None):
now = datetime.now()
self.notify_author_published()
def clean(self):
- for lc, ln in settings.LANGUAGES:
+ for lc, ln in app_settings.LANGUAGES:
if (getattr(self, "published_%s" % lc) and
not getattr(self, "slug_%s" % lc)):
raise ValidationError(
TEXTILE_HELP = _('Use <a href="https://txstyle.org/article/44/an-overview-of-the-textile-syntax">Textile</a> syntax.')
-add_translatable(Entry, {
+add_translatable(Entry, languages=app_settings.LANGUAGES, fields={
'slug': SlugNullField(unique=True, db_index=True, null=True, blank=True),
'title': models.CharField(_('title'), max_length=255, null=True, blank=True),
'lead': TextileField(
#
from django.contrib.sitemaps import Sitemap
from django.utils.translation import override
+from . import app_settings
from .models import Entry
-from django.conf import settings
class MigdalSitemap(Sitemap):
sitemaps = {}
-for lc, ln in settings.LANGUAGES:
+for lc, ln in app_settings.LANGUAGES:
sitemaps['entry_%s' % lc] = MigdalSitemap(lc)
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 import views
from fnpdjango.utils.urls import i18n_patterns
pats = []
pats += [
# entry list
url(string_concat(r'^', t.slug, r'/$'),
- 'migdal.views.entry_list', {'type_db': t.db},
+ 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<slug>[^/]+)/$'),
- 'migdal.views.entry', {'type_db': t.db},
+ views.entry, {'type_db': t.db},
name='migdal_entry_%s' % t.db),
]
urlpatterns = i18n_patterns(
# main page
- url(r'^$', 'migdal.views.main', name='migdal_main'),
+ url(r'^$', views.main, name='migdal_main'),
url(r'^rss.xml$', feeds.EntriesFeed(), name='migdal_main_feed'),
# submit new entry
- url(string_concat(r'^', _('submit'), r'/$'), 'migdal.views.submit', name='migdal_submit'),
- url(string_concat(r'^', _('submit'), r'/', _('thanks'), r'$'), 'migdal.views.submit_thanks',
+ url(string_concat(r'^', _('submit'), r'/$'), views.submit, name='migdal_submit'),
+ url(string_concat(r'^', _('submit'), r'/', _('thanks'), r'$'), views.submit_thanks,
name='migdal_submit_thanks'),
# category
url(string_concat(r'^', _('categories'), r'/(?P<category_slug>[^/]*)/$'),
- 'migdal.views.entry_list', name='migdal_category'),
+ views.entry_list, name='migdal_category'),
url(string_concat(r'^', _('categories'), r'/(?P<category_slug>[^/]*)/rss.xml$'),
feeds.EntriesFeed(), name='migdal_category_feed'),
- url(string_concat(r'^', _('search')), SearchPublishedView(), name='search'),
+ url(string_concat(r'^', _('search')), views.SearchPublishedView(), name='search'),
# type-specific views
*pats
)
setup(
name='django-migdal',
- version='0.8.4',
+ version='0.8.5',
author='Radek Czajka',
author_email='radoslaw.czajka@nowoczesnapolska.org.pl',
url='',