| 1 | # -*- coding: utf-8 -*- |
|---|
| 2 | ## |
|---|
| 3 | ## $Id: contribMod.py,v 1.71 2009/06/04 12:07:13 cangelov 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 | import MaKaC.webinterface.locators as locators |
|---|
| 23 | import MaKaC.webinterface.urlHandlers as urlHandlers |
|---|
| 24 | import MaKaC.webinterface.materialFactories as materialFactories |
|---|
| 25 | import MaKaC.webinterface.pages.contributions as contributions |
|---|
| 26 | import MaKaC.conference as conference |
|---|
| 27 | import MaKaC.user as user |
|---|
| 28 | import MaKaC.domain as domain |
|---|
| 29 | import MaKaC.webinterface.webFactoryRegistry as webFactoryRegistry |
|---|
| 30 | from MaKaC.webinterface.rh.base import RHModificationBaseProtected |
|---|
| 31 | from MaKaC.common.xmlGen import XMLGen |
|---|
| 32 | from MaKaC.common.utils import parseDateTime |
|---|
| 33 | from MaKaC.common import Config |
|---|
| 34 | from MaKaC.webinterface.rh.conferenceBase import RHSubmitMaterialBase |
|---|
| 35 | from MaKaC.webinterface.rh.base import RoomBookingDBMixin |
|---|
| 36 | from MaKaC.PDFinterface.conference import ConfManagerContribToPDF |
|---|
| 37 | from MaKaC.errors import FormValuesError |
|---|
| 38 | from MaKaC.conference import SubContribParticipation |
|---|
| 39 | from MaKaC.errors import MaKaCError |
|---|
| 40 | from MaKaC.i18n import _ |
|---|
| 41 | from MaKaC.webinterface.pages.conferences import WPConferenceModificationClosed |
|---|
| 42 | |
|---|
| 43 | class RHContribModifBase(RHModificationBaseProtected): |
|---|
| 44 | """ Base RH for contribution modification. |
|---|
| 45 | Sets the _target (the contribution) and the _conf (the conference) |
|---|
| 46 | """ |
|---|
| 47 | |
|---|
| 48 | def _checkParams(self, params): |
|---|
| 49 | l = locators.WebLocator() |
|---|
| 50 | l.setContribution(params) |
|---|
| 51 | self._target = l.getObject() |
|---|
| 52 | self._conf = self._target.getConference() |
|---|
| 53 | |
|---|
| 54 | def getWebFactory(self): |
|---|
| 55 | wr = webFactoryRegistry.WebFactoryRegistry() |
|---|
| 56 | self._wf = wr.getFactory(self._target.getConference()) |
|---|
| 57 | return self._wf |
|---|
| 58 | |
|---|
| 59 | class RCSessionCoordinator(object): |
|---|
| 60 | @staticmethod |
|---|
| 61 | def hasRights(request): |
|---|
| 62 | """ Returns true if the user is a Session Coordinator |
|---|
| 63 | """ |
|---|
| 64 | if request._target.getSession() != None: |
|---|
| 65 | return request._target.getSession().canCoordinate(request.getAW(), "modifContribs") |
|---|
| 66 | else: |
|---|
| 67 | return False |
|---|
| 68 | |
|---|
| 69 | class RCContributionPaperReviewingStaff(object): |
|---|
| 70 | |
|---|
| 71 | @staticmethod |
|---|
| 72 | def hasRights(request): |
|---|
| 73 | """ Returns true if the user is a PRM, or a Referee / Editor / Reviewer of the target contribution |
|---|
| 74 | """ |
|---|
| 75 | user = request.getAW().getUser() |
|---|
| 76 | confReview = request._target.getConference().getConfReview() |
|---|
| 77 | confReviewChoice = confReview.getChoice() |
|---|
| 78 | reviewManager = request._target.getReviewManager() |
|---|
| 79 | return (confReview.isPaperReviewManager(user) or \ |
|---|
| 80 | (reviewManager.hasReferee() and reviewManager.isReferee(user)) or \ |
|---|
| 81 | ((confReviewChoice == 3 or confReviewChoice == 4) and reviewManager.hasEditor() and reviewManager.isEditor(user)) or \ |
|---|
| 82 | ((confReviewChoice == 2 or confReviewChoice == 4) and request._target.getReviewManager().isReviewer(user))) |
|---|
| 83 | |
|---|
| 84 | class RCContributionReferee(object): |
|---|
| 85 | @staticmethod |
|---|
| 86 | def hasRights(request): |
|---|
| 87 | """ Returns true if the user is a referee of the target contribution |
|---|
| 88 | """ |
|---|
| 89 | user = request.getAW().getUser() |
|---|
| 90 | reviewManager = request._target.getReviewManager() |
|---|
| 91 | return reviewManager.hasReferee() and reviewManager.isReferee(user) |
|---|
| 92 | |
|---|
| 93 | class RCContributionEditor(object): |
|---|
| 94 | @staticmethod |
|---|
| 95 | def hasRights(request): |
|---|
| 96 | """ Returns true if the user is an editor of the target contribution |
|---|
| 97 | """ |
|---|
| 98 | |
|---|
| 99 | user = request.getAW().getUser() |
|---|
| 100 | reviewManager = request._target.getReviewManager() |
|---|
| 101 | return reviewManager.hasEditor() and reviewManager.isEditor(user) |
|---|
| 102 | |
|---|
| 103 | class RCContributionReviewer(object): |
|---|
| 104 | @staticmethod |
|---|
| 105 | def hasRights(request): |
|---|
| 106 | """ Returns true if the user is a reviewer of the target contribution |
|---|
| 107 | """ |
|---|
| 108 | user = request.getAW().getUser() |
|---|
| 109 | reviewManager = request._target.getReviewManager() |
|---|
| 110 | return reviewManager.isReviewer(user) |
|---|
| 111 | |
|---|
| 112 | class RHContribModifBaseSpecialSesCoordRights(RHContribModifBase): |
|---|
| 113 | """ Base class for any RH where a Session Coordinator has the rights to perform the request |
|---|
| 114 | """ |
|---|
| 115 | |
|---|
| 116 | def _checkProtection(self): |
|---|
| 117 | if not RCSessionCoordinator.hasRights(self): |
|---|
| 118 | RHContribModifBase._checkProtection(self) |
|---|
| 119 | |
|---|
| 120 | class RHContribModifBaseReviewingStaffRights(RHContribModifBase): |
|---|
| 121 | """ Base class for any RH where a member of the Paper Reviewing staff |
|---|
| 122 | (a PRM, or a Referee / Editor / Reviewer of the target contribution) |
|---|
| 123 | has the rights to perform the request |
|---|
| 124 | """ |
|---|
| 125 | |
|---|
| 126 | def _checkProtection(self): |
|---|
| 127 | if not RCContributionPaperReviewingStaff.hasRights(self): |
|---|
| 128 | RHContribModifBase._checkProtection(self); |
|---|
| 129 | |
|---|
| 130 | class RHContribModifBaseSpecialSesCoordAndReviewingStaffRights(RHContribModifBase): |
|---|
| 131 | """ Base class for any RH where a member of the Paper Reviewing staff |
|---|
| 132 | (a PRM, or a Referee / Editor / Reviewer of the target contribution), |
|---|
| 133 | OR a Session Coordinator has the rights to perform the request |
|---|
| 134 | """ |
|---|
| 135 | |
|---|
| 136 | def _checkProtection(self): |
|---|
| 137 | if not (RCSessionCoordinator.hasRights(self) or RCContributionPaperReviewingStaff.hasRights(self)): |
|---|
| 138 | RHContribModifBase._checkProtection(self); |
|---|
| 139 | |
|---|
| 140 | |
|---|
| 141 | class RHContributionModification(RHContribModifBaseSpecialSesCoordAndReviewingStaffRights): |
|---|
| 142 | _uh = urlHandlers.UHContributionModification |
|---|
| 143 | |
|---|
| 144 | def _checkParams(self, params): |
|---|
| 145 | RHContribModifBase._checkParams(self, params) |
|---|
| 146 | params["days"] = params.get("day", "all") |
|---|
| 147 | if params.get("day", None) is not None : |
|---|
| 148 | del params["day"] |
|---|
| 149 | |
|---|
| 150 | def _process(self): |
|---|
| 151 | params = self._getRequestParams() |
|---|
| 152 | if self._target.getOwner().isClosed(): |
|---|
| 153 | p = contributions.WPContributionModificationClosed(self, self._target) |
|---|
| 154 | else: |
|---|
| 155 | wf = self.getWebFactory() |
|---|
| 156 | if wf != None: |
|---|
| 157 | p = wf.getContributionModification(self, self._target) |
|---|
| 158 | else: |
|---|
| 159 | p = contributions.WPContributionModification(self, self._target) |
|---|
| 160 | return p.display(**params) |
|---|
| 161 | |
|---|
| 162 | class RHWithdraw(RHContribModifBaseSpecialSesCoordRights): |
|---|
| 163 | _uh=urlHandlers.UHContribModWithdraw |
|---|
| 164 | |
|---|
| 165 | def _checkParams(self, params): |
|---|
| 166 | RHContribModifBase._checkParams(self, params) |
|---|
| 167 | self._action="" |
|---|
| 168 | self._comment="" |
|---|
| 169 | if params.has_key("REACTIVATE"): |
|---|
| 170 | self._action="REACTIVATE" |
|---|
| 171 | elif params.has_key("OK"): |
|---|
| 172 | self._action="WITHDRAW" |
|---|
| 173 | self._comment=params.get("comment", "") |
|---|
| 174 | elif params.has_key("CANCEL"): |
|---|
| 175 | self._action="CANCEL" |
|---|
| 176 | |
|---|
| 177 | def _process(self): |
|---|
| 178 | url=urlHandlers.UHContributionModification.getURL(self._target) |
|---|
| 179 | if self._action=="REACTIVATE": |
|---|
| 180 | self._target.withdraw(self._getUser(), self._comment) |
|---|
| 181 | self._redirect(url) |
|---|
| 182 | return |
|---|
| 183 | elif self._action=="WITHDRAW": |
|---|
| 184 | self._target.withdraw(self._getUser(), self._comment) |
|---|
| 185 | self._redirect(url) |
|---|
| 186 | return |
|---|
| 187 | elif self._action=="CANCEL": |
|---|
| 188 | self._redirect(url) |
|---|
| 189 | return |
|---|
| 190 | p=contributions.WPModWithdraw(self, self._target) |
|---|
| 191 | return p.display() |
|---|
| 192 | |
|---|
| 193 | |
|---|
| 194 | class RHContributionAC(RHContribModifBaseSpecialSesCoordAndReviewingStaffRights): |
|---|
| 195 | _uh = urlHandlers.UHContribModifAC |
|---|
| 196 | |
|---|
| 197 | def _checkParams(self, params): |
|---|
| 198 | RHContribModifBase._checkParams(self, params) |
|---|
| 199 | params["days"] = params.get("day", "all") |
|---|
| 200 | if params.get("day", None) is not None : |
|---|
| 201 | del params["day"] |
|---|
| 202 | |
|---|
| 203 | def _process(self): |
|---|
| 204 | params = self._getRequestParams() |
|---|
| 205 | if self._target.getOwner().isClosed(): |
|---|
| 206 | p = contributions.WPContributionModificationClosed(self, self._target) |
|---|
| 207 | else: |
|---|
| 208 | p = contributions.WPContribModifAC(self, self._target) |
|---|
| 209 | wf = self.getWebFactory() |
|---|
| 210 | if wf != None: |
|---|
| 211 | p = wf.getContribModifAC(self, self._target) |
|---|
| 212 | return p.display(**params) |
|---|
| 213 | |
|---|
| 214 | |
|---|
| 215 | class RHContributionSC(RHContribModifBaseSpecialSesCoordAndReviewingStaffRights): |
|---|
| 216 | _uh = urlHandlers.UHContribModifSubCont |
|---|
| 217 | |
|---|
| 218 | def _checkParams(self, params): |
|---|
| 219 | RHContribModifBase._checkParams(self, params) |
|---|
| 220 | params["days"] = params.get("day", "all") |
|---|
| 221 | if params.get("day", None) is not None : |
|---|
| 222 | del params["day"] |
|---|
| 223 | |
|---|
| 224 | def _process(self): |
|---|
| 225 | params = self._getRequestParams() |
|---|
| 226 | p = contributions.WPContribModifSC(self, self._target) |
|---|
| 227 | wf = self.getWebFactory() |
|---|
| 228 | if wf != None: |
|---|
| 229 | p = wf.getContribModifSC(self, self._target) |
|---|
| 230 | return p.display(**params) |
|---|
| 231 | |
|---|
| 232 | class RHSubContribActions(RHContribModifBaseSpecialSesCoordRights): |
|---|
| 233 | _uh = urlHandlers.UHSubContribActions |
|---|
| 234 | |
|---|
| 235 | def _checkParams(self, params): |
|---|
| 236 | RHContribModifBase._checkParams(self, params) |
|---|
| 237 | self._confirm = params.has_key("confirm") |
|---|
| 238 | self._scIds = self._normaliseListParam(params.get("selSubContribs", [])) |
|---|
| 239 | self._action=None |
|---|
| 240 | if "cancel" in params: |
|---|
| 241 | return |
|---|
| 242 | self._action=[] |
|---|
| 243 | for id in self._scIds: |
|---|
| 244 | sc = self._target.getSubContributionById(id) |
|---|
| 245 | self._action.append(_ActionSubContribDelete(self, self._target, sc)) |
|---|
| 246 | if params.has_key("oldpos") and params["oldpos"]!='': |
|---|
| 247 | self._action = _ActionSubContribMove(self, params['newpos'+params['oldpos']], params['oldpos']) |
|---|
| 248 | |
|---|
| 249 | def _process(self): |
|---|
| 250 | if self._action is not None: |
|---|
| 251 | if isinstance(self._action, list): |
|---|
| 252 | for act in self._action: |
|---|
| 253 | act.perform() |
|---|
| 254 | else: |
|---|
| 255 | self._action.perform() |
|---|
| 256 | self._redirect(urlHandlers.UHContribModifSubCont.getURL(self._target)) |
|---|
| 257 | |
|---|
| 258 | class _ActionSubContribDelete: |
|---|
| 259 | |
|---|
| 260 | def __init__(self, rh, target, sc): |
|---|
| 261 | self._rh = rh |
|---|
| 262 | self._target = target |
|---|
| 263 | self._sc = sc |
|---|
| 264 | |
|---|
| 265 | def perform(self): |
|---|
| 266 | self._target.removeSubContribution(self._sc) |
|---|
| 267 | |
|---|
| 268 | class _ActionSubContribMove: |
|---|
| 269 | |
|---|
| 270 | def __init__(self, rh, newpos, oldpos): |
|---|
| 271 | self._rh = rh |
|---|
| 272 | self._newpos = int(newpos) |
|---|
| 273 | self._oldpos = int(oldpos) |
|---|
| 274 | |
|---|
| 275 | def perform(self): |
|---|
| 276 | scList = self._rh._target.getSubContributionList() |
|---|
| 277 | order = 0 |
|---|
| 278 | movedsubcontrib = scList[self._oldpos] |
|---|
| 279 | del scList[self._oldpos] |
|---|
| 280 | scList.insert(self._newpos, movedsubcontrib) |
|---|
| 281 | self._rh._target.notifyModification() |
|---|
| 282 | |
|---|
| 283 | #for sc in scList: |
|---|
| 284 | # sc.setOrder(scList.index(sc)) |
|---|
| 285 | |
|---|
| 286 | #------------------------------------------------------------------------------------- |
|---|
| 287 | |
|---|
| 288 | class RHContributionAddSC(RHContribModifBaseSpecialSesCoordRights): |
|---|
| 289 | _uh = urlHandlers.UHContribAddSubCont |
|---|
| 290 | |
|---|
| 291 | def _process(self): |
|---|
| 292 | p = contributions.WPContribAddSC(self, self._target) |
|---|
| 293 | params = self._getRequestParams() |
|---|
| 294 | if params.get("recalled", None) is None : |
|---|
| 295 | self._removePreservedParams() |
|---|
| 296 | self._removeDefinedList("presenter") |
|---|
| 297 | params.update(self._getPreservedParams()) |
|---|
| 298 | wf = self.getWebFactory() |
|---|
| 299 | if wf != None: |
|---|
| 300 | p = wf.getContribAddSC(self, self._target) |
|---|
| 301 | |
|---|
| 302 | params["presenterDefined"] = self._getDefinedDisplayList("presenter") |
|---|
| 303 | params["presenterOptions"] = self._getPersonOptions("presenter") |
|---|
| 304 | |
|---|
| 305 | params["days"] = params.get("day", "all") |
|---|
| 306 | if params.get("day", None) is not None : |
|---|
| 307 | del params["day"] |
|---|
| 308 | |
|---|
| 309 | return p.display(**params) |
|---|
| 310 | |
|---|
| 311 | def _getDefinedDisplayList(self, typeName): |
|---|
| 312 | return self._websession.getVar("%sList"%typeName) |
|---|
| 313 | |
|---|
| 314 | def _getPreservedParams(self): |
|---|
| 315 | params = self._websession.getVar("preservedParams") |
|---|
| 316 | if params is None : |
|---|
| 317 | return {} |
|---|
| 318 | return params |
|---|
| 319 | |
|---|
| 320 | def _removePreservedParams(self): |
|---|
| 321 | self._websession.setVar("preservedParams", None) |
|---|
| 322 | |
|---|
| 323 | def _removeDefinedList(self, typeName): |
|---|
| 324 | self._websession.setVar("%sList"%typeName, None) |
|---|
| 325 | |
|---|
| 326 | def _personInDefinedList(self, typeName, person): |
|---|
| 327 | list = self._websession.getVar("%sList"%typeName) |
|---|
| 328 | if list is None : |
|---|
| 329 | return False |
|---|
| 330 | for p in list : |
|---|
| 331 | if person.getFullName()+" "+person.getEmail() == p[0].getFullName()+" "+p[0].getEmail() : |
|---|
| 332 | return True |
|---|
| 333 | return False |
|---|
| 334 | |
|---|
| 335 | def _getPersonOptions(self, typeName): |
|---|
| 336 | html = [] |
|---|
| 337 | names = [] |
|---|
| 338 | text = {} |
|---|
| 339 | html.append("""<option value=""> </option>""") |
|---|
| 340 | for contribution in self._target.getConference().getContributionList() : |
|---|
| 341 | for speaker in contribution.getSpeakerList() : |
|---|
| 342 | name = speaker.getFullNameNoTitle() |
|---|
| 343 | if not name in names and not self._personInDefinedList(typeName, speaker): |
|---|
| 344 | text[name] = """<option value="s%s-%s">%s</option>"""%(contribution.getId(),speaker.getId(),name) |
|---|
| 345 | names.append(name) |
|---|
| 346 | for author in contribution.getAuthorList() : |
|---|
| 347 | name = author.getFullNameNoTitle() |
|---|
| 348 | if not name in names and not self._personInDefinedList(typeName, author): |
|---|
| 349 | text[name] = """<option value="a%s-%s">%s</option>"""%(contribution.getId(),author.getId(),name) |
|---|
| 350 | names.append(name) |
|---|
| 351 | for coauthor in contribution.getCoAuthorList() : |
|---|
| 352 | name = coauthor.getFullNameNoTitle() |
|---|
| 353 | if not name in names and not self._personInDefinedList(typeName, coauthor): |
|---|
| 354 | text[name] = """<option value="c%s-%s">%s</option>"""%(contribution.getId(),coauthor.getId(),name) |
|---|
| 355 | names.append(name) |
|---|
| 356 | names.sort() |
|---|
| 357 | for name in names: |
|---|
| 358 | html.append(text[name]) |
|---|
| 359 | return "".join(html) |
|---|
| 360 | |
|---|
| 361 | |
|---|
| 362 | #------------------------------------------------------------------------------------- |
|---|
| 363 | |
|---|
| 364 | class RHContributionCreateSC(RHContribModifBaseSpecialSesCoordRights): |
|---|
| 365 | _uh = urlHandlers.UHContribCreateSubCont |
|---|
| 366 | |
|---|
| 367 | def _process(self): |
|---|
| 368 | |
|---|
| 369 | params = self._getRequestParams() |
|---|
| 370 | #params.update(self._getPreservedParams()) |
|---|
| 371 | sc = self._target |
|---|
| 372 | """self._target - contribution owning new subcontribution""" |
|---|
| 373 | |
|---|
| 374 | if ("ok" in params): |
|---|
| 375 | sc = self._target.newSubContribution() |
|---|
| 376 | sc.setTitle( params.get("title", "") ) |
|---|
| 377 | sc.setDescription( params.get("description", "") ) |
|---|
| 378 | sc.setKeywords( params.get("keywords", "") ) |
|---|
| 379 | sc.setDuration( params.get("durationHours", ""), \ |
|---|
| 380 | params.get("durationMinutes", "") ) |
|---|
| 381 | sc.setSpeakerText( params.get("speakers", "") ) |
|---|
| 382 | sc.setParent(self._target) |
|---|
| 383 | for presenter in self._getDefinedList("presenter") : |
|---|
| 384 | sc.newSpeaker(presenter[0]) |
|---|
| 385 | |
|---|
| 386 | logInfo = sc.getLogInfo() |
|---|
| 387 | logInfo["subject"] = "Create new subcontribution: %s"%sc.getTitle() |
|---|
| 388 | self._target.getConference().getLogHandler().logAction(logInfo, "Timetable/SubContribution", self._getUser()) |
|---|
| 389 | |
|---|
| 390 | self._removePreservedParams() |
|---|
| 391 | self._removeDefinedList("presenter") |
|---|
| 392 | self._redirect(urlHandlers.UHContribModifSubCont.getURL(sc)) |
|---|
| 393 | elif params.get("performedAction", "") == "New presenter" : |
|---|
| 394 | self._preserveParams(params) |
|---|
| 395 | self._redirect(urlHandlers.UHContribCreateSubContPresenterNew.getURL(self._target)) |
|---|
| 396 | elif params.get("performedAction","") == "Search presenter" : |
|---|
| 397 | self._preserveParams(params) |
|---|
| 398 | self._redirect(urlHandlers.UHContribCreateSubContPresenterSearch.getURL(self._target)) |
|---|
| 399 | elif params.get("performedAction", "") == "Add as presenter" : |
|---|
| 400 | self._preserveParams(params) |
|---|
| 401 | url = urlHandlers.UHContribCreateSubContPersonAdd.getURL(self._target) |
|---|
| 402 | url.addParam("typeName", "presenter") |
|---|
| 403 | url.addParam("orgin", "added") |
|---|
| 404 | self._redirect(url) |
|---|
| 405 | elif params.get("performedAction", "") == "Remove presenters" : |
|---|
| 406 | self._preserveParams(params) |
|---|
| 407 | self._removePersons(params, "presenter") |
|---|
| 408 | url = urlHandlers.UHContribAddSubCont.getURL(self._target) |
|---|
| 409 | url.addParam("recalled", "true") |
|---|
| 410 | self._redirect(url) |
|---|
| 411 | else: |
|---|
| 412 | self._removePreservedParams() |
|---|
| 413 | self._removeDefinedList("presenter") |
|---|
| 414 | self._redirect(urlHandlers.UHContribModifSubCont.getURL(sc)) |
|---|
| 415 | |
|---|
| 416 | def _getPreservedParams(self): |
|---|
| 417 | params = self._websession.getVar("preservedParams") |
|---|
| 418 | if params is None : |
|---|
| 419 | return {} |
|---|
| 420 | return params |
|---|
| 421 | |
|---|
| 422 | def _preserveParams(self, params): |
|---|
| 423 | self._websession.setVar("preservedParams", params) |
|---|
| 424 | |
|---|
| 425 | def _removePreservedParams(self): |
|---|
| 426 | self._websession.setVar("preservedParams", None) |
|---|
| 427 | |
|---|
| 428 | def _getDefinedList(self, typeName): |
|---|
| 429 | definedList = self._websession.getVar("%sList"%typeName) |
|---|
| 430 | if definedList is None : |
|---|
| 431 | return [] |
|---|
| 432 | return definedList |
|---|
| 433 | |
|---|
| 434 | def _setDefinedList(self, definedList, typeName): |
|---|
| 435 | self._websession.setVar("%sList"%typeName, definedList) |
|---|
| 436 | |
|---|
| 437 | def _removeDefinedList(self, typeName): |
|---|
| 438 | self._websession.setVar("%sList"%typeName, None) |
|---|
| 439 | |
|---|
| 440 | def _removePersons(self, params, typeName): |
|---|
| 441 | persons = self._normaliseListParam(params.get("%ss"%typeName, [])) |
|---|
| 442 | definedList = self._getDefinedList(typeName) |
|---|
| 443 | personsToRemove = [] |
|---|
| 444 | for p in persons : |
|---|
| 445 | if int(p) < len(definedList) or int(p) >= 0 : |
|---|
| 446 | personsToRemove.append(definedList[int(p)]) |
|---|
| 447 | for person in personsToRemove : |
|---|
| 448 | definedList.remove(person) |
|---|
| 449 | self._setDefinedList(definedList, typeName) |
|---|
| 450 | |
|---|
| 451 | #------------------------------------------------------------------------------------- |
|---|
| 452 | |
|---|
| 453 | class RHNewSubcontributionPresenterSearch(RHContribModifBaseSpecialSesCoordRights): |
|---|
| 454 | _uh = urlHandlers.UHContribCreateSubContPresenterSearch |
|---|
| 455 | |
|---|
| 456 | def _checkParams(self, params): |
|---|
| 457 | RHContribModifBaseSpecialSesCoordRights._checkParams(self, params) |
|---|
| 458 | |
|---|
| 459 | def _process(self): |
|---|
| 460 | params = self._getRequestParams() |
|---|
| 461 | |
|---|
| 462 | params["newButtonAction"] = str(urlHandlers.UHContribCreateSubContPresenterNew.getURL()) |
|---|
| 463 | addURL = urlHandlers.UHContribCreateSubContPersonAdd.getURL() |
|---|
| 464 | addURL.addParam("orgin", "selected") |
|---|
| 465 | addURL.addParam("typeName", "presenter") |
|---|
| 466 | params["addURL"] = addURL |
|---|
| 467 | p = contributions.WSubContributionCreationPresenterSelect(self, self._target) |
|---|
| 468 | return p.display(**params) |
|---|
| 469 | |
|---|
| 470 | #------------------------------------------------------------------------------------- |
|---|
| 471 | |
|---|
| 472 | class RHNewSubcontributionPresenterNew(RHContribModifBaseSpecialSesCoordRights): |
|---|
| 473 | _uh = urlHandlers.UHContribCreateSubContPresenterNew |
|---|
| 474 | |
|---|
| 475 | def _checkParams(self, params): |
|---|
| 476 | RHContribModifBaseSpecialSesCoordRights._checkParams(self, params) |
|---|
| 477 | |
|---|
| 478 | def _process(self): |
|---|
| 479 | p = contributions.WSubContributionCreationPresenterNew(self, self._target) |
|---|
| 480 | return p.display() |
|---|
| 481 | |
|---|
| 482 | #------------------------------------------------------------------------------------- |
|---|
| 483 | |
|---|
| 484 | class RHNewSubcontributionPersonAdd(RHContribModifBaseSpecialSesCoordRights): |
|---|
| 485 | _uh = urlHandlers.UHContribCreateSubContPersonAdd |
|---|
| 486 | |
|---|
| 487 | def _checkParams(self, params): |
|---|
| 488 | RHContribModifBaseSpecialSesCoordRights._checkParams(self, params) |
|---|
| 489 | self._typeName = params.get("typeName", None) |
|---|
| 490 | if self._typeName is None : |
|---|
| 491 | raise MaKaCError( _("Type name of the person to add is not set.")) |
|---|
| 492 | |
|---|
| 493 | def _process(self): |
|---|
| 494 | params = self._getRequestParams() |
|---|
| 495 | self._errorList = [] |
|---|
| 496 | |
|---|
| 497 | definedList = self._getDefinedList(self._typeName) |
|---|
| 498 | if definedList is None : |
|---|
| 499 | definedList = [] |
|---|
| 500 | |
|---|
| 501 | if params.get("orgin", "") == "new" : |
|---|
| 502 | if params.get("ok", None) is None : |
|---|
| 503 | url = urlHandlers.UHContribAddSubCont.getURL(self._target) |
|---|
| 504 | url.addParam("recalled", "true") |
|---|
| 505 | self._redirect(url) |
|---|
| 506 | return |
|---|
| 507 | else : |
|---|
| 508 | person = SubContribParticipation() |
|---|
| 509 | person.setFirstName(params["name"]) |
|---|
| 510 | person.setFamilyName(params["surName"]) |
|---|
| 511 | person.setEmail(params["email"]) |
|---|
| 512 | person.setAffiliation(params["affiliation"]) |
|---|
| 513 | person.setAddress(params["address"]) |
|---|
| 514 | person.setPhone(params["phone"]) |
|---|
| 515 | person.setTitle(params["title"]) |
|---|
| 516 | person.setFax(params["fax"]) |
|---|
| 517 | if not self._alreadyDefined(person, definedList) : |
|---|
| 518 | definedList.append([person, params.has_key("submissionControl")]) |
|---|
| 519 | else : |
|---|
| 520 | self._errorList.append("%s has been already defined as %s of this session"%(person.getFullName(), self._typeName)) |
|---|
| 521 | |
|---|
| 522 | elif params.get("orgin", "") == "selected": |
|---|
| 523 | selectedList = self._normaliseListParam(self._getRequestParams().get("selectedPrincipals", [])) |
|---|
| 524 | |
|---|
| 525 | for s in selectedList : |
|---|
| 526 | if s[0:8] == "*author*" : |
|---|
| 527 | auths = self._target.getConference().getAuthorIndex() |
|---|
| 528 | selected = auths.getById(s[9:])[0] |
|---|
| 529 | else : |
|---|
| 530 | ph = user.PrincipalHolder() |
|---|
| 531 | selected = ph.getById(s) |
|---|
| 532 | if isinstance(selected, user.Avatar) : |
|---|
| 533 | person = SubContribParticipation() |
|---|
| 534 | person.setDataFromAvatar(selected) |
|---|
| 535 | if not self._alreadyDefined(person, definedList) : |
|---|
| 536 | definedList.append([person, params.has_key("submissionControl")]) |
|---|
| 537 | else : |
|---|
| 538 | self._errorList.append("%s has been already defined as %s of this session"%(person.getFullName(), self._typeName)) |
|---|
| 539 | |
|---|
| 540 | elif isinstance(selected, user.Group) : |
|---|
| 541 | for member in selected.getMemberList() : |
|---|
| 542 | person = SubContribParticipation() |
|---|
| 543 | person.setDataFromAvatar(member) |
|---|
| 544 | if not self._alreadyDefined(person, definedList) : |
|---|
| 545 | definedList.append([person, params.has_key("submissionControl")]) |
|---|
| 546 | else : |
|---|
| 547 | self._errorList.append("%s has been already defined as %s of this session"%(person.getFullName(), self._typeName)) |
|---|
| 548 | else : |
|---|
| 549 | person = SubContribParticipation() |
|---|
| 550 | person.setTitle(selected.getTitle()) |
|---|
| 551 | person.setFirstName(selected.getFirstName()) |
|---|
| 552 | person.setFamilyName(selected.getFamilyName()) |
|---|
| 553 | person.setEmail(selected.getEmail()) |
|---|
| 554 | person.setAddress(selected.getAddress()) |
|---|
| 555 | person.setAffiliation(selected.getAffiliation()) |
|---|
| 556 | person.setPhone(selected.getPhone()) |
|---|
| 557 | person.setFax(selected.getFax()) |
|---|
| 558 | if not self._alreadyDefined(person, definedList) : |
|---|
| 559 | definedList.append([person, params.has_key("submissionControl")]) |
|---|
| 560 | else : |
|---|
| 561 | self._errorList.append("%s has been already defined as %s of this session"%(person.getFullName(), self._typeName)) |
|---|
| 562 | |
|---|
| 563 | elif params.get("orgin", "") == "added" : |
|---|
| 564 | preservedParams = self._getPreservedParams() |
|---|
| 565 | chosen = preservedParams.get("%sChosen"%self._typeName, None) |
|---|
| 566 | if chosen is None or chosen == "" : |
|---|
| 567 | url = urlHandlers.UHContribAddSubCont.getURL(self._target) |
|---|
| 568 | url.addParam("recalled", "true") |
|---|
| 569 | self._redirect(url) |
|---|
| 570 | return |
|---|
| 571 | index = chosen.find("-") |
|---|
| 572 | objectId = chosen[1:index] |
|---|
| 573 | chosenId = chosen[index+1:len(chosen)] |
|---|
| 574 | if chosen[0:1] == "d" : |
|---|
| 575 | object = self._target.getConference().getSessionById(objectId) |
|---|
| 576 | else : |
|---|
| 577 | object = self._target.getConference().getContributionById(objectId) |
|---|
| 578 | chosenPerson = None |
|---|
| 579 | if chosen[0:1] == "s" : |
|---|
| 580 | chosenPerson = object.getSpeakerById(chosenId) |
|---|
| 581 | elif chosen[0:1] == "a" : |
|---|
| 582 | chosenPerson = object.getAuthorById(chosenId) |
|---|
| 583 | elif chosen[0:1] == "c" : |
|---|
| 584 | chosenPerson = object.getCoAuthorById(chosenId) |
|---|
| 585 | elif chosen[0:1] == "d" : |
|---|
| 586 | chosenPerson = object.getConvenerById(chosenId) |
|---|
| 587 | if chosenPerson is None : |
|---|
| 588 | self._redirect(urlHandlers.UHConfModScheduleNewContrib.getURL(self._target)) |
|---|
| 589 | return |
|---|
| 590 | person = SubContribParticipation() |
|---|
| 591 | person.setTitle(chosenPerson.getTitle()) |
|---|
| 592 | person.setFirstName(chosenPerson.getFirstName()) |
|---|
| 593 | person.setFamilyName(chosenPerson.getFamilyName()) |
|---|
| 594 | person.setEmail(chosenPerson.getEmail()) |
|---|
| 595 | person.setAddress(chosenPerson.getAddress()) |
|---|
| 596 | person.setAffiliation(chosenPerson.getAffiliation()) |
|---|
| 597 | person.setPhone(chosenPerson.getPhone()) |
|---|
| 598 | person.setFax(chosenPerson.getFax()) |
|---|
| 599 | if not self._alreadyDefined(person, definedList) : |
|---|
| 600 | definedList.append([person, params.has_key("submissionControl")]) |
|---|
| 601 | else : |
|---|
| 602 | self._errorList.append("%s has been already defined as %s of this session"%(person.getFullName(), self._typeName)) |
|---|
| 603 | else : |
|---|
| 604 | self._redirect(urlHandlers.UHConfModifSchedule.getURL(self._target)) |
|---|
| 605 | return |
|---|
| 606 | preservedParams = self._getPreservedParams() |
|---|
| 607 | preservedParams["errorMsg"] = self._errorList |
|---|
| 608 | self._preserveParams(preservedParams) |
|---|
| 609 | self._websession.setVar("%sList"%self._typeName, definedList) |
|---|
| 610 | |
|---|
| 611 | url = urlHandlers.UHContribAddSubCont.getURL(self._target) |
|---|
| 612 | url.addParam("recalled", "true") |
|---|
| 613 | self._redirect(url) |
|---|
| 614 | |
|---|
| 615 | |
|---|
| 616 | def _getDefinedList(self, typeName): |
|---|
| 617 | definedList = self._websession.getVar("%sList"%typeName) |
|---|
| 618 | if definedList is None : |
|---|
| 619 | return [] |
|---|
| 620 | return definedList |
|---|
| 621 | |
|---|
| 622 | def _alreadyDefined(self, person, definedList): |
|---|
| 623 | if person is None : |
|---|
| 624 | return True |
|---|
| 625 | if definedList is None : |
|---|
| 626 | return False |
|---|
| 627 | fullName = person.getFullName() |
|---|
| 628 | for p in definedList : |
|---|
| 629 | if p[0].getFullName() == fullName : |
|---|
| 630 | return True |
|---|
| 631 | return False |
|---|
| 632 | |
|---|
| 633 | def _getPreservedParams(self): |
|---|
| 634 | params = self._websession.getVar("preservedParams") |
|---|
| 635 | if params is None : |
|---|
| 636 | return {} |
|---|
| 637 | return params |
|---|
| 638 | |
|---|
| 639 | def _preserveParams(self, params): |
|---|
| 640 | self._websession.setVar("preservedParams", params) |
|---|
| 641 | |
|---|
| 642 | def _removePreservedParams(self): |
|---|
| 643 | self._websession.setVar("preservedParams", None) |
|---|
| 644 | |
|---|
| 645 | #------------------------------------------------------------------------------------- |
|---|
| 646 | |
|---|
| 647 | |
|---|
| 648 | #class RHContributionDeleteSC( RHContribModifBase ): |
|---|
| 649 | # _uh = urlHandlers.UHContriDeleteSubCont |
|---|
| 650 | # |
|---|
| 651 | # def _checkParams( self, params ): |
|---|
| 652 | # RHContribModifBase._checkParams( self, params ) |
|---|
| 653 | # self._confirm = params.has_key( "confirm" ) |
|---|
| 654 | # self._cancel = params.has_key( "cancel" ) |
|---|
| 655 | # self._scIds = self._normaliseListParam( params.get("selSubContribs", []) ) |
|---|
| 656 | |
|---|
| 657 | # def _process( self ): |
|---|
| 658 | # for id in self._scIds: |
|---|
| 659 | # sc = self._target.getSubContributionById( id ) |
|---|
| 660 | # self._target.removeSubContribution( sc ) |
|---|
| 661 | # self._redirect( urlHandlers.UHContribModifSubCont.getURL( self._target ) ) |
|---|
| 662 | |
|---|
| 663 | |
|---|
| 664 | class RHContributionUpSC(RHContribModifBaseSpecialSesCoordRights): |
|---|
| 665 | _uh = urlHandlers.UHContribUpSubCont |
|---|
| 666 | |
|---|
| 667 | def _checkParams(self, params): |
|---|
| 668 | RHContribModifBaseSpecialSesCoordRights._checkParams(self, params) |
|---|
| 669 | self._scId = params.get("subContId", "") |
|---|
| 670 | |
|---|
| 671 | def _process(self): |
|---|
| 672 | sc = self._target.getSubContributionById(self._scId) |
|---|
| 673 | self._target.upSubContribution(sc) |
|---|
| 674 | self._redirect(urlHandlers.UHContribModifSubCont.getURL(self._target)) |
|---|
| 675 | |
|---|
| 676 | |
|---|
| 677 | class RHContributionDownSC(RHContribModifBaseSpecialSesCoordRights): |
|---|
| 678 | _uh = urlHandlers.UHContribDownSubCont |
|---|
| 679 | |
|---|
| 680 | def _checkParams(self, params): |
|---|
| 681 | RHContribModifBaseSpecialSesCoordRights._checkParams(self, params) |
|---|
| 682 | self._scId = params.get("subContId", "") |
|---|
| 683 | |
|---|
| 684 | def _process(self): |
|---|
| 685 | sc = self._target.getSubContributionById(self._scId) |
|---|
| 686 | self._target.downSubContribution(sc) |
|---|
| 687 | self._redirect(urlHandlers.UHContribModifSubCont.getURL(self._target)) |
|---|
| 688 | |
|---|
| 689 | |
|---|
| 690 | class RHContributionTools(RHContribModifBaseSpecialSesCoordAndReviewingStaffRights): |
|---|
| 691 | _uh = urlHandlers.UHContribModifTools |
|---|
| 692 | |
|---|
| 693 | def _process(self): |
|---|
| 694 | if self._target.getOwner().isClosed(): |
|---|
| 695 | p = contributions.WPContributionModificationClosed(self, self._target) |
|---|
| 696 | else: |
|---|
| 697 | p = contributions.WPContributionModifTools(self, self._target) |
|---|
| 698 | wf = self.getWebFactory() |
|---|
| 699 | if wf != None: |
|---|
| 700 | p = wf.getContributionModifTools(self, self._target) |
|---|
| 701 | return p.display() |
|---|
| 702 | |
|---|
| 703 | |
|---|
| 704 | class RHContributionData( RoomBookingDBMixin, RHContribModifBaseSpecialSesCoordRights ): |
|---|
| 705 | _uh = urlHandlers.UHContributionDataModif |
|---|
| 706 | |
|---|
| 707 | def _checkParams( self, params ): |
|---|
| 708 | RHContribModifBaseSpecialSesCoordRights._checkParams(self, params) |
|---|
| 709 | |
|---|
| 710 | self._evt = self._target |
|---|
| 711 | |
|---|
| 712 | def _process(self): |
|---|
| 713 | if self._target.getOwner().isClosed(): |
|---|
| 714 | p = contributions.WPContributionModificationClosed(self, self._target) |
|---|
| 715 | else: |
|---|
| 716 | p = contributions.WPEditData(self, self._target) |
|---|
| 717 | wf = self.getWebFactory() |
|---|
| 718 | if wf != None: |
|---|
| 719 | p = wf.getContributionEditData(self, self._target) |
|---|
| 720 | return p.display(**self._getRequestParams()) |
|---|
| 721 | |
|---|
| 722 | |
|---|
| 723 | class RHContributionModifData(RHContribModifBaseSpecialSesCoordRights): |
|---|
| 724 | _uh = urlHandlers.UHContributionDataModification |
|---|
| 725 | |
|---|
| 726 | def _checkParams(self, params): |
|---|
| 727 | RHContribModifBaseSpecialSesCoordRights._checkParams(self, params) |
|---|
| 728 | self._type=None |
|---|
| 729 | self._check = int(params.get("check", 1)) |
|---|
| 730 | if params.has_key("type") and params["type"].strip()!="": |
|---|
| 731 | self._type=self._target.getConference().getContribTypeById(params["type"]) |
|---|
| 732 | self._cancel = params.has_key("cancel") |
|---|
| 733 | |
|---|
| 734 | def _process(self): |
|---|
| 735 | if not self._cancel: |
|---|
| 736 | params = self._getRequestParams() |
|---|
| 737 | |
|---|
| 738 | if params.has_key("dateTime"): |
|---|
| 739 | dateTime = parseDateTime(params["dateTime"]) |
|---|
| 740 | params["sYear"] = dateTime.year |
|---|
| 741 | params["sMonth"] = dateTime.month |
|---|
| 742 | params["sDay"] = dateTime.day |
|---|
| 743 | params["sHour"] = dateTime.hour |
|---|
| 744 | params["sMinute"] = dateTime.minute |
|---|
| 745 | else: |
|---|
| 746 | params["sYear"] = "" |
|---|
| 747 | params["sMonth"] = "" |
|---|
| 748 | params["sDay"] = "" |
|---|
| 749 | params["sHour"] = "" |
|---|
| 750 | params["sMinute"] = "" |
|---|
| 751 | |
|---|
| 752 | if params.has_key("duration"): |
|---|
| 753 | params["durMins"] = params["duration"]; |
|---|
| 754 | else: |
|---|
| 755 | params["durMins"] = "" |
|---|
| 756 | self._target.setValues(params) |
|---|
| 757 | self._target.setType(self._type) |
|---|
| 758 | self._redirect(urlHandlers.UHContributionModification.getURL(self._target)) |
|---|
| 759 | |
|---|
| 760 | |
|---|
| 761 | class RHSearchPrimaryAuthor (RHContribModifBaseSpecialSesCoordRights): |
|---|
| 762 | def _process(self): |
|---|
| 763 | p=contributions.WPModSearchPrimAuthor(self, self._target) |
|---|
| 764 | return p.display(**self._getRequestParams()) |
|---|
| 765 | |
|---|
| 766 | class RHSearchAddPrimaryAuthor (RHContribModifBaseSpecialSesCoordRights): |
|---|
| 767 | |
|---|
| 768 | def _newPrimAuthor(self, a): |
|---|
| 769 | auth = conference.ContributionParticipation() |
|---|
| 770 | p = self._getRequestParams() |
|---|
| 771 | auth.setTitle(a.getTitle()) |
|---|
| 772 | auth.setFirstName(a.getName()) |
|---|
| 773 | auth.setFamilyName(a.getSurName()) |
|---|
| 774 | auth.setAffiliation(a.getOrganisation()) |
|---|
| 775 | auth.setEmail(a.getEmail()) |
|---|
| 776 | auth.setAddress(a.getAddress()) |
|---|
| 777 | auth.setPhone(a.getTelephone()) |
|---|
| 778 | auth.setFax(a.getFax()) |
|---|
| 779 | self._target.addPrimaryAuthor(auth) |
|---|
| 780 | return auth |
|---|
| 781 | |
|---|
| 782 | def _newPrimAuthorFromAuthor(self, a): |
|---|
| 783 | auth = conference.ContributionParticipation() |
|---|
| 784 | p = self._getRequestParams() |
|---|
| 785 | auth.setTitle(a.getTitle()) |
|---|
| 786 | auth.setFirstName(a.getName()) |
|---|
| 787 | auth.setFamilyName(a.getSurName()) |
|---|
| 788 | auth.setAffiliation(a.getAffiliation()) |
|---|
| 789 | auth.setEmail(a.getEmail()) |
|---|
| 790 | auth.setAddress(a.getAddress()) |
|---|
| 791 | auth.setPhone(a.getPhone()) |
|---|
| 792 | auth.setFax(a.getFax()) |
|---|
| 793 | self._target.addPrimaryAuthor(auth) |
|---|
| 794 | return auth |
|---|
| 795 | |
|---|
| 796 | def _process(self): |
|---|
| 797 | params=self._getRequestParams() |
|---|
| 798 | if "selectedPrincipals" in params and not "cancel" in params: |
|---|
| 799 | ah=user.AvatarHolder() |
|---|
| 800 | authIndex = self._target.getConference().getAuthorIndex() |
|---|
| 801 | for id in self._normaliseListParam(params["selectedPrincipals"]): |
|---|
| 802 | if id[:9] == "*author*:": |
|---|
| 803 | id = id[9:] |
|---|
| 804 | auth=self._newPrimAuthorFromAuthor(authIndex.getById(id)[0]) |
|---|
| 805 | else: |
|---|
| 806 | auth=self._newPrimAuthor(ah.getById(id)) |
|---|
| 807 | if self._getRequestParams().has_key("submissionControl"): |
|---|
| 808 | self._target.grantSubmission(auth) |
|---|
| 809 | self._redirect(urlHandlers.UHContributionModification.getURL(self._target)) |
|---|
| 810 | |
|---|
| 811 | class RHSearchCoAuthor (RHContribModifBaseSpecialSesCoordRights): |
|---|
| 812 | def _process(self): |
|---|
| 813 | p=contributions.WPModSearchCoAuthor(self, self._target) |
|---|
| 814 | return p.display(**self._getRequestParams()) |
|---|
| 815 | |
|---|
| 816 | class RHSearchAddCoAuthor (RHContribModifBaseSpecialSesCoordRights): |
|---|
| 817 | |
|---|
| 818 | def _newCoAuthor(self, a): |
|---|
| 819 | auth = conference.ContributionParticipation() |
|---|
| 820 | p = self._getRequestParams() |
|---|
| 821 | auth.setTitle(a.getTitle()) |
|---|
| 822 | auth.setFirstName(a.getName()) |
|---|
| 823 | auth.setFamilyName(a.getSurName()) |
|---|
| 824 | auth.setAffiliation(a.getOrganisation()) |
|---|
| 825 | auth.setEmail(a.getEmail()) |
|---|
| 826 | auth.setAddress(a.getAddress()) |
|---|
| 827 | auth.setPhone(a.getTelephone()) |
|---|
| 828 | auth.setFax(a.getFax()) |
|---|
| 829 | self._target.addCoAuthor(auth) |
|---|
| 830 | return auth |
|---|
| 831 | |
|---|
| 832 | def _newCoAuthorFromAuthor(self, a): |
|---|
| 833 | auth = conference.ContributionParticipation() |
|---|
| 834 | p = self._getRequestParams() |
|---|
| 835 | auth.setTitle(a.getTitle()) |
|---|
| 836 | auth.setFirstName(a.getName()) |
|---|
| 837 | auth.setFamilyName(a.getSurName()) |
|---|
| 838 | auth.setAffiliation(a.getAffiliation()) |
|---|
| 839 | auth.setEmail(a.getEmail()) |
|---|
| 840 | auth.setAddress(a.getAddress()) |
|---|
| 841 | auth.setPhone(a.getPhone()) |
|---|
| 842 | auth.setFax(a.getFax()) |
|---|
| 843 | self._target.addCoAuthor(auth) |
|---|
| 844 | return auth |
|---|
| 845 | |
|---|
| 846 | def _process(self): |
|---|
| 847 | params=self._getRequestParams() |
|---|
| 848 | if "selectedPrincipals" in params and not "cancel" in params: |
|---|
| 849 | ah=user.AvatarHolder() |
|---|
| 850 | authIndex = self._target.getConference().getAuthorIndex() |
|---|
| 851 | for id in self._normaliseListParam(params["selectedPrincipals"]): |
|---|
| 852 | if id[:9] == "*author*:": |
|---|
| 853 | id = id[9:] |
|---|
| 854 | auth=self._newCoAuthorFromAuthor(authIndex.getById(id)[0]) |
|---|
| 855 | else: |
|---|
| 856 | auth=self._newCoAuthor(ah.getById(id)) |
|---|
| 857 | if self._getRequestParams().has_key("submissionControl"): |
|---|
| 858 | self._target.grantSubmission(auth) |
|---|
| 859 | self._redirect(urlHandlers.UHContributionModification.getURL(self._target)) |
|---|
| 860 | |
|---|
| 861 | |
|---|
| 862 | class RHSearchSpeakers (RHContribModifBaseSpecialSesCoordRights): |
|---|
| 863 | def _process(self): |
|---|
| 864 | p=contributions.WPModSearchSpeaker(self, self._target) |
|---|
| 865 | return p.display(**self._getRequestParams()) |
|---|
| 866 | |
|---|
| 867 | class RHSearchAddSpeakers (RHContribModifBaseSpecialSesCoordRights): |
|---|
| 868 | |
|---|
| 869 | def _newSpeaker(self, a): |
|---|
| 870 | auth = conference.ContributionParticipation() |
|---|
| 871 | p = self._getRequestParams() |
|---|
| 872 | auth.setTitle(a.getTitle()) |
|---|
| 873 | auth.setFirstName(a.getName()) |
|---|
| 874 | auth.setFamilyName(a.getSurName()) |
|---|
| 875 | auth.setAffiliation(a.getOrganisation()) |
|---|
| 876 | auth.setEmail(a.getEmail()) |
|---|
| 877 | auth.setAddress(a.getAddress()) |
|---|
| 878 | auth.setPhone(a.getTelephone()) |
|---|
| 879 | auth.setFax(a.getFax()) |
|---|
| 880 | self._target.newSpeaker(auth) |
|---|
| 881 | return auth |
|---|
| 882 | |
|---|
| 883 | def _newSpeakerFromAuthor(self, a): |
|---|
| 884 | auth = conference.ContributionParticipation() |
|---|
| 885 | p = self._getRequestParams() |
|---|
| 886 | auth.setTitle(a.getTitle()) |
|---|
| 887 | auth.setFirstName(a.getName()) |
|---|
| 888 | auth.setFamilyName(a.getSurName()) |
|---|
| 889 | auth.setAffiliation(a.getAffiliation()) |
|---|
| 890 | auth.setEmail(a.getEmail()) |
|---|
| 891 | auth.setAddress(a.getAddress()) |
|---|
| 892 | auth.setPhone(a.getPhone()) |
|---|
| 893 | auth.setFax(a.getFax()) |
|---|
| 894 | self._target.newSpeaker(auth) |
|---|
| 895 | return auth |
|---|
| 896 | |
|---|
| 897 | def _process(self): |
|---|
| 898 | params=self._getRequestParams() |
|---|
| 899 | if "selectedPrincipals" in params and not "cancel" in params: |
|---|
| 900 | ah=user.AvatarHolder() |
|---|
| 901 | authIndex = self._target.getConference().getAuthorIndex() |
|---|
| 902 | for id in self._normaliseListParam(params["selectedPrincipals"]): |
|---|
| 903 | if id[:9] == "*author*:": |
|---|
| 904 | id = id[9:] |
|---|
| 905 | auth=self._newSpeakerFromAuthor(authIndex.getById(id)[0]) |
|---|
| 906 | else: |
|---|
| 907 | auth=self._newSpeaker(ah.getById(id)) |
|---|
| 908 | if self._getRequestParams().has_key("submissionControl"): |
|---|
| 909 | self._target.grantSubmission(auth) |
|---|
| 910 | self._redirect(urlHandlers.UHContributionModification.getURL(self._target)) |
|---|
| 911 | |
|---|
| 912 | class RHNewPrimaryAuthor(RHContribModifBaseSpecialSesCoordRights): |
|---|
| 913 | |
|---|
| 914 | def _checkParams(self, params): |
|---|
| 915 | RHContribModifBaseSpecialSesCoordRights._checkParams(self, params) |
|---|
| 916 | self._action, self._new="", False |
|---|
| 917 | if params.has_key("ok"): |
|---|
| 918 | self._action = "perform" |
|---|
| 919 | elif params.has_key("ok_and_new"): |
|---|
| 920 | self._action = "perform" |
|---|
| 921 | self._new=True |
|---|
| 922 | elif params.has_key("cancel"): |
|---|
| 923 | self._action = "cancel" |
|---|
| 924 | |
|---|
| 925 | def _newPrimAuthor(self): |
|---|
| 926 | auth = conference.ContributionParticipation() |
|---|
| 927 | p = self._getRequestParams() |
|---|
| 928 | auth.setTitle(p.get("title", "")) |
|---|
| 929 | auth.setFirstName(p.get("name", "")) |
|---|
| 930 | auth.setFamilyName(p.get("surName", "")) |
|---|
| 931 | auth.setAffiliation(p.get("affiliation", "")) |
|---|
| 932 | auth.setEmail(p.get("email", "")) |
|---|
| 933 | auth.setAddress(p.get("address", "")) |
|---|
| 934 | auth.setPhone(p.get("phone", "")) |
|---|
| 935 | auth.setFax(p.get("fax", "")) |
|---|
| 936 | self._target.addPrimaryAuthor(auth) |
|---|
| 937 | return auth |
|---|
| 938 | |
|---|
| 939 | |
|---|
| 940 | def _process(self): |
|---|
| 941 | url=urlHandlers.UHContributionModification.getURL(self._target) |
|---|
| 942 | if self._action=="cancel": |
|---|
| 943 | self._redirect(url) |
|---|
| 944 | return |
|---|
| 945 | elif self._action == "perform": |
|---|
| 946 | auth=self._newPrimAuthor() |
|---|
| 947 | if self._getRequestParams().has_key("submissionControl"): |
|---|
| 948 | if self._getRequestParams().get("email", "").strip() == "": |
|---|
| 949 | raise FormValuesError("If you want to add the author as submitter, please enter their email") |
|---|
| 950 | self._target.grantSubmission(auth) |
|---|
| 951 | if not self._new: |
|---|
| 952 | self._redirect(url) |
|---|
| 953 | return |
|---|
| 954 | p = contributions.WPModNewPrimAuthor(self, self._target) |
|---|
| 955 | return p.display() |
|---|
| 956 | |
|---|
| 957 | |
|---|
| 958 | class RHPrimaryAuthorsActions: |
|---|
| 959 | """ |
|---|
| 960 | class to select the action to do with the selected authors |
|---|
| 961 | """ |
|---|
| 962 | def __init__(self, req): |
|---|
| 963 | self._req = req |
|---|
| 964 | |
|---|
| 965 | def process(self, params): |
|---|
| 966 | if params.has_key("REMOVE"): |
|---|
| 967 | return RHRemPrimaryAuthors(self._req).process(params) |
|---|
| 968 | elif params.has_key("MOVE"): |
|---|
| 969 | return RHMovePrimaryToCoAuthors(self._req).process(params) |
|---|
| 970 | return "no action to do" |
|---|
| 971 | |
|---|
| 972 | |
|---|
| 973 | class RHRemPrimaryAuthors(RHContribModifBaseSpecialSesCoordRights): |
|---|
| 974 | def _checkParams(self, params): |
|---|
| 975 | RHContribModifBaseSpecialSesCoordRights._checkParams(self, params) |
|---|
| 976 | self._list = [] |
|---|
| 977 | for id in self._normaliseListParam(params.get("selAuthor", [])): |
|---|
| 978 | self._list.append(self._target.getAuthorById(id)) |
|---|
| 979 | |
|---|
| 980 | def _process(self): |
|---|
| 981 | for auth in self._list: |
|---|
| 982 | self._target.removePrimaryAuthor(auth) |
|---|
| 983 | url=urlHandlers.UHContributionModification.getURL(self._target) |
|---|
| 984 | self._redirect(url) |
|---|
| 985 | |
|---|
| 986 | class RHMovePrimaryToCoAuthors(RHContribModifBaseSpecialSesCoordRights): |
|---|
| 987 | def _checkParams(self, params): |
|---|
| 988 | RHContribModifBaseSpecialSesCoordRights._checkParams(self, params) |
|---|
| 989 | self._list = [] |
|---|
| 990 | for id in self._normaliseListParam(params.get("selAuthor", [])): |
|---|
| 991 | self._list.append(self._target.getAuthorById(id)) |
|---|
| 992 | |
|---|
| 993 | def _process(self): |
|---|
| 994 | for auth in self._list: |
|---|
| 995 | self._target.removePrimaryAuthor(auth, 0, False) |
|---|
| 996 | self._target.addCoAuthor(auth) |
|---|
| 997 | url=urlHandlers.UHContributionModification.getURL(self._target) |
|---|
| 998 | self._redirect(url) |
|---|
| 999 | |
|---|
| 1000 | |
|---|
| 1001 | class RHEditPrimaryAuthor(RHContribModifBaseSpecialSesCoordRights): |
|---|
| 1002 | |
|---|
| 1003 | def _checkParams(self, params): |
|---|
| 1004 | RHContribModifBaseSpecialSesCoordRights._checkParams(self, params) |
|---|
| 1005 | self._authorId=params["authorId"] |
|---|
| 1006 | self._action="" |
|---|
| 1007 | if params.has_key("ok"): |
|---|
| 1008 | self._action = "perform" |
|---|
| 1009 | elif params.has_key("cancel"): |
|---|
| 1010 | self._action = "cancel" |
|---|
| 1011 | |
|---|
| 1012 | def _setPrimAuthorData(self): |
|---|
| 1013 | auth=self._target.getAuthorById(self._authorId) |
|---|
| 1014 | p = self._getRequestParams() |
|---|
| 1015 | auth.setTitle(p.get("title", "")) |
|---|
| 1016 | auth.setFirstName(p.get("name", "")) |
|---|
| 1017 | auth.setFamilyName(p.get("surName", "")) |
|---|
| 1018 | auth.setAffiliation(p.get("affiliation", "")) |
|---|
| 1019 | auth.setAddress(p.get("address", "")) |
|---|
| 1020 | auth.setPhone(p.get("phone", "")) |
|---|
| 1021 | auth.setFax(p.get("fax", "")) |
|---|
| 1022 | |
|---|
| 1023 | grantSubm=False |
|---|
| 1024 | if auth.getEmail().lower().strip() != p.get("email", "").lower().strip(): |
|---|
| 1025 | #----If it's already in the pending queue in order to grant |
|---|
| 1026 | # submission rights we must unindex and after the modification of the email, |
|---|
| 1027 | # index again... |
|---|
| 1028 | if self._target.getConference().getPendingQueuesMgr().isPendingSubmitter(auth): |
|---|
| 1029 | self._target.getConference().getPendingQueuesMgr().removePendingSubmitter(auth) |
|---|
| 1030 | grantSubm=True |
|---|
| 1031 | #----- |
|---|
| 1032 | |
|---|
| 1033 | auth.setEmail(p.get("email", "")) |
|---|
| 1034 | |
|---|
| 1035 | if grantSubm: |
|---|
| 1036 | self._target.grantSubmission(auth) |
|---|
| 1037 | |
|---|
| 1038 | def _process(self): |
|---|
| 1039 | if self._action != "": |
|---|
| 1040 | if self._action == "perform": |
|---|
| 1041 | self._setPrimAuthorData() |
|---|
| 1042 | url=urlHandlers.UHContributionModification.getURL(self._target) |
|---|
| 1043 | self._redirect(url) |
|---|
| 1044 | else: |
|---|
| 1045 | auth=self._target.getAuthorById(self._authorId) |
|---|
| 1046 | p = contributions.WPModPrimAuthor(self, self._target) |
|---|
| 1047 | return p.display(author=auth) |
|---|
| 1048 | |
|---|
| 1049 | |
|---|
| 1050 | class RHNewCoAuthor(RHContribModifBaseSpecialSesCoordRights): |
|---|
| 1051 | |
|---|
| 1052 | def _checkParams(self, params): |
|---|
| 1053 | RHContribModifBaseSpecialSesCoordRights._checkParams(self, params) |
|---|
| 1054 | self._action, self._new="", False |
|---|
| 1055 | if params.has_key("ok"): |
|---|
| 1056 | self._action = "perform" |
|---|
| 1057 | elif params.has_key("ok_and_new"): |
|---|
| 1058 | self._action = "perform" |
|---|
| 1059 | self._new=True |
|---|
| 1060 | elif params.has_key("cancel"): |
|---|
| 1061 | self._action = "cancel" |
|---|
| 1062 | |
|---|
| 1063 | def _newCoAuthor(self): |
|---|
| 1064 | auth = conference.ContributionParticipation() |
|---|
| 1065 | p = self._getRequestParams() |
|---|
| 1066 | auth.setTitle(p.get("title", "")) |
|---|
| 1067 | auth.setFirstName(p.get("name", "")) |
|---|
| 1068 | auth.setFamilyName(p.get("surName", "")) |
|---|
| 1069 | auth.setAffiliation(p.get("affiliation", "")) |
|---|
| 1070 | auth.setEmail(p.get("email", "")) |
|---|
| 1071 | auth.setAddress(p.get("address", "")) |
|---|
| 1072 | auth.setPhone(p.get("phone", "")) |
|---|
| 1073 | auth.setFax(p.get("fax", "")) |
|---|
| 1074 | self._target.addCoAuthor(auth) |
|---|
| 1075 | return auth |
|---|
| 1076 | |
|---|
| 1077 | def _process(self): |
|---|
| 1078 | url=urlHandlers.UHContributionModification.getURL(self._target) |
|---|
| 1079 | if self._action=="cancel": |
|---|
| 1080 | self._redirect(url) |
|---|
| 1081 | return |
|---|
| 1082 | elif self._action=="perform": |
|---|
| 1083 | auth=self._newCoAuthor() |
|---|
| 1084 | if self._getRequestParams().has_key("submissionControl"): |
|---|
| 1085 | if self._getRequestParams().get("email", "").strip() == "": |
|---|
| 1086 | raise FormValuesError("If you want to add the author as submitter, please enter their email") |
|---|
| 1087 | self._target.grantSubmission(auth) |
|---|
| 1088 | if not self._new: |
|---|
| 1089 | self._redirect(url) |
|---|
| 1090 | return |
|---|
| 1091 | p=contributions.WPModNewCoAuthor(self, self._target) |
|---|
| 1092 | return p.display() |
|---|
| 1093 | |
|---|
| 1094 | |
|---|
| 1095 | class RHCoAuthorsActions: |
|---|
| 1096 | """ |
|---|
| 1097 | class to select the action to do with the selected authors |
|---|
| 1098 | """ |
|---|
| 1099 | def __init__(self, req): |
|---|
| 1100 | self._req = req |
|---|
| 1101 | |
|---|
| 1102 | def process(self, params): |
|---|
| 1103 | if params.has_key("REMOVE"): |
|---|
| 1104 | return RHRemCoAuthors(self._req).process(params) |
|---|
| 1105 | elif params.has_key("MOVE"): |
|---|
| 1106 | return RHMoveCoToPrimaryAuthors(self._req).process(params) |
|---|
| 1107 | return "no action to do" |
|---|
| 1108 | |
|---|
| 1109 | |
|---|
| 1110 | class RHRemCoAuthors(RHContribModifBaseSpecialSesCoordRights): |
|---|
| 1111 | |
|---|
| 1112 | def _checkParams(self, params): |
|---|
| 1113 | RHContribModifBaseSpecialSesCoordRights._checkParams(self, params) |
|---|
| 1114 | self._list = [] |
|---|
| 1115 | for id in self._normaliseListParam(params.get("selAuthor", [])): |
|---|
| 1116 | self._list.append(self._target.getAuthorById(id)) |
|---|
| 1117 | |
|---|
| 1118 | def _process(self): |
|---|
| 1119 | for auth in self._list: |
|---|
| 1120 | self._target.removeCoAuthor(auth) |
|---|
| 1121 | url=urlHandlers.UHContributionModification.getURL(self._target) |
|---|
| 1122 | self._redirect(url) |
|---|
| 1123 | |
|---|
| 1124 | class RHMoveCoToPrimaryAuthors(RHContribModifBaseSpecialSesCoordRights): |
|---|
| 1125 | def _checkParams(self, params): |
|---|
| 1126 | RHContribModifBaseSpecialSesCoordRights._checkParams(self, params) |
|---|
| 1127 | self._list = [] |
|---|
| 1128 | for id in self._normaliseListParam(params.get("selAuthor", [])): |
|---|
| 1129 | self._list.append(self._target.getAuthorById(id)) |
|---|
| 1130 | |
|---|
| 1131 | def _process(self): |
|---|
| 1132 | for auth in self._list: |
|---|
| 1133 | self._target.removeCoAuthor(auth, 0, False) |
|---|
| 1134 | self._target.addPrimaryAuthor(auth) |
|---|
| 1135 | url=urlHandlers.UHContributionModification.getURL(self._target) |
|---|
| 1136 | self._redirect(url) |
|---|
| 1137 | |
|---|
| 1138 | class RHEditCoAuthor(RHContribModifBaseSpecialSesCoordRights): |
|---|
| 1139 | |
|---|
| 1140 | def _checkParams(self, params): |
|---|
| 1141 | RHContribModifBaseSpecialSesCoordRights._checkParams(self, params) |
|---|
| 1142 | self._authorId=params["authorId"] |
|---|
| 1143 | self._action="" |
|---|
| 1144 | if params.has_key("ok"): |
|---|
| 1145 | self._action = "perform" |
|---|
| 1146 | elif params.has_key("cancel"): |
|---|
| 1147 | self._action = "cancel" |
|---|
| 1148 | |
|---|
| 1149 | def _setCoAuthorData(self): |
|---|
| 1150 | auth=self._target.getAuthorById(self._authorId) |
|---|
| 1151 | p = self._getRequestParams() |
|---|
| 1152 | auth.setTitle(p.get("title", "")) |
|---|
| 1153 | auth.setFirstName(p.get("name", "")) |
|---|
| 1154 | auth.setFamilyName(p.get("surName", "")) |
|---|
| 1155 | auth.setAffiliation(p.get("affiliation", "")) |
|---|
| 1156 | auth.setAddress(p.get("address", "")) |
|---|
| 1157 | auth.setPhone(p.get("phone", "")) |
|---|
| 1158 | auth.setFax(p.get("fax", "")) |
|---|
| 1159 | |
|---|
| 1160 | grantSubm=False |
|---|
| 1161 | if auth.getEmail().lower().strip() != p.get("email", "").lower().strip(): |
|---|
| 1162 | #----If it's already in the pending queue in order to grant |
|---|
| 1163 | # submission rights we must unindex and after the modification of the email, |
|---|
| 1164 | # index again... |
|---|
| 1165 | if self._target.getConference().getPendingQueuesMgr().isPendingSubmitter(auth): |
|---|
| 1166 | self._target.getConference().getPendingQueuesMgr().removePendingSubmitter(auth) |
|---|
| 1167 | grantSubm=True |
|---|
| 1168 | #----- |
|---|
| 1169 | |
|---|
| 1170 | auth.setEmail(p.get("email", "")) |
|---|
| 1171 | |
|---|
| 1172 | if grantSubm: |
|---|
| 1173 | self._target.grantSubmission(auth) |
|---|
| 1174 | |
|---|
| 1175 | def _process(self): |
|---|
| 1176 | if self._action != "": |
|---|
| 1177 | if self._action == "perform": |
|---|
| 1178 | self._setCoAuthorData() |
|---|
| 1179 | url=urlHandlers.UHContributionModification.getURL(self._target) |
|---|
| 1180 | self._redirect(url) |
|---|
| 1181 | else: |
|---|
| 1182 | auth=self._target.getAuthorById(self._authorId) |
|---|
| 1183 | p = contributions.WPModCoAuthor(self, self._target) |
|---|
| 1184 | return p.display(author=auth) |
|---|
| 1185 | |
|---|
| 1186 | |
|---|
| 1187 | class RHRemSpeakers(RHContribModifBaseSpecialSesCoordRights): |
|---|
| 1188 | |
|---|
| 1189 | def _checkParams(self, params): |
|---|
| 1190 | RHContribModifBaseSpecialSesCoordRights._checkParams(self, params) |
|---|
| 1191 | self._list = [] |
|---|
| 1192 | for id in self._normaliseListParam(params.get("selSpeaker", [])): |
|---|
| 1193 | self._list.append(self._target.getSpeakerById(id)) |
|---|
| 1194 | |
|---|
| 1195 | def _process(self): |
|---|
| 1196 | for auth in self._list: |
|---|
| 1197 | if auth is None: |
|---|
| 1198 | continue |
|---|
| 1199 | self._target.removeSpeaker(auth) |
|---|
| 1200 | url=urlHandlers.UHContributionModification.getURL(self._target) |
|---|
| 1201 | self._redirect(url) |
|---|
| 1202 | |
|---|
| 1203 | |
|---|
| 1204 | class RHAddSpeakers(RHContribModifBaseSpecialSesCoordRights): |
|---|
| 1205 | |
|---|
| 1206 | def _checkParams(self, params): |
|---|
| 1207 | RHContribModifBaseSpecialSesCoordRights._checkParams(self, params) |
|---|
| 1208 | self._list = [] |
|---|
| 1209 | for id in self._normaliseListParam(params.get("selAuthor", [])): |
|---|
| 1210 | self._list.append(self._target.getAuthorById(id)) |
|---|
| 1211 | |
|---|
| 1212 | def _process(self): |
|---|
| 1213 | for auth in self._list: |
|---|
| 1214 | if auth is None: |
|---|
| 1215 | continue |
|---|
| 1216 | self._target.addSpeaker(auth) |
|---|
| 1217 | url=urlHandlers.UHContributionModification.getURL(self._target) |
|---|
| 1218 | self._redirect(url) |
|---|
| 1219 | |
|---|
| 1220 | |
|---|
| 1221 | class RHSetTrack(RHContribModifBase): |
|---|
| 1222 | |
|---|
| 1223 | def _checkParams(self, params): |
|---|
| 1224 | RHContribModifBase._checkParams(self, params) |
|---|
| 1225 | self._track=None |
|---|
| 1226 | if params.has_key("selTrack") and params["selTrack"].strip() != "": |
|---|
| 1227 | self._track = self._target.getConference().getTrackById(params["selTrack"]) |
|---|
| 1228 | |
|---|
| 1229 | def _process(self): |
|---|
| 1230 | self._target.setTrack(self._track) |
|---|
| 1231 | url=urlHandlers.UHContributionModification.getURL(self._target) |
|---|
| 1232 | self._redirect(url) |
|---|
| 1233 | |
|---|
| 1234 | |
|---|
| 1235 | class RHSetSession(RHContribModifBase): |
|---|
| 1236 | |
|---|
| 1237 | def _checkParams(self, params): |
|---|
| 1238 | RHContribModifBase._checkParams(self, params) |
|---|
| 1239 | self._session=None |
|---|
| 1240 | if params.has_key("selSession") and params["selSession"].strip() != "": |
|---|
| 1241 | self._session=self._target.getConference().getSessionById(params["selSession"]) |
|---|
| 1242 | |
|---|
| 1243 | def _process(self): |
|---|
| 1244 | self._target.setSession(self._session) |
|---|
| 1245 | url=urlHandlers.UHContributionModification.getURL(self._target) |
|---|
| 1246 | self._redirect(url) |
|---|
| 1247 | |
|---|
| 1248 | |
|---|
| 1249 | #class RHContributionSelectSpeakers( RHContribModifBase ): |
|---|
| 1250 | # _uh = urlHandlers.UHContributionSelectSpeakers |
|---|
| 1251 | # |
|---|
| 1252 | # def _process( self ): |
|---|
| 1253 | # p = contributions.WPcontribSelectChairs( self, self._target ) |
|---|
| 1254 | # return p.display( **self._getRequestParams() ) |
|---|
| 1255 | # |
|---|
| 1256 | # |
|---|
| 1257 | #class RHContributionAddSpeakers( RHContribModifBase ): |
|---|
| 1258 | # _uh = urlHandlers.UHContributionAddSpeakers |
|---|
| 1259 | # |
|---|
| 1260 | # def _checkParams( self, params ): |
|---|
| 1261 | # RHContribModifBase._checkParams( self, params ) |
|---|
| 1262 | # selSpeakerId = self._normaliseListParam( params.get( "selectedPrincipals", [] ) ) |
|---|
| 1263 | # ah = user.AvatarHolder() |
|---|
| 1264 | # self._speakers = [] |
|---|
| 1265 | # for id in selSpeakerId: |
|---|
| 1266 | # self._speakers.append( ah.getById( id ) ) |
|---|
| 1267 | # |
|---|
| 1268 | # def _process( self ): |
|---|
| 1269 | # for av in self._speakers: |
|---|
| 1270 | # self._target.addSpeaker( av ) |
|---|
| 1271 | # self._redirect( urlHandlers.UHContributionModification.getURL( self._target ) ) |
|---|
| 1272 | # |
|---|
| 1273 | # |
|---|
| 1274 | #class RHContributionRemoveSpeakers( RHContribModifBase ): |
|---|
| 1275 | # _uh = urlHandlers.UHContributionRemoveSpeakers |
|---|
| 1276 | # |
|---|
| 1277 | # def _checkParams( self, params ): |
|---|
| 1278 | # RHContribModifBase._checkParams( self, params ) |
|---|
| 1279 | # selSpeakerId = self._normaliseListParam( params.get( "selectedPrincipals", [] ) ) |
|---|
| 1280 | # ah = user.AvatarHolder() |
|---|
| 1281 | # self._speakers = [] |
|---|
| 1282 | # for id in selSpeakerId: |
|---|
| 1283 | # self._speakers.append( ah.getById( id ) ) |
|---|
| 1284 | # |
|---|
| 1285 | # def _process( self ): |
|---|
| 1286 | # for av in self._speakers: |
|---|
| 1287 | # self._target.removeSpeaker( av ) |
|---|
| 1288 | # self._redirect( urlHandlers.UHContributionModification.getURL( self._target ) ) |
|---|
| 1289 | |
|---|
| 1290 | |
|---|
| 1291 | class RHContributionAddMaterial(RHContribModifBaseSpecialSesCoordRights): |
|---|
| 1292 | _uh = urlHandlers.UHContributionAddMaterial |
|---|
| 1293 | |
|---|
| 1294 | def _checkParams(self, params): |
|---|
| 1295 | RHContribModifBaseSpecialSesCoordRights._checkParams(self, params) |
|---|
| 1296 | typeMat = params.get("typeMaterial", "notype") |
|---|
| 1297 | if typeMat=="notype" or typeMat.strip()=="": |
|---|
| 1298 | raise FormValuesError("Please choose a material type") |
|---|
| 1299 | self._mf = materialFactories.ContribMFRegistry().getById(typeMat) |
|---|
| 1300 | |
|---|
| 1301 | def _process(self): |
|---|
| 1302 | if self._mf: |
|---|
| 1303 | if not self._mf.needsCreationPage(): |
|---|
| 1304 | m = RHContributionPerformAddMaterial.create(self._target, self._mf, self._getRequestParams()) |
|---|
| 1305 | self._redirect(urlHandlers.UHMaterialModification.getURL(m)) |
|---|
| 1306 | return |
|---|
| 1307 | p = contributions.WPContribAddMaterial(self, self._target, self._mf) |
|---|
| 1308 | wf = self.getWebFactory() |
|---|
| 1309 | if wf != None: |
|---|
| 1310 | p = wf.getContribAddMaterial(self, self._target, self._mf) |
|---|
| 1311 | return p.display() |
|---|
| 1312 | |
|---|
| 1313 | |
|---|
| 1314 | class RHContributionPerformAddMaterial(RHContribModifBaseSpecialSesCoordRights): |
|---|
| 1315 | _uh = urlHandlers.UHContributionPerformAddMaterial |
|---|
| 1316 | |
|---|
| 1317 | def _checkParams(self, params): |
|---|
| 1318 | RHContribModifBaseSpecialSesCoordRights._checkParams(self, params) |
|---|
| 1319 | typeMat = params.get("typeMaterial", "") |
|---|
| 1320 | self._mf = materialFactories.ContribMFRegistry.getById(typeMat) |
|---|
| 1321 | |
|---|
| 1322 | @staticmethod |
|---|
| 1323 | def create(contrib, matFactory, matData): |
|---|
| 1324 | if matFactory: |
|---|
| 1325 | m = matFactory.create(contrib) |
|---|
| 1326 | else: |
|---|
| 1327 | m = conference.Material() |
|---|
| 1328 | contrib.addMaterial(m) |
|---|
| 1329 | m.setValues(matData) |
|---|
| 1330 | return m |
|---|
| 1331 | |
|---|
| 1332 | def _process(self): |
|---|
| 1333 | m = self.create(self._target, self._mf, self._getRequestParams()) |
|---|
| 1334 | self._redirect(urlHandlers.UHMaterialModification.getURL(m)) |
|---|
| 1335 | |
|---|
| 1336 | |
|---|
| 1337 | class RHContributionRemoveMaterials(RHContribModifBaseSpecialSesCoordRights): |
|---|
| 1338 | _uh = urlHandlers.UHContributionRemoveMaterials |
|---|
| 1339 | |
|---|
| 1340 | def _checkParams(self, params): |
|---|
| 1341 | RHContribModifBaseSpecialSesCoordRights._checkParams(self, params) |
|---|
| 1342 | #typeMat = params.get( "typeMaterial", "" ) |
|---|
| 1343 | #self._mf = materialFactories.ConfMFRegistry().getById( typeMat ) |
|---|
| 1344 | self._materialIds = self._normaliseListParam(params.get("deleteMaterial", [])) |
|---|
| 1345 | self._materialIds = self._normaliseListParam( params.get("materialId", []) ) |
|---|
| 1346 | self._returnURL = params.get("returnURL","") |
|---|
| 1347 | |
|---|
| 1348 | def _process(self): |
|---|
| 1349 | for id in self._materialIds: |
|---|
| 1350 | #Performing the deletion of special material types |
|---|
| 1351 | f = materialFactories.ContribMFRegistry().getById(id) |
|---|
| 1352 | if f: |
|---|
| 1353 | f.remove(self._target) |
|---|
| 1354 | else: |
|---|
| 1355 | #Performs the deletion of additional material types |
|---|
| 1356 | mat = self._target.getMaterialById( id ) |
|---|
| 1357 | self._target.removeMaterial( mat ) |
|---|
| 1358 | if self._returnURL != "": |
|---|
| 1359 | url = self._returnURL |
|---|
| 1360 | else: |
|---|
| 1361 | url = urlHandlers.UHContribModifMaterials.getURL( self._target ) |
|---|
| 1362 | self._redirect( url ) |
|---|
| 1363 | |
|---|
| 1364 | |
|---|
| 1365 | class RHMaterialsAdd(RHContribModifBase): |
|---|
| 1366 | _uh = urlHandlers.UHContribModifAddMaterials |
|---|
| 1367 | |
|---|
| 1368 | def _checkProtection(self): |
|---|
| 1369 | material, _ = self._rhSubmitMaterial._getMaterial() |
|---|
| 1370 | if self._target.canUserSubmit(self._aw.getUser()) \ |
|---|
| 1371 | and (not material or material.getReviewingState() < 3): |
|---|
| 1372 | return |
|---|
| 1373 | RHContribModifBase._checkProtection(self) |
|---|
| 1374 | |
|---|
| 1375 | def _checkParams(self, params): |
|---|
| 1376 | RHContribModifBase._checkParams(self, params) |
|---|
| 1377 | if not hasattr(self,"_rhSubmitMaterial"): |
|---|
| 1378 | self._rhSubmitMaterial=RHSubmitMaterialBase(self._target, self) |
|---|
| 1379 | self._rhSubmitMaterial._checkParams(params) |
|---|
| 1380 | |
|---|
| 1381 | def _process( self ): |
|---|
| 1382 | if self._target.getConference().isClosed(): |
|---|
| 1383 | p = WPConferenceModificationClosed( self, self._target ) |
|---|
| 1384 | return p.display() |
|---|
| 1385 | else: |
|---|
| 1386 | r=self._rhSubmitMaterial._process(self, self._getRequestParams()) |
|---|
| 1387 | if r is None: |
|---|
| 1388 | self._redirect(self._uh.getURL(self._target)) |
|---|
| 1389 | |
|---|
| 1390 | return r |
|---|
| 1391 | |
|---|
| 1392 | class RHContributionSelectManagers(RHContribModifBaseSpecialSesCoordRights): |
|---|
| 1393 | _uh = urlHandlers.UHContributionSelectManagers |
|---|
| 1394 | |
|---|
| 1395 | def _process(self): |
|---|
| 1396 | p = contributions.WPContributionSelectManagers(self, self._target) |
|---|
| 1397 | return p.display(**self._getRequestParams()) |
|---|
| 1398 | |
|---|
| 1399 | |
|---|
| 1400 | class RHContributionAddManagers(RHContribModifBaseSpecialSesCoordRights): |
|---|
| 1401 | _uh = urlHandlers.UHContributionAddManagers |
|---|
| 1402 | |
|---|
| 1403 | def _process(self): |
|---|
| 1404 | params = self._getRequestParams() |
|---|
| 1405 | if "selectedPrincipals" in params and not "cancel" in params: |
|---|
| 1406 | ph = user.PrincipalHolder() |
|---|
| 1407 | for id in self._normaliseListParam(params["selectedPrincipals"]): |
|---|
| 1408 | self._target.grantModification(ph.getById(id)) |
|---|
| 1409 | self._redirect(urlHandlers.UHContribModifAC.getURL(self._target)) |
|---|
| 1410 | |
|---|
| 1411 | |
|---|
| 1412 | class RHContributionRemoveManagers(RHContribModifBaseSpecialSesCoordRights): |
|---|
| 1413 | _uh = urlHandlers.UHContributionRemoveManagers |
|---|
| 1414 | |
|---|
| 1415 | def _process(self): |
|---|
| 1416 | params = self._getRequestParams() |
|---|
| 1417 | if ("selectedPrincipals" in params) and \ |
|---|
| 1418 | (len(params["selectedPrincipals"])!=0): |
|---|
| 1419 | ph = user.PrincipalHolder() |
|---|
| 1420 | for id in self._normaliseListParam(params["selectedPrincipals"]): |
|---|
| 1421 | self._target.revokeModification(ph.getById(id)) |
|---|
| 1422 | self._redirect(urlHandlers.UHContribModifAC.getURL(self._target)) |
|---|
| 1423 | |
|---|
| 1424 | |
|---|
| 1425 | class RHContributionSetVisibility(RHContribModifBaseSpecialSesCoordRights): |
|---|
| 1426 | _uh = urlHandlers.UHContributionSetVisibility |
|---|
| 1427 | |
|---|
| 1428 | def _process(self): |
|---|
| 1429 | params = self._getRequestParams() |
|---|
| 1430 | privacy = params.get("visibility","PUBLIC") |
|---|
| 1431 | self._protect = 0 |
|---|
| 1432 | if privacy == "PRIVATE": |
|---|
| 1433 | self._protect = 1 |
|---|
| 1434 | elif privacy == "PUBLIC": |
|---|
| 1435 | self._protect = 0 |
|---|
| 1436 | elif privacy == "ABSOLUTELY PUBLIC": |
|---|
| 1437 | self._protect = -1 |
|---|
| 1438 | self._target.setProtection(self._protect) |
|---|
| 1439 | self._redirect(urlHandlers.UHContribModifAC.getURL(self._target)) |
|---|
| 1440 | |
|---|
| 1441 | |
|---|
| 1442 | class RHContributionSelectAllowed(RHContribModifBaseSpecialSesCoordRights): |
|---|
| 1443 | _uh = urlHandlers.UHContributionSelectAllowed |
|---|
| 1444 | |
|---|
| 1445 | def _process(self): |
|---|
| 1446 | p = contributions.WPContributionSelectAllowed(self, self._target) |
|---|
| 1447 | return p.display(**self._getRequestParams()) |
|---|
| 1448 | |
|---|
| 1449 | |
|---|
| 1450 | class RHContributionAddAllowed(RHContribModifBaseSpecialSesCoordRights): |
|---|
| 1451 | _uh = urlHandlers.UHContributionAddAllowed |
|---|
| 1452 | |
|---|
| 1453 | def _process(self): |
|---|
| 1454 | params = self._getRequestParams() |
|---|
| 1455 | if "selectedPrincipals" in params and not "cancel" in params: |
|---|
| 1456 | ph = user.PrincipalHolder() |
|---|
| 1457 | for id in self._normaliseListParam(params["selectedPrincipals"]): |
|---|
| 1458 | self._target.grantAccess(ph.getById(id)) |
|---|
| 1459 | self._redirect(urlHandlers.UHContribModifAC.getURL(self._target)) |
|---|
| 1460 | |
|---|
| 1461 | |
|---|
| 1462 | class RHContributionRemoveAllowed(RHContribModifBaseSpecialSesCoordRights): |
|---|
| 1463 | _uh = urlHandlers.UHContributionRemoveAllowed |
|---|
| 1464 | |
|---|
| 1465 | def _process(self): |
|---|
| 1466 | params = self._getRequestParams() |
|---|
| 1467 | if ("selectedPrincipals" in params) and \ |
|---|
| 1468 | (len(params["selectedPrincipals"])!=0): |
|---|
| 1469 | ph = user.PrincipalHolder() |
|---|
| 1470 | for id in self._normaliseListParam(params["selectedPrincipals"]): |
|---|
| 1471 | self._target.revokeAccess(ph.getById(id)) |
|---|
| 1472 | self._redirect(urlHandlers.UHContribModifAC.getURL(self._target)) |
|---|
| 1473 | |
|---|
| 1474 | |
|---|
| 1475 | class RHContributionAddDomains(RHContribModifBaseSpecialSesCoordRights): |
|---|
| 1476 | _uh = urlHandlers.UHContributionAddDomain |
|---|
| 1477 | |
|---|
| 1478 | def _process(self): |
|---|
| 1479 | params = self._getRequestParams() |
|---|
| 1480 | if ("addDomain" in params) and (len(params["addDomain"])!=0): |
|---|
| 1481 | dh = domain.DomainHolder() |
|---|
| 1482 | for domId in self._normaliseListParam(params["addDomain"]): |
|---|
| 1483 | self._target.requireDomain(dh.getById(domId)) |
|---|
| 1484 | self._redirect(urlHandlers.UHContribModifAC.getURL(self._target)) |
|---|
| 1485 | |
|---|
| 1486 | |
|---|
| 1487 | class RHContributionRemoveDomains(RHContribModifBaseSpecialSesCoordRights): |
|---|
| 1488 | _uh = urlHandlers.UHContributionRemoveDomain |
|---|
| 1489 | |
|---|
| 1490 | def _process(self): |
|---|
| 1491 | params = self._getRequestParams() |
|---|
| 1492 | if ("selectedDomain" in params) and (len(params["selectedDomain"])!=0): |
|---|
| 1493 | dh = domain.DomainHolder() |
|---|
| 1494 | for domId in self._normaliseListParam(params["selectedDomain"]): |
|---|
| 1495 | self._target.freeDomain(dh.getById(domId)) |
|---|
| 1496 | #self._endRequest() |
|---|
| 1497 | self._redirect(urlHandlers.UHContribModifAC.getURL(self._target)) |
|---|
| 1498 | |
|---|
| 1499 | |
|---|
| 1500 | class RHContributionDeletion(RHContribModifBaseSpecialSesCoordRights): |
|---|
| 1501 | _uh = urlHandlers.UHContributionDelete |
|---|
| 1502 | |
|---|
| 1503 | def _checkParams(self, params): |
|---|
| 1504 | RHContribModifBaseSpecialSesCoordRights._checkParams(self, params) |
|---|
| 1505 | self._cancel = False |
|---|
| 1506 | if "cancel" in params: |
|---|
| 1507 | self._cancel = True |
|---|
| 1508 | self._confirmation = params.has_key("confirm") |
|---|
| 1509 | |
|---|
| 1510 | def _perform(self): |
|---|
| 1511 | conf = self._target.getConference() |
|---|
| 1512 | self._target.getOwner().getSchedule().removeEntry(self._target.getSchEntry()) |
|---|
| 1513 | #self._target.getOwner().removeContribution(self._target) |
|---|
| 1514 | self._target.delete() |
|---|
| 1515 | #conf.removeContribution(self._target) |
|---|
| 1516 | |
|---|
| 1517 | def _process(self): |
|---|
| 1518 | if self._cancel: |
|---|
| 1519 | self._redirect(urlHandlers.UHContribModifTools.getURL(self._target)) |
|---|
| 1520 | elif self._confirmation: |
|---|
| 1521 | owner = self._target.getOwner() |
|---|
| 1522 | self._perform() |
|---|
| 1523 | if self._target.getSession(): |
|---|
| 1524 | self._redirect(urlHandlers.UHsessionModification.getURL(owner)) |
|---|
| 1525 | else: |
|---|
| 1526 | self._redirect(urlHandlers.UHConferenceModification.getURL(owner)) |
|---|
| 1527 | else: |
|---|
| 1528 | p = contributions.WPContributionDeletion(self, self._target) |
|---|
| 1529 | return p.display() |
|---|
| 1530 | |
|---|
| 1531 | |
|---|
| 1532 | class RHContributionMove(RHContribModifBaseSpecialSesCoordRights): |
|---|
| 1533 | _uh = urlHandlers.UHContributionMove |
|---|
| 1534 | |
|---|
| 1535 | def _process(self): |
|---|
| 1536 | p = contributions.WPcontribMove(self, self._target) |
|---|
| 1537 | return p.display(**self._getRequestParams()) |
|---|
| 1538 | |
|---|
| 1539 | |
|---|
| 1540 | class RHContributionPerformMove(RHContribModifBaseSpecialSesCoordRights): |
|---|
| 1541 | _uh = urlHandlers.UHContributionPerformMove |
|---|
| 1542 | |
|---|
| 1543 | def _checkParams(self, params): |
|---|
| 1544 | RHContribModifBaseSpecialSesCoordRights._checkParams(self, params) |
|---|
| 1545 | self._dest = params["Destination"] |
|---|
| 1546 | |
|---|
| 1547 | def _process(self): |
|---|
| 1548 | conf = self._target.getConference() |
|---|
| 1549 | if self._dest == 'CONF': |
|---|
| 1550 | newOwner = conf |
|---|
| 1551 | else: |
|---|
| 1552 | newOwner = conf.getSessionById(self._dest) |
|---|
| 1553 | self._moveContrib(newOwner) |
|---|
| 1554 | self._redirect(urlHandlers.UHContribModifTools.getURL(self._target)) |
|---|
| 1555 | |
|---|
| 1556 | return "done" |
|---|
| 1557 | |
|---|
| 1558 | def _moveContrib(self, newOwner): |
|---|
| 1559 | owner = self._target.getOwner() |
|---|
| 1560 | owner.removeContribution(self._target) |
|---|
| 1561 | newOwner.addContribution(self._target) |
|---|
| 1562 | |
|---|
| 1563 | |
|---|
| 1564 | class RHContributionWriteMinutes(RHContribModifBaseSpecialSesCoordRights): |
|---|
| 1565 | _uh = urlHandlers.UHContributionWriteMinutes |
|---|
| 1566 | |
|---|
| 1567 | def _checkParams(self, params): |
|---|
| 1568 | RHContribModifBaseSpecialSesCoordRights._checkParams(self, params) |
|---|
| 1569 | self._cancel = params.has_key("cancel") |
|---|
| 1570 | self._save = params.has_key("OK") |
|---|
| 1571 | self._text = params.get("text", "")#.strip() |
|---|
| 1572 | |
|---|
| 1573 | def _process(self): |
|---|
| 1574 | if self._cancel: |
|---|
| 1575 | self._redirect(urlHandlers.UHContribModifTools.getURL(self._target)) |
|---|
| 1576 | elif self._save: |
|---|
| 1577 | #if self._text!="": |
|---|
| 1578 | minutes = self._target.getMinutes() |
|---|
| 1579 | if not minutes: |
|---|
| 1580 | minutes = self._target.createMinutes() |
|---|
| 1581 | minutes.setText(self._text) |
|---|
| 1582 | self._redirect(urlHandlers.UHContribModifTools.getURL(self._target)) |
|---|
| 1583 | else: |
|---|
| 1584 | p = contributions.WPContributionWriteMinutes(self, self._target) |
|---|
| 1585 | return p.display() |
|---|
| 1586 | |
|---|
| 1587 | class RHContributionToXML(RHContributionModification): |
|---|
| 1588 | _uh = urlHandlers.UHContribToXMLConfManager |
|---|
| 1589 | |
|---|
| 1590 | def _process(self): |
|---|
| 1591 | filename = "%s - contribution.xml"%self._target.getTitle() |
|---|
| 1592 | x = XMLGen() |
|---|
| 1593 | x.openTag("contribution") |
|---|
| 1594 | x.writeTag("Id", self._target.getId()) |
|---|
| 1595 | x.writeTag("Title", self._target.getTitle()) |
|---|
| 1596 | x.writeTag("Description", self._target.getDescription()) |
|---|
| 1597 | afm = self._target.getConference().getAbstractMgr().getAbstractFieldsMgr() |
|---|
| 1598 | for f in afm.getFields(): |
|---|
| 1599 | id = f.getId() |
|---|
| 1600 | if f.isActive() and self._target.getField(id).strip() != "": |
|---|
| 1601 | x.writeTag(id.replace(" ","_"),self._target.getField(id)) |
|---|
| 1602 | x.writeTag("Conference", self._target.getConference().getTitle()) |
|---|
| 1603 | session = self._target.getSession() |
|---|
| 1604 | if session!=None: |
|---|
| 1605 | x.writeTag("Session", self._target.getSession().getTitle()) |
|---|
| 1606 | l = [] |
|---|
| 1607 | for au in self._target.getAuthorList(): |
|---|
| 1608 | if self._target.isPrimaryAuthor(au): |
|---|
| 1609 | x.openTag("PrimaryAuthor") |
|---|
| 1610 | x.writeTag("FirstName", au.getFirstName()) |
|---|
| 1611 | x.writeTag("FamilyName", au.getFamilyName()) |
|---|
| 1612 | x.writeTag("Email", au.getEmail()) |
|---|
| 1613 | #x.writeTag("Affiliation", au.getAffiliation()) |
|---|
| 1614 | x.closeTag("PrimaryAuthor") |
|---|
| 1615 | else: |
|---|
| 1616 | l.append(au) |
|---|
| 1617 | |
|---|
| 1618 | for au in l: |
|---|
| 1619 | x.openTag("Co-Author") |
|---|
| 1620 | x.writeTag("FirstName", au.getFirstName()) |
|---|
| 1621 | x.writeTag("FamilyName", au.getFamilyName()) |
|---|
| 1622 | x.writeTag("Email", au.getEmail()) |
|---|
| 1623 | #x.writeTag("Affiliation", au.getAffiliation()) |
|---|
| 1624 | x.closeTag("Co-Author") |
|---|
| 1625 | |
|---|
| 1626 | for au in self._target.getSpeakerList(): |
|---|
| 1627 | x.openTag("Speaker") |
|---|
| 1628 | x.writeTag("FirstName", au.getFirstName ()) |
|---|
| 1629 | x.writeTag("FamilyName", au.getFamilyName()) |
|---|
| 1630 | x.writeTag("Email", au.getEmail()) |
|---|
| 1631 | #x.writeTag("Affiliation", au.getAffiliation()) |
|---|
| 1632 | x.closeTag("Speaker") |
|---|
| 1633 | |
|---|
| 1634 | #To change for the new contribution type system to: |
|---|
| 1635 | x.writeTag("ContributionType", self._target.getType()) |
|---|
| 1636 | |
|---|
| 1637 | t = self._target.getTrack() |
|---|
| 1638 | if t!=None: |
|---|
| 1639 | x.writeTag("Track", t.getTitle()) |
|---|
| 1640 | |
|---|
| 1641 | x.closeTag("contribution") |
|---|
| 1642 | |
|---|
| 1643 | data = x.getXml() |
|---|
| 1644 | |
|---|
| 1645 | cfg = Config.getInstance() |
|---|
| 1646 | mimetype = cfg.getFileTypeMimeType("XML") |
|---|
| 1647 | self._req.content_type = """%s"""%(mimetype) |
|---|
| 1648 | self._req.headers_out["Content-Length"] = "%s"%len(data) |
|---|
| 1649 | self._req.headers_out["Content-Disposition"] = """inline; filename="%s\""""%filename |
|---|
| 1650 | return data |
|---|
| 1651 | |
|---|
| 1652 | |
|---|
| 1653 | class RHContributionToPDF(RHContributionModification): |
|---|
| 1654 | _uh = urlHandlers.UHContribToPDFConfManager |
|---|
| 1655 | |
|---|
| 1656 | def _process(self): |
|---|
| 1657 | tz = self._target.getConference().getTimezone() |
|---|
| 1658 | filename = "%s - Contribution.pdf"%self._target.getTitle() |
|---|
| 1659 | pdf = ConfManagerContribToPDF(self._target.getConference(), self._target, tz=tz) |
|---|
| 1660 | data = pdf.getPDFBin() |
|---|
| 1661 | self._req.headers_out["Content-Length"] = "%s"%len(data) |
|---|
| 1662 | cfg = Config.getInstance() |
|---|
| 1663 | mimetype = cfg.getFileTypeMimeType("PDF") |
|---|
| 1664 | self._req.content_type = """%s"""%(mimetype) |
|---|
| 1665 | self._req.headers_out["Content-Disposition"] = """inline; filename="%s\""""%filename |
|---|
| 1666 | return data |
|---|
| 1667 | |
|---|
| 1668 | |
|---|
| 1669 | class RHAuthBase(RHContribModifBaseSpecialSesCoordRights): |
|---|
| 1670 | |
|---|
| 1671 | def _checkParams(self, params): |
|---|
| 1672 | RHContribModifBaseSpecialSesCoordRights._checkParams(self, params) |
|---|
| 1673 | self._auth=self._target.getAuthorById(params.get("authId", "")) |
|---|
| 1674 | |
|---|
| 1675 | |
|---|
| 1676 | class RHPrimAuthUp(RHAuthBase): |
|---|
| 1677 | |
|---|
| 1678 | def _process(self): |
|---|
| 1679 | contrib=self._target |
|---|
| 1680 | contrib.upPrimaryAuthor(self._auth) |
|---|
| 1681 | self._redirect(urlHandlers.UHContributionModification.getURL(contrib)) |
|---|
| 1682 | |
|---|
| 1683 | |
|---|
| 1684 | class RHPrimAuthDown(RHAuthBase): |
|---|
| 1685 | |
|---|
| 1686 | def _process(self): |
|---|
| 1687 | contrib=self._target |
|---|
| 1688 | contrib.downPrimaryAuthor(self._auth) |
|---|
| 1689 | self._redirect(urlHandlers.UHContributionModification.getURL(contrib)) |
|---|
| 1690 | |
|---|
| 1691 | |
|---|
| 1692 | class RHCoAuthUp(RHAuthBase): |
|---|
| 1693 | |
|---|
| 1694 | def _process(self): |
|---|
| 1695 | contrib=self._target |
|---|
| 1696 | contrib.upCoAuthor(self._auth) |
|---|
| 1697 | self._redirect(urlHandlers.UHContributionModification.getURL(contrib)) |
|---|
| 1698 | |
|---|
| 1699 | |
|---|
| 1700 | class RHCoAuthDown(RHAuthBase): |
|---|
| 1701 | |
|---|
| 1702 | def _process(self): |
|---|
| 1703 | contrib=self._target |
|---|
| 1704 | contrib.downCoAuthor(self._auth) |
|---|
| 1705 | self._redirect(urlHandlers.UHContributionModification.getURL(contrib)) |
|---|
| 1706 | |
|---|
| 1707 | class RHNewSpeaker(RHContribModifBaseSpecialSesCoordRights): |
|---|
| 1708 | |
|---|
| 1709 | def _checkParams(self, params): |
|---|
| 1710 | RHContribModifBaseSpecialSesCoordRights._checkParams(self, params) |
|---|
| 1711 | self._action="" |
|---|
| 1712 | if params.has_key("ok"): |
|---|
| 1713 | self._action = "perform" |
|---|
| 1714 | elif params.has_key("cancel"): |
|---|
| 1715 | self._action = "cancel" |
|---|
| 1716 | |
|---|
| 1717 | def _newSpeaker(self): |
|---|
| 1718 | auth = conference.ContributionParticipation() |
|---|
| 1719 | p = self._getRequestParams() |
|---|
| 1720 | auth.setTitle(p.get("title", "")) |
|---|
| 1721 | auth.setFirstName(p.get("name", "")) |
|---|
| 1722 | auth.setFamilyName(p.get("surName", "")) |
|---|
| 1723 | auth.setAffiliation(p.get("affiliation", "")) |
|---|
| 1724 | auth.setEmail(p.get("email", "")) |
|---|
| 1725 | auth.setAddress(p.get("address", "")) |
|---|
| 1726 | auth.setPhone(p.get("phone", "")) |
|---|
| 1727 | auth.setFax(p.get("fax", "")) |
|---|
| 1728 | self._target.newSpeaker(auth) |
|---|
| 1729 | return auth |
|---|
| 1730 | |
|---|
| 1731 | def _process(self): |
|---|
| 1732 | if self._action != "": |
|---|
| 1733 | if self._action == "perform": |
|---|
| 1734 | auth=self._newSpeaker() |
|---|
| 1735 | if self._getRequestParams().has_key("submissionControl"): |
|---|
| 1736 | if self._getRequestParams().get("email", "").strip() != "": |
|---|
| 1737 | #raise FormValuesError("If you want to add the author as submitter, please enter their email") |
|---|
| 1738 | self._target.grantSubmission(auth) |
|---|
| 1739 | url=urlHandlers.UHContributionModification.getURL(self._target) |
|---|
| 1740 | self._redirect(url) |
|---|
| 1741 | else: |
|---|
| 1742 | p = contributions.WPModNewSpeaker(self, self._target) |
|---|
| 1743 | wf = self.getWebFactory() |
|---|
| 1744 | if wf != None: |
|---|
| 1745 | p = wf.getContributionNewspeaker(self, self._target) |
|---|
| 1746 | return p.display() |
|---|
| 1747 | |
|---|
| 1748 | class RHEditSpeaker(RHContribModifBaseSpecialSesCoordRights): |
|---|
| 1749 | |
|---|
| 1750 | def _checkParams(self, params): |
|---|
| 1751 | RHContribModifBaseSpecialSesCoordRights._checkParams(self, params) |
|---|
| 1752 | self._authorId=params["authorId"] |
|---|
| 1753 | self._action="" |
|---|
| 1754 | if params.has_key("ok"): |
|---|
| 1755 | self._action = "perform" |
|---|
| 1756 | elif params.has_key("cancel"): |
|---|
| 1757 | self._action = "cancel" |
|---|
| 1758 | |
|---|
| 1759 | def _setSpeakerData(self): |
|---|
| 1760 | auth=self._target.getSpeakerById(self._authorId) |
|---|
| 1761 | if auth is not None: |
|---|
| 1762 | p = self._getRequestParams() |
|---|
| 1763 | auth.setTitle(p.get("title", "")) |
|---|
| 1764 | auth.setFirstName(p.get("name", "")) |
|---|
| 1765 | auth.setFamilyName(p.get("surName", "")) |
|---|
| 1766 | auth.setAffiliation(p.get("affiliation", "")) |
|---|
| 1767 | auth.setAddress(p.get("address", "")) |
|---|
| 1768 | auth.setPhone(p.get("phone", "")) |
|---|
| 1769 | auth.setFax(p.get("fax", "")) |
|---|
| 1770 | |
|---|
| 1771 | grantSubm=False |
|---|
| 1772 | if auth.getEmail().lower().strip() != p.get("email", "").lower().strip(): |
|---|
| 1773 | #----If it's already in the pending queue in order to grant |
|---|
| 1774 | # submission rights we must unindex and after the modification of the email, |
|---|
| 1775 | # index again... |
|---|
| 1776 | if self._target.getConference().getPendingQueuesMgr().isPendingSubmitter(auth): |
|---|
| 1777 | self._target.getConference().getPendingQueuesMgr().removePendingSubmitter(auth) |
|---|
| 1778 | grantSubm=True |
|---|
| 1779 | #----- |
|---|
| 1780 | |
|---|
| 1781 | auth.setEmail(p.get("email", "")) |
|---|
| 1782 | |
|---|
| 1783 | if grantSubm: |
|---|
| 1784 | if p.get("email", "").strip() == "": |
|---|
| 1785 | raise FormValuesError("This speaker is in a pending queue waiting to become submitter therefore the email address cannot be empty, please enter their email") |
|---|
| 1786 | self._target.grantSubmission(auth) |
|---|
| 1787 | elif p.has_key("submissionControl"): |
|---|
| 1788 | if p.get("email", "").strip() == "": |
|---|
| 1789 | raise FormValuesError("If you want to add the speaker as submitter, please enter their email") |
|---|
| 1790 | self._target.grantSubmission(auth) |
|---|
| 1791 | |
|---|
| 1792 | def _process(self): |
|---|
| 1793 | if self._action != "": |
|---|
| 1794 | if self._action == "perform": |
|---|
| 1795 | self._setSpeakerData() |
|---|
| 1796 | url=urlHandlers.UHContributionModification.getURL(self._target) |
|---|
| 1797 | self._redirect(url) |
|---|
| 1798 | else: |
|---|
| 1799 | auth=self._target.getSpeakerById(self._authorId) |
|---|
| 1800 | p = contributions.WPModSpeaker(self, self._target) |
|---|
| 1801 | wf = self.getWebFactory() |
|---|
| 1802 | if wf != None: |
|---|
| 1803 | p = wf.getModSpeaker(self, self._target) |
|---|
| 1804 | return p.display(author=auth) |
|---|
| 1805 | |
|---|
| 1806 | |
|---|
| 1807 | class RHSubmittersRem(RHContribModifBaseSpecialSesCoordRights): |
|---|
| 1808 | _uh=urlHandlers.UHContribModSubmittersRem |
|---|
| 1809 | |
|---|
| 1810 | def _checkParams(self, params): |
|---|
| 1811 | RHContribModifBaseSpecialSesCoordRights._checkParams(self, params) |
|---|
| 1812 | self._submitters=[] |
|---|
| 1813 | self._pendings=[] |
|---|
| 1814 | ah=user.PrincipalHolder() |
|---|
| 1815 | for id in self._normaliseListParam(params.get("selUsers", [])): |
|---|
| 1816 | av=ah.getById(id) |
|---|
| 1817 | if av is None: |
|---|
| 1818 | self._pendings.append(id) |
|---|
| 1819 | else: |
|---|
| 1820 | self._submitters.append(av) |
|---|
| 1821 | |
|---|
| 1822 | def _process(self): |
|---|
| 1823 | for sub in self._submitters: |
|---|
| 1824 | self._target.revokeSubmission(sub) |
|---|
| 1825 | for email in self._pendings: |
|---|
| 1826 | self._target.revokeSubmissionEmail(email) |
|---|
| 1827 | self._redirect(urlHandlers.UHContribModifAC.getURL(self._target)) |
|---|
| 1828 | |
|---|
| 1829 | |
|---|
| 1830 | class RHSubmittersSel(RHContribModifBaseSpecialSesCoordRights): |
|---|
| 1831 | _uh=urlHandlers.UHContribModSubmittersSel |
|---|
| 1832 | |
|---|
| 1833 | def _process(self): |
|---|
| 1834 | p=contributions.WPModSubmittersSel(self, self._target) |
|---|
| 1835 | return p.display(**self._getRequestParams()) |
|---|
| 1836 | |
|---|
| 1837 | |
|---|
| 1838 | class RHSubmittersAdd(RHContribModifBaseSpecialSesCoordRights): |
|---|
| 1839 | _uh=urlHandlers.UHContribModSubmittersAdd |
|---|
| 1840 | |
|---|
| 1841 | def _checkParams(self, params): |
|---|
| 1842 | RHContribModifBaseSpecialSesCoordRights._checkParams(self, params) |
|---|
| 1843 | self._submitterRole=self._normaliseListParam(params.get("submitterRole", [])) |
|---|
| 1844 | |
|---|
| 1845 | def _process(self): |
|---|
| 1846 | params=self._getRequestParams() |
|---|
| 1847 | if "selectedPrincipals" in params and not "cancel" in params: |
|---|
| 1848 | ah=user.PrincipalHolder() |
|---|
| 1849 | for id in self._normaliseListParam(params["selectedPrincipals"]): |
|---|
| 1850 | av=ah.getById(id) |
|---|
| 1851 | self._target.grantSubmission(av) |
|---|
| 1852 | if self._submitterRole!=[] and not isinstance(av, user.Group): |
|---|
| 1853 | cp=conference.ContributionParticipation() |
|---|
| 1854 | cp.setDataFromAvatar(av) |
|---|
| 1855 | if "primaryAuthor" in self._submitterRole: |
|---|
| 1856 | self._target.addPrimaryAuthor(cp) |
|---|
| 1857 | elif "coAuthor" in self._submitterRole: |
|---|
| 1858 | self._target.addCoAuthor(cp) |
|---|
| 1859 | if "speaker" in self._submitterRole: |
|---|
| 1860 | if self._submitterRole in ["primaryAuthor", "coAuthor"]: |
|---|
| 1861 | self._target.addSpeaker(cp) |
|---|
| 1862 | else: |
|---|
| 1863 | self._target.newSpeaker(cp) |
|---|
| 1864 | self._redirect(urlHandlers.UHContribModifAC.getURL(self._target)) |
|---|
| 1865 | |
|---|
| 1866 | class RHMaterials(RHContribModifBaseSpecialSesCoordAndReviewingStaffRights): |
|---|
| 1867 | _uh = urlHandlers.UHContribModifMaterials |
|---|
| 1868 | |
|---|
| 1869 | def _checkProtection(self): |
|---|
| 1870 | """ This disables people that are not conference managers or track coordinators to |
|---|
| 1871 | delete files from a contribution. |
|---|
| 1872 | """ |
|---|
| 1873 | RHContribModifBaseSpecialSesCoordAndReviewingStaffRights._checkProtection(self) |
|---|
| 1874 | for key in self._paramsForCheckProtection.keys(): |
|---|
| 1875 | if key.find("delete")!=-1: |
|---|
| 1876 | RHContribModifBaseSpecialSesCoordRights._checkProtection(self) |
|---|
| 1877 | |
|---|
| 1878 | def _checkParams(self, params): |
|---|
| 1879 | RHContribModifBaseSpecialSesCoordAndReviewingStaffRights._checkParams(self, params) |
|---|
| 1880 | #if not hasattr(self, "_rhSubmitMaterial"): |
|---|
| 1881 | # self._rhSubmitMaterial=RHSubmitMaterialBase(self._target, self) |
|---|
| 1882 | #self._rhSubmitMaterial._checkParams(params) |
|---|
| 1883 | params["days"] = params.get("day", "all") |
|---|
| 1884 | if params.get("day", None) is not None : |
|---|
| 1885 | del params["day"] |
|---|
| 1886 | # note from DavidMC: i wrote this long parameter name in order |
|---|
| 1887 | # not to overwrite a possibly existing _params in a base class |
|---|
| 1888 | # we need to store the params so that _checkProtection can know |
|---|
| 1889 | # if the action is to upload a file, delete etc. |
|---|
| 1890 | self._paramsForCheckProtection = params |
|---|
| 1891 | |
|---|
| 1892 | def _process(self): |
|---|
| 1893 | if self._target.getOwner().isClosed(): |
|---|
| 1894 | p = WPConferenceModificationClosed( self, self._target ) |
|---|
| 1895 | return p.display() |
|---|
| 1896 | |
|---|
| 1897 | p = contributions.WPContributionModifMaterials( self, self._target ) |
|---|
| 1898 | return p.display(**self._getRequestParams()) |
|---|
| 1899 | |
|---|
| 1900 | |
|---|
| 1901 | |
|---|
| 1902 | class RHContributionReportNumberEdit(RHContribModifBase): |
|---|
| 1903 | |
|---|
| 1904 | def _checkParams(self, params): |
|---|
| 1905 | RHContribModifBase._checkParams(self, params) |
|---|
| 1906 | self._reportNumberSystem=params.get("reportNumberSystem","") |
|---|
| 1907 | |
|---|
| 1908 | def _process(self): |
|---|
| 1909 | if self._reportNumberSystem!="": |
|---|
| 1910 | p=contributions.WPContributionReportNumberEdit(self,self._target, self._reportNumberSystem) |
|---|
| 1911 | return p.display() |
|---|
| 1912 | else: |
|---|
| 1913 | self._redirect(urlHandlers.UHContributionModification.getURL( self._target )) |
|---|
| 1914 | |
|---|
| 1915 | class RHContributionReportNumberPerformEdit(RHContribModifBase): |
|---|
| 1916 | |
|---|
| 1917 | def _checkParams(self, params): |
|---|
| 1918 | RHContribModifBase._checkParams(self, params) |
|---|
| 1919 | self._reportNumberSystem=params.get("reportNumberSystem","") |
|---|
| 1920 | self._reportNumber=params.get("reportNumber","") |
|---|
| 1921 | |
|---|
| 1922 | def _process(self): |
|---|
| 1923 | if self._reportNumberSystem!="" and self._reportNumber!="": |
|---|
| 1924 | self._target.getReportNumberHolder().addReportNumber(self._reportNumberSystem, self._reportNumber) |
|---|
| 1925 | self._redirect("%s#reportNumber"%urlHandlers.UHContributionModification.getURL( self._target )) |
|---|
| 1926 | |
|---|
| 1927 | |
|---|
| 1928 | class RHContributionReportNumberRemove(RHContribModifBase): |
|---|
| 1929 | |
|---|
| 1930 | def _checkParams(self, params): |
|---|
| 1931 | RHContribModifBase._checkParams(self, params) |
|---|
| 1932 | self._reportNumberIdsToBeDeleted=self._normaliseListParam( params.get("deleteReportNumber",[])) |
|---|
| 1933 | |
|---|
| 1934 | def _process(self): |
|---|
| 1935 | nbDeleted = 0 |
|---|
| 1936 | for id in self._reportNumberIdsToBeDeleted: |
|---|
| 1937 | self._target.getReportNumberHolder().removeReportNumberById(int(id)-nbDeleted) |
|---|
| 1938 | nbDeleted += 1 |
|---|
| 1939 | self._redirect("%s#reportNumber"%urlHandlers.UHContributionModification.getURL( self._target )) |
|---|
| 1940 | |
|---|
| 1941 | |
|---|
| 1942 | |
|---|