Package: tgapp-calendarevents
About calendareventscalendarevents is a Pluggable calendars and events application for TurboGears2.
It permits to create events which are associated to entities defined inside the
application which plugs it in.Calendarevents provides support for multiple calendars and event types, by defining
new event types it is possible to define how the event relates to external entities
like a blog post that describes it.When displaying events if available weather informations for the day and location
of the event will be provided.Installingcalendarevents can be installed both from pypi or from bitbucket:easy_install tgapp-calendareventsshould just work for most of the usersPlugging calendareventsIn your applicationconfig/app_cfg.pyimportplug:from tgext.pluggable import plugThen at theend of the filecall plug with calendarevents:plug(base_config, 'calendarevents', event_types=[...])At least one event type must be defined inside theevent_typesargument.
Defining event types is explained inside the Event Types section.You will be able to access the calendars athttp://localhost:8080/calendarevents.Event Typescalendarevents needs the application to define at least one EventType to work.Event types must be defined inheriting from thecalendarevents.EventTypeclass,
for example to define an event for a concert which relates to a blog article that
describes the concert itself:from tw2.core.js import js_function
from tw2.core.resources import JSLink, CSSLink

class Concert(EventType):
    name = 'Concert'
    resources = [
        JSLink(modname='calendarevents.public', filename='js/calendarevents.js'),
        CSSLink(modname='calendarevents.public', filename='css/fullcalendar.css')
    ]
    events = {'eventClick': js_function('calendarevents.eventClick'),
              'dayClick': js_function('calendarevents.dayClick')}

    def get_linkable_entities(self, calendar):
        return [(a.uid, a.title) for a in model.DBSession.query(model.Article)]

    def get_linked_entity_info(self, event):
        return model.DBSession.query(model.Article).get(event.linked_entity_id).title

    def get_linked_entity_url(self, event):
        return tg.url('/blog/view/%s' % event.linked_entity_id)

plug(base_config, 'calendarevents', event_types=[Concert()])Event types can also specify some additional options to change the calendevents
behavior. If theEventTypespecifiesforce_redirect = Trueas a class
property whenever the event page is opened the user gets redirected to the
linked entity url.EventTypecan also update the calendar informations be exposing acalendar_data(self, event)->dictmethod that can return any
additional information for the event (for example it can mark the
event as allDay or not).resourcesare required only if you want to use js_hooks for fullcalendar events.resourcesshould be a list of toscaWidget injected resources,eventsare the injected js methods for overriding js_hooks.js_hooksIf you want to use js_hooks you must inject resource in your event type, see prior section.
for now supported events for the js_hooks areeventClickanddayClick.The .js hook script can follow this example:(function(w) {
  w.calendarevents = {
    eventClick: function(base_url, event, view) {
      window.location.href = base_url+event.uid;
    },
    dayClick: function(base_url, date, allDay, view) {
    }
  };
})(window);note: if you inject js_hooks you replace the default behavior
note:from version 0.2.0 date holds a moment for the clicked dayExposed Partialscalendarevents exposes a partial to render event boxes inside other pages:calendarevents.partials:event(event) - Renders an event boxCalendar Partialcalendarevents.partials:calendar(cal,view='month',all_day_slot=False,start_from=datetime.utcnow())The calendar partial expose a partial with just a calendar, parameters accepted are:cal-> (required) the calendar object, for now the js events are managed only by theevent_typeassigned tothat calendarevent_sources-> a dictionary in the following format:{'event_sources': [{'events': availability_events_list,
                    'color': 'Blue',
                    'text_color': ''},
                   {'events': occupation_events_list,
                    'color': 'Red',
                    'text_color': ''}]}colorandtext_colorare optional,eventsshould be a list ofevent.calendar_dataproperty, if you did
not provide this, events are taken fromcalobjectstart_from-> (datetime) starting calendar dateview-> (String)  (default value “month”) type of the calendar view (month,basicWeek,basicDay,agendaWeek,agendaDay,custom_days)all_day_slot-> (Bool) (default value: False) Event slot are displayed for all day or for the real time slotslot_minutes-> (Int or String) (default value: ‘00:15:00’ or 15) Minutes slot duration, if is integer slot_minutes < 60first_hour-> (Int or String) (default value: ‘08:00:00’ or 8) First hour displayedtime_format-> (String) (default value: “HH:mm”), the display format for timecolumn_format-> (String) (default value: “D/M”), the display format for column datefirst_day-> (Int) (default value: 0), the fist day of weekday_to_show-> (Int) (default value: 8), day to show in view custom daysslot_label_interval-> (String) (default value: ‘01:00:00’), Interval of the slot labelUtilsinsidecalendarvents.lib.utilsyou can find a bunch of utils to view and manage events and calendar:create_calendar(name, events_type)- create a new calendar, events_type should be a stringget_calendar(calendar_id)- retrieve thecalendarfor the givencalendar_idcreate_event(cal, name, summary, datetime, location, linked_entity_type, linked_entity_id, end_time)- create a
newcalendar_eventget_event(event_id)- retrieve thecalendar_eventfor the givenevent_idget_calendar_events_from_datetime(calendar, start_time, active)retrieve all the activecalendar_eventfor
the given calendar starting from the givenstart_timeget_calendar_day_events(calendar, start_time, active)retrieve all the activecalendar_eventfor the given
calendar and the givenstart_timeget_calendar_events_in_range(calendar, start_time, end_time, active)- retrieve all the activecalendar_eventfor the given calendar and the given range of time (start_time-end_time)deactivate_event(event_id)- deactivate acalendar_event, by default standard get event utils retrieve only
active eventsactivate_event(event_id)- put thecalendar_eventin active state