How to use eventy - 10 common examples

To help you get started, we’ve selected a few eventy examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github powellc / django-eventy / eventy / models.py View on Github external
def get_previous_event_time(self):
        """Determines the previous event time"""

        if not self._previous:
            try:
                qs = EventTime.objects.all().exclude(id__exact=self.id)
                event_time= qs.filter(start__lte=self.start).order_by('-start')[0]
            except (EventTime.DoesNotExist, IndexError):
                event_time = None
            self._previous = event_time

        return self._previous

class RelatedEvent(models.Model):
    eventtime = models.ForeignKey(EventTime)
    content_type = models.ForeignKey(ContentType)
    object_id = models.PositiveIntegerField()
    content_object = generic.GenericForeignKey('content_type', 'object_id')

    def __unicode__(self):
        return self.eventtime.event.__unicode__()
github powellc / django-eventy / eventy / templatetags / eventy_tags.py View on Github external
def render(self, context):
        if self.calendar_slug == 'all':
            events = EventTime.upcoming_objects.all().order_by('start')
        else:
            events = EventTime.upcoming_objects.filter(event__calendar__slug=self.calendar_slug).order_by('start')

        if self.excluded_cals:
            for cal_slug in self.excluded_cals:
                events = events.exclude(event__calendar__slug=cal_slug)

        logging.debug('Fetching %s events from calendar %s excluding %s.' % (self.limit, self.calendar_slug, self.excluded_cals))
        if self.limit == 1:
            try:
                context[self.varname] = events[0]
            except:
                context[self.varname] = None
        else:
            try:
                context[self.varname] = events[:self.limit]
github powellc / django-eventy / eventy / models.py View on Github external
def get_next_event_time(self):
        """Determines the next event time"""

        if not self._next:
            try:
                qs = EventTime.objects.filter(event=self.event).exclude(id__exact=self.id)
                event_time= qs.filter(start__gte=self.start).order_by('start')[0]
            except (EventTime.DoesNotExist, IndexError):
                event_time = None
            self._next = event_time

        return self._next
github powellc / django-eventy / eventy / templatetags / eventy_tags.py View on Github external
def render(self, context):
        if self.calendar_slug == 'all':
            events = EventTime.upcoming_objects.all().order_by('start')
        else:
            events = EventTime.upcoming_objects.filter(event__calendar__slug=self.calendar_slug).order_by('start')

        if self.excluded_cals:
            for cal_slug in self.excluded_cals:
                events = events.exclude(event__calendar__slug=cal_slug)

        logging.debug('Fetching %s events from calendar %s excluding %s.' % (self.limit, self.calendar_slug, self.excluded_cals))
        if self.limit == 1:
            try:
                context[self.varname] = events[0]
            except:
                context[self.varname] = None
        else:
            try:
                context[self.varname] = events[:self.limit]
            except:
                context[self.varname] = None
github powellc / django-eventy / eventy / models.py View on Github external
def save(self, *args, **kwargs):
        if not self.slug:
            self.slug = self.event.slug

        if self.place and not self.place_string:
            self.place_string = self.place.__unicode__()
        super(EventTime, self).save(*args, **kwargs)
github powellc / django-committees / committees / models.py View on Github external
    @property
    def full_name(self):
        return u'%s %s' % (self.first_name, self.last_name)

    @property
    def on_board(self):
        for t in self.term_set.all():
            if t.group.order == 10:
                return True

    @models.permalink
    def get_absolute_url(self):
        return ('cm-person-detail', None, {'slug': self.slug})


class Meeting(MarkupMixin, TimeStampedModel, EventTime):
    '''
    Meeting model.

    A general meeting model. 
    '''
    group = models.ForeignKey(Group)
    agenda = models.TextField(_('Agenda'), blank=True, null=True)
    rendered_agenda = models.TextField(_('Rendered agenda'), blank=True, null=True)
    business_arising=models.TextField(_('Business arising'), blank=True, null=True)

    def __init__(self, *args, **kwargs):
        super (Meeting, self).__init__(*args, **kwargs)
        self._next = None
        self._previous = None

    class Meta:
github powellc / django-eventy / eventy / models.py View on Github external
def get_previous_event_time(self):
        """Determines the previous event time"""

        if not self._previous:
            try:
                qs = EventTime.objects.all().exclude(id__exact=self.id)
                event_time= qs.filter(start__lte=self.start).order_by('-start')[0]
            except (EventTime.DoesNotExist, IndexError):
                event_time = None
            self._previous = event_time

        return self._previous
github powellc / django-eventy / eventy / views.py View on Github external
def get_queryset(self):
        try:
            if self.kwargs['cal_slug']:
                return EventTime.upcoming_objects.filter(event__calendar__slug=self.kwargs['cal_slug'])
        except:
            pass

        try:
            if self.kwargs['slug']:
                return EventTime.upcoming_objects.filter(event__slug=self.kwargs['slug'])
        except:
            logging.debug('Returning all upcoming events...')
            return EventTime.upcoming_objects.all()
github powellc / django-eventy / eventy / views.py View on Github external
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()

    def get_context_data(self, **kwargs):
        context = super(EventListView, self).get_context_data(**kwargs)
        context['month'] = EventCalendar(self.get_queryset()).formatmonth(datetime.now().year, datetime.now().month)
        if self.calendar:
            context['calendar'] = self.calendar
        return context

class EventDetailView(DateDetailView):
    context_object_name = "event"
    queryset=EventTime.upcoming_objects.all()
    allow_future = True
    date_field = 'start'

class EventYearView(YearArchiveView):
    context_object_name = "event_list"
    allow_future = True
    date_field = 'start'
    allow_empty = True

    def get_queryset(self):
        try:
            if self.kwargs['cal_slug']:
                return EventTime.upcoming_objects.filter(event__calendar__slug=self.kwargs['cal_slug'])
        except:
            pass
github powellc / django-eventy / eventy / views.py View on Github external
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()