Alejandro Núñez Liz avatar Alejandro Núñez Liz committed a43c03a Draft

Integración con placeholder Django-CMS, añadido soporte multiidioma con dependencia de django-hvad.

Comments (0)

Files changed (21)

AUTHORS

-* Pexego S.L. (Avenida de Magoi 66 - Lugo )
-* Alejandro Núñez Liz <alejandro@toporojo.es>
-
-* Based on: http://python.majibu.org/preguntas/869/error-de-codificacion-ascii-localizando-htmlcalendar
+Copyright © 2013, Alejandro Núñez Liz
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions
+are met:
+
+   1. Redistributions of source code must retain the above copyright
+      notice, this list of conditions and the following disclaimer.
+   2. Redistributions in binary form must reproduce the above copyright
+      notice, this list of conditions and the following disclaimer in the
+      documentation and/or other materials provided with the distribution.
+   3. The name of the author may not be used to endorse or promote products
+      derived from this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR
+IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+include LICENSE.txt
+include README.txt
+recursive-include simple_events/locale *
+recursive-include simple_events/templates *
+recursive-include docs *
+recursive-exclude * *.pyc

README.md

-django-cms-simple-events
-========================
-A django-cms application for managing an events calendar.
-
-Dependancies
-============
-
-- django (tested with 1.4.2)
-- django-cms (tested with 2.3.5)
-
-
-Getting Started
-===============
-Add simple_events to your installed apps and syncdb (or migrate, if you have south installed).
-
-Your installed apps should look something like this:
-
-INSTALLED_APPS = (
-
-    'django.contrib.auth',
-    
-    'django.contrib.contenttypes',
-    
-    'django.contrib.sessions',
-    
-    'django.contrib.sites',
-    
-    'django.contrib.messages',
-    
-    'django.contrib.admin',
-    
-    'cms',
-    
-    ...
-    
-    'simple_events',
-    
-)
+=============================
+Django CMS Simple Events
+============================
+
+Name: django-cms-simple-events
+Description: A `Django CMS <http://www.django-cms.org/>`_ application for managing an events calendar.
+Download: https://bitbucket.org/chucu/django-cms-simple-events
+
+
+Dependancies
+============
+
+- django (tested with 1.5.1)
+- django-cms (tested with 2.4)
+- django-hvad
+
+
+Installation
+============
+
+Download
+--------
+
+From PyPI
+'''''''''
+
+You can simply type into a terminal ``pip install django-cms-simple-events`` or ``easy_install django-cms-simple-events``.
+
+Manually
+''''''''
+
+You can download from https://bitbucket.org/chucu/django-cms-simple-events.
+
+Unzip the file you downloaded. Then go in your terminal and ``cd`` into the unpacked folder. 
+Then type ``python setup.py install`` in your terminal.
+
+Setup
+-----
+
+Put ``'simple_events'`` in your ``INSTALLED_APPS`` section in settings.py. 
+Don't forget to syncdb your database or migrate if you're using South.
+
+Example:
+
+INSTALLED_APPS = ( 
+    ...
+    'hvad',
+    'simple_events',
+)
Add a comment to this file

dist/django-cms-simple-events-0.3.tar.gz

Binary file added.

+django-cms>=2.3
+django-hvad
+# -*- coding: utf-8 -*-
+import os
+from setuptools import setup
+
+README = open(os.path.join(os.path.dirname(__file__), 'README.txt')).read()
+
+# allow setup.py to be run from any path
+os.chdir(os.path.normpath(os.path.join(os.path.abspath(__file__), os.pardir)))
+
+setup(
+    name = 'django-cms-simple-events',
+    version = '0.4',
+    packages = ['simple_events'],
+    include_package_data = True,
+    license = 'BSD License', # example license
+    description = 'A django-cms application for managing an events calendar.',
+    long_description = README,
+    url = 'http://www.toporojo.es/',
+    author = 'Alejandro Núñez Liz',
+    author_email = 'alejandro@toporojo.es',
+    classifiers = [
+        'Environment :: Web Environment',
+        'Framework :: Django',
+        'Intended Audience :: Developers',
+        'License :: OSI Approved :: BSD License', # example license
+        'Operating System :: OS Independent',
+        'Programming Language :: Python',
+        'Programming Language :: Python :: 2.6',
+        'Programming Language :: Python :: 2.7',
+        'Topic :: Internet :: WWW/HTTP',
+        'Topic :: Internet :: WWW/HTTP :: Dynamic Content',
+    ],
+    zip_safe=False,
+    install_requires=['django-hvad', ],
+)

simple_events/admin.py

 from django.contrib import admin
 from django.utils.translation import ugettext as _
+from cms.admin.placeholderadmin import PlaceholderAdmin
+from hvad.admin import TranslatableAdmin
 
 from models import *
 
-class EventCategoryAdmin(admin.ModelAdmin):
-    list_display = ['name',]
-
+class EventCategoryAdmin(TranslatableAdmin):
+    date_hierarchy = 'created'
+    list_display = ('slug', '__unicode__', 'all_translations')    
+    
+    fieldsets = (
+        ('Event category info',{
+            'fields': ('name', 'slug'),
+        }),
+    )
+    
+    def __init__(self, *args, **kwargs):
+        super(EventCategoryAdmin, self).__init__(*args, **kwargs)
+        self.prepopulated_fields = {'slug': ('name',)}
+    
     def queryset(self, request):
         return EventCategory.on_site.all()
 
 admin.site.register(EventCategory, EventCategoryAdmin)
 
 
-class EventAdmin(admin.ModelAdmin):
-    list_display = ['name', 'start', 'category_list']
-    list_filter = ['start', 'categories',]
-    search_fields = ['name', 'description', 'location']
+class EventAdmin(TranslatableAdmin, PlaceholderAdmin):
     date_hierarchy = 'start'
+    list_display = ('slug', '__unicode__', 'start', 'all_translations', )
+    list_filter = ('start', 'categories', )
+    search_fields = ['start', ]
     filter_horizontal = ['categories']
     fieldsets = (
         ('Event info',{
-            'fields': ('name', 'start', 'description'),
+            'fields': ('name', 'slug', 'start', 'description'),
         }),
         (_(u'More options...'),{
             'classes': ['collapse'],
-            'fields': ('location', 'time', 'end', 'categories'),
+            'fields': ( 'time', 'end', 'categories'),
         }),
     )
     
-    # Descomentar para usar tinymce en el administrador.
-    #~ def formfield_for_dbfield(self, db_field, **kwargs):
-        #~ from django.core.urlresolvers import reverse
-        #~ from tinymce.widgets import TinyMCE
-        #~ if db_field.name == 'description':
-            #~ return db_field.formfield(widget=TinyMCE(
-            #~ attrs={'cols': 80, 'rows': 30},
-                #~ mce_attrs={'external_link_list_url': reverse('tinymce.views.flatpages_link_list')},
-            #~ ))
-        #~ return super(EventAdmin, self).formfield_for_dbfield(db_field, **kwargs)
-        
+    def __init__(self, *args, **kwargs):
+        super(EventAdmin, self).__init__(*args, **kwargs)
+        self.prepopulated_fields = {'slug': ('name',)}
+    
     def queryset(self, request):
         return Event.on_site.all()
 	
         current_site = Site.objects.get_current()
         if current_site not in obj.sites.all():
             obj.sites.add(current_site)
+            
+admin.site.register(Event, EventAdmin)
 
-admin.site.register(Event, EventAdmin)

simple_events/cms_plugins.py

                 cssclass += ' today'
                 body = '<a class="tipsy" href="#" title="%s">%d</a>' % (_('Today'), day)
                 if day in self.events:
-                    d = reverse('events_day', args=(self.year, self.month, day))
+                    d = reverse('events_day', args=[self.year, self.month, day])
                     body = '<a class="tipsy" href="%s" title="%s">%d</a>' % (d, _("Events found"), day)
                 return self.day_cell(cssclass, body)
 
Add a comment to this file

simple_events/locale/es/LC_MESSAGES/django.mo

Binary file modified.

simple_events/locale/es/LC_MESSAGES/django.po

 msgstr ""
 "Project-Id-Version: 0.1\n"
 "Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2012-12-10 19:31+0100\n"
+"POT-Creation-Date: 2013-04-23 14:20+0200\n"
 "PO-Revision-Date: 2012-11-15 16:58+0100\n"
 "Last-Translator: Alejandro Núñez <alejandro@toporojo.es>\n"
 "Language-Team: Español <LL@li.org>\n"
 "Content-Transfer-Encoding: 8bit\n"
 "Plural-Forms: nplurals=2; plural=(n != 1)\n"
 
-#: admin.py:32
+#: admin.py:45
 msgid "More options..."
 msgstr "Más opciones..."
 
 msgid "Calendar Events"
 msgstr "Calendario de eventos"
 
-#: models.py:16
+#: models.py:22
 msgid "Name"
 msgstr "Nombre"
 
-#: models.py:26
+#: models.py:24 models.py:91
+msgid "Slug"
+msgstr ""
+
+#: models.py:25 models.py:92
+msgid ""
+"Name in lowercase with no spaces which will be chown in the URL of the "
+"navigator"
+msgstr ""
+"Nombre en minúsculas y sin espacio que será usado en la URL del navegador"
+
+#: models.py:39 models.py:166 models.py:170
+msgid "Events"
+msgstr "Eventos"
+
+#: models.py:41
 msgid "Event category"
 msgstr "Categoría de eventos"
 
-#: models.py:27
+#: models.py:42
 msgid "Event categories"
 msgstr "Categorías de eventos"
 
-#: models.py:68
+#: models.py:83
 msgid ""
 "The end date must be after the start date.  Please select a new end date, or "
 "leave blank if this event is only one day long."
 "una nueva fecha de finalización o dejala en blanco si el evento es de un "
 "solo día."
 
-#: models.py:74
+#: models.py:88
 msgid "Title"
 msgstr "Título"
 
-#: models.py:74
+#: models.py:89
 msgid "Example: \"Second Annual Charity Auction\""
 msgstr "Ejemplo:\"Segunda subasta anual de caridad\""
 
-#: models.py:75
+#: models.py:93
 msgid "Description"
 msgstr "Descripción"
 
-#: models.py:76
-msgid ""
-"* Optional.  Give more details on this event (items to bring, links to other "
-"sites, etc)."
-msgstr ""
-"* Opcional. Dar más detalles sobre este evento (artículos para llevar, "
-"enlaces a otros sitios, etc.)"
-
-#: models.py:77
-msgid "Location"
-msgstr "Lugar"
-
-#: models.py:77
-msgid "* Optional."
-msgstr "* Opcional."
-
-#: models.py:78
+#: models.py:95
 msgid "Date"
 msgstr "Fecha"
 
-#: models.py:79
+#: models.py:96
 msgid ""
 "Format: yyyy-mm-dd.  When does this event take place?  If the event is "
 "longer than one day, enter the start date here and the end date below."
 "Formato: aaaa-mm-dd. Si el evento es más largo de un día, escriba la fecha "
 "de inicio y la de finalización más abajo."
 
-#: models.py:81
+#: models.py:98
+msgid "Time"
+msgstr "Hora"
+
+#: models.py:99
 msgid "* Optional.  Examples: \"8 am - 4 pm\", \"7:30 pm\""
 msgstr "* Opcional. Ejemplo: \"8 am - 4 pm\", \"7:30 pm\""
 
-#: models.py:83
+#: models.py:101
 msgid "End date"
 msgstr "Fecha de finalización"
 
-#: models.py:84
+#: models.py:102
 msgid ""
 "* Optional.  If this event is more than one day long, enter the end date "
 "here.  Defaults to \"start\" date if left blank."
 "* Opcional. Si este evento es más de un día largo, introduzca la fecha de "
 "finalización aquí."
 
-#: models.py:104
+#: models.py:135
 msgid "(No categories)"
 msgstr "(Sin categorías)"
 
-#: models.py:136
+#: models.py:169
 msgid "Event"
 msgstr "Evento"
 
-#: models.py:137 templates/simple_events/base.html:6
-msgid "Events"
-msgstr "Eventos"
-
-#: templates/simple_events/event_detail.html:6
+#: templates/simple_events/event_detail.html:3
 msgid "This event is over."
 msgstr "Este evento ha finalizado."
 
-#: templates/simple_events/event_detail.html:24
+#: templates/simple_events/event_detail.html:21
 msgid "Next event"
 msgstr "Próximo evento"
 
-#: templates/simple_events/event_detail.html:29
+#: templates/simple_events/event_detail.html:26
 msgid "Previous event"
 msgstr "Evento anterior"
 
-#: templates/simple_events/events_archive.html:8
+#: templates/simple_events/events_archive.html:7
 msgid "Past events"
 msgstr "Eventos pasados"
 
-#: templates/simple_events/events_archive.html:10
+#: templates/simple_events/events_archive.html:9
 msgid "Next events"
 msgstr "Próximos eventos"
 
+#~ msgid ""
+#~ "* Optional.  Give more details on this event (items to bring, links to "
+#~ "other sites, etc)."
+#~ msgstr ""
+#~ "* Opcional. Dar más detalles sobre este evento (artículos para llevar, "
+#~ "enlaces a otros sitios, etc.)"
+
+#~ msgid "Location"
+#~ msgstr "Lugar"
+
+#~ msgid "* Optional."
+#~ msgstr "* Opcional."
+
 #~ msgid "Next Month"
 #~ msgstr "Més anterior"
Add a comment to this file

simple_events/locale/gl/LC_MESSAGES/django.mo

Binary file modified.

simple_events/locale/gl/LC_MESSAGES/django.po

 msgstr ""
 "Project-Id-Version: 0.1\n"
 "Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2012-12-10 19:31+0100\n"
+"POT-Creation-Date: 2013-04-23 14:20+0200\n"
 "PO-Revision-Date: 2012-11-15 16:58+0100\n"
 "Last-Translator: Alejandro Núñez <alejandro@toporojo.es>\n"
 "Language-Team: Gallego <LL@li.org>\n"
 "Content-Transfer-Encoding: 8bit\n"
 "Plural-Forms: nplurals=2; plural=(n != 1)\n"
 
-#: admin.py:32
+#: admin.py:45
 msgid "More options..."
 msgstr "Máis opcións..."
 
 #: cms_app.py:6
 msgid "Simple events aplication"
-msgstr "Aplicación simple para eventos"
+msgstr "Aplicación sinxela para xestionar eventos"
 
 #: cms_plugins.py:32
 msgid "Today"
 msgid "Calendar Events"
 msgstr "Calendario de eventos"
 
-#: models.py:16
+#: models.py:22
 msgid "Name"
 msgstr "Nome"
 
-#: models.py:26
+#: models.py:24 models.py:91
+msgid "Slug"
+msgstr ""
+
+#: models.py:25 models.py:92
+msgid ""
+"Name in lowercase with no spaces which will be chown in the URL of the "
+"navigator"
+msgstr "Nome en minúsculas e sen espazos que será usado na URL do navegador"
+
+#: models.py:39 models.py:166 models.py:170
+msgid "Events"
+msgstr "Eventos"
+
+#: models.py:41
 msgid "Event category"
 msgstr "Categoría de eventos"
 
-#: models.py:27
+#: models.py:42
 msgid "Event categories"
 msgstr "Categorías de eventos"
 
-#: models.py:68
+#: models.py:83
 msgid ""
 "The end date must be after the start date.  Please select a new end date, or "
 "leave blank if this event is only one day long."
 "A data de finalización debe ser posterior a data de inicio. Selecciona unha "
 "nova data de finalización ou deixaa en branco se o evento é de un só día."
 
-#: models.py:74
+#: models.py:88
 msgid "Title"
 msgstr "Título"
 
-#: models.py:74
+#: models.py:89
 msgid "Example: \"Second Annual Charity Auction\""
 msgstr "Exemplo:\"Segunda subasta anual de caridade\""
 
-#: models.py:75
+#: models.py:93
 msgid "Description"
 msgstr "Descrición"
 
-#: models.py:76
-msgid ""
-"* Optional.  Give more details on this event (items to bring, links to other "
-"sites, etc)."
-msgstr ""
-"* Opcional. Dar máis detalles sobre este evento (artículos a levar, enlaces "
-"a outros sitios, etc.)"
-
-#: models.py:77
-msgid "Location"
-msgstr "Lugar"
-
-#: models.py:77
-msgid "* Optional."
-msgstr "* Opcional."
-
-#: models.py:78
+#: models.py:95
 msgid "Date"
 msgstr "Data"
 
-#: models.py:79
+#: models.py:96
 msgid ""
 "Format: yyyy-mm-dd.  When does this event take place?  If the event is "
 "longer than one day, enter the start date here and the end date below."
 "Formato: aaaa-mm-dd. Se o evento es máis longo dun día, escriba a data de "
 "inicio e a de finalización máis abaixo."
 
-#: models.py:81
+#: models.py:98
+msgid "Time"
+msgstr "Hora"
+
+#: models.py:99
 msgid "* Optional.  Examples: \"8 am - 4 pm\", \"7:30 pm\""
 msgstr "* Opcional. Exemplo: \"8 am - 4 pm\", \"7:30 pm\""
 
-#: models.py:83
+#: models.py:101
 msgid "End date"
 msgstr "Data de finalización"
 
-#: models.py:84
+#: models.py:102
 msgid ""
 "* Optional.  If this event is more than one day long, enter the end date "
 "here.  Defaults to \"start\" date if left blank."
 "* Opcional. Se este evento é máis longo dun día, introduzca a data de "
 "finalización aquí."
 
-#: models.py:104
+#: models.py:135
 msgid "(No categories)"
 msgstr "(Sen categorías)"
 
-#: models.py:136
+#: models.py:169
 msgid "Event"
 msgstr "Evento"
 
-#: models.py:137 templates/simple_events/base.html:6
-msgid "Events"
-msgstr "Eventos"
-
-#: templates/simple_events/event_detail.html:6
+#: templates/simple_events/event_detail.html:3
 msgid "This event is over."
 msgstr "Este evento xa finalizou."
 
-#: templates/simple_events/event_detail.html:24
+#: templates/simple_events/event_detail.html:21
 msgid "Next event"
 msgstr "Próximo evento"
 
-#: templates/simple_events/event_detail.html:29
+#: templates/simple_events/event_detail.html:26
 msgid "Previous event"
 msgstr "Evento anterior"
 
-#: templates/simple_events/events_archive.html:8
+#: templates/simple_events/events_archive.html:7
 msgid "Past events"
 msgstr "Eventos pasados"
 
-#: templates/simple_events/events_archive.html:10
+#: templates/simple_events/events_archive.html:9
 msgid "Next events"
 msgstr "Próximos eventos"
 
+#~ msgid ""
+#~ "* Optional.  Give more details on this event (items to bring, links to "
+#~ "other sites, etc)."
+#~ msgstr ""
+#~ "* Opcional. Dar máis detalles sobre este evento (artículos a levar, "
+#~ "enlaces a outros sitios, etc.)"
+
+#~ msgid "Location"
+#~ msgstr "Lugar"
+
+#~ msgid "* Optional."
+#~ msgstr "* Opcional."
+
 #~ msgid "Next Month"
 #~ msgstr "Més anterior"

simple_events/models.py

 from django.template.defaultfilters import date as datefilter
 from django.conf import settings
 from django.utils.translation import ugettext as _
+
 from cms.models import CMSPlugin # django-cms
+from cms.models.fields import PlaceholderField
 
-class EventCategory(models.Model):
-    objects = models.Manager()
+from hvad.models import TranslatableModel, TranslatedFields
+from hvad.manager import TranslationManager
+
+
+class EventCategory(TranslatableModel):
     on_site = CurrentSiteManager(field_name='sites')
-    name = models.CharField(_(u"Name"), max_length=100)
+    translations = TranslatedFields(
+        name = models.CharField(_(u"Name"), max_length=100)
+    )
+    slug = models.SlugField(_('Slug'),
+            help_text=_('Name in lowercase with no spaces which will be chown in the URL of the navigator'))
     sites = models.ManyToManyField(Site)
-
+    created = models.DateTimeField(auto_now_add=True, editable=False)
+    updated = models.DateTimeField(auto_now=True, editable=False)
+    
+    objects = TranslationManager()
+    
     def site_list(self):
         return self.sites.all()
 
         return self.name
 
     class Meta:
+        app_label =  _("Events")
+        db_table = 'simple_events_eventcategory'
         verbose_name = _(u'Event category')
         verbose_name_plural = _(u'Event categories')
 
         if  date(*[int(v) for v in field_data.split('-')]) <=  date(*[int(v) for v in all_data['start'].split('-')]):
             raise ValidationError(_("The end date must be after the start date.  Please select a new end date, or leave blank if this event is only one day long."))
 
-class Event(models.Model):
-    objects = models.Manager()
+class Event(TranslatableModel):
     on_site = EventManager(field_name='sites')
+    translations = TranslatedFields(
+        name = models.CharField(_("Title"), max_length=250, 
+                help_text=_(u'Example: "Second Annual Charity Auction"'))
+    )
+    slug = models.SlugField(_('Slug'), unique_for_date='start', 
+            help_text=_('Name in lowercase with no spaces which will be chown in the URL of the navigator'))
+    description = PlaceholderField('event_description', blank=True, null=True, verbose_name=_('Description'),)
 
-    name = models.CharField(_("Title"), max_length=250, help_text=_(u'Example: "Second Annual Charity Auction"'))
-    description = models.TextField(_("Description"), blank=True,
-        help_text=_(u'* Optional.  Give more details on this event (items to bring, links to other sites, etc).'))
-    location = models.TextField(_("Location"), blank=True, help_text=_(u"* Optional."))
     start = models.DateField(_(u"Date"),
         help_text=_(u'Format: yyyy-mm-dd.  When does this event take place?  '
         'If the event is longer than one day, enter the start date here and the end date below.'))
-    time = models.CharField(blank=True, max_length=100, help_text=_(u'* Optional.  Examples: "8 am - 4 pm", "7:30 pm"'))
+    time = models.CharField(_("Time"), blank=True, max_length=100, 
+        help_text=_(u'* Optional.  Examples: "8 am - 4 pm", "7:30 pm"'))
     # Todo -- continue to validate that the end is after the start?
     end = models.DateField(_(u'End date'), blank=True, null=True,
         help_text=_(u'* Optional.  If this event is more than one day long, enter the end date here.  Defaults to "start" date if left blank.'))
-    categories = models.ManyToManyField(EventCategory, blank=True, null=True, limit_choices_to={'sites__id': settings.SITE_ID})
-    sites = models.ManyToManyField(Site, editable=False, default=[settings.SITE_ID])
-	
+    categories = models.ManyToManyField(EventCategory, blank=True, 
+        null=True, limit_choices_to={'sites__id': settings.SITE_ID})
+    sites = models.ManyToManyField(Site, editable=False, 
+        default=[settings.SITE_ID])
+       
+    created = models.DateTimeField(auto_now_add=True, editable=False)
+    updated = models.DateTimeField(auto_now=True, editable=False)
+    
+
+    objects = TranslationManager()
+    
     def __unicode__(self):
         return self.name
 
     @models.permalink
     def get_absolute_url(self):
-        return reverse('event_detail', args=(self.id,))
-
+        return ('event_detail', None, {
+            'year': self.start.strftime("%Y"),
+            'month': self.start.strftime("%m"),
+            'day': self.start.strftime("%d"),
+            'slug': self.slug,
+            })
+        
     def has_passed(self):
         if self.end:
             return self.end < date.today()
     date_span.allow_tags = True
     
     class Meta:
+        app_label =  _("Events")
+        db_table = 'simple_events_event'
         ordering = ('-start',)
         verbose_name = _(u'Event')
         verbose_name_plural = _(u'Events')

simple_events/templates/simple_events/event_detail.html

 {% load i18n %}
-
 	{% if event.has_passed %}
 		<p>{% trans "This event is over." %}</p>
 	{% endif %}

simple_events/templates/simple_events/events_archive.html

             <h2>{{ dates.grouper }}</h2>
             <ul>
             {% for event in dates.list %}
-                <li><a href="{% url event_detail event.id %}" title="{{ event.name }}">{{ event.name }}</a></li>
+                <li><a href='{% url "events_detail" event.start|date:"Y" event.start|date:"n" event.start|date:"d" event.slug %}' title="{{ event.name }}">{{ event.name }}</a></li>
             {% endfor %}
             </ul>
         {% endfor %}
Add a comment to this file

simple_events/templatetags/__init__.py

Empty file removed.

simple_events/templatetags/event_tags.py

-from django import template
-from models import Event
-
-register = template.Library()
-
-@register.tag
-def get_upcoming_events(parser, token):
-	"""
-		{% get_upcoming_events as events %}
-		{% get_upcoming_events as events with num=5 days=180 categories=1,13 %}
-		5 = number of events
-		60 = in the next 60 days
-		categories = 
-			- Not supplied (None): any category
-			- 'none' (string): uncategorized
-			- 1,2,3 (string in list): in any of the supplied categories
-	"""
-	bits = token.split_contents()
-	if len(bits) == 3:
-		# Get all the upcoming events.
-		if bits[1] != 'as':
-			raise template.TemplateSyntaxError("Second argument to 'get_upcoming_events' must be 'as': {% get_upcoming_events as events %}")
-		return UpcomingEventsNode(bits[2])
-	if len(bits) > 3:
-		# Some options were specified.
-		if bits[3] != 'with':
-			raise template.TemplateSyntaxError("get_upcoming_events expects paramters if using 'with'")
-		if len(bits) < 5:
-			raise template.TemplateSyntaxError("get_upcoming_events expects paramters if using 'with'")
-		kwargs = {}
-		for arg in bits[4:]:
-			key, value = arg.split('=')
-			kwargs.update({str(key):value})
-		return UpcomingEventsNode(bits[2], **kwargs)
-	
-class UpcomingEventsNode(template.Node):
-	
-	def __init__(self, varname, num=None, days=None, categories=None):
-		self.varname = varname
-		self.num = num
-		self.days = days
-		if categories is not None and categories.lower() != 'none':
-			self.categories = [ int(c) for c in categories.split(',') ]
-		else:
-			self.categories = categories
-		
-	def render(self, context):
-		events = Event.on_site.upcoming(self.days)
-		if self.categories == 'none':
-			# Get only events that have no (null) category.
-			# ick...
-			event_ids = [ e.id for e in events if e.categories.all().count() ==0 ]
-			events = events.filter(id__in=event_ids)
-		elif self.categories is not None and isinstance(self.categories, list):
-			events = events.filter(categories__id__in=self.categories)
-		if self.num is None:
-			context[self.varname] = events
-		else:
-			context[self.varname] = events[:int(self.num)]
-		return u''

simple_events/urls.py

 from django.conf.urls.defaults import *
 from models import Event
-
-event_dict = {
-	'queryset': Event.on_site.all(),
-	'template_object_name': 'event'
-}
+from django.views.generic.dates import DateDetailView
 
 urlpatterns = patterns('',
-    url(r'^$', 'simple_events.views.events', name="events"),
-    url(r'^(?P<year>\d{4})/(?P<month>\d+)/(?P<day>\d+)/$','simple_events.views.events_day', name="events_day"),
+    url(r'^$', 'simple_events.views.events', name='events'),
+    url(r'^(?P<year>\d{4})/(?P<month>\d+)/(?P<day>\d+)/$',
+            'simple_events.views.events_day', name="events_day"),
+    url(r'^(?P<year>\d{4})/(?P<month>\d+)/(?P<day>\d+)/(?P<slug>[-\w]+)/$',
+            'simple_events.views.events_detail', name="events_detail"),
 )
-urlpatterns += patterns('django.views.generic',
-	url(r'^event-(?P<object_id>\d+)/$', 'list_detail.object_detail', event_dict, name="event_detail"),
-)

simple_events/views.py

 def events_day(request, year, month, day):
     events = Event.objects.filter(start=date(int(year), int(month), int(day)))
     return locals()
+    
+@render_to('simple_events/event_detail.html')
+def events_detail(request, year, month, day, slug):
+    event = Event.objects.get(start=date(int(year), int(month), int(day)), slug=slug)
+    return locals()
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.