| 1 | # -*- coding: utf-8 -*- |
|---|
| 2 | ## |
|---|
| 3 | ## |
|---|
| 4 | ## This file is part of CDS Indico. |
|---|
| 5 | ## Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007 CERN. |
|---|
| 6 | ## |
|---|
| 7 | ## CDS 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 2 of the |
|---|
| 10 | ## License, or (at your option) any later version. |
|---|
| 11 | ## |
|---|
| 12 | ## CDS 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 CDS Indico; if not, write to the Free Software Foundation, Inc., |
|---|
| 19 | ## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. |
|---|
| 20 | |
|---|
| 21 | from datetime import timedelta,datetime, time |
|---|
| 22 | import os, sys |
|---|
| 23 | import MaKaC.common.info as info |
|---|
| 24 | import MaKaC.webinterface.rh.base as base |
|---|
| 25 | import MaKaC.webinterface.rh.conferenceBase as conferenceBase |
|---|
| 26 | import MaKaC.webinterface.pages.conferences as conferences |
|---|
| 27 | import MaKaC.webinterface.pages.abstracts as abstracts |
|---|
| 28 | import MaKaC.webinterface.pages.authors as authors |
|---|
| 29 | import MaKaC.webinterface.urlHandlers as urlHandlers |
|---|
| 30 | import MaKaC.webinterface.displayMgr as displayMgr |
|---|
| 31 | import MaKaC.webinterface.internalPagesMgr as internalPagesMgr |
|---|
| 32 | import MaKaC.user as user |
|---|
| 33 | import MaKaC.webinterface.mail as mail |
|---|
| 34 | from MaKaC.webinterface.pages.errors import WPAccessError |
|---|
| 35 | import MaKaC.conference as conference |
|---|
| 36 | from MaKaC.common import Config, DBMgr |
|---|
| 37 | from MaKaC.common.utils import isStringHTML,sortContributionByDate |
|---|
| 38 | from MaKaC.authentication import AuthenticatorMgr |
|---|
| 39 | from MaKaC.webinterface.rh.base import RHDisplayBaseProtected |
|---|
| 40 | from MaKaC.webinterface.rh.base import RoomBookingDBMixin |
|---|
| 41 | from MaKaC.webinterface.rh.conferenceBase import RHConferenceBase, RHSubmitMaterialBase |
|---|
| 42 | import MaKaC.common.filters as filters |
|---|
| 43 | import MaKaC.webinterface.common.contribFilters as contribFilters |
|---|
| 44 | from MaKaC.errors import MaKaCError, ModificationError, NoReportError, AccessError |
|---|
| 45 | from MaKaC.PDFinterface.conference import ConfManagerContribsToPDF,TimeTablePlain,AbstractBook, SimplifiedTimeTablePlain, ProgrammeToPDF, TimetablePDFFormat |
|---|
| 46 | from xml.sax.saxutils import escape |
|---|
| 47 | from MaKaC.participant import Participant |
|---|
| 48 | from MaKaC.ICALinterface.conference import ConferenceToiCal |
|---|
| 49 | from MaKaC.common.contribPacker import ConferencePacker, ZIPFileHandler |
|---|
| 50 | import StringIO, zipfile |
|---|
| 51 | from MaKaC.i18n import _ |
|---|
| 52 | |
|---|
| 53 | import MaKaC.common.timezoneUtils as timezoneUtils |
|---|
| 54 | from reportlab.platypus.doctemplate import LayoutError |
|---|
| 55 | from MaKaC.webinterface.rh.base import RH |
|---|
| 56 | from MaKaC.webinterface.common.tools import cleanHTMLHeaderFilename |
|---|
| 57 | |
|---|
| 58 | class RHConfSignIn( conferenceBase.RHConferenceBase ): |
|---|
| 59 | |
|---|
| 60 | def _checkParams( self, params ): |
|---|
| 61 | conferenceBase.RHConferenceBase._checkParams( self, params ) |
|---|
| 62 | self._login = params.get( "login", "" ).strip() |
|---|
| 63 | self._password = params.get( "password", "" ).strip() |
|---|
| 64 | self._returnURL = params.get( "returnURL", "").strip() |
|---|
| 65 | if self._returnURL == "": |
|---|
| 66 | self._returnURL = urlHandlers.UHConferenceDisplay.getURL( self._conf ) |
|---|
| 67 | self._loginURL = params.get( "loginURL", "").strip() |
|---|
| 68 | self._signIn = params.get("signIn", "").strip() |
|---|
| 69 | |
|---|
| 70 | |
|---|
| 71 | def _process( self ): |
|---|
| 72 | self._tohttps = True |
|---|
| 73 | #Check for automatic login |
|---|
| 74 | auth = AuthenticatorMgr() |
|---|
| 75 | av = auth.autoLogin(self) |
|---|
| 76 | if av: |
|---|
| 77 | url = self._returnURL |
|---|
| 78 | self._getSession().setUser( av ) |
|---|
| 79 | self._redirect( url ) |
|---|
| 80 | if not self._signIn: |
|---|
| 81 | p = conferences.WPConfSignIn( self, self._conf ) |
|---|
| 82 | return p.display( returnURL = self._returnURL ) |
|---|
| 83 | else: |
|---|
| 84 | li = user.LoginInfo( self._login, self._password ) |
|---|
| 85 | av = auth.getAvatar(li) |
|---|
| 86 | if not av: |
|---|
| 87 | p = conferences.WPConfSignIn( self, self._conf, login = self._login, msg = "Wrong login or password" ) |
|---|
| 88 | return p.display( returnURL = self._returnURL ) |
|---|
| 89 | elif not av.isActivated(): |
|---|
| 90 | if av.isDisabled(): |
|---|
| 91 | self._redirect(urlHandlers.UHConfDisabledAccount.getURL(self._conf, av)) |
|---|
| 92 | else: |
|---|
| 93 | self._redirect(urlHandlers.UHConfUnactivatedAccount.getURL( self._conf, av)) |
|---|
| 94 | return "your account is not active\nPlease activate it and retry" |
|---|
| 95 | else: |
|---|
| 96 | url = self._returnURL |
|---|
| 97 | self._getSession().setUser( av ) |
|---|
| 98 | tzUtil = timezoneUtils.SessionTZ(av) |
|---|
| 99 | tz = tzUtil.getSessionTZ() |
|---|
| 100 | self._getSession().setVar("ActiveTimezone",tz) |
|---|
| 101 | self._redirect( url ) |
|---|
| 102 | |
|---|
| 103 | # REPLACED BY RHSignOut IN login.py |
|---|
| 104 | #class RHConfSignOut( conferenceBase.RHConferenceBase ): |
|---|
| 105 | # |
|---|
| 106 | # def _process( self ): |
|---|
| 107 | # if self._getUser(): |
|---|
| 108 | # self._getSession().setUser( None ) |
|---|
| 109 | # self._setUser( None ) |
|---|
| 110 | # self._redirect( urlHandlers.UHConferenceDisplay.getURL( self._conf ) ) |
|---|
| 111 | |
|---|
| 112 | |
|---|
| 113 | |
|---|
| 114 | class RHConferenceAccessKey( conferenceBase.RHConferenceBase ): |
|---|
| 115 | |
|---|
| 116 | def _checkParams( self, params ): |
|---|
| 117 | conferenceBase.RHConferenceBase._checkParams(self, params ) |
|---|
| 118 | self._accesskey = params.get( "accessKey", "" ).strip() |
|---|
| 119 | |
|---|
| 120 | def _process( self ): |
|---|
| 121 | access_keys = self._getSession().getVar("accessKeys") |
|---|
| 122 | if access_keys == None: |
|---|
| 123 | access_keys = {} |
|---|
| 124 | access_keys[self._conf.getUniqueId()] = self._accesskey |
|---|
| 125 | self._getSession().setVar("accessKeys",access_keys) |
|---|
| 126 | url = urlHandlers.UHConferenceDisplay.getURL( self._conf ) |
|---|
| 127 | self._redirect( url ) |
|---|
| 128 | |
|---|
| 129 | |
|---|
| 130 | class RHConferenceForceAccessKey( conferenceBase.RHConferenceBase ): |
|---|
| 131 | |
|---|
| 132 | def _checkParams( self, params ): |
|---|
| 133 | conferenceBase.RHConferenceBase._checkParams(self, params ) |
|---|
| 134 | |
|---|
| 135 | def _process( self ): |
|---|
| 136 | wp = WPAccessError( self ) |
|---|
| 137 | return wp.display() |
|---|
| 138 | |
|---|
| 139 | |
|---|
| 140 | class RHConfDisabledAccount( conferenceBase.RHConferenceBase ): |
|---|
| 141 | |
|---|
| 142 | def _checkParams( self, params ): |
|---|
| 143 | conferenceBase.RHConferenceBase._checkParams(self, params ) |
|---|
| 144 | self._userId = params.get( "userId", "" ).strip() |
|---|
| 145 | |
|---|
| 146 | def _process( self ): |
|---|
| 147 | av = user.AvatarHolder().getById( self._userId ) |
|---|
| 148 | p = conferences.WPConfAccountDisabled( self, self._conf, av ) |
|---|
| 149 | return p.display() |
|---|
| 150 | |
|---|
| 151 | |
|---|
| 152 | class RHConfUnactivatedAccount( conferenceBase.RHConferenceBase ): |
|---|
| 153 | |
|---|
| 154 | def _checkParams( self, params ): |
|---|
| 155 | conferenceBase.RHConferenceBase._checkParams(self, params ) |
|---|
| 156 | self._userId = params.get( "userId", "" ).strip() |
|---|
| 157 | |
|---|
| 158 | def _process( self ): |
|---|
| 159 | av = user.AvatarHolder().getById(self._userId) |
|---|
| 160 | p = conferences.WPConfUnactivatedAccount( self, self._conf, av ) |
|---|
| 161 | return p.display() |
|---|
| 162 | |
|---|
| 163 | |
|---|
| 164 | class RHConfSendActivation( conferenceBase.RHConferenceBase ): |
|---|
| 165 | |
|---|
| 166 | def _checkParams( self, params ): |
|---|
| 167 | conferenceBase.RHConferenceBase._checkParams(self, params ) |
|---|
| 168 | self._userId = params.get( "userId", "" ).strip() |
|---|
| 169 | |
|---|
| 170 | def _process( self ): |
|---|
| 171 | av = user.AvatarHolder().getById(self._userId) |
|---|
| 172 | sm = mail.sendConfirmationRequest(av) |
|---|
| 173 | sm.send() |
|---|
| 174 | self._redirect( urlHandlers.UHConfSignIn.getURL( self._conf ) ) |
|---|
| 175 | |
|---|
| 176 | |
|---|
| 177 | class _UserUtils: |
|---|
| 178 | |
|---|
| 179 | def setUserData( self, a, userData): |
|---|
| 180 | a.setName( userData["name"] ) |
|---|
| 181 | a.setSurName( userData["surName"] ) |
|---|
| 182 | a.setTitle( userData["title"] ) |
|---|
| 183 | a.setOrganisation( userData["organisation"] ) |
|---|
| 184 | a.setAddress( userData["address"] ) |
|---|
| 185 | a.setEmail( userData["email"] ) |
|---|
| 186 | a.setTelephone( userData["telephone"] ) |
|---|
| 187 | a.setFax( userData["fax"] ) |
|---|
| 188 | ################################## |
|---|
| 189 | # Fermi timezone awareness # |
|---|
| 190 | ################################## |
|---|
| 191 | a.setTimezone(userData["timezone"]) |
|---|
| 192 | a.setDisplayTZMode(userData["displayTZMode"]) |
|---|
| 193 | ################################## |
|---|
| 194 | # Fermi timezone awareness(end) # |
|---|
| 195 | ################################## |
|---|
| 196 | setUserData = classmethod( setUserData ) |
|---|
| 197 | |
|---|
| 198 | |
|---|
| 199 | class RHConfUserCreation( conferenceBase.RHConferenceBase ): |
|---|
| 200 | _uh = urlHandlers.UHConfUserCreation |
|---|
| 201 | |
|---|
| 202 | def _checkProtection( self ): |
|---|
| 203 | pass |
|---|
| 204 | |
|---|
| 205 | def _checkParams( self, params ): |
|---|
| 206 | self._params = params |
|---|
| 207 | conferenceBase.RHConferenceBase._checkParams( self, params ) |
|---|
| 208 | self._save = params.get("Save", "") |
|---|
| 209 | self._returnURL = params.get( "returnURL", "").strip() |
|---|
| 210 | |
|---|
| 211 | def _process( self ): |
|---|
| 212 | save = False |
|---|
| 213 | ih = AuthenticatorMgr() |
|---|
| 214 | self._params["msg"] = "" |
|---|
| 215 | if self._save: |
|---|
| 216 | save = True |
|---|
| 217 | #check submited data |
|---|
| 218 | if not self._params.get("name",""): |
|---|
| 219 | self._params["msg"] += "You must enter a name.<br>" |
|---|
| 220 | save = False |
|---|
| 221 | if not self._params.get("surName",""): |
|---|
| 222 | self._params["msg"] += "You must enter a surname.<br>" |
|---|
| 223 | save = False |
|---|
| 224 | if not self._params.get("organisation",""): |
|---|
| 225 | self._params["msg"] += "You must enter the name of your organisation.<br>" |
|---|
| 226 | save = False |
|---|
| 227 | if not self._params.get("email",""): |
|---|
| 228 | self._params["msg"] += "You must enter an email address.<br>" |
|---|
| 229 | save = False |
|---|
| 230 | if not self._params.get("login",""): |
|---|
| 231 | self._params["msg"] += "You must enter a login.<br>" |
|---|
| 232 | save = False |
|---|
| 233 | if not self._params.get("password",""): |
|---|
| 234 | self._params["msg"] += "You must define a password.<br>" |
|---|
| 235 | save = False |
|---|
| 236 | if self._params.get("password","") != self._params.get("passwordBis",""): |
|---|
| 237 | self._params["msg"] += "You must enter the same password two time.<br>" |
|---|
| 238 | save = False |
|---|
| 239 | if not ih.isLoginFree(self._params.get("login","")): |
|---|
| 240 | self._params["msg"] += "Sorry, the login you requested is already in use. Please choose another one.<br>" |
|---|
| 241 | save = False |
|---|
| 242 | |
|---|
| 243 | if save: |
|---|
| 244 | #Data are OK, Now check if there is an existing user or create a new one |
|---|
| 245 | ah = user.AvatarHolder() |
|---|
| 246 | res = ah.match({"email": self._params["email"]}, exact=1, forceWithoutExtAuth=True) |
|---|
| 247 | if res: |
|---|
| 248 | #we find a user with the same email |
|---|
| 249 | a = res[0] |
|---|
| 250 | #check if the user have an identity: |
|---|
| 251 | if a.getIdentityList(): |
|---|
| 252 | self._redirect( urlHandlers.UHConfUserExistWithIdentity.getURL( self._conf, a)) |
|---|
| 253 | return |
|---|
| 254 | else: |
|---|
| 255 | #create the identity to the user and send the comfirmatio email |
|---|
| 256 | li = user.LoginInfo( self._params["login"], self._params["password"] ) |
|---|
| 257 | id = ih.createIdentity( li, a, "Local" ) |
|---|
| 258 | ih.add( id ) |
|---|
| 259 | DBMgr.getInstance().commit() |
|---|
| 260 | notif = _AccountActivationNotification( a, self._conf, self._returnURL ) |
|---|
| 261 | mail.Mailer.send( notif ) |
|---|
| 262 | else: |
|---|
| 263 | a = user.Avatar() |
|---|
| 264 | _UserUtils.setUserData( a, self._params ) |
|---|
| 265 | ah.add(a) |
|---|
| 266 | li = user.LoginInfo( self._params["login"], self._params["password"] ) |
|---|
| 267 | id = ih.createIdentity( li, a, "Local" ) |
|---|
| 268 | ih.add( id ) |
|---|
| 269 | DBMgr.getInstance().commit() |
|---|
| 270 | notif = _AccountActivationNotification( a, self._conf, self._returnURL ) |
|---|
| 271 | mail.Mailer.send( notif ) |
|---|
| 272 | self._redirect( urlHandlers.UHConfUserCreated.getURL( self._conf, a ) ) |
|---|
| 273 | else: |
|---|
| 274 | p = conferences.WPConfUserCreation( self, self._conf, self._params ) |
|---|
| 275 | return p.display() |
|---|
| 276 | |
|---|
| 277 | |
|---|
| 278 | class _AccountActivationNotification: |
|---|
| 279 | |
|---|
| 280 | def __init__( self, dest, conf, returnURL=""): |
|---|
| 281 | self._destination = dest |
|---|
| 282 | self._conf = conf |
|---|
| 283 | self._returnURL=returnURL |
|---|
| 284 | |
|---|
| 285 | def getSubject( self ): |
|---|
| 286 | return "User account activation (%s)"%self._conf.getTitle() |
|---|
| 287 | |
|---|
| 288 | def getDestination( self ): |
|---|
| 289 | return self._destination |
|---|
| 290 | |
|---|
| 291 | def getCCList(self): |
|---|
| 292 | return [] |
|---|
| 293 | |
|---|
| 294 | def getToList(self): |
|---|
| 295 | return [] |
|---|
| 296 | |
|---|
| 297 | def getMsg( self ): |
|---|
| 298 | url = urlHandlers.UHConfActiveAccount.getURL( self._conf, self._destination ) |
|---|
| 299 | url.addParam( "key", self._destination.getKey() ) |
|---|
| 300 | if self._returnURL.strip() != "": |
|---|
| 301 | url.addParam( "returnURL", self._returnURL ) |
|---|
| 302 | return """Welcome to Indico, |
|---|
| 303 | You have created a new account on the Indico conference management system. |
|---|
| 304 | |
|---|
| 305 | In order to activate your new account and being able to be authenticated by the system, please open on your web browser the following URL: |
|---|
| 306 | |
|---|
| 307 | %s |
|---|
| 308 | |
|---|
| 309 | Once you've done it, your account will be fully operational so you can log in and start using the system normally. |
|---|
| 310 | |
|---|
| 311 | Good luck and thank you for using our system. |
|---|
| 312 | """%( url ) |
|---|
| 313 | |
|---|
| 314 | |
|---|
| 315 | class RHConfUserCreated( conferenceBase.RHConferenceBase ): |
|---|
| 316 | |
|---|
| 317 | def _checkParams( self, params ): |
|---|
| 318 | conferenceBase.RHConferenceBase._checkParams( self, params ) |
|---|
| 319 | self._av = user.AvatarHolder().getById(params["userId"]) |
|---|
| 320 | |
|---|
| 321 | def _process( self ): |
|---|
| 322 | p = conferences.WPConfUserCreated( self, self._conf, self._av ) |
|---|
| 323 | return p.display() |
|---|
| 324 | |
|---|
| 325 | |
|---|
| 326 | class RHConfActivate( conferenceBase.RHConferenceBase ): |
|---|
| 327 | |
|---|
| 328 | def _checkParams( self, params ): |
|---|
| 329 | conferenceBase.RHConferenceBase._checkParams(self, params ) |
|---|
| 330 | self._userId = params.get( "userId", "" ).strip() |
|---|
| 331 | self._key = params.get( "key", "" ).strip() |
|---|
| 332 | self._returnURL = params.get( "returnURL", "").strip() |
|---|
| 333 | |
|---|
| 334 | |
|---|
| 335 | def _process( self ): |
|---|
| 336 | av = user.AvatarHolder().getById(self._userId) |
|---|
| 337 | if av.isActivated(): |
|---|
| 338 | p = conferences.WPConfAccountAlreadyActivated( self, self._conf, av ) |
|---|
| 339 | return p.display() |
|---|
| 340 | #return "your account is already activated" |
|---|
| 341 | if av.isDisabled(): |
|---|
| 342 | p = conferences.WPConfAccountDisabled( self, self._conf, av ) |
|---|
| 343 | return p.display() |
|---|
| 344 | #return "your account is disabled. please, ask to enable it" |
|---|
| 345 | elif self._key == av.getKey(): |
|---|
| 346 | av.activateAccount() |
|---|
| 347 | p = conferences.WPConfAccountActivated( self, self._conf, av, self._returnURL ) |
|---|
| 348 | return p.display() |
|---|
| 349 | #return "Your account is activate now" |
|---|
| 350 | else: |
|---|
| 351 | return "Wrong key. Please, ask for a new one" |
|---|
| 352 | |
|---|
| 353 | |
|---|
| 354 | class RHConfUserExistWithIdentity( conferenceBase.RHConferenceBase ): |
|---|
| 355 | |
|---|
| 356 | def _checkParams( self, params ): |
|---|
| 357 | conferenceBase.RHConferenceBase._checkParams( self, params ) |
|---|
| 358 | self._av = user.AvatarHolder().getById(params["userId"]) |
|---|
| 359 | |
|---|
| 360 | def _process( self ): |
|---|
| 361 | p = conferences.WPConfUserExistWithIdentity( self, self._conf, self._av ) |
|---|
| 362 | return p.display() |
|---|
| 363 | |
|---|
| 364 | |
|---|
| 365 | class RHConfSendLogin( conferenceBase.RHConferenceBase ): |
|---|
| 366 | |
|---|
| 367 | def _checkParams( self, params ): |
|---|
| 368 | conferenceBase.RHConferenceBase._checkParams( self, params ) |
|---|
| 369 | self._userId = params.get( "userId", "" ).strip() |
|---|
| 370 | self._email = params.get("email", "").strip() |
|---|
| 371 | |
|---|
| 372 | def _process( self ): |
|---|
| 373 | av = None |
|---|
| 374 | if self._userId != "": |
|---|
| 375 | av = user.AvatarHolder().getById(self._userId) |
|---|
| 376 | elif self._email != "": |
|---|
| 377 | try: |
|---|
| 378 | av = user.AvatarHolder().match({"email":self._email})[0] |
|---|
| 379 | except IndexError: |
|---|
| 380 | pass |
|---|
| 381 | if av: |
|---|
| 382 | sm = mail.sendLoginInfo(av) |
|---|
| 383 | sm.send() |
|---|
| 384 | self._redirect(urlHandlers.UHConfSignIn.getURL( self._conf )) |
|---|
| 385 | |
|---|
| 386 | |
|---|
| 387 | class RHConferenceBaseDisplay( RHConferenceBase, RHDisplayBaseProtected ): |
|---|
| 388 | |
|---|
| 389 | def _checkParams( self, params ): |
|---|
| 390 | RHConferenceBase._checkParams( self, params ) |
|---|
| 391 | |
|---|
| 392 | def _checkProtection( self ): |
|---|
| 393 | from MaKaC.webinterface.rh.collaboration import RCCollaborationAdmin, RCCollaborationPluginAdmin |
|---|
| 394 | if not RCCollaborationAdmin.hasRights(self, None) and \ |
|---|
| 395 | not RCCollaborationPluginAdmin.hasRights(self, plugins = "any"): |
|---|
| 396 | RHDisplayBaseProtected._checkProtection( self ) |
|---|
| 397 | |
|---|
| 398 | |
|---|
| 399 | class RHConferenceDisplay( RoomBookingDBMixin, RHConferenceBaseDisplay ): |
|---|
| 400 | _uh = urlHandlers.UHConferenceDisplay |
|---|
| 401 | |
|---|
| 402 | def _process( self ): |
|---|
| 403 | params = self._getRequestParams() |
|---|
| 404 | |
|---|
| 405 | #set default variables |
|---|
| 406 | if not self._reqParams.has_key("showDate"): |
|---|
| 407 | self._reqParams["showDate"] = "all" |
|---|
| 408 | if not self._reqParams.has_key("showSession"): |
|---|
| 409 | self._reqParams["showSession"] = "all" |
|---|
| 410 | if not self._reqParams.has_key("detailLevel"): |
|---|
| 411 | self._reqParams["detailLevel"] = "contribution" |
|---|
| 412 | #get default/selected view |
|---|
| 413 | view = "static" |
|---|
| 414 | wf = self.getWebFactory() |
|---|
| 415 | if wf != None: |
|---|
| 416 | type = self.getWebFactory().getId() |
|---|
| 417 | else: |
|---|
| 418 | type = "conference" |
|---|
| 419 | if self._reqParams.has_key("view"): |
|---|
| 420 | view = self._reqParams["view"] |
|---|
| 421 | else: |
|---|
| 422 | view = displayMgr.ConfDisplayMgrRegistery().getDisplayMgr(self._target).getDefaultStyle() |
|---|
| 423 | # if no default view was attributed, then get the configuration default |
|---|
| 424 | if view == "": |
|---|
| 425 | styleMgr = info.HelperMaKaCInfo.getMaKaCInfoInstance().getStyleManager() |
|---|
| 426 | view =styleMgr.getDefaultStylesheetForEventType( type ) |
|---|
| 427 | displayMgr.ConfDisplayMgrRegistery().getDisplayMgr(self._target).setDefaultStyle( view ) |
|---|
| 428 | isLibxml = True |
|---|
| 429 | warningText = "" |
|---|
| 430 | try: |
|---|
| 431 | import libxml2 |
|---|
| 432 | import libxslt |
|---|
| 433 | except: |
|---|
| 434 | isLibxml = False |
|---|
| 435 | # create the html factory |
|---|
| 436 | if type == "conference": |
|---|
| 437 | self._page = None |
|---|
| 438 | intPagesMgr=internalPagesMgr.InternalPagesMgrRegistery().getInternalPagesMgr(self._target) |
|---|
| 439 | for page in intPagesMgr.getPagesList(): |
|---|
| 440 | if page.isHome(): |
|---|
| 441 | self._page = page |
|---|
| 442 | if not self._page: |
|---|
| 443 | p = conferences.WPConferenceDisplay( self, self._target ) |
|---|
| 444 | else: |
|---|
| 445 | p = conferences.WPInternalPageDisplay(self,self._target, self._page) |
|---|
| 446 | elif view != "static" and isLibxml: |
|---|
| 447 | p = conferences.WPXSLConferenceDisplay( self, self._target, view, type, self._reqParams ) |
|---|
| 448 | else: |
|---|
| 449 | if view != "static": |
|---|
| 450 | warningText = "libxml2 and libxslt python modules need to be installed if you want to use a stylesheet-driven display - switching to static display" |
|---|
| 451 | if wf != None: |
|---|
| 452 | p = wf.getConferenceDisplayPage( self, self._target, self._reqParams ) |
|---|
| 453 | else: |
|---|
| 454 | p = conferences.WPConferenceDisplay( self, self._target ) |
|---|
| 455 | # generate the html |
|---|
| 456 | |
|---|
| 457 | return warningText + p.display(**params) |
|---|
| 458 | |
|---|
| 459 | |
|---|
| 460 | class RHConferenceOtherViews( RoomBookingDBMixin, RHConferenceBaseDisplay ): |
|---|
| 461 | """this class is for the conference type objects only |
|---|
| 462 | it is an alternative to the standard TimeTable view""" |
|---|
| 463 | _uh = urlHandlers.UHConferenceOtherViews |
|---|
| 464 | |
|---|
| 465 | def _process( self ): |
|---|
| 466 | #set default variables |
|---|
| 467 | if not self._reqParams.has_key("showDate"): |
|---|
| 468 | self._reqParams["showDate"] = "all" |
|---|
| 469 | if not self._reqParams.has_key("showSession"): |
|---|
| 470 | self._reqParams["showSession"] = "all" |
|---|
| 471 | if not self._reqParams.has_key("detailLevel"): |
|---|
| 472 | self._reqParams["detailLevel"] = "contribution" |
|---|
| 473 | #get default/selected view |
|---|
| 474 | view = "standard" |
|---|
| 475 | type = "conference" |
|---|
| 476 | if self._reqParams.has_key("view"): |
|---|
| 477 | view = self._reqParams["view"] |
|---|
| 478 | else: |
|---|
| 479 | view = displayMgr.ConfDisplayMgrRegistery().getDisplayMgr(self._target).getDefaultStyle() |
|---|
| 480 | # if no default view was attributed, then get the configuration default |
|---|
| 481 | if view == "": |
|---|
| 482 | styleMgr = info.HelperMaKaCInfo.getMaKaCInfoInstance().getStyleManager() |
|---|
| 483 | view =styleMgr.getDefaultStylesheetForEventType( type ) |
|---|
| 484 | displayMgr.ConfDisplayMgrRegistery().getDisplayMgr(self._target).setDefaultStyle( view ) |
|---|
| 485 | # create the html factory |
|---|
| 486 | if view != "static": |
|---|
| 487 | p = conferences.WPXSLConferenceDisplay( self, self._target, view, type, self._reqParams ) |
|---|
| 488 | else: |
|---|
| 489 | p = conferences.WPMeetingTimeTable( self, self._target,"parallel","meeting",self._reqParams ) |
|---|
| 490 | # generate the html |
|---|
| 491 | if view == "xml" and self._reqParams.get('fr') == 'no': |
|---|
| 492 | self._req.content_type = "text/xml" |
|---|
| 493 | return p.display() |
|---|
| 494 | |
|---|
| 495 | |
|---|
| 496 | class RHConferenceGetLogo(RHConferenceBaseDisplay): |
|---|
| 497 | |
|---|
| 498 | def _process(self): |
|---|
| 499 | logo=self._target.getLogo() |
|---|
| 500 | self._req.headers_out["Content-Length"]="%s"%logo.getSize() |
|---|
| 501 | cfg=Config.getInstance() |
|---|
| 502 | mimetype=cfg.getFileTypeMimeType(logo.getFileType()) |
|---|
| 503 | self._req.content_type="""%s"""%(mimetype) |
|---|
| 504 | self._req.headers_out["Content-Disposition"]="""inline; filename="%s\""""%cleanHTMLHeaderFilename(logo.getFileName()) |
|---|
| 505 | return self._target.getLogo().readBin() |
|---|
| 506 | |
|---|
| 507 | |
|---|
| 508 | class RHConferenceGetCSS(RHConferenceBaseDisplay): |
|---|
| 509 | |
|---|
| 510 | """ |
|---|
| 511 | CSS which is used just for a conference. |
|---|
| 512 | """ |
|---|
| 513 | |
|---|
| 514 | def _process(self): |
|---|
| 515 | sm = displayMgr.ConfDisplayMgrRegistery().getDisplayMgr(self._conf).getStyleManager() |
|---|
| 516 | css=sm.getLocalCSS() |
|---|
| 517 | if css: |
|---|
| 518 | self._req.headers_out["Content-Length"]="%s"%css.getSize() |
|---|
| 519 | self._req.content_type="text/css" |
|---|
| 520 | self._req.headers_out["Content-Disposition"]="""inline; filename="%s\""""%css.getFileName() |
|---|
| 521 | return css.readBin() |
|---|
| 522 | |
|---|
| 523 | return "" |
|---|
| 524 | |
|---|
| 525 | |
|---|
| 526 | class RHConferenceGetPic(RHConferenceBaseDisplay): |
|---|
| 527 | |
|---|
| 528 | def _checkParams(self, params): |
|---|
| 529 | RHConferenceBaseDisplay._checkParams( self, params ) |
|---|
| 530 | self._picId = params.get("picId","") |
|---|
| 531 | |
|---|
| 532 | def _process(self): |
|---|
| 533 | im = displayMgr.ConfDisplayMgrRegistery().getDisplayMgr(self._conf).getImagesManager() |
|---|
| 534 | pic=im.getPic(self._picId).getLocalFile() |
|---|
| 535 | self._req.headers_out["Content-Length"]="%s"%pic.getSize() |
|---|
| 536 | cfg=Config.getInstance() |
|---|
| 537 | mimetype=cfg.getFileTypeMimeType(pic.getFileType()) |
|---|
| 538 | self._req.content_type="""%s"""%(mimetype) |
|---|
| 539 | self._req.headers_out["Content-Disposition"]="""inline; filename="%s\""""%pic.getFileName() |
|---|
| 540 | return pic.readBin() |
|---|
| 541 | |
|---|
| 542 | |
|---|
| 543 | class RHConferenceEmail(RHConferenceBaseDisplay, base.RHProtected): |
|---|
| 544 | _uh = urlHandlers.UHConferenceEmail |
|---|
| 545 | |
|---|
| 546 | def _checkProtection(self): |
|---|
| 547 | base.RHProtected._checkProtection(self) |
|---|
| 548 | |
|---|
| 549 | def _checkParams( self, params ): |
|---|
| 550 | RHConferenceBaseDisplay._checkParams( self, params ) |
|---|
| 551 | self._auth = params.has_key("authId") |
|---|
| 552 | self._chair = params.has_key("chairId") |
|---|
| 553 | if params.has_key("contribId"): |
|---|
| 554 | contrib = self._conf.getContributionById(params.get("contribId","")) |
|---|
| 555 | if self._chair: |
|---|
| 556 | chairid=params.get("chairId","") |
|---|
| 557 | self._emailto =self._conf.getChairById(chairid).getEmail() |
|---|
| 558 | if self._auth: |
|---|
| 559 | authid=params.get("authId","") |
|---|
| 560 | self._emailto =contrib.getAuthorById(authid).getEmail() |
|---|
| 561 | |
|---|
| 562 | def _process(self): |
|---|
| 563 | p=conferences.WPEMail(self, self._target) |
|---|
| 564 | return p.display(emailto=self._emailto) |
|---|
| 565 | |
|---|
| 566 | class RHConferenceSendEmail (RHConferenceBaseDisplay, base.RHProtected): |
|---|
| 567 | _uh = urlHandlers.UHConferenceSendEmail |
|---|
| 568 | |
|---|
| 569 | def _checkProtection(self): |
|---|
| 570 | base.RHProtected._checkProtection(self) |
|---|
| 571 | |
|---|
| 572 | def _checkParams(self, params): |
|---|
| 573 | RHConferenceBaseDisplay._checkParams( self, params ) |
|---|
| 574 | self._to = params.get("to","") |
|---|
| 575 | self._cc = params.get("cc","") |
|---|
| 576 | self._from=params.get("from","") |
|---|
| 577 | self._subject=params.get("subject","") |
|---|
| 578 | self._body = params.get("body","") |
|---|
| 579 | self._send = params.has_key("OK") |
|---|
| 580 | |
|---|
| 581 | def _process(self): |
|---|
| 582 | if self._send: |
|---|
| 583 | mail.personMail.send(self._to, self._cc, self._from,self._subject,self._body) |
|---|
| 584 | p = conferences.WPSentEmail(self, self._target) |
|---|
| 585 | return p.display() |
|---|
| 586 | else: |
|---|
| 587 | self._redirect(urlHandlers.UHConferenceDisplay.getURL(self._conf)) |
|---|
| 588 | |
|---|
| 589 | |
|---|
| 590 | |
|---|
| 591 | class RHConferenceProgram( RHConferenceBaseDisplay ): |
|---|
| 592 | _uh = urlHandlers.UHConferenceProgram |
|---|
| 593 | |
|---|
| 594 | def _checkParams( self, params ): |
|---|
| 595 | RHConferenceBaseDisplay._checkParams( self, params ) |
|---|
| 596 | self._xs = self._normaliseListParam( params.get("xs", []) ) |
|---|
| 597 | |
|---|
| 598 | |
|---|
| 599 | def _process( self ): |
|---|
| 600 | p = conferences.WPConferenceProgram( self, self._target ) |
|---|
| 601 | return p.display( xs = self._xs ) |
|---|
| 602 | |
|---|
| 603 | |
|---|
| 604 | class RHConferenceProgramPDF( RHConferenceBaseDisplay ): |
|---|
| 605 | |
|---|
| 606 | def _process( self ): |
|---|
| 607 | tz = timezoneUtils.DisplayTZ(self._aw,self._target).getDisplayTZ() |
|---|
| 608 | filename = "%s - Programme.pdf"%cleanHTMLHeaderFilename(self._target.getTitle()) |
|---|
| 609 | from MaKaC.PDFinterface.conference import ProgrammeToPDF |
|---|
| 610 | pdf = ProgrammeToPDF(self._target, tz=tz) |
|---|
| 611 | data = pdf.getPDFBin() |
|---|
| 612 | #self._req.headers_out["Accept-Ranges"] = "bytes" |
|---|
| 613 | self._req.headers_out["Content-Length"] = "%s"%len(data) |
|---|
| 614 | cfg = Config.getInstance() |
|---|
| 615 | mimetype = cfg.getFileTypeMimeType( "PDF" ) |
|---|
| 616 | #self._req.content_type = """%s; name="%s\""""%(mimetype, filename ) |
|---|
| 617 | self._req.content_type = """%s"""%(mimetype) |
|---|
| 618 | self._req.headers_out["Content-Disposition"] = """inline; filename="%s\""""%filename |
|---|
| 619 | return data |
|---|
| 620 | |
|---|
| 621 | class RHConferenceTimeTable( RoomBookingDBMixin, RHConferenceBaseDisplay ): |
|---|
| 622 | _uh = urlHandlers.UHConferenceTimeTable |
|---|
| 623 | |
|---|
| 624 | def _process( self ): |
|---|
| 625 | defStyle = displayMgr.ConfDisplayMgrRegistery().getDisplayMgr(self._target).getDefaultStyle() |
|---|
| 626 | if defStyle in ["", "static", "parallel"]: |
|---|
| 627 | p = conferences.WPConferenceTimeTable( self, self._target ) |
|---|
| 628 | return p.display( **self._getRequestParams() ) |
|---|
| 629 | else: |
|---|
| 630 | url = urlHandlers.UHConferenceOtherViews.getURL( self._conf ) |
|---|
| 631 | url.addParam("view", defStyle) |
|---|
| 632 | self._redirect(url) |
|---|
| 633 | |
|---|
| 634 | |
|---|
| 635 | class RHTimeTablePDF(RHConferenceTimeTable): |
|---|
| 636 | |
|---|
| 637 | fontsizes = ['xxx-small', 'xx-small', 'x-small', 'smaller', 'small', 'normal', 'large', 'larger'] |
|---|
| 638 | |
|---|
| 639 | def _checkParams(self,params): |
|---|
| 640 | RHConferenceTimeTable._checkParams(self,params) |
|---|
| 641 | self._showSessions=self._normaliseListParam(params.get("showSessions",[])) |
|---|
| 642 | if "all" in self._showSessions: |
|---|
| 643 | self._showSessions.remove("all") |
|---|
| 644 | self._showDays=self._normaliseListParam(params.get("showDays",[])) |
|---|
| 645 | if "all" in self._showDays: |
|---|
| 646 | self._showDays.remove("all") |
|---|
| 647 | self._sortingCrit=None |
|---|
| 648 | if params.has_key("sortBy") and params["sortBy"].strip()!="": |
|---|
| 649 | self._sortingCrit=contribFilters.SortingCriteria([params.get( "sortBy", "number").strip()]) |
|---|
| 650 | self._pagesize = params.get('pagesize','A4') |
|---|
| 651 | self._fontsize = params.get('fontsize','normal') |
|---|
| 652 | try: |
|---|
| 653 | self._firstPageNumber = int(params.get('firstPageNumber','1')) |
|---|
| 654 | except ValueError: |
|---|
| 655 | self._firstPageNumber = 1 |
|---|
| 656 | self._showSpeakerAffiliation = False |
|---|
| 657 | if params.has_key("showSpeakerAffiliation"): |
|---|
| 658 | self._showSpeakerAffiliation = True |
|---|
| 659 | # Keep track of the used layout for getting back after cancelling |
|---|
| 660 | # the export. |
|---|
| 661 | self._view = params.get("view", displayMgr.ConfDisplayMgrRegistery().getDisplayMgr(self._target).getDefaultStyle()) |
|---|
| 662 | |
|---|
| 663 | def _reduceFontSize( self ): |
|---|
| 664 | index = self.fontsizes.index(self._fontsize) |
|---|
| 665 | if index > 0: |
|---|
| 666 | self._fontsize = self.fontsizes[index-1] |
|---|
| 667 | return True |
|---|
| 668 | return False |
|---|
| 669 | |
|---|
| 670 | def _process(self): |
|---|
| 671 | tz = timezoneUtils.DisplayTZ(self._aw,self._target).getDisplayTZ() |
|---|
| 672 | params = self._getRequestParams() |
|---|
| 673 | ttPDFFormat=TimetablePDFFormat(params) |
|---|
| 674 | |
|---|
| 675 | # Choose action depending on the button pressed |
|---|
| 676 | if params.has_key("cancel"): |
|---|
| 677 | # If the export is cancelled, redirect to the display |
|---|
| 678 | # page |
|---|
| 679 | url = urlHandlers.UHConferenceDisplay.getURL(self._conf) |
|---|
| 680 | url.addParam("view", self._view) |
|---|
| 681 | self._redirect(url) |
|---|
| 682 | else : |
|---|
| 683 | retry = True |
|---|
| 684 | while retry: |
|---|
| 685 | if params.get("typeTT","normalTT")=="normalTT": |
|---|
| 686 | filename = "timetable.pdf" |
|---|
| 687 | pdf = TimeTablePlain(self._target,self.getAW(), |
|---|
| 688 | showSessions=self._showSessions,showDays=self._showDays, |
|---|
| 689 | sortingCrit=self._sortingCrit, ttPDFFormat=ttPDFFormat, |
|---|
| 690 | pagesize = self._pagesize, fontsize = self._fontsize, |
|---|
| 691 | firstPageNumber = self._firstPageNumber, |
|---|
| 692 | showSpeakerAffiliation = self._showSpeakerAffiliation) |
|---|
| 693 | else: |
|---|
| 694 | filename = "SimplifiedTimetable.pdf" |
|---|
| 695 | pdf = SimplifiedTimeTablePlain(self._target,self.getAW(), |
|---|
| 696 | showSessions=self._showSessions,showDays=self._showDays, |
|---|
| 697 | sortingCrit=self._sortingCrit, ttPDFFormat=ttPDFFormat, |
|---|
| 698 | pagesize = self._pagesize, fontsize = self._fontsize) |
|---|
| 699 | try: |
|---|
| 700 | data=pdf.getPDFBin() |
|---|
| 701 | retry = False |
|---|
| 702 | except LayoutError, e: |
|---|
| 703 | if not self._reduceFontSize(): |
|---|
| 704 | raise MaKaCError("Error in PDF generation - One of the paragraphs does not fit on a page") |
|---|
| 705 | except Exception, e: |
|---|
| 706 | raise e |
|---|
| 707 | |
|---|
| 708 | ## tries = 5 |
|---|
| 709 | ## while tries: |
|---|
| 710 | ## if params.get("typeTT","normalTT")=="normalTT": |
|---|
| 711 | ## filename = "timetable.pdf" |
|---|
| 712 | ## pdf = TimeTablePlain(self._target,self.getAW(), |
|---|
| 713 | ## showSessions=self._showSessions,showDays=self._showDays, |
|---|
| 714 | ## sortingCrit=self._sortingCrit, ttPDFFormat=ttPDFFormat, |
|---|
| 715 | ## pagesize = self._pagesize, fontsize = self._fontsize, firstPageNumber = self._firstPageNumber, tz=tz) |
|---|
| 716 | ## else: |
|---|
| 717 | ## filename = "SimplifiedTimetable.pdf" |
|---|
| 718 | ## pdf = SimplifiedTimeTablePlain(self._target,self.getAW(), |
|---|
| 719 | ## showSessions=self._showSessions,showDays=self._showDays, |
|---|
| 720 | ## sortingCrit=self._sortingCrit, ttPDFFormat=ttPDFFormat, |
|---|
| 721 | ## pagesize = self._pagesize, fontsize = self._fontsize, tz=tz) |
|---|
| 722 | ## try: |
|---|
| 723 | ## data=pdf.getPDFBin() |
|---|
| 724 | ## tries = 0 |
|---|
| 725 | ## except LayoutError, e: |
|---|
| 726 | ## if self._reduceFontSize(): |
|---|
| 727 | ## tries -= 1 |
|---|
| 728 | ## else: |
|---|
| 729 | ## tries = 0 |
|---|
| 730 | ## raise MaKaCError(str(e)) |
|---|
| 731 | |
|---|
| 732 | self._req.headers_out["Content-Length"] = "%s"%len(data) |
|---|
| 733 | cfg=Config.getInstance() |
|---|
| 734 | mimetype=cfg.getFileTypeMimeType("PDF") |
|---|
| 735 | self._req.content_type = """%s"""%(mimetype) |
|---|
| 736 | self._req.headers_out["Content-Disposition"]="""inline; filename="%s\""""%filename |
|---|
| 737 | return data |
|---|
| 738 | |
|---|
| 739 | class RHTimeTableCustomizePDF(RHConferenceTimeTable): |
|---|
| 740 | |
|---|
| 741 | def _checkParams(self,params): |
|---|
| 742 | RHConferenceTimeTable._checkParams(self,params) |
|---|
| 743 | self._cancel = params.has_key("cancel") |
|---|
| 744 | self._view = params.get("view", "standard") |
|---|
| 745 | |
|---|
| 746 | def _process(self): |
|---|
| 747 | # TODO: why not construct p this way only if wf == None? |
|---|
| 748 | p=conferences.WPTimeTableCustomizePDF(self, self._target) |
|---|
| 749 | wf = self.getWebFactory() |
|---|
| 750 | if wf != None: |
|---|
| 751 | p=wf.getTimeTableCustomizePDF(self, self._target, self._view) |
|---|
| 752 | return p.display(**self._getRequestParams()) |
|---|
| 753 | |
|---|
| 754 | |
|---|
| 755 | class _HideWithdrawnFilterField(filters.FilterField): |
|---|
| 756 | """ |
|---|
| 757 | """ |
|---|
| 758 | _id = "hide_withdrawn" |
|---|
| 759 | |
|---|
| 760 | def __init__(self,conf,values): |
|---|
| 761 | pass |
|---|
| 762 | |
|---|
| 763 | def satisfies(self,contribution): |
|---|
| 764 | """ |
|---|
| 765 | """ |
|---|
| 766 | return not isinstance(contribution.getCurrentStatus(),conference.ContribStatusWithdrawn) |
|---|
| 767 | |
|---|
| 768 | |
|---|
| 769 | class ContributionsFilterCrit(filters.FilterCriteria): |
|---|
| 770 | _availableFields = { \ |
|---|
| 771 | contribFilters.TypeFilterField.getId():contribFilters.TypeFilterField, \ |
|---|
| 772 | contribFilters.TrackFilterField.getId():contribFilters.TrackFilterField, \ |
|---|
| 773 | contribFilters.SessionFilterField.getId():contribFilters.SessionFilterField, \ |
|---|
| 774 | _HideWithdrawnFilterField.getId(): _HideWithdrawnFilterField |
|---|
| 775 | } |
|---|
| 776 | |
|---|
| 777 | |
|---|
| 778 | class RHContributionList( RHConferenceBaseDisplay ): |
|---|
| 779 | _uh = urlHandlers.UHContributionList |
|---|
| 780 | |
|---|
| 781 | def _checkParams( self, params ): |
|---|
| 782 | RHConferenceBaseDisplay._checkParams( self, params ) |
|---|
| 783 | # Sorting |
|---|
| 784 | self._sortingCrit=contribFilters.SortingCriteria( [params.get( "sortBy", "number").strip()] ) |
|---|
| 785 | self._order = params.get("order","down") |
|---|
| 786 | # Filtering |
|---|
| 787 | filterUsed = params.has_key( "OK" ) # this variable is true when the |
|---|
| 788 | # filter has been used |
|---|
| 789 | filter = {"hide_withdrawn": True} |
|---|
| 790 | ltypes = [] |
|---|
| 791 | if not filterUsed: |
|---|
| 792 | for type in self._conf.getContribTypeList(): |
|---|
| 793 | ltypes.append( type.getId() ) |
|---|
| 794 | else: |
|---|
| 795 | for id in self._normaliseListParam( params.get("selTypes", []) ): |
|---|
| 796 | ltypes.append(id) |
|---|
| 797 | filter["type"] = ltypes |
|---|
| 798 | |
|---|
| 799 | ltracks = [] |
|---|
| 800 | if not filterUsed: |
|---|
| 801 | for track in self._conf.getTrackList(): |
|---|
| 802 | ltracks.append( track.getId() ) |
|---|
| 803 | filter["track"] = self._normaliseListParam( params.get("selTracks", ltracks) ) |
|---|
| 804 | |
|---|
| 805 | lsessions = [] |
|---|
| 806 | if not filterUsed: |
|---|
| 807 | for session in self._conf.getSessionList(): |
|---|
| 808 | lsessions.append( session.getId() ) |
|---|
| 809 | filter["session"] = self._normaliseListParam( params.get("selSessions", lsessions) ) |
|---|
| 810 | |
|---|
| 811 | self._filterCrit=ContributionsFilterCrit(self._conf,filter) |
|---|
| 812 | typeShowNoValue, trackShowNoValue, sessionShowNoValue = True, True, True |
|---|
| 813 | if filterUsed: |
|---|
| 814 | if self._conf.getContribTypeList(): |
|---|
| 815 | typeShowNoValue = params.has_key("typeShowNoValue") |
|---|
| 816 | if self._conf.getTrackList(): |
|---|
| 817 | trackShowNoValue = params.has_key("trackShowNoValue") |
|---|
| 818 | if self._conf.getSessionList(): |
|---|
| 819 | sessionShowNoValue = params.has_key("sessionShowNoValue") |
|---|
| 820 | self._filterCrit.getField("type").setShowNoValue( typeShowNoValue ) |
|---|
| 821 | self._filterCrit.getField("track").setShowNoValue( trackShowNoValue ) |
|---|
| 822 | self._filterCrit.getField("session").setShowNoValue( sessionShowNoValue ) |
|---|
| 823 | self._sc=params.get("sc",1) |
|---|
| 824 | self._nc=params.get("nc",20) |
|---|
| 825 | |
|---|
| 826 | |
|---|
| 827 | def _process( self ): |
|---|
| 828 | p = conferences.WPContributionList( self, self._target ) |
|---|
| 829 | return p.display(sortingCrit = self._sortingCrit, filterCrit = self._filterCrit, sc=self._sc, nc=self._nc, order=self._order) |
|---|
| 830 | |
|---|
| 831 | |
|---|
| 832 | class RHAuthorIndex(RHConferenceBaseDisplay): |
|---|
| 833 | _uh=urlHandlers.UHConfAuthorIndex |
|---|
| 834 | |
|---|
| 835 | def _checkParams( self, params ): |
|---|
| 836 | RHConferenceBaseDisplay._checkParams( self, params ) |
|---|
| 837 | self._view=params.get("view","full") |
|---|
| 838 | self._letter=params.get("letter","a") |
|---|
| 839 | |
|---|
| 840 | def _process(self): |
|---|
| 841 | p=conferences.WPAuthorIndex(self,self._target) |
|---|
| 842 | return p.display(viewMode=self._view,selLetter=self._letter) |
|---|
| 843 | |
|---|
| 844 | class RHSpeakerIndex(RHConferenceBaseDisplay): |
|---|
| 845 | _uh=urlHandlers.UHConfAuthorIndex |
|---|
| 846 | |
|---|
| 847 | def _checkParams( self, params ): |
|---|
| 848 | RHConferenceBaseDisplay._checkParams( self, params ) |
|---|
| 849 | self._view=params.get("view","full") |
|---|
| 850 | self._letter=params.get("letter","a") |
|---|
| 851 | |
|---|
| 852 | def _process(self): |
|---|
| 853 | p=conferences.WPSpeakerIndex(self,self._target) |
|---|
| 854 | return p.display(viewMode=self._view,selLetter=self._letter) |
|---|
| 855 | |
|---|
| 856 | class RHMyStuff(RHConferenceBaseDisplay,base.RHProtected): |
|---|
| 857 | _uh=urlHandlers.UHConfMyStuff |
|---|
| 858 | |
|---|
| 859 | def _checkProtection(self): |
|---|
| 860 | base.RHProtected._checkProtection(self) |
|---|
| 861 | |
|---|
| 862 | def _process(self): |
|---|
| 863 | p=conferences.WPMyStuff(self,self._target) |
|---|
| 864 | return p.display() |
|---|
| 865 | |
|---|
| 866 | |
|---|
| 867 | class RHContribsActions: |
|---|
| 868 | """ |
|---|
| 869 | class to select the action to do with the selected abstracts |
|---|
| 870 | """ |
|---|
| 871 | def __init__(self, req): |
|---|
| 872 | self._req = req |
|---|
| 873 | |
|---|
| 874 | def process(self, params): |
|---|
| 875 | if params.has_key("PDF"): |
|---|
| 876 | return RHContributionListToPDF(self._req).process(params) |
|---|
| 877 | return "no action to do" |
|---|
| 878 | |
|---|
| 879 | class RHContributionListToPDF(RHConferenceBaseDisplay): |
|---|
| 880 | |
|---|
| 881 | def _checkParams( self, params ): |
|---|
| 882 | RHConferenceBaseDisplay._checkParams( self, params ) |
|---|
| 883 | self._contribIds = self._normaliseListParam( params.get("contributions", []) ) |
|---|
| 884 | self._contribs = [] |
|---|
| 885 | for id in self._contribIds: |
|---|
| 886 | contrib = self._conf.getContributionById(id) |
|---|
| 887 | if contrib.canAccess(self.getAW()): |
|---|
| 888 | self._contribs.append(contrib) |
|---|
| 889 | |
|---|
| 890 | def _process( self ): |
|---|
| 891 | tz = timezoneUtils.DisplayTZ(self._aw,self._conf).getDisplayTZ() |
|---|
| 892 | filename = "Contributions.pdf" |
|---|
| 893 | if not self._contribs: |
|---|
| 894 | return "No contributions to print" |
|---|
| 895 | from MaKaC.PDFinterface.conference import ConfManagerContribsToPDF |
|---|
| 896 | pdf = ConfManagerContribsToPDF(self._conf, self._contribs, tz=tz) |
|---|
| 897 | data = pdf.getPDFBin() |
|---|
| 898 | self._req.set_content_length(len(data)) |
|---|
| 899 | cfg = Config.getInstance() |
|---|
| 900 | mimetype = cfg.getFileTypeMimeType( "PDF" ) |
|---|
| 901 | self._req.content_type = """%s"""%(mimetype) |
|---|
| 902 | self._req.headers_out["Content-Disposition"] = """inline; filename="%s\""""%filename |
|---|
| 903 | return data |
|---|
| 904 | |
|---|
| 905 | |
|---|
| 906 | class RHConferenceMenuClose(RHConferenceBaseDisplay): |
|---|
| 907 | |
|---|
| 908 | def _checkParams( self, params ): |
|---|
| 909 | RHConferenceBaseDisplay._checkParams( self, params ) |
|---|
| 910 | self._currentURL = params.get("currentURL","") |
|---|
| 911 | |
|---|
| 912 | def _process( self ): |
|---|
| 913 | websession = self._getSession() |
|---|
| 914 | websession.setVar("menuStatus", "close") |
|---|
| 915 | self._redirect(self._currentURL) |
|---|
| 916 | |
|---|
| 917 | |
|---|
| 918 | class RHConferenceMenuOpen(RHConferenceBaseDisplay): |
|---|
| 919 | |
|---|
| 920 | def _checkParams( self, params ): |
|---|
| 921 | RHConferenceBaseDisplay._checkParams( self, params ) |
|---|
| 922 | self._currentURL = params.get("currentURL","") |
|---|
| 923 | |
|---|
| 924 | def _process( self ): |
|---|
| 925 | websession = self._getSession() |
|---|
| 926 | websession.setVar("menuStatus", "open") |
|---|
| 927 | self._redirect(self._currentURL) |
|---|
| 928 | |
|---|
| 929 | |
|---|
| 930 | class RHAbstractBook(RHConferenceBaseDisplay): |
|---|
| 931 | _uh=urlHandlers.UHConfAbstractBook |
|---|
| 932 | |
|---|
| 933 | def _checkProtection( self ): |
|---|
| 934 | RHConferenceBaseDisplay._checkProtection(self) |
|---|
| 935 | if not self._conf.hasEnabledSection("cfa"): |
|---|
| 936 | raise MaKaCError( _("The Call For Abstracts was disabled by the conference managers")) |
|---|
| 937 | |
|---|
| 938 | def _process( self ): |
|---|
| 939 | p=conferences.WPAbstractBookCustomise(self,self._target) |
|---|
| 940 | return p.display() |
|---|
| 941 | |
|---|
| 942 | class RHAbstractBookPerform(RHConferenceBaseDisplay): |
|---|
| 943 | _uh=urlHandlers.UHConfAbstractBook |
|---|
| 944 | |
|---|
| 945 | def _checkParams( self, params ): |
|---|
| 946 | RHConferenceBaseDisplay._checkParams( self, params ) |
|---|
| 947 | self._sortBy = params.get("sortBy","") |
|---|
| 948 | |
|---|
| 949 | def _process( self ): |
|---|
| 950 | tz = timezoneUtils.DisplayTZ(self._aw,self._target).getDisplayTZ() |
|---|
| 951 | filename = "%s - Book of abstracts.pdf"%cleanHTMLHeaderFilename(self._target.getTitle()) |
|---|
| 952 | from MaKaC.PDFinterface.conference import AbstractBook |
|---|
| 953 | pdf = AbstractBook(self._target,self.getAW(), self._sortBy, tz=tz) |
|---|
| 954 | data = pdf.getPDFBin() |
|---|
| 955 | self._req.headers_out["Content-Length"] = "%s"%len(data) |
|---|
| 956 | cfg = Config.getInstance() |
|---|
| 957 | mimetype = cfg.getFileTypeMimeType( "PDF" ) |
|---|
| 958 | self._req.content_type = """%s"""%(mimetype) |
|---|
| 959 | self._req.headers_out["Content-Disposition"] = """inline; filename="%s\""""%filename |
|---|
| 960 | return data |
|---|
| 961 | |
|---|
| 962 | |
|---|
| 963 | class RHConfParticipantsNewPending(RHConferenceBaseDisplay): |
|---|
| 964 | _uh = urlHandlers.UHConfParticipantsNewPending |
|---|
| 965 | |
|---|
| 966 | def _process( self ): |
|---|
| 967 | params = self._getRequestParams() |
|---|
| 968 | |
|---|
| 969 | errorList = [] |
|---|
| 970 | if self._conf.getStartDate() < timezoneUtils.nowutc() : |
|---|
| 971 | errorList.append("This event began on %s"%self._conf.getStartDate()) |
|---|
| 972 | errorList.append("You cannot apply for participation after the event began") |
|---|
| 973 | url = urlHandlers.UHConferenceDisplay.getURL( self._conf ) |
|---|
| 974 | url.addParam("errorMsg", errorList) |
|---|
| 975 | self._redirect(url) |
|---|
| 976 | |
|---|
| 977 | if not self._conf.getParticipation().isAllowedForApplying() : |
|---|
| 978 | errorList.append("Participation in this event is restricted to persons invited") |
|---|
| 979 | errorList.append("If you insist on taking part in this event, please contact the event manager") |
|---|
| 980 | url = urlHandlers.UHConferenceDisplay.getURL( self._conf ) |
|---|
| 981 | url.addParam("errorMsg", errorList) |
|---|
| 982 | self._redirect(url) |
|---|
| 983 | |
|---|
| 984 | |
|---|
| 985 | params["formAction"] = str(urlHandlers.UHConfParticipantsAddPending.getURL(self._conf)) |
|---|
| 986 | user = self._getUser() |
|---|
| 987 | if user is not None : |
|---|
| 988 | params["titleValue"] = user.getTitle() |
|---|
| 989 | params["surNameValue"] = user.getFamilyName() |
|---|
| 990 | params["nameValue"] = user.getName() |
|---|
| 991 | params["emailValue"] = user.getEmail() |
|---|
| 992 | params["addressValue"] = user.getAddress() |
|---|
| 993 | params["affiliationValue"] = user.getAffiliation() |
|---|
| 994 | params["phoneValue"] = user.getTelephone() |
|---|
| 995 | params["faxValue"] = user.getFax() |
|---|
| 996 | |
|---|
| 997 | params["disabledTitle"] = params["disabledSurName"] = True |
|---|
| 998 | params["disabledName"] = params["disabledEmail"] = True |
|---|
| 999 | params["disabledAddress"] = params["disabledPhone"] = True |
|---|
| 1000 | params["disabledFax"] = params["disabledAffiliation"] = True |
|---|
| 1001 | |
|---|
| 1002 | |
|---|
| 1003 | wf=self.getWebFactory() |
|---|
| 1004 | if wf is not None: |
|---|
| 1005 | p = wf.getConfModifParticipantsNewPending(self, self._conf) |
|---|
| 1006 | else : |
|---|
| 1007 | p = conferences.WPConfModifParticipantsNewPending( self, self._target ) |
|---|
| 1008 | return p.display(**params) |
|---|
| 1009 | |
|---|
| 1010 | |
|---|
| 1011 | class RHConfParticipantsAddPending(RHConferenceBaseDisplay): |
|---|
| 1012 | _uh = urlHandlers.UHConfParticipantsAddPending |
|---|
| 1013 | |
|---|
| 1014 | def _process( self ): |
|---|
| 1015 | params = self._getRequestParams() |
|---|
| 1016 | errorList = [] |
|---|
| 1017 | infoList = [] |
|---|
| 1018 | if params.has_key("ok") : |
|---|
| 1019 | user = self._getUser() |
|---|
| 1020 | pending = Participant(self._conf, user) |
|---|
| 1021 | if user is None : |
|---|
| 1022 | pending.setTitle(params.get("title","")) |
|---|
| 1023 | pending.setFamilyName(params.get("surName","")) |
|---|
| 1024 | pending.setFirstName(params.get("name","")) |
|---|
| 1025 | pending.setEmail(params.get("email","")) |
|---|
| 1026 | pending.setAffiliation(params.get("affiliation","")) |
|---|
| 1027 | pending.setAddress(params.get("address","")) |
|---|
| 1028 | pending.setTelephone(params.get("phone","")) |
|---|
| 1029 | pending.setFax(params.get("fax","")) |
|---|
| 1030 | participation = self._conf.getParticipation() |
|---|
| 1031 | if participation.alreadyParticipating(pending) != 0: |
|---|
| 1032 | errorList.append("The participant identified by email '%s' is already in the participants' list" |
|---|
| 1033 | % pending.getEmail()) |
|---|
| 1034 | errorList.append("Please check if you are not already added to the meeting.") |
|---|
| 1035 | else: |
|---|
| 1036 | if participation.addPendingParticipant(pending): |
|---|
| 1037 | infoList.append("The participant identified by email '%s' has been added to the list of pending participants" |
|---|
| 1038 | % pending.getEmail()) |
|---|
| 1039 | else: |
|---|
| 1040 | errorList.append("The participant cannot be added.") |
|---|
| 1041 | |
|---|
| 1042 | url = urlHandlers.UHConferenceDisplay.getURL( self._conf ) |
|---|
| 1043 | url.addParam("errorMsg", errorList) |
|---|
| 1044 | url.addParam("infoMsg", infoList) |
|---|
| 1045 | self._redirect(url) |
|---|
| 1046 | |
|---|
| 1047 | |
|---|
| 1048 | class RHConfParticipantsRefusal(RHConferenceBaseDisplay): |
|---|
| 1049 | _uh = urlHandlers.UHConfParticipantsRefusal |
|---|
| 1050 | |
|---|
| 1051 | def _checkParams( self, params ): |
|---|
| 1052 | RHConferenceBaseDisplay._checkParams(self, params ) |
|---|
| 1053 | self._confirm = params.has_key( "confirm" ) |
|---|
| 1054 | self._cancel = params.has_key( "cancel" ) |
|---|
| 1055 | |
|---|
| 1056 | def _process( self ): |
|---|
| 1057 | params = self._getRequestParams() |
|---|
| 1058 | participantId = params["participantId"] |
|---|
| 1059 | if self._cancel: |
|---|
| 1060 | participant = self._conf.getParticipation().getParticipantById(participantId) |
|---|
| 1061 | url = urlHandlers.UHConferenceDisplay.getURL( self._conf ) |
|---|
| 1062 | self._redirect( url ) |
|---|
| 1063 | elif self._confirm: |
|---|
| 1064 | participant = self._conf.getParticipation().getParticipantById(participantId) |
|---|
| 1065 | participant.setStatusRefused() |
|---|
| 1066 | url = urlHandlers.UHConferenceDisplay.getURL( self._conf ) |
|---|
| 1067 | self._redirect( url ) |
|---|
| 1068 | else: |
|---|
| 1069 | return conferences.WPConfModifParticipantsRefuse( self, self._conf ).display(**params) |
|---|
| 1070 | |
|---|
| 1071 | |
|---|
| 1072 | class RHConfParticipantsInvitation(RHConferenceBaseDisplay): |
|---|
| 1073 | _uh = urlHandlers.UHConfParticipantsInvitation |
|---|
| 1074 | |
|---|
| 1075 | def _checkParams( self, params ): |
|---|
| 1076 | RHConferenceBaseDisplay._checkParams(self, params ) |
|---|
| 1077 | self._confirm = params.has_key( "confirm" ) |
|---|
| 1078 | self._cancel = params.has_key( "cancel" ) |
|---|
| 1079 | |
|---|
| 1080 | def _process( self ): |
|---|
| 1081 | params = self._getRequestParams() |
|---|
| 1082 | participantId = params["participantId"] |
|---|
| 1083 | if self._cancel: |
|---|
| 1084 | participant = self._conf.getParticipation().getParticipantById(participantId) |
|---|
| 1085 | if participant == None: |
|---|
| 1086 | raise NoReportError("It seems you have been withdrawn from the list of invited participants") |
|---|
| 1087 | participant.setStatusRejected() |
|---|
| 1088 | url = urlHandlers.UHConferenceDisplay.getURL( self._conf ) |
|---|
| 1089 | self._redirect( url ) |
|---|
| 1090 | elif self._confirm: |
|---|
| 1091 | participant = self._conf.getParticipation().getParticipantById(participantId) |
|---|
| 1092 | if participant == None: |
|---|
| 1093 | raise NoReportError("It seems you have been withdrawn from the list of invited participants") |
|---|
| 1094 | participant.setStatusAccepted() |
|---|
| 1095 | url = urlHandlers.UHConferenceDisplay.getURL( self._conf ) |
|---|
| 1096 | self._redirect( url ) |
|---|
| 1097 | else: |
|---|
| 1098 | return conferences.WPConfModifParticipantsInvite( self, self._conf ).display(**params) |
|---|
| 1099 | |
|---|
| 1100 | class RHConferenceToiCal(RHConferenceBaseDisplay): |
|---|
| 1101 | |
|---|
| 1102 | def _process( self ): |
|---|
| 1103 | filename = "%s - Event.ics"%cleanHTMLHeaderFilename(self._target.getTitle()) |
|---|
| 1104 | ical = ConferenceToiCal(self._target.getConference()) |
|---|
| 1105 | data = ical.getBody() |
|---|
| 1106 | self._req.headers_out["Content-Length"] = "%s"%len(data) |
|---|
| 1107 | cfg = Config.getInstance() |
|---|
| 1108 | mimetype = cfg.getFileTypeMimeType( "ICAL" ) |
|---|
| 1109 | self._req.content_type = """%s"""%(mimetype) |
|---|
| 1110 | self._req.headers_out["Content-Disposition"] = """inline; filename="%s\""""%filename |
|---|
| 1111 | return data |
|---|
| 1112 | |
|---|
| 1113 | class RHConferenceToXML(RHConferenceBaseDisplay): |
|---|
| 1114 | |
|---|
| 1115 | def _checkParams( self, params ): |
|---|
| 1116 | RHConferenceBaseDisplay._checkParams( self, params ) |
|---|
| 1117 | self._xmltype = params.get("xmltype","standard") |
|---|
| 1118 | |
|---|
| 1119 | def _process( self ): |
|---|
| 1120 | filename = "%s - Event.xml"%cleanHTMLHeaderFilename(self._target.getTitle()) |
|---|
| 1121 | from MaKaC.common.xmlGen import XMLGen |
|---|
| 1122 | from MaKaC.common.output import outputGenerator, XSLTransformer |
|---|
| 1123 | xmlgen = XMLGen() |
|---|
| 1124 | xmlgen.initXml() |
|---|
| 1125 | outgen = outputGenerator(self.getAW(), xmlgen) |
|---|
| 1126 | xmlgen.openTag("event") |
|---|
| 1127 | outgen.confToXML(self._target.getConference(),0,0,1) |
|---|
| 1128 | xmlgen.closeTag("event") |
|---|
| 1129 | basexml = xmlgen.getXml() |
|---|
| 1130 | path = Config.getInstance().getStylesheetsDir() |
|---|
| 1131 | stylepath = "%s.xsl" % (os.path.join(path,self._xmltype)) |
|---|
| 1132 | if self._xmltype != "standard" and os.path.exists(stylepath): |
|---|
| 1133 | try: |
|---|
| 1134 | parser = XSLTransformer(stylepath) |
|---|
| 1135 | data = parser.process(basexml) |
|---|
| 1136 | except: |
|---|
| 1137 | data = "Cannot parse stylesheet: %s" % sys.exc_info()[0] |
|---|
| 1138 | else: |
|---|
| 1139 | data = basexml |
|---|
| 1140 | self._req.headers_out["Content-Length"] = "%s"%len(data) |
|---|
| 1141 | cfg = Config.getInstance() |
|---|
| 1142 | mimetype = cfg.getFileTypeMimeType( "XML" ) |
|---|
| 1143 | self._req.content_type = """%s"""%(mimetype) |
|---|
| 1144 | self._req.headers_out["Content-Disposition"] = """inline; filename="%s\""""%filename |
|---|
| 1145 | return data |
|---|
| 1146 | |
|---|
| 1147 | |
|---|
| 1148 | class RHConferenceToMarcXML(RHConferenceBaseDisplay): |
|---|
| 1149 | |
|---|
| 1150 | def _process( self ): |
|---|
| 1151 | filename = "%s - Event.xml"%cleanHTMLHeaderFilename(self._target.getTitle()) |
|---|
| 1152 | from MaKaC.common.xmlGen import XMLGen |
|---|
| 1153 | from MaKaC.common.output import outputGenerator |
|---|
| 1154 | xmlgen = XMLGen() |
|---|
| 1155 | xmlgen.initXml() |
|---|
| 1156 | outgen = outputGenerator(self.getAW(), xmlgen) |
|---|
| 1157 | xmlgen.openTag("marc:record", [["xmlns:marc","http://www.loc.gov/MARC21/slim"],["xmlns:xsi","http://www.w3.org/2001/XMLSchema-instance"],["xsi:schemaLocation", "http://www.loc.gov/MARC21/slim http://www.loc.gov/standards/marcxml/schema/MARC21slim.xsd"]]) |
|---|
| 1158 | outgen.confToXMLMarc21(self._target.getConference()) |
|---|
| 1159 | xmlgen.closeTag("marc:record") |
|---|
| 1160 | data = xmlgen.getXml() |
|---|
| 1161 | self._req.headers_out["Content-Length"] = "%s"%len(data) |
|---|
| 1162 | cfg = Config.getInstance() |
|---|
| 1163 | mimetype = cfg.getFileTypeMimeType( "XML" ) |
|---|
| 1164 | self._req.content_type = """%s"""%(mimetype) |
|---|
| 1165 | self._req.headers_out["Content-Disposition"] = """inline; filename="%s\""""%filename |
|---|
| 1166 | return data |
|---|
| 1167 | |
|---|
| 1168 | class RHWriteMinutes( RHConferenceBaseDisplay ): |
|---|
| 1169 | |
|---|
| 1170 | def _checkProtection(self): |
|---|
| 1171 | if not self._target.canModify( self.getAW() ): |
|---|
| 1172 | if self._target.getModifKey() != "": |
|---|
| 1173 | raise ModificationError() |
|---|
| 1174 | if self._getUser() == None: |
|---|
| 1175 | self._preserveParams() |
|---|
| 1176 | self._checkSessionUser() |
|---|
| 1177 | else: |
|---|
| 1178 | raise ModificationError() |
|---|
| 1179 | |
|---|
| 1180 | def _preserveParams(self): |
|---|
| 1181 | preservedParams = self._getRequestParams().copy() |
|---|
| 1182 | self._websession.setVar("minutesPreservedParams",preservedParams) |
|---|
| 1183 | |
|---|
| 1184 | def _getPreservedParams(self): |
|---|
| 1185 | params = self._websession.getVar("minutesPreservedParams") |
|---|
| 1186 | if params is None : |
|---|
| 1187 | return {} |
|---|
| 1188 | return params |
|---|
| 1189 | |
|---|
| 1190 | def _removePreservedParams(self): |
|---|
| 1191 | self._websession.setVar("minutesPreservedParams",None) |
|---|
| 1192 | |
|---|
| 1193 | def _checkParams( self, params ): |
|---|
| 1194 | RHConferenceBaseDisplay._checkParams( self, params ) |
|---|
| 1195 | preservedParams = self._getPreservedParams() |
|---|
| 1196 | if preservedParams != {}: |
|---|
| 1197 | params.update(preservedParams) |
|---|
| 1198 | self._removePreservedParams() |
|---|
| 1199 | self._cancel = params.has_key("cancel") |
|---|
| 1200 | self._save = params.has_key("OK") |
|---|
| 1201 | self._compile = params.has_key("compile") |
|---|
| 1202 | self._text = params.get("text", "")#.strip() |
|---|
| 1203 | |
|---|
| 1204 | def _getCompiledMinutes( self ): |
|---|
| 1205 | minutes = [] |
|---|
| 1206 | isHTML = False |
|---|
| 1207 | cList = self._target.getContributionList() |
|---|
| 1208 | cList.sort(sortContributionByDate) |
|---|
| 1209 | for c in cList: |
|---|
| 1210 | if c.getMinutes(): |
|---|
| 1211 | minText = c.getMinutes().getText() |
|---|
| 1212 | minutes.append([c.getTitle(),minText]) |
|---|
| 1213 | if isStringHTML(minText): |
|---|
| 1214 | isHTML = True |
|---|
| 1215 | if isHTML: |
|---|
| 1216 | lb = "<br>" |
|---|
| 1217 | else: |
|---|
| 1218 | lb = "\n" |
|---|
| 1219 | text = "%s (%s)%s" % (self._target.getTitle(), self._target.getStartDate().strftime("%d %b %Y"), lb) |
|---|
| 1220 | part = self._target.getParticipation().getPresentParticipantListText() |
|---|
| 1221 | if part != "": |
|---|
| 1222 | text += "Present: %s%s" % (part,lb) |
|---|
| 1223 | uList = self._target.getChairList() |
|---|
| 1224 | chairs = "" |
|---|
| 1225 | for chair in uList: |
|---|
| 1226 | if chairs != "": |
|---|
| 1227 | chairs += "; " |
|---|
| 1228 | chairs += chair.getFullName() |
|---|
| 1229 | if len(uList) > 0: |
|---|
| 1230 | text += "Chaired by: %s%s%s" % (chairs, lb, lb) |
|---|
| 1231 | for min in minutes: |
|---|
| 1232 | text += "==================%s%s%s==================%s%s%s%s" % (lb,min[0],lb,lb,min[1],lb,lb) |
|---|
| 1233 | return text |
|---|
| 1234 | |
|---|
| 1235 | def _process( self ): |
|---|
| 1236 | wf=self.getWebFactory() |
|---|
| 1237 | if self._compile: |
|---|
| 1238 | minutes = self._target.getMinutes() |
|---|
| 1239 | if not minutes: |
|---|
| 1240 | minutes = self._target.createMinutes() |
|---|
| 1241 | text = self._getCompiledMinutes() |
|---|
| 1242 | minutes.setText( text ) |
|---|
| 1243 | if self._save: |
|---|
| 1244 | minutes = self._target.getMinutes() |
|---|
| 1245 | if not minutes: |
|---|
| 1246 | minutes = self._target.createMinutes() |
|---|
| 1247 | minutes.setText( self._text ) |
|---|
| 1248 | elif not self._cancel: |
|---|
| 1249 | if wf is None: |
|---|
| 1250 | wp = conferences.WPConfDisplayWriteMinutes(self, self._target) |
|---|
| 1251 | else: |
|---|
| 1252 | wp = wf.getConferenceDisplayWriteMinutes( self, self._conf) |
|---|
| 1253 | return wp.display() |
|---|
| 1254 | self._redirect( urlHandlers.UHConferenceDisplay.getURL( self._target ) ) |
|---|
| 1255 | |
|---|
| 1256 | |
|---|
| 1257 | class RHInternalPageDisplay(RHConferenceBaseDisplay): |
|---|
| 1258 | _uh=urlHandlers.UHInternalPageDisplay |
|---|
| 1259 | |
|---|
| 1260 | def _checkParams(self,params): |
|---|
| 1261 | RHConferenceBaseDisplay._checkParams(self,params) |
|---|
| 1262 | if params.has_key("pageId"): |
|---|
| 1263 | pageId=params.get("pageId") |
|---|
| 1264 | intPagesMgr=internalPagesMgr.InternalPagesMgrRegistery().getInternalPagesMgr(self._conf) |
|---|
| 1265 | self._page=intPagesMgr.getPageById(pageId) |
|---|
| 1266 | self._target = self._page |
|---|
| 1267 | if self._page is None: |
|---|
| 1268 | raise MaKaCError( _("The webpage, you are trying to access, does not exist")) |
|---|
| 1269 | else: |
|---|
| 1270 | raise MaKaCError( _("The webpage, you are trying to access, does not exist")) |
|---|
| 1271 | |
|---|
| 1272 | def _checkProtection(self): |
|---|
| 1273 | if not self._conf.canView( self.getAW() ): |
|---|
| 1274 | from MaKaC.conference import Link,LocalFile |
|---|
| 1275 | |
|---|
| 1276 | if self._conf.getAccessKey() != "": |
|---|
| 1277 | raise AccessError() |
|---|
| 1278 | if self._getUser() == None: |
|---|
| 1279 | self._checkSessionUser() |
|---|
| 1280 | else: |
|---|
| 1281 | raise AccessError() |
|---|
| 1282 | |
|---|
| 1283 | def _process( self ): |
|---|
| 1284 | p=conferences.WPInternalPageDisplay(self,self._conf, self._page) |
|---|
| 1285 | return p.display() |
|---|
| 1286 | |
|---|
| 1287 | class RHConferenceLatexPackage(RHConferenceBaseDisplay): |
|---|
| 1288 | |
|---|
| 1289 | def _process( self ): |
|---|
| 1290 | #return "nothing" |
|---|
| 1291 | filename = "%s-BookOfAbstracts.zip"%cleanHTMLHeaderFilename(self._target.getTitle()) |
|---|
| 1292 | zipdata = StringIO.StringIO() |
|---|
| 1293 | zip = zipfile.ZipFile(zipdata, "w") |
|---|
| 1294 | for cont in self._target.getContributionList(): |
|---|
| 1295 | f = [] |
|---|
| 1296 | f.append("""\\section*{%s}"""%cont.getTitle()) |
|---|
| 1297 | f.append(" ") |
|---|
| 1298 | l = [] |
|---|
| 1299 | affil = {} |
|---|
| 1300 | i = 1 |
|---|
| 1301 | for pa in cont.getPrimaryAuthorList(): |
|---|
| 1302 | if pa.getAffiliation() in affil.keys(): |
|---|
| 1303 | num = affil[pa.getAffiliation()] |
|---|
| 1304 | else: |
|---|
| 1305 | affil[pa.getAffiliation()] = i |
|---|
| 1306 | num = i |
|---|
| 1307 | i += 1 |
|---|
| 1308 | |
|---|
| 1309 | l.append("""\\noindent \\underline{%s}$^%d$"""%(pa.getFullName(), num)) |
|---|
| 1310 | |
|---|
| 1311 | for ca in cont.getCoAuthorList(): |
|---|
| 1312 | if ca.getAffiliation() in affil.keys(): |
|---|
| 1313 | num = affil[ca.getAffiliation()] |
|---|
| 1314 | else: |
|---|
| 1315 | affil[ca.getAffiliation()] = i |
|---|
| 1316 | num = i |
|---|
| 1317 | i += 1 |
|---|
| 1318 | l.append("""%s$^%d$"""%(ca.getFullName(), num)) |
|---|
| 1319 | |
|---|
| 1320 | f.append(",\n".join(l)) |
|---|
| 1321 | f.append("\n") |
|---|
| 1322 | l = [] |
|---|
| 1323 | for key in affil.keys(): |
|---|
| 1324 | l.append("""$^%d$%s"""%(affil[key], key)) |
|---|
| 1325 | f.append("\\noindent " + ",\n".join(l)) |
|---|
| 1326 | f.append("\n") |
|---|
| 1327 | f.append("""\\noindent %s"""%cont.getDescription()) |
|---|
| 1328 | zip.writestr("contribution-%s"%cont.getId(), "\n".join(f)) |
|---|
| 1329 | zip.close() |
|---|
| 1330 | data = zipdata.getvalue() |
|---|
| 1331 | zipdata.close() |
|---|
| 1332 | |
|---|
| 1333 | #self._req.headers_out["Accept-Ranges"] = "bytes" |
|---|
| 1334 | self._req.headers_out["Content-Length"] = "%s"%len(data) |
|---|
| 1335 | cfg = Config.getInstance() |
|---|
| 1336 | mimetype = cfg.getFileTypeMimeType( "ZIP" ) |
|---|
| 1337 | #self._req.content_type = """%s; name="%s\""""%(mimetype, filename ) |
|---|
| 1338 | self._req.content_type = """%s"""%(mimetype) |
|---|
| 1339 | self._req.headers_out["Content-Disposition"] = """inline; filename="%s\""""%filename |
|---|
| 1340 | return data |
|---|
| 1341 | |
|---|
| 1342 | |
|---|
| 1343 | class RHFullMaterialPackage(RHConferenceBaseDisplay): |
|---|
| 1344 | _uh=urlHandlers.UHConferenceDisplayMaterialPackage |
|---|
| 1345 | |
|---|
| 1346 | def _checkParams( self, params ): |
|---|
| 1347 | RHConferenceBaseDisplay._checkParams( self, params ) |
|---|
| 1348 | self._errors = params.get("errors","") |
|---|
| 1349 | |
|---|
| 1350 | def _process( self ): |
|---|
| 1351 | |
|---|
| 1352 | wf = self.getWebFactory() |
|---|
| 1353 | if wf!=None : #Event == Meeting/Lecture |
|---|
| 1354 | p = wf.getDisplayFullMaterialPackage(self,self._target) |
|---|
| 1355 | else : #Event == Conference |
|---|
| 1356 | p = conferences.WPDisplayFullMaterialPackage(self,self._target) |
|---|
| 1357 | return p.display(errors=self._errors) |
|---|
| 1358 | |
|---|
| 1359 | |
|---|
| 1360 | |
|---|
| 1361 | |
|---|
| 1362 | class RHFullMaterialPackagePerform(RHConferenceBaseDisplay): |
|---|
| 1363 | _uh=urlHandlers.UHConferenceDisplayMaterialPackagePerform |
|---|
| 1364 | |
|---|
| 1365 | def _checkParams( self, params ): |
|---|
| 1366 | RHConferenceBaseDisplay._checkParams( self, params ) |
|---|
| 1367 | self._days=self._normaliseListParam(params.get("days",[])) |
|---|
| 1368 | self._mainResource = (params.get("mainResource","") != "") |
|---|
| 1369 | self._fromDate = "" |
|---|
| 1370 | fromDay = params.get("fromDay","") |
|---|
| 1371 | fromMonth = params.get("fromMonth","") |
|---|
| 1372 | fromYear = params.get("fromYear","") |
|---|
| 1373 | if fromDay != "" and fromMonth != "" and fromYear != "" and \ |
|---|
| 1374 | fromDay != "dd" and fromMonth != "mm" and fromYear != "yyyy": |
|---|
| 1375 | self._fromDate = "%s %s %s"%(fromDay, fromMonth, fromYear) |
|---|
| 1376 | self._cancel = params.has_key("cancel") |
|---|
| 1377 | self._materialTypes=self._normaliseListParam(params.get("materialType",[])) |
|---|
| 1378 | self._sessionList = self._normaliseListParam(params.get("sessionList",[])) |
|---|
| 1379 | |
|---|
| 1380 | def _process( self ): |
|---|
| 1381 | if not self._cancel: |
|---|
| 1382 | if self._materialTypes != []: |
|---|
| 1383 | p=ConferencePacker(self._conf, self._aw) |
|---|
| 1384 | path=p.pack(self._materialTypes, self._days, self._mainResource, self._fromDate, ZIPFileHandler(),self._sessionList) |
|---|
| 1385 | filename = "full-material.zip" |
|---|
| 1386 | cfg = Config.getInstance() |
|---|
| 1387 | mimetype = cfg.getFileTypeMimeType( "ZIP" ) |
|---|
| 1388 | self._req.content_type = """%s"""%(mimetype) |
|---|
| 1389 | self._req.headers_out["Content-Disposition"] = """inline; filename="%s\""""%filename |
|---|
| 1390 | self._req.sendfile(path) |
|---|
| 1391 | else: |
|---|
| 1392 | url = urlHandlers.UHConferenceDisplayMaterialPackage.getURL(self._conf) |
|---|
| 1393 | url.addParam("errors", "You have to select at least one material type") |
|---|
| 1394 | self._redirect( url ) |
|---|
| 1395 | else: |
|---|
| 1396 | self._redirect( urlHandlers.UHConferenceDisplay.getURL( self._conf ) ) |
|---|
| 1397 | |
|---|
| 1398 | |
|---|
| 1399 | class RHShortURLRedirect(RH): |
|---|
| 1400 | |
|---|
| 1401 | def _checkParams( self, params ): |
|---|
| 1402 | self._tag = params.get("tag", "").strip() |
|---|
| 1403 | |
|---|
| 1404 | def _process(self): |
|---|
| 1405 | from MaKaC.conference import ConferenceHolder |
|---|
| 1406 | ch = ConferenceHolder() |
|---|
| 1407 | from MaKaC.common.url import ShortURLMapper |
|---|
| 1408 | sum = ShortURLMapper() |
|---|
| 1409 | if ch.hasKey(self._tag): |
|---|
| 1410 | conf = ch.getById(self._tag) |
|---|
| 1411 | self._redirect(urlHandlers.UHConferenceDisplay.getURL(conf)) |
|---|
| 1412 | elif sum.hasKey(self._tag): |
|---|
| 1413 | conf = sum.getById(self._tag) |
|---|
| 1414 | self._redirect(urlHandlers.UHConferenceDisplay.getURL(conf)) |
|---|
| 1415 | else: |
|---|
| 1416 | raise MaKaCError("Bad event tag or Id : \"%s\""%self._tag) |
|---|
| 1417 | |
|---|