[Cubicweb] cubicweb-calendarf

Nicolas Chauvat nicolas.chauvat at logilab.fr
Tue Sep 7 17:49:01 CEST 2010


On Tue, Sep 07, 2010 at 09:54:17AM -0500, Carlos Balderas wrote:
> Here is a calendar cube that uses fullcalendar jquery plugin (
> http://arshaw.com/fullcalendar/).
> http://hg.logilab.org/cubes/calendarf/

Great work!

> >>>>>>>>>>>>>
> One thing that would be nice is to turn calendarevent into an
> interface.
> Currently, the calendarevent-view has a
>  __select__ = isinstance('CalendarEvent')
> but it would be better to have a
>  __select__ = adaptable('ICalendarEvent')
> then implement adapters for existing entities to be displayed in the
> fullcalendar.
> <<<<<<<<<<<<<<<<<<<<<<

Let me try to get you jumpstarted.

Some pointers:



>From what I read in calendarf/views.py, you need to get from the
entity to be displayed the following attributes:

    title, startdate and enddate, allday (boolean), 

According to the schema.py, CalendarEvents also have attributes that
are not used by the logic of the cube at this point:

    description, location, repeat, privacy

This means that you could try to reuse ICalendarable that defines
methods start and stop.

In calendarf/views.py, change CalendarEventJsonView:

   __select__ = adaptable('ICalendarEvent')

and in call():

   for entity in self.cw_rset.entities():
       event = entity.cw_adapt_to('ICalendarable')
       title = entity.dc_title()
       startdate = event.start
       enddate = event.stop
       allday = event.start.day != event.stop.day # for example

       # rest more or less the same

And Shazam! the fullcalendar works for every app where entities are
adapted to ICalendarable, which means most apps we have :)

Thanks again for contributing to the death of our old-and-ugly calendars.

Nicolas Chauvat

logilab.fr - services en informatique scientifique et gestion de connaissances  

More information about the Cubicweb mailing list