| 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 | |
|---|
| 22 | from MaKaC.plugins.Collaboration.base import WCSPageTemplateBase, WJSBase |
|---|
| 23 | from MaKaC.common.utils import formatDateTime |
|---|
| 24 | from datetime import timedelta |
|---|
| 25 | from MaKaC.webinterface.common.tools import strip_ml_tags, unescape_html |
|---|
| 26 | from MaKaC.plugins.Collaboration.EVO.common import getMinStartDate,\ |
|---|
| 27 | getMaxEndDate |
|---|
| 28 | from MaKaC.plugins.Collaboration.collaborationTools import CollaborationTools |
|---|
| 29 | from MaKaC.i18n import _ |
|---|
| 30 | from MaKaC.common.timezoneUtils import nowutc, getAdjustedDate |
|---|
| 31 | |
|---|
| 32 | class WNewBookingForm(WCSPageTemplateBase): |
|---|
| 33 | |
|---|
| 34 | def getVars(self): |
|---|
| 35 | vars = WCSPageTemplateBase.getVars( self ) |
|---|
| 36 | |
|---|
| 37 | vars["EventTitle"] = self._conf.getTitle() |
|---|
| 38 | vars["EventDescription"] = unescape_html(strip_ml_tags( self._conf.getDescription())).strip() |
|---|
| 39 | |
|---|
| 40 | defaultStartDate = self._conf.getAdjustedStartDate() - timedelta(0,0,0,0,CollaborationTools.getCollaborationOptionValue("startMinutes")) |
|---|
| 41 | nowStartDate = getAdjustedDate(nowutc() - timedelta(0,0,0,0, self._EVOOptions["allowedPastMinutes"].getValue() / 2), self._conf) |
|---|
| 42 | vars["DefaultStartDate"] = formatDateTime(max(defaultStartDate, nowStartDate)) |
|---|
| 43 | |
|---|
| 44 | defaultEndDate = self._conf.getAdjustedEndDate() |
|---|
| 45 | nowEndDate = nowStartDate + timedelta(0,0,0,0, self._EVOOptions["allowedMinutes"].getValue()) |
|---|
| 46 | vars["DefaultEndDate"] = formatDateTime(max(defaultEndDate, nowEndDate)) |
|---|
| 47 | |
|---|
| 48 | communities = self._EVOOptions["communityList"].getValue() #a dict communityId : communityName |
|---|
| 49 | communityItems = communities.items() # a list of tuples (communityId, communityName) |
|---|
| 50 | communityItems.sort(key = lambda t: t[1]) # we sort by the second member of the tuple (the name) |
|---|
| 51 | vars["Communities"] = communityItems |
|---|
| 52 | |
|---|
| 53 | return vars |
|---|
| 54 | |
|---|
| 55 | class WMain (WJSBase): |
|---|
| 56 | |
|---|
| 57 | def getVars(self): |
|---|
| 58 | vars = WJSBase.getVars( self ) |
|---|
| 59 | |
|---|
| 60 | vars["AllowedStartMinutes"] = self._EVOOptions["allowedPastMinutes"].getValue() |
|---|
| 61 | vars["MinStartDate"] = formatDateTime(getMinStartDate(self._conf)) |
|---|
| 62 | vars["MaxEndDate"] = formatDateTime(getMaxEndDate(self._conf)) |
|---|
| 63 | vars["AllowedMarginMinutes"] = self._EVOOptions["allowedMinutes"].getValue() |
|---|
| 64 | |
|---|
| 65 | return vars |
|---|
| 66 | |
|---|
| 67 | class WExtra (WJSBase): |
|---|
| 68 | |
|---|
| 69 | def getVars(self): |
|---|
| 70 | vars = WJSBase.getVars( self ) |
|---|
| 71 | |
|---|
| 72 | vars["AllowedStartMinutes"] = self._EVOOptions["allowedPastMinutes"].getValue() |
|---|
| 73 | if self._conf: |
|---|
| 74 | vars["MinStartDate"] = formatDateTime(getMinStartDate(self._conf), format = "%a %d/%m %H:%M") |
|---|
| 75 | vars["MaxEndDate"] = formatDateTime(getMaxEndDate(self._conf), format = "%a %d/%m %H:%M") |
|---|
| 76 | else: |
|---|
| 77 | vars["MinStartDate"] = '' |
|---|
| 78 | vars["MaxEndDate"] = '' |
|---|
| 79 | |
|---|
| 80 | return vars |
|---|
| 81 | |
|---|
| 82 | class WIndexing(WJSBase): |
|---|
| 83 | pass |
|---|
| 84 | |
|---|
| 85 | class WInformationDisplay(WCSPageTemplateBase): |
|---|
| 86 | |
|---|
| 87 | def __init__(self, booking, displayTz): |
|---|
| 88 | WCSPageTemplateBase.__init__(self, booking.getConference(), 'EVO', None) |
|---|
| 89 | self._booking = booking |
|---|
| 90 | self._displayTz = displayTz |
|---|
| 91 | |
|---|
| 92 | def getVars(self): |
|---|
| 93 | vars = WCSPageTemplateBase.getVars( self ) |
|---|
| 94 | |
|---|
| 95 | vars["Booking"] = self._booking |
|---|
| 96 | |
|---|
| 97 | return vars |
|---|
| 98 | |
|---|
| 99 | class XMLGenerator(object): |
|---|
| 100 | |
|---|
| 101 | @classmethod |
|---|
| 102 | def getDisplayName(cls): |
|---|
| 103 | return "EVO" |
|---|
| 104 | |
|---|
| 105 | @classmethod |
|---|
| 106 | def getCustomBookingXML(cls, booking, displayTz, out): |
|---|
| 107 | booking.checkCanStart() |
|---|
| 108 | if (booking.canBeStarted()): |
|---|
| 109 | out.openTag("launchInfo") |
|---|
| 110 | out.writeTag("launchText", _("Join Now!")) |
|---|
| 111 | out.writeTag("launchLink", booking.getURL()) |
|---|
| 112 | out.writeTag("launchTooltip", _('Click here to join the EVO meeting!')) |
|---|
| 113 | out.closeTag("launchInfo") |
|---|
| 114 | |
|---|
| 115 | out.openTag("information") |
|---|
| 116 | |
|---|
| 117 | if booking.getHasAccessPassword(): |
|---|
| 118 | out.openTag("section") |
|---|
| 119 | out.writeTag("title", _('Protection:')) |
|---|
| 120 | out.writeTag("line", _('This EVO meeting is protected by a password')) |
|---|
| 121 | out.closeTag("section") |
|---|
| 122 | out.openTag("section") |
|---|
| 123 | out.writeTag("title", _('Description:')) |
|---|
| 124 | out.writeTag("line", booking._bookingParams["meetingDescription"]) |
|---|
| 125 | out.closeTag("section") |
|---|
| 126 | out.closeTag("information") |
|---|
| 127 | |
|---|