Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def get_queryset(self):
try:
cal_slug = self.kwargs['cal_slug']
self.calendar = get_object_or_404(Calendar, slug=cal_slug)
except:
self.calendar = None
return EventTime.upcoming_objects.all()
"""Calendar model."""
class Meta:
verbose_name = _('calendar')
verbose_name_plural=_('calendars')
def __unicode__(self):
return self.title
@models.permalink
def get_absolute_url(self):
return ('event-calendar-detail', None, { 'cal_slug': self.slug, })
class Event(TitleSlugDescriptionModel, TimeStampedModel):
"""Event model"""
calendar=models.ForeignKey(Calendar, blank=True, null=True)
submitted_by = models.ForeignKey(User, blank=True, null=True)
class Meta:
verbose_name = _('event')
verbose_name_plural = _('events')
def __init__(self, *args, **kwargs):
super (Event, self).__init__(*args, **kwargs)
self._upcoming = None
self._past = None
@property
def upcoming_event_times(self):
if not self._upcoming:
try:
times = self.event_times.all().filter(start__gte=datetime.now().date)
from django.conf.urls.defaults import *
from django.views.generic import ListView, DetailView
from eventy.models import Event, EventTime, Calendar, Place
from eventy.views import EventDetailView, EventDayView, EventMonthView, EventYearView, EventListView
urlpatterns = patterns('',
url(r'^(?P\d{4})/(?P\w{3})/(?P\d{1,2})/$', view=EventDayView.as_view(), name='ev-events-day'),
url(r'^(?P\d{4})/(?P\w{3})/$', view=EventMonthView.as_view(), name='ev-events-month'),
url(r'^(?P\d{4})/$', view=EventYearView.as_view(), name='ev-events-year'),
url(r'^calendars/(?P[-\w]+)/(?P\d{4})/$', view=EventYearView.as_view(), name='ev-calendar-year'),
url(r'^calendars/(?P[-\w]+)/(?P\d{4})/(?P\w{3})/$', view=EventMonthView.as_view(), name='ev-calendar-month'),
url(r'^calendars/(?P[-\w]+)/$', view=EventListView.as_view(), name='ev-calendar-detail'),
url(r'^calendars/$', view=ListView.as_view(model=Calendar), name='ev-calendar-list'),
url(r'^places/$', view=ListView.as_view(model=Place), name='place-list'),
url(r'^places/(?P[-\w]+)/$', view=DetailView.as_view(model=Place), name='place-detail'),
url(r'^(?P[-\w]+)/(?P\d{4})/(?P\w{3})/(?P\d{1,2})/$', view=EventDetailView.as_view(), name='ev-event-detail'),
url(r'^(?P[-\w]+)/(?P\d{4})/(?P\w{3})/$', view=EventMonthView.as_view(), name='ev-event-month'),
url(r'^(?P[-\w]+)/(?P\d{4})/$', view=EventYearView.as_view(), name='ev-event-year'),
url(r'^(?P[-\w]+)/$', view=DetailView.as_view(model=Event), name='ev-events-info'),
url(r'^$', view=EventListView.as_view(), name='event-list'),
)