class EventAdmin(admin.ModelAdmin):
+ fieldsets = (
+ (None, {'fields': ('date', 'link')}),
+ ) + tuple(
+ (ln, {'fields': (
+ ('published_%s' % lc),
+ 'title_%s' % lc,
+ 'organizer_%s' % lc,
+ 'place_%s' % lc,
+ )})
+ for lc, ln in settings.LANGUAGES
+ )
list_display = translated_fields(
('title', 'place', 'organizer'), settings.LANGUAGES
) + ('date',)
msgstr ""
"Project-Id-Version: prawokultury-events\n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2012-08-28 15:15+0200\n"
-"PO-Revision-Date: 2012-08-28 11:28+0100\n"
+"POT-Creation-Date: 2012-08-30 15:58+0200\n"
+"PO-Revision-Date: 2012-08-30 15:59+0100\n"
"Last-Translator: Radek Czajka <radoslaw.czajka@nowoczesnapolska.org.pl>\n"
"Language-Team: FNP <fundacja@nowoczesnapolska.org.pl>\n"
"Language: \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"
+"Plural-Forms: nplurals=3; plural=(n==1 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2)\n"
-#: models.py:11
+#: models.py:13
msgid "date"
msgstr "data"
-#: models.py:12
+#: models.py:14
msgid "link"
msgstr "link"
-#: models.py:15
+#: models.py:17
msgid "event"
msgstr "wydarzenie"
-#: models.py:16
+#: models.py:18
msgid "events"
msgstr "wydarzenia"
-#: models.py:24
+#: models.py:29
+#, python-format
+msgid "Published event should have a title in relevant language (%s)."
+msgstr "Opublikowane wydarzenie powinno mieć tytuł w odpowiednim języku (%s)."
+
+#: models.py:33
msgid "title"
msgstr "tytuł"
-#: models.py:25
+#: models.py:34
msgid "organizer"
msgstr "organizator"
-#: models.py:26
+#: models.py:36
msgid "place"
msgstr "miejsce"
+#: models.py:37
+msgid "published"
+msgstr "opublikowane"
+
#: urls.py:11
msgid "past"
msgstr "przeszle"
#: templates/events/snippets/events_box.html:21
msgid "more events"
msgstr "więcej wydarzeń"
+
--- /dev/null
+# -*- 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 'Event.published_pl'
+ db.add_column('events_event', 'published_pl',
+ self.gf('django.db.models.fields.BooleanField')(default=False),
+ keep_default=False)
+
+ # Adding field 'Event.published_en'
+ db.add_column('events_event', 'published_en',
+ self.gf('django.db.models.fields.BooleanField')(default=False),
+ keep_default=False)
+
+ if not db.dry_run:
+ orm.Event.objects.all().update(published_pl=True, published_en=True)
+
+
+ def backwards(self, orm):
+ # Deleting field 'Event.published_pl'
+ db.delete_column('events_event', 'published_pl')
+
+ # Deleting field 'Event.published_en'
+ db.delete_column('events_event', 'published_en')
+
+
+ models = {
+ 'events.event': {
+ 'Meta': {'ordering': "['date']", 'object_name': 'Event'},
+ 'date': ('django.db.models.fields.DateTimeField', [], {'max_length': '255', 'db_index': 'True'}),
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'link': ('django.db.models.fields.URLField', [], {'max_length': '200'}),
+ 'organizer_en': ('django.db.models.fields.CharField', [], {'db_index': 'True', 'max_length': '255', 'blank': 'True'}),
+ 'organizer_pl': ('django.db.models.fields.CharField', [], {'db_index': 'True', 'max_length': '255', 'blank': 'True'}),
+ 'place_en': ('django.db.models.fields.CharField', [], {'max_length': '255', 'blank': 'True'}),
+ 'place_pl': ('django.db.models.fields.CharField', [], {'max_length': '255', 'blank': 'True'}),
+ 'published_en': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
+ 'published_pl': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
+ 'title_en': ('django.db.models.fields.CharField', [], {'max_length': '255', 'blank': 'True'}),
+ 'title_pl': ('django.db.models.fields.CharField', [], {'max_length': '255', 'blank': 'True'})
+ }
+ }
+
+ complete_apps = ['events']
\ No newline at end of file
# 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.core.exceptions import ValidationError
from django.db import models
-from django.utils.translation import ugettext_lazy as _
+from django.utils.translation import ugettext_lazy as _, ugettext
from migdal.helpers import add_translatable
def __unicode__(self):
return self.title
+ def clean(self):
+ for lc, ln in settings.LANGUAGES:
+ if (getattr(self, "published_%s" % lc) and
+ not getattr(self, "title_%s" % lc)):
+ raise ValidationError(
+ ugettext("Published event should have a title in relevant language (%s).") % lc)
+
add_translatable(Event, {
- 'title': models.CharField(_('title'), max_length=255),
- 'organizer': models.CharField(_('organizer'), max_length=255, db_index=True),
- 'place': models.CharField(_('place'), max_length=255),
+ 'title': models.CharField(_('title'), max_length=255, blank=True),
+ 'organizer': models.CharField(_('organizer'), max_length=255,
+ db_index=True, blank=True),
+ 'place': models.CharField(_('place'), max_length=255, blank=True),
+ 'published': models.BooleanField(_('published'), default=False),
})
@register.inclusion_tag('events/snippets/events_box.html', takes_context=True)
def events_box(context, limit=app_settings.BOX_LENGTH):
- objects = Event.objects.filter(date__gte=datetime.now())[:limit]
+ lang = context['request'].LANGUAGE_CODE
+ objects = Event.objects.filter(**{"published_%s" % lang: True})
+ objects = objects.filter(date__gte=datetime.now())[:limit]
return {'objects': objects}
def events(request):
+ events = Event.objects.filter(date__gte=datetime.now())
+ events = events.filter(**{"published_%s" % request.LANGUAGE_CODE: True})
return render(request, 'events/event_list.html', {
- 'object_list': Event.objects.filter(date__gte=datetime.now())
+ 'object_list': events,
})
def events_past(request):
+ events = Event.objects.filter(date__lte=datetime.now()).order_by('-date')
+ events = events.filter(**{"published_%s" % request.LANGUAGE_CODE: True})
return render(request, 'events/event_list.html', {
- 'object_list': Event.objects.filter(date__lte=datetime.now()
- ).order_by('-date'),
+ 'object_list': events,
'past': True,
})
msgstr ""
"Project-Id-Version: django-migdal 0.1\n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2012-08-30 11:15+0200\n"
-"PO-Revision-Date: 2012-08-30 11:17+0100\n"
+"POT-Creation-Date: 2012-08-30 15:59+0200\n"
+"PO-Revision-Date: 2012-08-30 16:00+0100\n"
"Last-Translator: Radek Czajka <radoslaw.czajka@nowoczesnapolska.org.pl>\n"
"Language-Team: FNP <fundacja@nowoczesnapolska.org.pl>\n"
"Language: Polish\n"
msgstr "ostatnie"
#: feeds.py:32
-#: models.py:52
+#: models.py:54
msgid "entries"
msgstr "wpisy"
msgid "Content"
msgstr "Treść"
-#: models.py:17
+#: models.py:19
msgid "taxonomy"
msgstr "taksonomia"
-#: models.py:21
+#: models.py:23
msgid "category"
msgstr "kategoria"
-#: models.py:22
-#: models.py:48
+#: models.py:24
+#: models.py:50
#: urls.py:41
#: urls.py:43
msgid "categories"
msgstr "kategorie"
-#: models.py:43
+#: models.py:45
msgid "author"
msgstr "autor"
-#: models.py:44
+#: models.py:46
msgid "author email"
msgstr "e-mail autora"
-#: models.py:45
+#: models.py:47
msgid "Used only to display gravatar and send notifications."
msgstr "Używany tylko do wyświetlenia gravatara i wysyłania powiadomień."
-#: models.py:46
+#: models.py:48
msgid "image"
msgstr "obrazek"
-#: models.py:47
+#: models.py:49
msgid "promoted"
msgstr "promowane"
-#: models.py:51
+#: models.py:53
msgid "entry"
msgstr "wpis"
-#: models.py:93
+#: models.py:77
+#, 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:96
#, python-format
msgid "Your story has been published at %s."
msgstr "Twój wpis został opublikowany na stronie %s."
-#: models.py:101
+#: models.py:104
msgid "needed"
msgstr "potrzebne"
-#: models.py:102
+#: models.py:105
msgid "Unneeded"
msgstr "Niepotrzebne"
-#: models.py:102
+#: models.py:105
msgid "Needed"
msgstr "Potrzebne"
-#: models.py:102
+#: models.py:105
msgid "Done"
msgstr "Ukończone"
-#: models.py:108
+#: models.py:111
msgid "title"
msgstr "tytuł"
-#: models.py:109
+#: models.py:112
msgid "lead"
msgstr "lead"
-#: models.py:110
-#: models.py:112
+#: models.py:113
+#: models.py:115
msgid "Use <a href=\"http://textile.thresholdstate.com/\">Textile</a> syntax."
msgstr "Włączona składnia <a href=\"http://textile.thresholdstate.com/\">Textile</a>."
-#: models.py:111
+#: models.py:114
msgid "body"
msgstr "treść"
-#: models.py:113
+#: models.py:116
msgid "published"
msgstr "opublikowane"
-#: models.py:118
+#: models.py:121
msgid "file"
msgstr "plik"
-#: models.py:136
+#: models.py:139
#, python-format
msgid "New comment under your story at %s."
msgstr "Nowy komentarz pod Twoim wpisem na stronie %s."