| 1 | # -*- coding: utf-8 -*- |
|---|
| 2 | ## |
|---|
| 3 | ## |
|---|
| 4 | ## This file is part of Indico. |
|---|
| 5 | ## Copyright (C) 2002 - 2013 European Organization for Nuclear Research (CERN). |
|---|
| 6 | ## |
|---|
| 7 | ## Indico is free software; you can redistribute it and/or |
|---|
| 8 | ## modify it under the terms of the GNU General Public License as |
|---|
| 9 | ## published by the Free Software Foundation; either version 3 of the |
|---|
| 10 | ## License, or (at your option) any later version. |
|---|
| 11 | ## |
|---|
| 12 | ## Indico is distributed in the hope that it will be useful, but |
|---|
| 13 | ## WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 14 | ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|---|
| 15 | ## General Public License for more details. |
|---|
| 16 | ## |
|---|
| 17 | ## You should have received a copy of the GNU General Public License |
|---|
| 18 | ## along with Indico;if not, see <http://www.gnu.org/licenses/>. |
|---|
| 19 | |
|---|
| 20 | from MaKaC.plugins.Collaboration.base import WCSPageTemplateBase, WJSBase, WCSCSSBase,\ |
|---|
| 21 | CollaborationTools |
|---|
| 22 | from MaKaC.plugins.Collaboration.WebcastRequest.common import getCommonTalkInformation |
|---|
| 23 | from MaKaC.conference import Contribution |
|---|
| 24 | from MaKaC.common.fossilize import fossilize |
|---|
| 25 | from MaKaC.fossils.contribution import IContributionWithSpeakersFossil |
|---|
| 26 | from MaKaC.plugins.Collaboration.WebcastRequest.fossils import IContributionWRFossil |
|---|
| 27 | from MaKaC.common.Conversion import Conversion |
|---|
| 28 | from MaKaC.common.timezoneUtils import isSameDay |
|---|
| 29 | from MaKaC.plugins.Collaboration import urlHandlers as collaborationUrlHandlers |
|---|
| 30 | from MaKaC.webinterface.rh.collaboration import RCCollaborationAdmin, RCCollaborationPluginAdmin |
|---|
| 31 | |
|---|
| 32 | class WNewBookingForm(WCSPageTemplateBase): |
|---|
| 33 | |
|---|
| 34 | def getVars(self): |
|---|
| 35 | vars=WCSPageTemplateBase.getVars( self ) |
|---|
| 36 | |
|---|
| 37 | vars["Conference"] = self._conf |
|---|
| 38 | vars["IsSingleBooking"] = not CollaborationTools.getCSBookingClass(self._pluginId)._allowMultiple |
|---|
| 39 | |
|---|
| 40 | isLecture = self._conf.getType() == 'simple_event' |
|---|
| 41 | vars["IsLecture"] = isLecture |
|---|
| 42 | |
|---|
| 43 | underTheLimit = self._conf.getNumberOfContributions() <= self._WebcastRequestOptions["contributionLoadLimit"].getValue() |
|---|
| 44 | manager = self._conf.getCSBookingManager() |
|---|
| 45 | user = self._rh._getUser() |
|---|
| 46 | isManager = user.isAdmin() or RCCollaborationAdmin.hasRights(user=user) or RCCollaborationPluginAdmin.hasRights(user=user, plugins=['WebcastRequest']) |
|---|
| 47 | booking = manager.getSingleBooking('WebcastRequest') |
|---|
| 48 | initialChoose = booking is not None and booking._bookingParams['talks'] == 'choose' |
|---|
| 49 | initialDisplay = (self._conf.getNumberOfContributions() > 0 and underTheLimit) or (booking is not None and initialChoose) |
|---|
| 50 | |
|---|
| 51 | vars["DisplayTalks"] = initialDisplay |
|---|
| 52 | vars["InitialChoose"] = initialChoose |
|---|
| 53 | vars["isManager"] = isManager |
|---|
| 54 | |
|---|
| 55 | talks, wcRoomFullNames, wcRoomNames, webcastAbleTalks, webcastUnableTalks = getCommonTalkInformation(self._conf) |
|---|
| 56 | nWebcastCapable = len(webcastAbleTalks) |
|---|
| 57 | |
|---|
| 58 | |
|---|
| 59 | |
|---|
| 60 | vars["HasWebcastCapableTalks"] = nWebcastCapable > 0 |
|---|
| 61 | vars["NTalks"] = len(talks) |
|---|
| 62 | |
|---|
| 63 | # list of "locationName:roomName" strings |
|---|
| 64 | vars["WebcastCapableRooms"] = wcRoomFullNames |
|---|
| 65 | vars["NWebcastCapableContributions"] = nWebcastCapable |
|---|
| 66 | |
|---|
| 67 | # we see if the event itself is webcast capable (depends on event's room) |
|---|
| 68 | confLocation = self._conf.getLocation() |
|---|
| 69 | confRoom = self._conf.getRoom() |
|---|
| 70 | if confLocation and confRoom and (confLocation.getName() + ":" + confRoom.getName() in wcRoomNames): |
|---|
| 71 | topLevelWebcastCapable = True |
|---|
| 72 | else: |
|---|
| 73 | topLevelWebcastCapable = False |
|---|
| 74 | |
|---|
| 75 | # Finally, this event is webcast capable if the event itself or |
|---|
| 76 | # or one of its talks are capable or user is admin, collaboration |
|---|
| 77 | # manager or webcast plugin manager |
|---|
| 78 | vars["WebcastCapable"] = topLevelWebcastCapable or nWebcastCapable > 0 or isManager |
|---|
| 79 | |
|---|
| 80 | webcastAbleTalks.sort(key = Contribution.contributionStartDateForSort) |
|---|
| 81 | talks.sort(key = Contribution.contributionStartDateForSort) |
|---|
| 82 | |
|---|
| 83 | fossil_args = dict(tz=self._conf.getTimezone(), |
|---|
| 84 | units='(hours)_minutes', |
|---|
| 85 | truncate=True) |
|---|
| 86 | |
|---|
| 87 | vars["Contributions"] = fossilize(talks, IContributionWRFossil, **fossil_args) |
|---|
| 88 | vars["ContributionsAble"] = fossilize(webcastAbleTalks, IContributionWRFossil, **fossil_args) |
|---|
| 89 | vars["ContributionsUnable"] = fossilize(webcastUnableTalks, IContributionWRFossil, **fossil_args) |
|---|
| 90 | |
|---|
| 91 | vars["Audiences"] = CollaborationTools.getOptionValue('WebcastRequest', "webcastAudiences") |
|---|
| 92 | vars["linkToEA"] = collaborationUrlHandlers.UHCollaborationElectronicAgreement.getURL(self._conf) |
|---|
| 93 | vars["agreementName"] = CollaborationTools.getOptionValue("WebcastRequest", "AgreementName") |
|---|
| 94 | return vars |
|---|
| 95 | |
|---|
| 96 | |
|---|
| 97 | class WMain (WJSBase): |
|---|
| 98 | pass |
|---|
| 99 | |
|---|
| 100 | |
|---|
| 101 | class WIndexing(WJSBase): |
|---|
| 102 | pass |
|---|
| 103 | |
|---|
| 104 | |
|---|
| 105 | class WExtra (WJSBase): |
|---|
| 106 | def getVars(self): |
|---|
| 107 | vars = WJSBase.getVars( self ) |
|---|
| 108 | |
|---|
| 109 | if self._conf: |
|---|
| 110 | vars["ConferenceId"] = self._conf.getId() |
|---|
| 111 | vars["NumberOfContributions"] = self._conf.getNumberOfContributions() |
|---|
| 112 | |
|---|
| 113 | # these 2 vars are used to see if contrib dates shown should include day or just time |
|---|
| 114 | vars["ConfStartDate"] = Conversion.datetime(self._conf.getAdjustedStartDate()) |
|---|
| 115 | vars["IsMultiDayEvent"] = not isSameDay(self._conf.getStartDate(), self._conf.getEndDate(), self._conf.getTimezone()) |
|---|
| 116 | |
|---|
| 117 | location = "" |
|---|
| 118 | if self._conf.getLocation() and self._conf.getLocation().getName(): |
|---|
| 119 | location = self._conf.getLocation().getName().strip() |
|---|
| 120 | vars["ConfLocation"] = location |
|---|
| 121 | |
|---|
| 122 | room = "" |
|---|
| 123 | if self._conf.getRoom() and self._conf.getRoom().getName(): |
|---|
| 124 | room = self._conf.getRoom().getName().strip() |
|---|
| 125 | vars["ConfRoom"] = room |
|---|
| 126 | |
|---|
| 127 | else: |
|---|
| 128 | # this is so that template can still be rendered in indexes page... |
|---|
| 129 | # if necessary, we should refactor the Extra.js code so that it gets the |
|---|
| 130 | # conference data from the booking, now that the booking has the conference inside |
|---|
| 131 | vars["ConferenceId"] = "" |
|---|
| 132 | vars["NumberOfContributions"] = 0 |
|---|
| 133 | vars["ConfStartDate"] = "" |
|---|
| 134 | vars["IsMultiDayEvent"] = False |
|---|
| 135 | vars["ConfLocation"] = "" |
|---|
| 136 | vars["ConfRoom"] = "" |
|---|
| 137 | |
|---|
| 138 | return vars |
|---|
| 139 | |
|---|
| 140 | |
|---|
| 141 | class WStyle (WCSCSSBase): |
|---|
| 142 | pass |
|---|