source: indico/indico/MaKaC/plugins/Collaboration/Vidyo/pages.py @ 3632eb

burotelhello-world-walkthroughipv6v0.97-seriesv0.98-seriesv0.98.2v0.98.3v0.98b1v0.98b2v0.99v1.0v1.1
Last change on this file since 3632eb was 3632eb, checked in by Jose Benito <jose.benito.gonzalez@…>, 2 years ago

[IMP] Add option to display VidVoice? phone numbers

  • enabled by default
  • fixes #636
  • Property mode set to 100644
File size: 7.5 KB
Line 
1# -*- coding: utf-8 -*-
2##
3## $Id: pages.py,v 1.9 2009/04/25 13:56:04 dmartinc Exp $
4##
5## This file is part of CDS Indico.
6## Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007 CERN.
7##
8## CDS Indico is free software; you can redistribute it and/or
9## modify it under the terms of the GNU General Public License as
10## published by the Free Software Foundation; either version 2 of the
11## License, or (at your option) any later version.
12##
13## CDS Indico is distributed in the hope that it will be useful, but
14## WITHOUT ANY WARRANTY; without even the implied warranty of
15## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16## General Public License for more details.
17##
18## You should have received a copy of the GNU General Public License
19## along with CDS Indico; if not, write to the Free Software Foundation, Inc.,
20## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
21
22from MaKaC.plugins.Collaboration.base import WCSPageTemplateBase, WJSBase, WCSCSSBase
23from MaKaC.webinterface.common.tools import strip_ml_tags, unescape_html
24from MaKaC.i18n import _
25from MaKaC.fossils.user import IAvatarFossil
26from MaKaC.webinterface.pages.collaboration import WAdvancedTabBase
27from MaKaC.plugins.Collaboration.Vidyo.common import VidyoTools,\
28    getVidyoOptionValue
29from datetime import timedelta
30from MaKaC.common import info
31
32
33
34class WNewBookingForm(WCSPageTemplateBase):
35
36    def getVars(self):
37        variables = WCSPageTemplateBase.getVars(self)
38
39        variables["EventTitle"] = VidyoTools.defaultRoomName(self._conf)
40        variables["EventDescription"] = unescape_html(strip_ml_tags(self._conf.getDescription())).strip()
41
42        return variables
43
44
45
46class WAdvancedTab(WAdvancedTabBase):
47
48    def getVars(self):
49        variables = WAdvancedTabBase.getVars(self)
50        return variables
51
52
53
54class WMain (WJSBase):
55
56    def getVars(self):
57        variables = WJSBase.getVars(self)
58
59        variables["LoggedInUser"] = self._user.fossilize(IAvatarFossil)
60        variables["MaxNameLength"] = VidyoTools.maxRoomNameLength(self._conf)
61
62        return variables
63
64
65
66class WExtra (WJSBase):
67
68    def getVars(self):
69        variables = WJSBase.getVars(self)
70        return variables
71
72
73class WIndexing(WJSBase):
74    pass
75
76
77
78class WStyle (WCSCSSBase):
79    pass
80
81
82
83class WInformationDisplay(WCSPageTemplateBase):
84
85    def __init__(self, booking, displayTz):
86        WCSPageTemplateBase.__init__(self, booking.getConference(), 'Vidyo', None)
87        self._booking = booking
88        self._displayTz = displayTz
89
90    def getVars(self):
91        variables = WCSPageTemplateBase.getVars(self)
92
93        variables["Booking"] = self._booking
94        variables["PhoneNumbers"] = getVidyoOptionValue("phoneNumbers")
95
96        return variables
97
98
99class XMLGenerator(object):
100
101    @classmethod
102    def getDisplayName(cls):
103        return _("Vidyo public room: ")
104
105    @classmethod
106    def getFirstLineInfo(cls, booking, displayTz):
107        return booking.getBookingParamByName('roomName')
108
109    @classmethod
110    def getCustomBookingXML(cls, booking, displayTz, out):
111        if (booking.canBeStarted()):
112            out.openTag("launchInfo")
113            out.writeTag("launchText", _("Join Now!"))
114            out.writeTag("launchLink", booking.getURL())
115            out.writeTag("launchTooltip", _('Click here to join the Vidyo room!'))
116            out.closeTag("launchInfo")
117
118        out.writeTag("firstLineInfo", booking.getBookingParamByName("roomName"))
119
120        out.openTag("information")
121
122        out.openTag("section")
123        out.writeTag("title", _('Room name:'))
124        out.writeTag("line", booking.getBookingParamByName("roomName"))
125        out.closeTag("section")
126
127        out.openTag("section")
128        out.writeTag("title", _('Extension:'))
129        out.writeTag("line", booking.getExtension())
130        out.closeTag("section")
131
132        if booking.getHasPin():
133            out.openTag("section")
134            out.writeTag("title", _('PIN:'))
135            if booking.getBookingParamByName("displayPin"):
136                out.writeTag("line", booking.getPin())
137            else:
138                out.writeTag("line", _('This Vidyo room is protected by a PIN'))
139            out.closeTag("section")
140
141        out.openTag("section")
142        out.writeTag("title", _('Owner:'))
143        out.writeTag("line", booking.getOwnerObject().getFullName())
144        out.closeTag("section")
145
146        if booking.getBookingParamByName("displayURL"):
147            out.openTag("section")
148            out.writeTag("title", _('Auto-join URL:'))
149            out.openTag("linkLine")
150            out.writeTag("href", booking.getURL())
151            out.writeTag("caption", booking.getURL())
152            out.closeTag("linkLine")
153            out.closeTag("section")
154
155        if booking.getBookingParamByName("displayPhoneNumbers") and getVidyoOptionValue("phoneNumbers"):
156            out.openTag("section")
157            out.writeTag("title", _('VidyoVoice phone numbers:'))
158            out.writeTag("line", ', '.join(getVidyoOptionValue("phoneNumbers")))
159            out.closeTag("section")
160
161        out.openTag("section")
162        out.writeTag("title", _('Description:'))
163        out.writeTag("line", booking.getBookingParamByName("roomDescription"))
164        out.closeTag("section")
165        out.closeTag("information")
166
167
168
169## Vidyo custom classes for action results
170
171class WShowOldRoomIndexActionResult(WCSPageTemplateBase):
172
173    def __init__(self, maxDate):
174        WCSPageTemplateBase.__init__(self, None, "Vidyo", None)
175        self._maxDate = maxDate
176
177    def getVars(self):
178        variables = WCSPageTemplateBase.getVars(self)
179
180        variables["MaxDate"] = self._maxDate
181        variables["TotalRoomCount"] = VidyoTools.getEventEndDateIndex().getCount()
182
183        oldBookingsPerConfIterator = VidyoTools.getEventEndDateIndex().iterBookingsPerConf(maxDate = self._maxDate)
184        newBookingsPerConfIterator = VidyoTools.getEventEndDateIndex().iterBookingsPerConf(minDate = self._maxDate + timedelta(seconds = 1))
185        variables["OldBookings"] = WBookingsList(oldBookingsPerConfIterator).getHTML()
186        variables["NewBookings"] = WBookingsList(newBookingsPerConfIterator).getHTML()
187        variables["ServerTZ"] = info.HelperMaKaCInfo.getMaKaCInfoInstance().getTimezone()
188
189        return variables
190
191class WBookingsList(WCSPageTemplateBase):
192
193    def __init__(self, bookingsPerConfIterator):
194        WCSPageTemplateBase.__init__(self, None, "Vidyo", None)
195        self._bookingsPerConfIterator = bookingsPerConfIterator
196
197    def getVars(self):
198        variables = WCSPageTemplateBase.getVars(self)
199
200        variables["BookingsPerConfIterator"] = self._bookingsPerConfIterator
201        variables["ServerTZ"] = info.HelperMaKaCInfo.getMaKaCInfoInstance().getTimezone()
202        variables["PairSorter"] = lambda pair: pair[0].getTitle() #we cannot have ":" in the template
203
204        return variables
205
206class WDeleteOldRoomsActionResult(WCSPageTemplateBase):
207
208    def __init__(self, maxDate, previousTotal, newTotal, error = False, attainedDate = None):
209        WCSPageTemplateBase.__init__(self, None, "Vidyo", None)
210        self._maxDate = maxDate
211        self._previousTotal = previousTotal
212        self._newTotal = newTotal
213        self._error = error
214        self._attainedDate = attainedDate
215
216    def getVars(self):
217        variables = WCSPageTemplateBase.getVars(self)
218
219        variables["MaxDate"] = self._maxDate
220        variables["ServerTZ"] = info.HelperMaKaCInfo.getMaKaCInfoInstance().getTimezone()
221        variables["PreviousTotal"] = self._previousTotal
222        variables["NewTotal"] = self._newTotal
223        variables["Error"] = self._error
224        variables["AttainedDate"] = self._attainedDate
225
226        return variables
Note: See TracBrowser for help on using the repository browser.