web/views/calendar.py
author Aurelien Campeas <aurelien.campeas@logilab.fr>
Fri, 26 Apr 2013 12:10:37 +0200
changeset 8941 7b26fe71404f
parent 8307 8be58694f416
child 9256 697a8181ba30
permissions -rw-r--r--
drop xhtml content-type support (closes #2065651) * HTMLStream does not care about xml any more * reqquest.demote_to_html and .xhtml_browser are deprecated * web config: drop force-html-content-type option * adjust tests
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
8941
7b26fe71404f drop xhtml content-type support (closes #2065651)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8307
diff changeset
     1
# copyright 2003-2013 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
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
     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
8153
e225e70239ed [views] calendar id in CalendarView must be unique (closes #2143864)
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 7183
diff changeset
    29
from cubicweb.utils import json_dumps, make_uid
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    30
from cubicweb.interfaces import ICalendarable
8190
2a3c1b787688 [vreg] move base registry implementation to logilab.common. Closes #1916014
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 8153
diff changeset
    31
from cubicweb.predicates import implements, adaptable
5556
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):
6864
ea95004494a2 [adapters] fix #1424467 caused by precedence of bw compat method while the adapter is concret for a given class
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5895
diff changeset
    47
    __needs_bw_compat__ = True
5556
9ab2b4c74baf [entity] introduce a new 'adapters' registry
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5424
diff changeset
    48
    __regid__ = 'ICalendarable'
5895
6a3f776292a5 [selectors] avoid spurious warning when using implements by design
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5726
diff changeset
    49
    __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
    50
9ab2b4c74baf [entity] introduce a new 'adapters' registry
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5424
diff changeset
    51
    @property
9ab2b4c74baf [entity] introduce a new 'adapters' registry
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5424
diff changeset
    52
    @implements_adapter_compat('ICalendarable')
9ab2b4c74baf [entity] introduce a new 'adapters' registry
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5424
diff changeset
    53
    def start(self):
9ab2b4c74baf [entity] introduce a new 'adapters' registry
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5424
diff changeset
    54
        """return start date"""
9ab2b4c74baf [entity] introduce a new 'adapters' registry
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5424
diff changeset
    55
        raise NotImplementedError
9ab2b4c74baf [entity] introduce a new 'adapters' registry
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5424
diff changeset
    56
9ab2b4c74baf [entity] introduce a new 'adapters' registry
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5424
diff changeset
    57
    @property
9ab2b4c74baf [entity] introduce a new 'adapters' registry
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5424
diff changeset
    58
    @implements_adapter_compat('ICalendarable')
9ab2b4c74baf [entity] introduce a new 'adapters' registry
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5424
diff changeset
    59
    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
    60
        """return stop date"""
5556
9ab2b4c74baf [entity] introduce a new 'adapters' registry
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5424
diff changeset
    61
        raise NotImplementedError
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    62
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    63
1025
aebf37f460c1 some datetime fixes
sylvain.thenault@logilab.fr
parents: 1016
diff changeset
    64
# Calendar views ##############################################################
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    65
1644
45bec81a9e1c makes vobject optional
sylvain.thenault@logilab.fr
parents: 1635
diff changeset
    66
try:
45bec81a9e1c makes vobject optional
sylvain.thenault@logilab.fr
parents: 1635
diff changeset
    67
    from vobject import iCalendar
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    68
1644
45bec81a9e1c makes vobject optional
sylvain.thenault@logilab.fr
parents: 1635
diff changeset
    69
    class iCalView(EntityView):
45bec81a9e1c makes vobject optional
sylvain.thenault@logilab.fr
parents: 1635
diff changeset
    70
        """A calendar view that generates a iCalendar file (RFC 2445)
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    71
1644
45bec81a9e1c makes vobject optional
sylvain.thenault@logilab.fr
parents: 1635
diff changeset
    72
        Does apply to ICalendarable compatible entities
45bec81a9e1c makes vobject optional
sylvain.thenault@logilab.fr
parents: 1635
diff changeset
    73
        """
5556
9ab2b4c74baf [entity] introduce a new 'adapters' registry
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5424
diff changeset
    74
        __select__ = adaptable('ICalendarable')
4244
2c3de1953d00 rename need_navigation into paginable
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4212
diff changeset
    75
        paginable = False
1644
45bec81a9e1c makes vobject optional
sylvain.thenault@logilab.fr
parents: 1635
diff changeset
    76
        content_type = 'text/calendar'
45bec81a9e1c makes vobject optional
sylvain.thenault@logilab.fr
parents: 1635
diff changeset
    77
        title = _('iCalendar')
45bec81a9e1c makes vobject optional
sylvain.thenault@logilab.fr
parents: 1635
diff changeset
    78
        templatable = False
3377
dd9d292b6a6d use __regid__ instead of id on appobject classes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2996
diff changeset
    79
        __regid__ = 'ical'
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    80
1644
45bec81a9e1c makes vobject optional
sylvain.thenault@logilab.fr
parents: 1635
diff changeset
    81
        def call(self):
45bec81a9e1c makes vobject optional
sylvain.thenault@logilab.fr
parents: 1635
diff changeset
    82
            ical = iCalendar()
3451
6b46d73823f5 [api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 3377
diff changeset
    83
            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
    84
                task = self.cw_rset.complete_entity(i, 0)
1644
45bec81a9e1c makes vobject optional
sylvain.thenault@logilab.fr
parents: 1635
diff changeset
    85
                event = ical.add('vevent')
45bec81a9e1c makes vobject optional
sylvain.thenault@logilab.fr
parents: 1635
diff changeset
    86
                event.add('summary').value = task.dc_title()
45bec81a9e1c makes vobject optional
sylvain.thenault@logilab.fr
parents: 1635
diff changeset
    87
                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
    88
                icalendarable = task.cw_adapt_to('ICalendarable')
9ab2b4c74baf [entity] introduce a new 'adapters' registry
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5424
diff changeset
    89
                if icalendarable.start:
9ab2b4c74baf [entity] introduce a new 'adapters' registry
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5424
diff changeset
    90
                    event.add('dtstart').value = icalendarable.start
9ab2b4c74baf [entity] introduce a new 'adapters' registry
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5424
diff changeset
    91
                if icalendarable.stop:
9ab2b4c74baf [entity] introduce a new 'adapters' registry
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5424
diff changeset
    92
                    event.add('dtend').value = icalendarable.stop
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    93
1644
45bec81a9e1c makes vobject optional
sylvain.thenault@logilab.fr
parents: 1635
diff changeset
    94
            buff = ical.serialize()
45bec81a9e1c makes vobject optional
sylvain.thenault@logilab.fr
parents: 1635
diff changeset
    95
            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
    96
                buff = unicode(buff, self._cw.encoding)
1644
45bec81a9e1c makes vobject optional
sylvain.thenault@logilab.fr
parents: 1635
diff changeset
    97
            self.w(buff)
45bec81a9e1c makes vobject optional
sylvain.thenault@logilab.fr
parents: 1635
diff changeset
    98
45bec81a9e1c makes vobject optional
sylvain.thenault@logilab.fr
parents: 1635
diff changeset
    99
except ImportError:
45bec81a9e1c makes vobject optional
sylvain.thenault@logilab.fr
parents: 1635
diff changeset
   100
    pass
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   101
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   102
class hCalView(EntityView):
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   103
    """A calendar view that generates a hCalendar file
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   104
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   105
    Does apply to ICalendarable compatible entities
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   106
    """
3377
dd9d292b6a6d use __regid__ instead of id on appobject classes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2996
diff changeset
   107
    __regid__ = 'hcal'
5556
9ab2b4c74baf [entity] introduce a new 'adapters' registry
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5424
diff changeset
   108
    __select__ = adaptable('ICalendarable')
4244
2c3de1953d00 rename need_navigation into paginable
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4212
diff changeset
   109
    paginable = False
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   110
    title = _('hCalendar')
524
eee3983e29e9 hcal is a microformat and can be inserted in html
sylvain.thenault@logilab.fr
parents: 431
diff changeset
   111
    #templatable = False
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   112
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   113
    def call(self):
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   114
        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
   115
        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
   116
            task = self.cw_rset.complete_entity(i, 0)
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   117
            self.w(u'<div class="vevent">')
2312
af4d8f75c5db use xml_escape
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 1977
diff changeset
   118
            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
   119
            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
   120
                   % 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
   121
            icalendarable = task.cw_adapt_to('ICalendarable')
9ab2b4c74baf [entity] introduce a new 'adapters' registry
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5424
diff changeset
   122
            if icalendarable.start:
9ab2b4c74baf [entity] introduce a new 'adapters' registry
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5424
diff changeset
   123
                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
   124
                       % (icalendarable.start.isoformat(),
9ab2b4c74baf [entity] introduce a new 'adapters' registry
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5424
diff changeset
   125
                          self._cw.format_date(icalendarable.start)))
9ab2b4c74baf [entity] introduce a new 'adapters' registry
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5424
diff changeset
   126
            if icalendarable.stop:
9ab2b4c74baf [entity] introduce a new 'adapters' registry
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5424
diff changeset
   127
                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
   128
                       % (icalendarable.stop.isoformat(),
9ab2b4c74baf [entity] introduce a new 'adapters' registry
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5424
diff changeset
   129
                          self._cw.format_date(icalendarable.stop)))
0
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
        self.w(u'</div>')
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   132
1025
aebf37f460c1 some datetime fixes
sylvain.thenault@logilab.fr
parents: 1016
diff changeset
   133
aebf37f460c1 some datetime fixes
sylvain.thenault@logilab.fr
parents: 1016
diff changeset
   134
class CalendarItemView(EntityView):
3377
dd9d292b6a6d use __regid__ instead of id on appobject classes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2996
diff changeset
   135
    __regid__ = 'calendaritem'
1025
aebf37f460c1 some datetime fixes
sylvain.thenault@logilab.fr
parents: 1016
diff changeset
   136
aebf37f460c1 some datetime fixes
sylvain.thenault@logilab.fr
parents: 1016
diff changeset
   137
    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
   138
        task = self.cw_rset.complete_entity(row, 0)
1025
aebf37f460c1 some datetime fixes
sylvain.thenault@logilab.fr
parents: 1016
diff changeset
   139
        task.view('oneline', w=self.w)
aebf37f460c1 some datetime fixes
sylvain.thenault@logilab.fr
parents: 1016
diff changeset
   140
        if dates:
5556
9ab2b4c74baf [entity] introduce a new 'adapters' registry
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5424
diff changeset
   141
            icalendarable = task.cw_adapt_to('ICalendarable')
9ab2b4c74baf [entity] introduce a new 'adapters' registry
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5424
diff changeset
   142
            if icalendarable.start and icalendarable.stop:
9ab2b4c74baf [entity] introduce a new 'adapters' registry
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5424
diff changeset
   143
                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
   144
                       % {'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
   145
                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
   146
                       % {'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
   147
            else:
9ab2b4c74baf [entity] introduce a new 'adapters' registry
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5424
diff changeset
   148
                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
   149
                                                      or icalendarable.stop))
1604
fd943737d630 delete-trailing-whitespaces
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   150
fd943737d630 delete-trailing-whitespaces
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   151
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   152
class _TaskEntry(object):
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   153
    def __init__(self, task, color, index=0):
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   154
        self.task = task
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   155
        self.color = color
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   156
        self.index = index
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   157
        self.length = 1
5556
9ab2b4c74baf [entity] introduce a new 'adapters' registry
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5424
diff changeset
   158
        icalendarable = task.cw_adapt_to('ICalendarable')
9ab2b4c74baf [entity] introduce a new 'adapters' registry
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5424
diff changeset
   159
        self.start = icalendarable.start
9ab2b4c74baf [entity] introduce a new 'adapters' registry
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5424
diff changeset
   160
        self.stop = icalendarable.stop
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   161
1025
aebf37f460c1 some datetime fixes
sylvain.thenault@logilab.fr
parents: 1016
diff changeset
   162
    def in_working_hours(self):
aebf37f460c1 some datetime fixes
sylvain.thenault@logilab.fr
parents: 1016
diff changeset
   163
        """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
   164
        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
   165
            return True
aebf37f460c1 some datetime fixes
sylvain.thenault@logilab.fr
parents: 1016
diff changeset
   166
        return False
1604
fd943737d630 delete-trailing-whitespaces
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   167
1025
aebf37f460c1 some datetime fixes
sylvain.thenault@logilab.fr
parents: 1016
diff changeset
   168
    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
   169
        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
   170
fd943737d630 delete-trailing-whitespaces
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   171
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
   172
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
   173
    __regid__ = 'calendar'
5556
9ab2b4c74baf [entity] introduce a new 'adapters' registry
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5424
diff changeset
   174
    __select__ = adaptable('ICalendarable')
9ab2b4c74baf [entity] introduce a new 'adapters' registry
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5424
diff changeset
   175
4244
2c3de1953d00 rename need_navigation into paginable
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4212
diff changeset
   176
    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
   177
    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
   178
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
    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
   180
        'firstDay': 1,
8287
2d660890d3e8 [js] translate calendar in french (closes #2167866)
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 8153
diff changeset
   181
        'firstHour': 8,
2d660890d3e8 [js] translate calendar in french (closes #2167866)
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 8153
diff changeset
   182
        'defaultView': 'month',
2d660890d3e8 [js] translate calendar in french (closes #2167866)
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 8153
diff changeset
   183
        'editable': True,
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
   184
        '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
   185
                   '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
   186
                   '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
   187
                   },
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
        }
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
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   190
    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
   191
        self._cw.add_css(('fullcalendar.css', 'cubicweb.calendar.css'))
8295
302dcb3c6858 [js] fix $.fullCalendar.regional call (closes #2232028)
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 8290
diff changeset
   192
        self._cw.add_js(('jquery.ui.js', 'fullcalendar.min.js', 'jquery.qtip.min.js', 'fullcalendar.locale.js'))
8153
e225e70239ed [views] calendar id in CalendarView must be unique (closes #2143864)
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 7183
diff changeset
   193
        self.calendar_id = 'cal' + make_uid('uid')
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
   194
        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
   195
        # write calendar div to load jquery fullcalendar object
8153
e225e70239ed [views] calendar id in CalendarView must be unique (closes #2143864)
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 7183
diff changeset
   196
        self.w(u'<div id="%s"></div>' % self.calendar_id)
1604
fd943737d630 delete-trailing-whitespaces
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   197
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
   198
    def add_onload(self):
8290
d07dadd8f664 fix events display in calendar (closes #2167866)
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 8287
diff changeset
   199
        fullcalendar_options = self.fullcalendar_options.copy()
d07dadd8f664 fix events display in calendar (closes #2167866)
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 8287
diff changeset
   200
        fullcalendar_options['events'] = self.get_events()
8287
2d660890d3e8 [js] translate calendar in french (closes #2167866)
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 8153
diff changeset
   201
        # i18n
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
   202
        # 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
   203
        js = """
8287
2d660890d3e8 [js] translate calendar in french (closes #2167866)
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 8153
diff changeset
   204
        var options = $.fullCalendar.regional('%s', %s);
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
        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
   206
          // 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
   207
          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
   208
          $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
   209
          // 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
   210
          $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
   211
        };
8153
e225e70239ed [views] calendar id in CalendarView must be unique (closes #2143864)
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 7183
diff changeset
   212
        $("#%s").fullCalendar(options);
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
   213
        """ #"
8290
d07dadd8f664 fix events display in calendar (closes #2167866)
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 8287
diff changeset
   214
        self._cw.add_onload(js % (self._cw.lang, json_dumps(fullcalendar_options), self.calendar_id))
1604
fd943737d630 delete-trailing-whitespaces
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   215
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
   216
    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
   217
        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
   218
        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
   219
            icalendarable = entity.cw_adapt_to('ICalendarable')
7183
5ea2bfd55399 [web] fix CalendarView : both icalendarable.start and icalendarable.stop dates can be None
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 6882
diff changeset
   220
            if not (icalendarable.start and icalendarable.stop):
5ea2bfd55399 [web] fix CalendarView : both icalendarable.start and icalendarable.stop dates can be None
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 6882
diff changeset
   221
                continue
5ea2bfd55399 [web] fix CalendarView : both icalendarable.start and icalendarable.stop dates can be None
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 6882
diff changeset
   222
            start_date = icalendarable.start or  icalendarable.stop
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
   223
            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
   224
                     '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
   225
                     '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
   226
                     '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
   227
                     '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
   228
                     }
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
            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
   230
            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
   231
            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
   232
                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
   233
                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
   234
            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
   235
        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
   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
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
   238
    __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
   239
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
    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
   241
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
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
   243
    __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
   244
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
    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
   246
    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
   247
    fullcalendar_options['defaultView'] = 'agendaWeek'