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