How to use the eventy.models.EventTime function in eventy

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 / 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()