class EventAdmin(admin.ModelAdmin):
fieldsets = (
- (None, {'fields': ('date', 'link')}),
+ (None, {'fields': ('date', 'date_end', 'link')}),
) + tuple(
(ln, {'fields': (
('published_%s' % lc),
--- /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.date_end'
+ db.add_column('events_event', 'date_end',
+ self.gf('django.db.models.fields.DateTimeField')(db_index=True, default='2000-01-01 0:00', max_length=255, blank=True),
+ keep_default=False)
+
+ if not db.dry_run:
+ orm.Event.objects.all().update(date_end=models.F('date'))
+
+ def backwards(self, orm):
+ # Deleting field 'Event.date_end'
+ db.delete_column('events_event', 'date_end')
+
+
+ models = {
+ 'events.event': {
+ 'Meta': {'ordering': "['date']", 'object_name': 'Event'},
+ 'date': ('django.db.models.fields.DateTimeField', [], {'max_length': '255', 'db_index': 'True'}),
+ 'date_end': ('django.db.models.fields.DateTimeField', [], {'db_index': 'True', 'max_length': '255', 'blank': '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
class Event(models.Model):
date = models.DateTimeField(_('date'), max_length=255, db_index=True)
+ date_end = models.DateTimeField(_('end date'), max_length=255,
+ db_index=True, blank=True)
link = models.URLField(_('link'))
class Meta:
return self.title
def clean(self):
+ if self.date_end:
+ if self.date_end < self.date:
+ raise ValidationError(
+ ugettext("End date must not be earlier than start."))
+ else:
+ self.date_end = self.date
for lc, ln in settings.LANGUAGES:
if (getattr(self, "published_%s" % lc) and
not getattr(self, "title_%s" % lc)):
def events_box(context, limit=app_settings.BOX_LENGTH):
lang = context['request'].LANGUAGE_CODE
objects = Event.objects.filter(**{"published_%s" % lang: True})
- objects = objects.filter(date__gte=datetime.now())[:limit]
+ objects = objects.filter(date_end__gte=datetime.now())[:limit]
return {'objects': objects}
def events(request):
- events = Event.objects.filter(date__gte=datetime.now())
+ events = Event.objects.filter(date_end__gte=datetime.now())
events = events.filter(**{"published_%s" % request.LANGUAGE_CODE: True})
return render(request, 'events/event_list.html', {
'object_list': events,
#
from itertools import chain
from migdal.models import Entry
-from migdal.settings import TYPES
+from migdal import app_settings
from django.utils.translation import get_language
if entry_type:
object_list = object_list.filter(type=entry_type.db)
else:
- object_list = object_list.filter(type__in=[t.db for t in TYPES if t.on_main])
+ object_list = object_list.filter(type__in=[t.db for t in app_settings.TYPES if t.on_main])
if category:
object_list = object_list.filter(categories=category)
from django.utils.translation import ugettext as _, string_concat
from migdal import api
from migdal.models import Category
-from migdal.settings import TYPES_DICT
+from migdal import app_settings
class EntriesFeed(Feed):
else:
category = None
if type_db:
- entry_type = TYPES_DICT[type_db]
+ entry_type = app_settings.TYPES_DICT[type_db]
else:
entry_type = None
return {'entry_type': entry_type, 'category': category}
from django import forms
from django.utils.translation import ugettext_lazy as _, get_language
from migdal.models import Entry
-from migdal.settings import TYPE_SUBMIT
+from migdal import app_settings
from slughifi import slughifi
from django.core.mail import mail_managers
from django import template
def clean(self):
data = super(SubmitForm, self).clean()
- data['type'] = TYPE_SUBMIT
+ data['type'] = app_settings.TYPE_SUBMIT
orig_slug = slughifi(data.get('title_%s' % lang, ''))
slug = orig_slug
number = 2