Skip to content

A Django application allowing developers to synchronise instances of their models with Google Calendar.

License

Notifications You must be signed in to change notification settings

incuna/django-gcal

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

28 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

djangogcal

Forked from https://code.google.com/p/django-gcal/ on Google Code, by metzen and emperorofcheese.

Released under an MIT licence.

About

A Django application allowing developers to synchronise instances of their models with Google Calendar. Using Django's signals mechanism and generic relations, no changes to the model being synchronised are required, and synchronisation occurs without user intervention over the models lifecycle.

Usage

In a typical scenario, the following steps are required to use django-gcal:

  • Add djangogcal to the list of installed applications in your settings.py.
  • Define a djangogcal.adapter.CalendarAdapter for each model you want synchronised.
  • Instantiate a djangogcal.observer.CalendarObserver for each Google Calendar feed.
  • Call the CalendarObserver.observe(model, adapter) method to link models with the Google Calendar feed.
  • See GettingStarted for more information, and RelatedModels for information about sending updates when related objects are changed.

Example

The code in this example is sufficient to bind a model to Google Calendar:

from django.conf import settings

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

from models import Showing

class ShowingCalendarAdapter(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.start_time,
            end=instance.end_time,
            title=instance.title
        )

observer = CalendarObserver(email=settings.CALENDAR_EMAIL,
                            password=settings.CALENDAR_PASSWORD)
observer.observe(Showing, ShowingCalendarAdapter())

About

A Django application allowing developers to synchronise instances of their models with Google Calendar.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages