Ejemplo n.º 1
0
class EventSchema(DocumentSchema):
    start = colander.SchemaNode(colander.DateTime(default_tzinfo=None),
                                title=_(u"Start"))
    end = colander.SchemaNode(colander.DateTime(default_tzinfo=None),
                              title=_(u"End"),
                              missing=None)
    all_day = colander.SchemaNode(colander.Boolean(), title=_(u"All day"))
Ejemplo n.º 2
0
class CalendarSchema(ContentSchema):
    feeds = Feeds(
        missing=[],
        title=_(u"Calendar feeds"),
        description=_(u"Paste Google calendar XML feeds here"),
    )
    weekends = colander.SchemaNode(colander.Boolean(), title=_(u"Weekends"))
Ejemplo n.º 3
0
class EventSchema(DocumentSchema):
    """ Schema for events. """

    start = colander.SchemaNode(colander.DateTime(default_tzinfo=None),
                                title=_(u"Start"))
    end = colander.SchemaNode(colander.DateTime(default_tzinfo=None),
                              title=_(u"End"),
                              missing=None)
    all_day = colander.SchemaNode(colander.Boolean(), title=_(u"All day"))
    link_to_file = colander.SchemaNode(
        colander.Boolean(),
        title=_(u"Link to File"),
        description=_(u"When activated, the link in an associated calendar "
                      u"view points to the first contained file of the event "
                      u"(instead of to the calendar node)."))
Ejemplo n.º 4
0
class Event(Document):
    """ Events are documents with start and optional end datetime. """

    implements(IDefaultWorkflow)

    id = Column('id', Integer, ForeignKey('documents.id'), primary_key=True)
    start = Column('start', DateTime(), nullable=False)
    end = Column('end', DateTime())
    all_day = Column('all_day', Boolean())
    link_to_file = Column('link_to_file', Boolean())

    type_info = Document.type_info.copy(
        name=u'Event',
        title=_(u'Event'),
        add_view=u'add_event',
        addable_to=[u'Calendar'],
    )

    def __init__(self,
                 start=None,
                 end=None,
                 all_day=False,
                 link_to_file=False,
                 in_navigation=False,
                 **kwargs):

        super(Event, self).__init__(in_navigation=in_navigation, **kwargs)

        self.start = start
        self.end = end
        self.all_day = all_day
        self.link_to_file = link_to_file
Ejemplo n.º 5
0
class Feeds(colander.SequenceSchema):
    """ Schema for calendar feeds. """

    feed = colander.SchemaNode(
        colander.String(),
        title=_(u"Feed"),
        missing=None,
    )
Ejemplo n.º 6
0
class Calendar(Content):
    implements(IDefaultWorkflow)

    id = Column(Integer, ForeignKey('contents.id'), primary_key=True)
    feeds = Column(JsonType(), nullable=False)
    weekends = Column(Boolean())

    type_info = Content.type_info.copy(
        name=u'Calendar',
        title=_(u'Calendar'),
        add_view=u'add_calendar',
        addable_to=[u'Document'],
    )

    def __init__(self, feeds=(), weekends=True, **kwargs):
        super(Calendar, self).__init__(**kwargs)
        self.feeds = feeds
        self.weekends = weekends
Ejemplo n.º 7
0
class Event(Document):
    id = Column('id', Integer, ForeignKey('documents.id'), primary_key=True)
    start = Column('start', DateTime(), nullable=False)
    end = Column('end', DateTime())
    all_day = Column('all_day', Boolean())

    type_info = Content.type_info.copy(
        name=u'Event',
        title=_(u'Event'),
        add_view=u'add_event',
        addable_to=[u'Calendar'],
    )

    def __init__(self,
                 start=None,
                 end=None,
                 all_day=False,
                 in_navigation=False,
                 **kwargs):
        super(Event, self).__init__(in_navigation=in_navigation, **kwargs)
        self.start = start
        self.end = end
        self.all_day = all_day
Ejemplo n.º 8
0
class EventAddForm(AddFormView):
    """ Form to add a new event. """

    schema_factory = EventSchema
    add = Event
    item_type = _(u"Event")
Ejemplo n.º 9
0
class CalendarAddForm(AddFormView):
    """ Form to add a new calendar. """

    schema_factory = CalendarSchema
    add = Calendar
    item_type = _(u"Calendar")
Ejemplo n.º 10
0
class EventAddForm(AddFormView):
    schema_factory = EventSchema
    add = Event
    item_type = _(u"Event")
Ejemplo n.º 11
0
class CalendarAddForm(AddFormView):
    schema_factory = CalendarSchema
    add = Calendar
    item_type = _(u"Calendar")
Ejemplo n.º 12
0
class Feeds(colander.SequenceSchema):
    feed = colander.SchemaNode(
        colander.String(),
        title=_(u"Feed"),
        missing=None,
        )
Ejemplo n.º 13
0
class Event(Document):
    """ Events are documents with start and optional end datetime. """

    implements(IDefaultWorkflow)

    id = Column('id', Integer, ForeignKey('documents.id'), primary_key=True)
    start = Column('start', DateTime(), nullable=False)
    end = Column('end', DateTime())
    all_day = Column('all_day', Boolean())
    link_to_file = Column('link_to_file', Boolean())

    other_calendars = relationship(
        "Calendar",
        secondary=other_calendars_association_table,
    )

    type_info = Document.type_info.copy(
        name=u'Event',
        title=_(u'Event'),
        add_view=u'add_event',
        addable_to=[u'Calendar'],
    )

    def __init__(self,
                 start=None,
                 end=None,
                 all_day=False,
                 link_to_file=False,
                 other_calendar_list=None,
                 other_calendar_id_list=None,
                 in_navigation=False,
                 **kwargs):

        super(Event, self).__init__(in_navigation=in_navigation, **kwargs)

        self.start = start
        self.end = end
        self.all_day = all_day
        self.link_to_file = link_to_file

        self.other_calendars = Event._setup_other_calendars(
            other_calendar_list, other_calendar_id_list)

    @staticmethod
    def _setup_other_calendars(cal_list, cal_id_list):
        """
        Argument parsing method (convenience) for other_calendar_list

        Supplied with either a list of calendars or a list of calendar ids,
        this method ensures that a list of calendars is returned.

        If all arguments evaluate to False, an empty list is returned.

        :param list cal_list: list of calendars
        :param list calendar_id: list of calendar ids
        :returns: list of calendars
        """
        if cal_list:
            return cal_list

        if not cal_id_list:
            return []

        return [Calendar.query.get(calendar_id) for calendar_id in cal_id_list]