# 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),
+ EntryType('news', _('news'), commentable=True, on_main=True, promotable=True),
+ EntryType('publications', _('publications')),
+ EntryType('info', _('info')),
)
TYPE_SUBMIT = 'news'
TAXONOMIES = (
)
LAST_COMMENTS = 5
+ MENU = []
+
TYPES_DICT = None
def _more_TYPES_DICT(self, value):
return dict((t.db, t) for t in self.TYPES)
def _more_TYPES_ON_MAIN(self, value):
return tuple(t.db for t in self.TYPES if t.on_main)
+ TYPES_PROMOTABLE = None
+ def _more_TYPES_PROMOTABLE(self, value):
+ return tuple(t.db for t in self.TYPES if t.promotable)
+
OBLIGATORY_LANGUAGES = None
def _more_OBLIGATORY_LANGUAGES(self, value):
return value or tuple(lang for lang in settings.LANGUAGES
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.models import Entry, Attachment
from migdal import app_settings
from migdal.helpers import translated_fields
+from prawokultury.model_helpers import filtered_model
class AttachmentInline(admin.TabularInline):
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
- ])
+def filtered_entry_admin(typ):
+ class EntryAdmin(admin.ModelAdmin):
+ def queryset(self, request):
+ return self.model.objects.filter(type=typ)
- 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,)
+ date_hierarchy = 'date'
+ readonly_fields = ('date', 'changed_at') + \
+ translated_fields(('published_at',))
+ _promo_if_necessary = ('promo',) if typ.promotable else ()
+ fieldsets = (
+ (None, {
+ 'fields': _promo_if_necessary + (
+ '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
+ )
-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
- ])
+ if typ.categorized:
+ fieldsets += (
+ (_('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) + \
+ ('date', 'author') + \
+ _promo_if_necessary + \
+ translated_fields(('published_at',)) + \
+ translated_fields(('needed',), app_settings.OPTIONAL_LANGUAGES)
+ list_filter = _promo_if_necessary + \
+ translated_fields(('published',)) + \
+ translated_fields(('needed',), app_settings.OPTIONAL_LANGUAGES)
+ inlines = (AttachmentInline,)
+ search_fields = ('title_pl', 'title_en')
+ return EntryAdmin
-admin.site.register(Entry, EntryAdmin)
-admin.site.register(Category, CategoryAdmin)
+
+for typ in app_settings.TYPES:
+ newmodel = filtered_model("Entry_%s" % typ.db, Entry, 'type', typ.db, typ.slug)
+ admin.site.register(newmodel, filtered_entry_admin(typ))
+
+
+if app_settings.TAXONOMIES:
+ from migdal.models import Category
+
+ 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(Category, CategoryAdmin)
from django.utils.translation import get_language, string_concat
-class EntryType(namedtuple('EntryType', 'db slug commentable on_main')):
- __slots__ = ()
+class EntryType(object):
+ def __init__(self, db, slug, commentable=False, on_main=False,
+ promotable=False, categorized=False):
+ self.db = db
+ self.slug = slug
+ self.commentable = commentable
+ self.on_main = on_main
+ self.promotable = promotable
+ self.categorized = categorized
+
def __unicode__(self):
return unicode(self.slug)
@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')),
+ #ModelMenuItem(Entry.objects.get(slug_pl='o-nas')),
+ #MenuItem(_(u'Events'), reverse('events')),
]
- #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'))
+ # TODO: context-aware language switcher
+ if context['request'].LANGUAGE_CODE == 'pl':
+ items.append(MenuItem(u'en', '/en/', html_id='item-lang'))
+ else:
+ items.append(MenuItem(u'pl', '/', html_id='item-lang'))
for item in items:
item.check_active(chooser, value)
return {'items': items}
]
-# Disable en for now.
-urlpatterns = patterns('',
- url(r'^en/', handler404),
-)
-urlpatterns += i18n_patterns('',
+urlpatterns = i18n_patterns('',
# main page
url(r'^$', 'migdal.views.entry_list', name='migdal_main'),
url(r'^rss.xml$', feeds.EntriesFeed(), name='migdal_main_feed'),
text, rel='nofollow')
-class LazyUGettextLazy():
+class LazyUGettextLazy(object):
"""You can use it to internationalize strings in settings.
Just import this class as gettext.
--- /dev/null
+from django.utils.translation import string_concat
+
+def filtered_model(name, model, field, value, verbose_extra=None):
+ """Creates a proxy model filtering objects by a field."""
+ verbose_extra = verbose_extra or value
+ class Meta:
+ proxy = True
+ app_label = model._meta.app_label
+ verbose_name = string_concat(model._meta.verbose_name,
+ ': ', verbose_extra)
+ verbose_name_plural = string_concat(model._meta.verbose_name_plural,
+ ': ', verbose_extra)
+
+ def save(self, *args, **kwargs):
+ if not getattr(self, field):
+ setattr(self, field, value)
+ return model.save(self, *args, **kwargs)
+
+ attrs = {'__module__': '', 'Meta': Meta, 'save': save}
+ return type(name, (model,), attrs)
INSTALLED_APPS = (
'prawokultury',
- 'events',
+ #'events',
'migdal',
+ #'forms',
'gravatar',
'south',
- 'django.contrib.comments',
- 'django_comments_xtd',
+ #'django.contrib.comments',
+ #'django_comments_xtd',
'pipeline',
'haystack',
'pagination',
--- /dev/null
+if 'django_cas' in INSTALLED_APPS:
+ AUTHENTICATION_BACKENDS = (
+ 'django.contrib.auth.backends.ModelBackend',
+ 'django_cas.backends.CASBackend',
+ )
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
+)
+
+if 'django_cas' in INSTALLED_APPS:
+ MIDDLEWARE_CLASSES += (
+ 'django_cas.middleware.CASMiddleware',
+ )
+
+MIDDLEWARE_CLASSES += (
'django.contrib.messages.middleware.MessageMiddleware',
'piwik.django.middleware.PiwikMiddleware',
# Uncomment the next line for simple clickjacking protection:
THUMBNAIL_QUALITY = 95
GRAVATAR_DEFAULT_IMAGE = 'http://localhost:8000/static/img/avatar.png'
+
+CAS_SERVER_URL = 'http://logowanie.nowoczesnapolska.org.pl/cas/'
+CAS_VERSION = '1'
+from prawokultury.helpers import LazyUGettextLazy as gettext
+from migdal.helpers import EntryType
+
+MIGDAL_TYPES = (
+ EntryType('info', gettext('info'), commentable=False, on_main=False),
+)
+
+MIGDAL_TAXONOMIES = ()
\ No newline at end of file
<!DOCTYPE html>
{% load url from future %}
{% load i18n static %}
-{% load common_tags migdal_tags events_tags share %}
+{% load common_tags migdal_tags share %}
{% load compressed %}
<html prefix="og: http://ogp.me/ns#">
<head>
- <title>{% block "titleextra" %}{% endblock %}{% trans "Culture's right" %}</title>
+ <title>{% block "titleextra" %}{% endblock %}CopyCamp</title>
<link rel="shortcut icon" type="image/png" href="{% static "img/favicon.png" %}" />
{% compressed_css 'base' %}
<meta property='og:url' content='{% block "ogurl" %}{% url 'migdal_main' %}{% endblock %}' />
- <meta property='og:title' content='{% block "ogtitle" %}{% trans "Culture's right" %}{% endblock %}' />
- <meta property='og:site_name' content='{% trans "Culture's right" %}' />
- <meta property='og:description' content='{% block "ogdescription" %}Prawokultury.pl to strona edukacyjna mająca za zadanie w przystępny i rzetelny sposób informować o wszelkich kwestiach związanych z prawem autorskim.{% endblock %}' />
+ <meta property='og:title' content='{% block "ogtitle" %}CopyCamp{% endblock %}' />
+ <meta property='og:site_name' content='CopyCamp' />
+ <meta property='og:description' content='{% block "ogdescription" %}CopyCamp!{% endblock %}' />
<meta property='og:type' content='{% block "ogtype" %}website{% endblock %}' />
<meta property='og:image' content='{% block "ogimage" %}{{ "/static/img/square-logo.png"|build_absolute_uri:request }}{% endblock %}' />
<meta property='og:locale' content='pl_PL' />
<div id="header-bar">
<div class="bar-left">
<a id="logo" href="{% url "migdal_main" %}">
- <img alt="{% trans "Culture's right" %}"
+ <img alt="{% trans "CopyCamp" %}"
src="{% static "img/logo.png" %}" /></a>
</div>
<div class="bar-right">
- <div class="org-fnp">
- <span>{% trans "Organizer" %}</span><br/>
- <a href="http://nowoczesnapolska.org.pl">
- <img src="{% static 'img/logo-fnp.png' %}"
- alt="{% trans "Modern Poland Foundation" %}" /></a>
- </div><div class="org-trust">
- <span>{% trans "Sponsor" %}</span><br/>
- <a href="http://ceetrust.org">
- <img src="{% static 'img/logo-trust.png' %}"
- alt="{% trans "Trust for Civil Society in Central and Eastern Europe" %}" /></a>
+ <div class="social">
+ {% url 'migdal_main' as main_url %}
+ {% share main_url "CopyCamp" "big" %}
</div>
</div>
<div style="clear: both;"></div>
<div id="sidebar" class="bar-right">
{% block "sidebar" %}
<div class="sidebar-box">
- <h3><a href="{% url 'events' %}">{% trans "Upcoming events" %}</a></h3>
- {% events_box %}
- </div>
- <div id="sidebar-box-categories" class="sidebar-box">
- {% categories 'topics' %}
- {% categories 'types' %}
- </div>
- <div class="sidebar-box social">
- <a href="{% url 'migdal_main_feed' %}" title="RSS feed">
- <img src="{% static 'img/rss.png' %}" alt="RSS feed" /></a>
- {% url 'migdal_main' as main_url %}
- {% trans "Culture's right" as site_name %}
- {% share main_url site_name "big" %}
- </div>
- <div class="sidebar-box">
- <h3>{% trans "Latest comments" %}</h3>
- {% last_comments %}
+ (Sponsorzy)
</div>
{% endblock %}
</div>
url(r'^media/(?P<path>.*)$', 'django.views.static.serve', {
'document_root': settings.MEDIA_ROOT,
}),
+
+ (r'^accounts/login/$', 'django_cas.views.login'),
+ (r'^accounts/logout/$', 'django_cas.views.logout'),
) + i18n_patterns('',
url(string_concat(r'^', _('events'), r'/'), include('events.urls')),
url(r'^comments/', include('django_comments_xtd.urls')),
Django>=1.4,<1.5
+#django_cas
+-e hg+https://bitbucket.org/cpcc/django-cas@197f156ee943#egg=django_cas
South>=0.7.4
PIL
sorl-thumbnail>=11.09,<12
django-pagination
+#django-jsonfield
+-e git+git://github.com/bradjasper/django-jsonfield.git@2f427368ad70bf8d9a0580df58ec0eb0654d62ae#egg=django-jsonfield
+
textile
django-markupfield
django-gravatar