Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
self._past= times
return self._past
def __unicode__(self):
return self.title
@models.permalink
def get_absolute_url(self):
return ('event-info', None, { 'slug': self.event.slug, })
class EventTime(models.Model):
"""EventTime model
This model does most of the heavy lifting as to whether """
event = models.ForeignKey(Event, related_name='event_times')
start = models.DateTimeField()
end = models.DateTimeField(blank=True, null=True)
place = models.ForeignKey(Place, blank=True, null=True)
place_string = models.CharField(_('One-off place'), max_length=200, blank=True)
is_all_day = models.BooleanField(default=False)
notes = models.TextField(_('Notes'), blank=True, null=True)
slug = models.SlugField(_('Event slug'), blank=True, editable=False)
objects = models.Manager()
upcoming_objects = UpcomingManager()
class Meta:
verbose_name = _('event time')
verbose_name_plural = _('event times')
get_latest_by = 'start'
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'),
)
def past_event_times(self):
if not self._past:
try:
times = self.event_times.all().filter(start__lte=datetime.now().date)
except(Event.DoesNotExist, IndexError):
times = None
self._past= times
return self._past
def __init__(self, *args, **kwargs):
super (Event, self).__init__(*args, **kwargs)
self._upcoming = None
self._past = None