web/views/calendar.py
author Stephanie Marcu <stephanie.marcu@logilab.fr>
Thu, 09 Dec 2010 15:27:01 +0100
changeset 6736 36ed2bf7ad3d
parent 5895 6a3f776292a5
child 6882 b5e34836f84e
permissions -rw-r--r--
[#615712] replace calendar views with views using fullcalendar jquery plugin (remove old_calendar)
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
5421
8167de96c523 proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4582
diff changeset
     1
# copyright 2003-2010 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
8167de96c523 proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4582
diff changeset
     2
# contact http://www.logilab.fr/ -- mailto:contact@logilab.fr
8167de96c523 proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4582
diff changeset
     3
#
8167de96c523 proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4582
diff changeset
     4
# This file is part of CubicWeb.
8167de96c523 proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4582
diff changeset
     5
#
8167de96c523 proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4582
diff changeset
     6
# CubicWeb is free software: you can redistribute it and/or modify it under the
8167de96c523 proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4582
diff changeset
     7
# terms of the GNU Lesser General Public License as published by the Free
8167de96c523 proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4582
diff changeset
     8
# Software Foundation, either version 2.1 of the License, or (at your option)
8167de96c523 proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4582
diff changeset
     9
# any later version.
8167de96c523 proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4582
diff changeset
    10
#
5424
8ecbcbff9777 replace logilab-common by CubicWeb in disclaimer
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5421
diff changeset
    11
# CubicWeb is distributed in the hope that it will be useful, but WITHOUT
5421
8167de96c523 proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4582
diff changeset
    12
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
8167de96c523 proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4582
diff changeset
    13
# FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
8167de96c523 proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4582
diff changeset
    14
# details.
8167de96c523 proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4582
diff changeset
    15
#
8167de96c523 proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4582
diff changeset
    16
# You should have received a copy of the GNU Lesser General Public License along
8167de96c523 proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4582
diff changeset
    17
# with CubicWeb.  If not, see <http://www.gnu.org/licenses/>.
5556
9ab2b4c74baf [entity] introduce a new 'adapters' registry
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5424
diff changeset
    18
"""html calendar views"""
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    19
1881
75540944ae18 fix dc_description format arg
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 1802
diff changeset
    20
__docformat__ = "restructuredtext en"
75540944ae18 fix dc_description format arg
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 1802
diff changeset
    21
_ = unicode
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    22
6736
36ed2bf7ad3d [#615712] replace calendar views with views using fullcalendar jquery plugin (remove old_calendar)
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 5895
diff changeset
    23
import copy
36ed2bf7ad3d [#615712] replace calendar views with views using fullcalendar jquery plugin (remove old_calendar)
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 5895
diff changeset
    24
from datetime import timedelta
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    25
2312
af4d8f75c5db use xml_escape
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 1977
diff changeset
    26
from logilab.mtconverter import xml_escape
6736
36ed2bf7ad3d [#615712] replace calendar views with views using fullcalendar jquery plugin (remove old_calendar)
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 5895
diff changeset
    27
from logilab.common.date import todatetime
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    28
6736
36ed2bf7ad3d [#615712] replace calendar views with views using fullcalendar jquery plugin (remove old_calendar)
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 5895
diff changeset
    29
from cubicweb.utils import json_dumps
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    30
from cubicweb.interfaces import ICalendarable
5556
9ab2b4c74baf [entity] introduce a new 'adapters' registry
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5424
diff changeset
    31
from cubicweb.selectors import implements, adaptable
9ab2b4c74baf [entity] introduce a new 'adapters' registry
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5424
diff changeset
    32
from cubicweb.view import EntityView, EntityAdapter, implements_adapter_compat
9ab2b4c74baf [entity] introduce a new 'adapters' registry
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5424
diff changeset
    33
6736
36ed2bf7ad3d [#615712] replace calendar views with views using fullcalendar jquery plugin (remove old_calendar)
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 5895
diff changeset
    34
# useful constants & functions ################################################
36ed2bf7ad3d [#615712] replace calendar views with views using fullcalendar jquery plugin (remove old_calendar)
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 5895
diff changeset
    35
36ed2bf7ad3d [#615712] replace calendar views with views using fullcalendar jquery plugin (remove old_calendar)
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 5895
diff changeset
    36
ONEDAY = timedelta(1)
36ed2bf7ad3d [#615712] replace calendar views with views using fullcalendar jquery plugin (remove old_calendar)
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 5895
diff changeset
    37
36ed2bf7ad3d [#615712] replace calendar views with views using fullcalendar jquery plugin (remove old_calendar)
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 5895
diff changeset
    38
WEEKDAYS = (_("monday"), _("tuesday"), _("wednesday"), _("thursday"),
36ed2bf7ad3d [#615712] replace calendar views with views using fullcalendar jquery plugin (remove old_calendar)
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 5895
diff changeset
    39
            _("friday"), _("saturday"), _("sunday"))
36ed2bf7ad3d [#615712] replace calendar views with views using fullcalendar jquery plugin (remove old_calendar)
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 5895
diff changeset
    40
MONTHNAMES = ( _('january'), _('february'), _('march'), _('april'), _('may'),
36ed2bf7ad3d [#615712] replace calendar views with views using fullcalendar jquery plugin (remove old_calendar)
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 5895
diff changeset
    41
               _('june'), _('july'), _('august'), _('september'), _('october'),
36ed2bf7ad3d [#615712] replace calendar views with views using fullcalendar jquery plugin (remove old_calendar)
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 5895
diff changeset
    42
               _('november'), _('december')
36ed2bf7ad3d [#615712] replace calendar views with views using fullcalendar jquery plugin (remove old_calendar)
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 5895
diff changeset
    43
               )
36ed2bf7ad3d [#615712] replace calendar views with views using fullcalendar jquery plugin (remove old_calendar)
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 5895
diff changeset
    44
5556
9ab2b4c74baf [entity] introduce a new 'adapters' registry
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5424
diff changeset
    45
9ab2b4c74baf [entity] introduce a new 'adapters' registry
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5424
diff changeset
    46
class ICalendarableAdapter(EntityAdapter):
9ab2b4c74baf [entity] introduce a new 'adapters' registry
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5424
diff changeset
    47
    __regid__ = 'ICalendarable'
5895
6a3f776292a5 [selectors] avoid spurious warning when using implements by design
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5726
diff changeset
    48
    __select__ = implements(ICalendarable, warn=False) # XXX for bw compat, should be abstract
5556
9ab2b4c74baf [entity] introduce a new 'adapters' registry
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5424
diff changeset
    49
9ab2b4c74baf [entity] introduce a new 'adapters' registry
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5424
diff changeset
    50
    @property
9ab2b4c74baf [entity] introduce a new 'adapters' registry
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5424
diff changeset
    51
    @implements_adapter_compat('ICalendarable')
9ab2b4c74baf [entity] introduce a new 'adapters' registry
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5424
diff changeset
    52
    def start(self):
9ab2b4c74baf [entity] introduce a new 'adapters' registry
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5424
diff changeset
    53
        """return start date"""
9ab2b4c74baf [entity] introduce a new 'adapters' registry
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5424
diff changeset
    54
        raise NotImplementedError
9ab2b4c74baf [entity] introduce a new 'adapters' registry
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5424
diff changeset
    55
9ab2b4c74baf [entity] introduce a new 'adapters' registry
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5424
diff changeset
    56
    @property
9ab2b4c74baf [entity] introduce a new 'adapters' registry
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5424
diff changeset
    57
    @implements_adapter_compat('ICalendarable')
9ab2b4c74baf [entity] introduce a new 'adapters' registry
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5424
diff changeset
    58
    def stop(self):
6736
36ed2bf7ad3d [#615712] replace calendar views with views using fullcalendar jquery plugin (remove old_calendar)
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 5895
diff changeset
    59
        """return stop date"""
5556
9ab2b4c74baf [entity] introduce a new 'adapters' registry
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5424
diff changeset
    60
        raise NotImplementedError
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    61
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    62
1025
aebf37f460c1 some datetime fixes
sylvain.thenault@logilab.fr
parents: 1016
diff changeset
    63
# Calendar views ##############################################################
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    64
1644
45bec81a9e1c makes vobject optional
sylvain.thenault@logilab.fr
parents: 1635
diff changeset
    65
try:
45bec81a9e1c makes vobject optional
sylvain.thenault@logilab.fr
parents: 1635
diff changeset
    66
    from vobject import iCalendar
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    67
1644
45bec81a9e1c makes vobject optional
sylvain.thenault@logilab.fr
parents: 1635
diff changeset
    68
    class iCalView(EntityView):
45bec81a9e1c makes vobject optional
sylvain.thenault@logilab.fr
parents: 1635
diff changeset
    69
        """A calendar view that generates a iCalendar file (RFC 2445)
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    70
1644
45bec81a9e1c makes vobject optional
sylvain.thenault@logilab.fr
parents: 1635
diff changeset
    71
        Does apply to ICalendarable compatible entities
45bec81a9e1c makes vobject optional
sylvain.thenault@logilab.fr
parents: 1635
diff changeset
    72
        """
5556
9ab2b4c74baf [entity] introduce a new 'adapters' registry
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5424
diff changeset
    73
        __select__ = adaptable('ICalendarable')
4244
2c3de1953d00 rename need_navigation into paginable
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4212
diff changeset
    74
        paginable = False
1644
45bec81a9e1c makes vobject optional
sylvain.thenault@logilab.fr
parents: 1635
diff changeset
    75
        content_type = 'text/calendar'
45bec81a9e1c makes vobject optional
sylvain.thenault@logilab.fr
parents: 1635
diff changeset
    76
        title = _('iCalendar')
45bec81a9e1c makes vobject optional
sylvain.thenault@logilab.fr
parents: 1635
diff changeset
    77
        templatable = False
3377
dd9d292b6a6d use __regid__ instead of id on appobject classes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2996
diff changeset
    78
        __regid__ = 'ical'
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    79
1644
45bec81a9e1c makes vobject optional
sylvain.thenault@logilab.fr
parents: 1635
diff changeset
    80
        def call(self):
45bec81a9e1c makes vobject optional
sylvain.thenault@logilab.fr
parents: 1635
diff changeset
    81
            ical = iCalendar()
3451
6b46d73823f5 [api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 3377
diff changeset
    82
            for i in range(len(self.cw_rset.rows)):
3457
0924d0d08d60 [api] __regid__, cw_* and friends
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 3451
diff changeset
    83
                task = self.cw_rset.complete_entity(i, 0)
1644
45bec81a9e1c makes vobject optional
sylvain.thenault@logilab.fr
parents: 1635
diff changeset
    84
                event = ical.add('vevent')
45bec81a9e1c makes vobject optional
sylvain.thenault@logilab.fr
parents: 1635
diff changeset
    85
                event.add('summary').value = task.dc_title()
45bec81a9e1c makes vobject optional
sylvain.thenault@logilab.fr
parents: 1635
diff changeset
    86
                event.add('description').value = task.dc_description()
5556
9ab2b4c74baf [entity] introduce a new 'adapters' registry
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5424
diff changeset
    87
                icalendarable = task.cw_adapt_to('ICalendarable')
9ab2b4c74baf [entity] introduce a new 'adapters' registry
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5424
diff changeset
    88
                if icalendarable.start:
9ab2b4c74baf [entity] introduce a new 'adapters' registry
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5424
diff changeset
    89
                    event.add('dtstart').value = icalendarable.start
9ab2b4c74baf [entity] introduce a new 'adapters' registry
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5424
diff changeset
    90
                if icalendarable.stop:
9ab2b4c74baf [entity] introduce a new 'adapters' registry
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5424
diff changeset
    91
                    event.add('dtend').value = icalendarable.stop
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    92
1644
45bec81a9e1c makes vobject optional
sylvain.thenault@logilab.fr
parents: 1635
diff changeset
    93
            buff = ical.serialize()
45bec81a9e1c makes vobject optional
sylvain.thenault@logilab.fr
parents: 1635
diff changeset
    94
            if not isinstance(buff, unicode):
3451
6b46d73823f5 [api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 3377
diff changeset
    95
                buff = unicode(buff, self._cw.encoding)
1644
45bec81a9e1c makes vobject optional
sylvain.thenault@logilab.fr
parents: 1635
diff changeset
    96
            self.w(buff)
45bec81a9e1c makes vobject optional
sylvain.thenault@logilab.fr
parents: 1635
diff changeset
    97
45bec81a9e1c makes vobject optional
sylvain.thenault@logilab.fr
parents: 1635
diff changeset
    98
except ImportError:
45bec81a9e1c makes vobject optional
sylvain.thenault@logilab.fr
parents: 1635
diff changeset
    99
    pass
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   100
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   101
class hCalView(EntityView):
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   102
    """A calendar view that generates a hCalendar file
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   103
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   104
    Does apply to ICalendarable compatible entities
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   105
    """
3377
dd9d292b6a6d use __regid__ instead of id on appobject classes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2996
diff changeset
   106
    __regid__ = 'hcal'
5556
9ab2b4c74baf [entity] introduce a new 'adapters' registry
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5424
diff changeset
   107
    __select__ = adaptable('ICalendarable')
4244
2c3de1953d00 rename need_navigation into paginable
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4212
diff changeset
   108
    paginable = False
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   109
    title = _('hCalendar')
524
eee3983e29e9 hcal is a microformat and can be inserted in html
sylvain.thenault@logilab.fr
parents: 431
diff changeset
   110
    #templatable = False
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   111
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   112
    def call(self):
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   113
        self.w(u'<div class="hcalendar">')
3451
6b46d73823f5 [api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 3377
diff changeset
   114
        for i in range(len(self.cw_rset.rows)):
3457
0924d0d08d60 [api] __regid__, cw_* and friends
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 3451
diff changeset
   115
            task = self.cw_rset.complete_entity(i, 0)
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   116
            self.w(u'<div class="vevent">')
2312
af4d8f75c5db use xml_escape
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 1977
diff changeset
   117
            self.w(u'<h3 class="summary">%s</h3>' % xml_escape(task.dc_title()))
1881
75540944ae18 fix dc_description format arg
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 1802
diff changeset
   118
            self.w(u'<div class="description">%s</div>'
75540944ae18 fix dc_description format arg
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 1802
diff changeset
   119
                   % task.dc_description(format='text/html'))
5556
9ab2b4c74baf [entity] introduce a new 'adapters' registry
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5424
diff changeset
   120
            icalendarable = task.cw_adapt_to('ICalendarable')
9ab2b4c74baf [entity] introduce a new 'adapters' registry
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5424
diff changeset
   121
            if icalendarable.start:
9ab2b4c74baf [entity] introduce a new 'adapters' registry
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5424
diff changeset
   122
                self.w(u'<abbr class="dtstart" title="%s">%s</abbr>'
9ab2b4c74baf [entity] introduce a new 'adapters' registry
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5424
diff changeset
   123
                       % (icalendarable.start.isoformat(),
9ab2b4c74baf [entity] introduce a new 'adapters' registry
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5424
diff changeset
   124
                          self._cw.format_date(icalendarable.start)))
9ab2b4c74baf [entity] introduce a new 'adapters' registry
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5424
diff changeset
   125
            if icalendarable.stop:
9ab2b4c74baf [entity] introduce a new 'adapters' registry
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5424
diff changeset
   126
                self.w(u'<abbr class="dtstop" title="%s">%s</abbr>'
9ab2b4c74baf [entity] introduce a new 'adapters' registry
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5424
diff changeset
   127
                       % (icalendarable.stop.isoformat(),
9ab2b4c74baf [entity] introduce a new 'adapters' registry
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5424
diff changeset
   128
                          self._cw.format_date(icalendarable.stop)))
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   129
            self.w(u'</div>')
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   130
        self.w(u'</div>')
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   131
1025
aebf37f460c1 some datetime fixes
sylvain.thenault@logilab.fr
parents: 1016
diff changeset
   132
aebf37f460c1 some datetime fixes
sylvain.thenault@logilab.fr
parents: 1016
diff changeset
   133
class CalendarItemView(EntityView):
3377
dd9d292b6a6d use __regid__ instead of id on appobject classes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2996
diff changeset
   134
    __regid__ = 'calendaritem'
1025
aebf37f460c1 some datetime fixes
sylvain.thenault@logilab.fr
parents: 1016
diff changeset
   135
aebf37f460c1 some datetime fixes
sylvain.thenault@logilab.fr
parents: 1016
diff changeset
   136
    def cell_call(self, row, col, dates=False):
3457
0924d0d08d60 [api] __regid__, cw_* and friends
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 3451
diff changeset
   137
        task = self.cw_rset.complete_entity(row, 0)
1025
aebf37f460c1 some datetime fixes
sylvain.thenault@logilab.fr
parents: 1016
diff changeset
   138
        task.view('oneline', w=self.w)
aebf37f460c1 some datetime fixes
sylvain.thenault@logilab.fr
parents: 1016
diff changeset
   139
        if dates:
5556
9ab2b4c74baf [entity] introduce a new 'adapters' registry
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5424
diff changeset
   140
            icalendarable = task.cw_adapt_to('ICalendarable')
9ab2b4c74baf [entity] introduce a new 'adapters' registry
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5424
diff changeset
   141
            if icalendarable.start and icalendarable.stop:
9ab2b4c74baf [entity] introduce a new 'adapters' registry
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5424
diff changeset
   142
                self.w('<br/> %s' % self._cw._('from %(date)s')
9ab2b4c74baf [entity] introduce a new 'adapters' registry
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5424
diff changeset
   143
                       % {'date': self._cw.format_date(icalendarable.start)})
9ab2b4c74baf [entity] introduce a new 'adapters' registry
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5424
diff changeset
   144
                self.w('<br/> %s' % self._cw._('to %(date)s')
9ab2b4c74baf [entity] introduce a new 'adapters' registry
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5424
diff changeset
   145
                       % {'date': self._cw.format_date(icalendarable.stop)})
9ab2b4c74baf [entity] introduce a new 'adapters' registry
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5424
diff changeset
   146
            else:
9ab2b4c74baf [entity] introduce a new 'adapters' registry
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5424
diff changeset
   147
                self.w('<br/>%s'%self._cw.format_date(icalendarable.start
9ab2b4c74baf [entity] introduce a new 'adapters' registry
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5424
diff changeset
   148
                                                      or icalendarable.stop))
1604
fd943737d630 delete-trailing-whitespaces
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   149
fd943737d630 delete-trailing-whitespaces
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   150
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   151
class _TaskEntry(object):
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   152
    def __init__(self, task, color, index=0):
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   153
        self.task = task
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   154
        self.color = color
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   155
        self.index = index
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   156
        self.length = 1
5556
9ab2b4c74baf [entity] introduce a new 'adapters' registry
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5424
diff changeset
   157
        icalendarable = task.cw_adapt_to('ICalendarable')
9ab2b4c74baf [entity] introduce a new 'adapters' registry
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5424
diff changeset
   158
        self.start = icalendarable.start
9ab2b4c74baf [entity] introduce a new 'adapters' registry
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5424
diff changeset
   159
        self.stop = icalendarable.stop
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   160
1025
aebf37f460c1 some datetime fixes
sylvain.thenault@logilab.fr
parents: 1016
diff changeset
   161
    def in_working_hours(self):
aebf37f460c1 some datetime fixes
sylvain.thenault@logilab.fr
parents: 1016
diff changeset
   162
        """predicate returning True is the task is in working hours"""
5556
9ab2b4c74baf [entity] introduce a new 'adapters' registry
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5424
diff changeset
   163
        if todatetime(self.start).hour > 7 and todatetime(self.stop).hour < 20:
1025
aebf37f460c1 some datetime fixes
sylvain.thenault@logilab.fr
parents: 1016
diff changeset
   164
            return True
aebf37f460c1 some datetime fixes
sylvain.thenault@logilab.fr
parents: 1016
diff changeset
   165
        return False
1604
fd943737d630 delete-trailing-whitespaces
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   166
1025
aebf37f460c1 some datetime fixes
sylvain.thenault@logilab.fr
parents: 1016
diff changeset
   167
    def is_one_day_task(self):
5556
9ab2b4c74baf [entity] introduce a new 'adapters' registry
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5424
diff changeset
   168
        return self.start and self.stop and self.start.isocalendar() == self.stop.isocalendar()
1604
fd943737d630 delete-trailing-whitespaces
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   169
fd943737d630 delete-trailing-whitespaces
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   170
6736
36ed2bf7ad3d [#615712] replace calendar views with views using fullcalendar jquery plugin (remove old_calendar)
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 5895
diff changeset
   171
class CalendarView(EntityView):
36ed2bf7ad3d [#615712] replace calendar views with views using fullcalendar jquery plugin (remove old_calendar)
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 5895
diff changeset
   172
    __regid__ = 'calendar'
5556
9ab2b4c74baf [entity] introduce a new 'adapters' registry
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5424
diff changeset
   173
    __select__ = adaptable('ICalendarable')
9ab2b4c74baf [entity] introduce a new 'adapters' registry
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5424
diff changeset
   174
4244
2c3de1953d00 rename need_navigation into paginable
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4212
diff changeset
   175
    paginable = False
6736
36ed2bf7ad3d [#615712] replace calendar views with views using fullcalendar jquery plugin (remove old_calendar)
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 5895
diff changeset
   176
    title = _('calendar')
36ed2bf7ad3d [#615712] replace calendar views with views using fullcalendar jquery plugin (remove old_calendar)
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 5895
diff changeset
   177
36ed2bf7ad3d [#615712] replace calendar views with views using fullcalendar jquery plugin (remove old_calendar)
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 5895
diff changeset
   178
    fullcalendar_options = {
36ed2bf7ad3d [#615712] replace calendar views with views using fullcalendar jquery plugin (remove old_calendar)
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 5895
diff changeset
   179
        'firstDay': 1,
36ed2bf7ad3d [#615712] replace calendar views with views using fullcalendar jquery plugin (remove old_calendar)
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 5895
diff changeset
   180
        'header': {'left': 'prev,next today',
36ed2bf7ad3d [#615712] replace calendar views with views using fullcalendar jquery plugin (remove old_calendar)
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 5895
diff changeset
   181
                   'center': 'title',
36ed2bf7ad3d [#615712] replace calendar views with views using fullcalendar jquery plugin (remove old_calendar)
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 5895
diff changeset
   182
                   'right': 'month,agendaWeek,agendaDay',
36ed2bf7ad3d [#615712] replace calendar views with views using fullcalendar jquery plugin (remove old_calendar)
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 5895
diff changeset
   183
                   },
36ed2bf7ad3d [#615712] replace calendar views with views using fullcalendar jquery plugin (remove old_calendar)
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 5895
diff changeset
   184
        'editable': True,
36ed2bf7ad3d [#615712] replace calendar views with views using fullcalendar jquery plugin (remove old_calendar)
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 5895
diff changeset
   185
        'defaultView': 'month',
36ed2bf7ad3d [#615712] replace calendar views with views using fullcalendar jquery plugin (remove old_calendar)
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 5895
diff changeset
   186
        'timeFormat': {'month': '',
36ed2bf7ad3d [#615712] replace calendar views with views using fullcalendar jquery plugin (remove old_calendar)
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 5895
diff changeset
   187
                       '': 'H:mm'},
36ed2bf7ad3d [#615712] replace calendar views with views using fullcalendar jquery plugin (remove old_calendar)
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 5895
diff changeset
   188
        'firstHour': 8,
36ed2bf7ad3d [#615712] replace calendar views with views using fullcalendar jquery plugin (remove old_calendar)
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 5895
diff changeset
   189
        'axisFormat': 'H:mm',
36ed2bf7ad3d [#615712] replace calendar views with views using fullcalendar jquery plugin (remove old_calendar)
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 5895
diff changeset
   190
        'columnFormat': {'month': 'dddd',
36ed2bf7ad3d [#615712] replace calendar views with views using fullcalendar jquery plugin (remove old_calendar)
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 5895
diff changeset
   191
                         'agendaWeek': 'dddd yyyy/M/dd',
36ed2bf7ad3d [#615712] replace calendar views with views using fullcalendar jquery plugin (remove old_calendar)
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 5895
diff changeset
   192
                         'agendaDay': 'dddd yyyy/M/dd'}
36ed2bf7ad3d [#615712] replace calendar views with views using fullcalendar jquery plugin (remove old_calendar)
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 5895
diff changeset
   193
        }
36ed2bf7ad3d [#615712] replace calendar views with views using fullcalendar jquery plugin (remove old_calendar)
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 5895
diff changeset
   194
1604
fd943737d630 delete-trailing-whitespaces
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   195
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   196
    def call(self):
6736
36ed2bf7ad3d [#615712] replace calendar views with views using fullcalendar jquery plugin (remove old_calendar)
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 5895
diff changeset
   197
        self._cw.demote_to_html()
36ed2bf7ad3d [#615712] replace calendar views with views using fullcalendar jquery plugin (remove old_calendar)
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 5895
diff changeset
   198
        self._cw.add_css(('fullcalendar.css', 'cubicweb.calendar.css'))
36ed2bf7ad3d [#615712] replace calendar views with views using fullcalendar jquery plugin (remove old_calendar)
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 5895
diff changeset
   199
        self._cw.add_js(('jquery.ui.js', 'fullcalendar.min.js', 'jquery.qtip.min.js'))
36ed2bf7ad3d [#615712] replace calendar views with views using fullcalendar jquery plugin (remove old_calendar)
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 5895
diff changeset
   200
        self.add_onload()
36ed2bf7ad3d [#615712] replace calendar views with views using fullcalendar jquery plugin (remove old_calendar)
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 5895
diff changeset
   201
        # write calendar div to load jquery fullcalendar object
36ed2bf7ad3d [#615712] replace calendar views with views using fullcalendar jquery plugin (remove old_calendar)
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 5895
diff changeset
   202
        self.w(u'<div id="calendar"></div>')
1604
fd943737d630 delete-trailing-whitespaces
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   203
fd943737d630 delete-trailing-whitespaces
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   204
6736
36ed2bf7ad3d [#615712] replace calendar views with views using fullcalendar jquery plugin (remove old_calendar)
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 5895
diff changeset
   205
    def add_onload(self):
36ed2bf7ad3d [#615712] replace calendar views with views using fullcalendar jquery plugin (remove old_calendar)
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 5895
diff changeset
   206
        fullcalendar_options = self.fullcalendar_options.copy()
36ed2bf7ad3d [#615712] replace calendar views with views using fullcalendar jquery plugin (remove old_calendar)
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 5895
diff changeset
   207
        fullcalendar_options['events'] = self.get_events()
36ed2bf7ad3d [#615712] replace calendar views with views using fullcalendar jquery plugin (remove old_calendar)
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 5895
diff changeset
   208
        fullcalendar_options['buttonText'] = {'today': self._cw._('today'),
36ed2bf7ad3d [#615712] replace calendar views with views using fullcalendar jquery plugin (remove old_calendar)
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 5895
diff changeset
   209
                                              'month': self._cw._('month'),
36ed2bf7ad3d [#615712] replace calendar views with views using fullcalendar jquery plugin (remove old_calendar)
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 5895
diff changeset
   210
                                              'week': self._cw._('week'),
36ed2bf7ad3d [#615712] replace calendar views with views using fullcalendar jquery plugin (remove old_calendar)
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 5895
diff changeset
   211
                                              'day': self._cw._('day')}
36ed2bf7ad3d [#615712] replace calendar views with views using fullcalendar jquery plugin (remove old_calendar)
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 5895
diff changeset
   212
        # js callback to add a tooltip and to put html in event's title
36ed2bf7ad3d [#615712] replace calendar views with views using fullcalendar jquery plugin (remove old_calendar)
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 5895
diff changeset
   213
        js = """
36ed2bf7ad3d [#615712] replace calendar views with views using fullcalendar jquery plugin (remove old_calendar)
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 5895
diff changeset
   214
        var options = %s;
36ed2bf7ad3d [#615712] replace calendar views with views using fullcalendar jquery plugin (remove old_calendar)
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 5895
diff changeset
   215
        options.eventRender = function(event, $element) {
36ed2bf7ad3d [#615712] replace calendar views with views using fullcalendar jquery plugin (remove old_calendar)
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 5895
diff changeset
   216
          // add a tooltip for each event
36ed2bf7ad3d [#615712] replace calendar views with views using fullcalendar jquery plugin (remove old_calendar)
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 5895
diff changeset
   217
          var div = '<div class="tooltip">'+ event.description+ '</div>';
36ed2bf7ad3d [#615712] replace calendar views with views using fullcalendar jquery plugin (remove old_calendar)
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 5895
diff changeset
   218
          $element.append(div);
36ed2bf7ad3d [#615712] replace calendar views with views using fullcalendar jquery plugin (remove old_calendar)
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 5895
diff changeset
   219
          // allow to have html tags in event's title
36ed2bf7ad3d [#615712] replace calendar views with views using fullcalendar jquery plugin (remove old_calendar)
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 5895
diff changeset
   220
          $element.find('span.fc-event-title').html($element.find('span.fc-event-title').text());
36ed2bf7ad3d [#615712] replace calendar views with views using fullcalendar jquery plugin (remove old_calendar)
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 5895
diff changeset
   221
        };
36ed2bf7ad3d [#615712] replace calendar views with views using fullcalendar jquery plugin (remove old_calendar)
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 5895
diff changeset
   222
        $("#calendar").fullCalendar(options);
36ed2bf7ad3d [#615712] replace calendar views with views using fullcalendar jquery plugin (remove old_calendar)
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 5895
diff changeset
   223
        """ #"
36ed2bf7ad3d [#615712] replace calendar views with views using fullcalendar jquery plugin (remove old_calendar)
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 5895
diff changeset
   224
        self._cw.add_onload(js % json_dumps(fullcalendar_options))
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   225
1604
fd943737d630 delete-trailing-whitespaces
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   226
6736
36ed2bf7ad3d [#615712] replace calendar views with views using fullcalendar jquery plugin (remove old_calendar)
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 5895
diff changeset
   227
    def get_events(self):
36ed2bf7ad3d [#615712] replace calendar views with views using fullcalendar jquery plugin (remove old_calendar)
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 5895
diff changeset
   228
        events = []
36ed2bf7ad3d [#615712] replace calendar views with views using fullcalendar jquery plugin (remove old_calendar)
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 5895
diff changeset
   229
        for entity in self.cw_rset.entities():
36ed2bf7ad3d [#615712] replace calendar views with views using fullcalendar jquery plugin (remove old_calendar)
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 5895
diff changeset
   230
            icalendarable = entity.cw_adapt_to('ICalendarable')
36ed2bf7ad3d [#615712] replace calendar views with views using fullcalendar jquery plugin (remove old_calendar)
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 5895
diff changeset
   231
            event = {'eid': entity.eid,
36ed2bf7ad3d [#615712] replace calendar views with views using fullcalendar jquery plugin (remove old_calendar)
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 5895
diff changeset
   232
                     'title': entity.view('calendaritem'),
36ed2bf7ad3d [#615712] replace calendar views with views using fullcalendar jquery plugin (remove old_calendar)
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 5895
diff changeset
   233
                     'url': xml_escape(entity.absolute_url()),
36ed2bf7ad3d [#615712] replace calendar views with views using fullcalendar jquery plugin (remove old_calendar)
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 5895
diff changeset
   234
                     'className': 'calevent',
36ed2bf7ad3d [#615712] replace calendar views with views using fullcalendar jquery plugin (remove old_calendar)
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 5895
diff changeset
   235
                     'description': entity.view('tooltip'),
36ed2bf7ad3d [#615712] replace calendar views with views using fullcalendar jquery plugin (remove old_calendar)
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 5895
diff changeset
   236
                     }
36ed2bf7ad3d [#615712] replace calendar views with views using fullcalendar jquery plugin (remove old_calendar)
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 5895
diff changeset
   237
            start_date = icalendarable.start
36ed2bf7ad3d [#615712] replace calendar views with views using fullcalendar jquery plugin (remove old_calendar)
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 5895
diff changeset
   238
            if not start_date:
36ed2bf7ad3d [#615712] replace calendar views with views using fullcalendar jquery plugin (remove old_calendar)
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 5895
diff changeset
   239
                start_date = icalendarable.stop
36ed2bf7ad3d [#615712] replace calendar views with views using fullcalendar jquery plugin (remove old_calendar)
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 5895
diff changeset
   240
            event['start'] = start_date.strftime('%Y-%m-%dT%H:%M')
36ed2bf7ad3d [#615712] replace calendar views with views using fullcalendar jquery plugin (remove old_calendar)
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 5895
diff changeset
   241
            event['allDay'] = True
36ed2bf7ad3d [#615712] replace calendar views with views using fullcalendar jquery plugin (remove old_calendar)
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 5895
diff changeset
   242
            if icalendarable.stop:
36ed2bf7ad3d [#615712] replace calendar views with views using fullcalendar jquery plugin (remove old_calendar)
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 5895
diff changeset
   243
                event['end'] = icalendarable.stop.strftime('%Y-%m-%dT%H:%M')
36ed2bf7ad3d [#615712] replace calendar views with views using fullcalendar jquery plugin (remove old_calendar)
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 5895
diff changeset
   244
                event['allDay'] = False
36ed2bf7ad3d [#615712] replace calendar views with views using fullcalendar jquery plugin (remove old_calendar)
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 5895
diff changeset
   245
            events.append(event)
36ed2bf7ad3d [#615712] replace calendar views with views using fullcalendar jquery plugin (remove old_calendar)
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 5895
diff changeset
   246
        return events
36ed2bf7ad3d [#615712] replace calendar views with views using fullcalendar jquery plugin (remove old_calendar)
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 5895
diff changeset
   247
36ed2bf7ad3d [#615712] replace calendar views with views using fullcalendar jquery plugin (remove old_calendar)
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 5895
diff changeset
   248
class OneMonthCal(CalendarView):
36ed2bf7ad3d [#615712] replace calendar views with views using fullcalendar jquery plugin (remove old_calendar)
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 5895
diff changeset
   249
    __regid__ = 'onemonthcal'
36ed2bf7ad3d [#615712] replace calendar views with views using fullcalendar jquery plugin (remove old_calendar)
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 5895
diff changeset
   250
36ed2bf7ad3d [#615712] replace calendar views with views using fullcalendar jquery plugin (remove old_calendar)
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 5895
diff changeset
   251
    title = _('one month')
36ed2bf7ad3d [#615712] replace calendar views with views using fullcalendar jquery plugin (remove old_calendar)
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 5895
diff changeset
   252
36ed2bf7ad3d [#615712] replace calendar views with views using fullcalendar jquery plugin (remove old_calendar)
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 5895
diff changeset
   253
class OneWeekCal(CalendarView):
36ed2bf7ad3d [#615712] replace calendar views with views using fullcalendar jquery plugin (remove old_calendar)
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 5895
diff changeset
   254
    __regid__ = 'oneweekcal'
36ed2bf7ad3d [#615712] replace calendar views with views using fullcalendar jquery plugin (remove old_calendar)
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 5895
diff changeset
   255
36ed2bf7ad3d [#615712] replace calendar views with views using fullcalendar jquery plugin (remove old_calendar)
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 5895
diff changeset
   256
    title = _('one week')
36ed2bf7ad3d [#615712] replace calendar views with views using fullcalendar jquery plugin (remove old_calendar)
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 5895
diff changeset
   257
    fullcalendar_options = CalendarView.fullcalendar_options.copy()
36ed2bf7ad3d [#615712] replace calendar views with views using fullcalendar jquery plugin (remove old_calendar)
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 5895
diff changeset
   258
    fullcalendar_options['defaultView'] = 'agendaWeek'