Ejemplo n.º 1
0
    class Meta:
        ordering = ["-starts_at"]


from django.conf import settings

from djangogcal.adapter import CalendarAdapter, CalendarEventData
from djangogcal.observer import CalendarObserver


class EventCalendarAdapter(CalendarAdapter):
    """
    A calendar adapter for the Showing model.
    """
    def get_event_data(self, instance):
        """
        Returns a CalendarEventData object filled with data from the adaptee.
        """
        return CalendarEventData(
            start=instance.starts_at,
            end=instance.ends_at,
            title=instance.name,
            content=((instance.description[:200] + '...') if len(
                instance.description) > 200 else instance.description) +
            ' Register Here: ' + instance.link)


observer = CalendarObserver(email=settings.CALENDAR_EMAIL,
                            password=settings.CALENDAR_PASSWORD)
observer.observe(Event, EventCalendarAdapter())
Ejemplo n.º 2
0
        blank=True,
        default=REGISTERED
    )
    comment = models.TextField(
        blank=True,
        default="",
        help_text="If you have a message for the organisers, enter it here \
        and they will get back to you."
    )


from django.conf import settings

from djangogcal.adapter import CalendarAdapter, CalendarEventData
from djangogcal.observer import CalendarObserver

class EventCalendarAdapter(CalendarAdapter):
    def get_event_data(self, instance):
        return CalendarEventData(
            start=instance.start_time,
            end=instance.end_time,
            title=instance.name,
            content=instance.description
        )

observer = CalendarObserver(email=settings.CALENDAR_EMAIL,
                            password=settings.CALENDAR_PASSWORD)
observer.observe(Event, EventCalendarAdapter())


Ejemplo n.º 3
0
    
class SortieCalendarAdapter(CalendarAdapter):
    """
    A calendar adapter for the Sortie model.
    """
    
    def get_event_data(self, instance):
        """
        Returns a CalendarEventData object filled with data from the adaptee.
        """
        try:
            description = "<a href='http://%s%s'>Voir le d&eacute;tail de l'activit&eacute;</a><br/>%s" % (Site.objects.get(pk=settings.SITE_ID).domain, instance.get_absolute_url(), instance.description)
            titre = "%s: %s" % (instance.get_type_label(), instance.titre)
            start = instance.date_debut
            end = instance.date_fin
            if end.time() == datetime.time(0, 0):
                end = end + datetime.timedelta(days=1)
            return CalendarEventData(
                start=start,
                end=end,
                title=titre,
                where=[instance.lieu, "RDV: %s" % instance.rdv,],
                content=description,
            )
        except:
            return None

observer = CalendarObserver(email=settings.CALENDAR_EMAIL,
                            password=settings.CALENDAR_PASSWORD)
observer.observe(Sortie, SortieCalendarAdapter())