| 1 | # -*- coding: utf-8 -*- |
|---|
| 2 | ## |
|---|
| 3 | ## |
|---|
| 4 | ## This file is part of CDS Indico. |
|---|
| 5 | ## Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007 CERN. |
|---|
| 6 | ## |
|---|
| 7 | ## CDS Indico is free software; you can redistribute it and/or |
|---|
| 8 | ## modify it under the terms of the GNU General Public License as |
|---|
| 9 | ## published by the Free Software Foundation; either version 2 of the |
|---|
| 10 | ## License, or (at your option) any later version. |
|---|
| 11 | ## |
|---|
| 12 | ## CDS Indico is distributed in the hope that it will be useful, but |
|---|
| 13 | ## WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 14 | ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|---|
| 15 | ## General Public License for more details. |
|---|
| 16 | ## |
|---|
| 17 | ## You should have received a copy of the GNU General Public License |
|---|
| 18 | ## along with CDS Indico; if not, write to the Free Software Foundation, Inc., |
|---|
| 19 | ## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. |
|---|
| 20 | |
|---|
| 21 | import MaKaC.webinterface.locators as locators |
|---|
| 22 | import MaKaC.webinterface.urlHandlers as urlHandlers |
|---|
| 23 | import MaKaC.webinterface.materialFactories as materialFactories |
|---|
| 24 | import MaKaC.webinterface.pages.contributions as contributions |
|---|
| 25 | import MaKaC.conference as conference |
|---|
| 26 | import MaKaC.user as user |
|---|
| 27 | import MaKaC.domain as domain |
|---|
| 28 | import MaKaC.webinterface.webFactoryRegistry as webFactoryRegistry |
|---|
| 29 | from MaKaC.webinterface.rh.base import RHModificationBaseProtected |
|---|
| 30 | from MaKaC.common.xmlGen import XMLGen |
|---|
| 31 | from MaKaC.common.utils import parseDateTime |
|---|
| 32 | from MaKaC.common import Config |
|---|
| 33 | from MaKaC.webinterface.rh.conferenceBase import RHSubmitMaterialBase |
|---|
| 34 | from MaKaC.webinterface.rh.base import RoomBookingDBMixin |
|---|
| 35 | from MaKaC.PDFinterface.conference import ConfManagerContribToPDF |
|---|
| 36 | from MaKaC.errors import FormValuesError |
|---|
| 37 | from MaKaC.conference import SubContribParticipation |
|---|
| 38 | from MaKaC.errors import MaKaCError |
|---|
| 39 | from MaKaC.i18n import _ |
|---|
| 40 | from MaKaC.webinterface.pages.conferences import WPConferenceModificationClosed |
|---|
| 41 | from MaKaC.webinterface.rh.materialDisplay import RHMaterialDisplayCommon |
|---|
| 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 | confPaperReview = request._target.getConference().getConfPaperReview() |
|---|
| 77 | paperReviewChoice = confPaperReview.getChoice() |
|---|
| 78 | reviewManager = request._target.getReviewManager() |
|---|
| 79 | return (confPaperReview.isPaperReviewManager(user) or \ |
|---|
| 80 | (reviewManager.hasReferee() and reviewManager.isReferee(user)) or \ |
|---|
| 81 | ((paperReviewChoice == 3 or paperReviewChoice == 4) and reviewManager.hasEditor() and reviewManager.isEditor(user)) or \ |
|---|
| 82 | ((paperReviewChoice == 2 or paperReviewChoice == 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 | class RHContributionModification(RHContribModifBaseSpecialSesCoordAndReviewingStaffRights): |
|---|
| 141 | _uh = urlHandlers.UHContributionModification |
|---|
| 142 | |
|---|
| 143 | def _checkParams(self, params): |
|---|
| 144 | RHContribModifBase._checkParams(self, params) |
|---|
| 145 | params["days"] = params.get("day", "all") |
|---|
| 146 | if params.get("day", None) is not None : |
|---|
| 147 | del params["day"] |
|---|
| 148 | |
|---|
| 149 | def _process(self): |
|---|
| 150 | params = self._getRequestParams() |
|---|
| 151 | if self._target.getOwner().isClosed(): |
|---|
| 152 | p = contributions.WPContributionModificationClosed(self, self._target) |
|---|
| 153 | else: |
|---|
| 154 | wf = self.getWebFactory() |
|---|
| 155 | if wf != None: |
|---|
| 156 | p = wf.getContributionModification(self, self._target) |
|---|
| 157 | else: |
|---|
| 158 | p = contributions.WPContributionModification(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(RHContribModifBaseSpecialSesCoordRights): |
|---|
| 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 | elif index == -1 : #person data doesn't contain proper id |
|---|
| 587 | if self._getUser() and chosenId in self._getUser().getPersonalInfo().getBasket().getUsers() : #checking if such person is listed on favourites |
|---|
| 588 | chosenPerson = self._getUser().getPersonalInfo().getBasket().getUsers()[chosenId] |
|---|
| 589 | if chosenPerson is None : |
|---|
| 590 | self._redirect(urlHandlers.UHConfModScheduleNewContrib.getURL(self._target)) |
|---|
| 591 | return |
|---|
| 592 | person = SubContribParticipation() |
|---|
| 593 | person.setTitle(chosenPerson.getTitle()) |
|---|
| 594 | person.setFirstName(chosenPerson.getFirstName()) |
|---|
| 595 | person.setFamilyName(chosenPerson.getFamilyName()) |
|---|
| 596 | person.setEmail(chosenPerson.getEmail()) |
|---|
| 597 | person.setAddress(chosenPerson.getAddress()) |
|---|
| 598 | person.setAffiliation(chosenPerson.getAffiliation()) |
|---|
| 599 | person.setPhone(chosenPerson.getPhone()) |
|---|
| 600 | person.setFax(chosenPerson.getFax()) |
|---|
| 601 | if not self._alreadyDefined(person, definedList) : |
|---|
| 602 | definedList.append([person, params.has_key("submissionControl")]) |
|---|
| 603 | else : |
|---|
| 604 | self._errorList.append("%s has been already defined as %s of this session"%(person.getFullName(), self._typeName)) |
|---|
| 605 | else : |
|---|
| 606 | self._redirect(urlHandlers.UHConfModifSchedule.getURL(self._target)) |
|---|
| 607 | return |
|---|
| 608 | preservedParams = self._getPreservedParams() |
|---|
| 609 | preservedParams["errorMsg"] = self._errorList |
|---|
| 610 | self._preserveParams(preservedParams) |
|---|
| 611 | self._websession.setVar("%sList"%self._typeName, definedList) |
|---|
| 612 | |
|---|
| 613 | url = urlHandlers.UHContribAddSubCont.getURL(self._target) |
|---|
| 614 | url.addParam("recalled", "true") |
|---|
| 615 | self._redirect(url) |
|---|
| 616 | |
|---|
| 617 | |
|---|
| 618 | def _getDefinedList(self, typeName): |
|---|
| 619 | definedList = self._websession.getVar("%sList"%typeName) |
|---|
| 620 | if definedList is None : |
|---|
| 621 | return [] |
|---|
| 622 | return definedList |
|---|
| 623 | |
|---|
| 624 | def _alreadyDefined(self, person, definedList): |
|---|
| 625 | if person is None : |
|---|
| 626 | return True |
|---|
| 627 | if definedList is None : |
|---|
| 628 | return False |
|---|
| 629 | fullName = person.getFullName() |
|---|
| 630 | for p in definedList : |
|---|
| 631 | if p[0].getFullName() == fullName : |
|---|
| 632 | return True |
|---|
| 633 | return False |
|---|
| 634 | |
|---|
| 635 | def _getPreservedParams(self): |
|---|
| 636 | params = self._websession.getVar("preservedParams") |
|---|
| 637 | if params is None : |
|---|
| 638 | return {} |
|---|
| 639 | return params |
|---|
| 640 | |
|---|
| 641 | def _preserveParams(self, params): |
|---|
| 642 | self._websession.setVar("preservedParams", params) |
|---|
| 643 | |
|---|
| 644 | def _removePreservedParams(self): |
|---|
| 645 | self._websession.setVar("preservedParams", None) |
|---|
| 646 | |
|---|
| 647 | #------------------------------------------------------------------------------------- |
|---|
| 648 | |
|---|
| 649 | |
|---|
| 650 | #class RHContributionDeleteSC( RHContribModifBase ): |
|---|
| 651 | # _uh = urlHandlers.UHContriDeleteSubCont |
|---|
| 652 | # |
|---|
| 653 | # def _checkParams( self, params ): |
|---|
| 654 | # RHContribModifBase._checkParams( self, params ) |
|---|
| 655 | # self._confirm = params.has_key( "confirm" ) |
|---|
| 656 | # self._cancel = params.has_key( "cancel" ) |
|---|
| 657 | # self._scIds = self._normaliseListParam( params.get("selSubContribs", []) ) |
|---|
| 658 | |
|---|
| 659 | # def _process( self ): |
|---|
| 660 | # for id in self._scIds: |
|---|
| 661 | # sc = self._target.getSubContributionById( id ) |
|---|
| 662 | # self._target.removeSubContribution( sc ) |
|---|
| 663 | # self._redirect( urlHandlers.UHContribModifSubCont.getURL( self._target ) ) |
|---|
| 664 | |
|---|
| 665 | |
|---|
| 666 | class RHContributionUpSC(RHContribModifBaseSpecialSesCoordRights): |
|---|
| 667 | _uh = urlHandlers.UHContribUpSubCont |
|---|
| 668 | |
|---|
| 669 | def _checkParams(self, params): |
|---|
| 670 | RHContribModifBaseSpecialSesCoordRights._checkParams(self, params) |
|---|
| 671 | self._scId = params.get("subContId", "") |
|---|
| 672 | |
|---|
| 673 | def _process(self): |
|---|
| 674 | sc = self._target.getSubContributionById(self._scId) |
|---|
| 675 | self._target.upSubContribution(sc) |
|---|
| 676 | self._redirect(urlHandlers.UHContribModifSubCont.getURL(self._target)) |
|---|
| 677 | |
|---|
| 678 | |
|---|
| 679 | class RHContributionDownSC(RHContribModifBaseSpecialSesCoordRights): |
|---|
| 680 | _uh = urlHandlers.UHContribDownSubCont |
|---|
| 681 | |
|---|
| 682 | def _checkParams(self, params): |
|---|
| 683 | RHContribModifBaseSpecialSesCoordRights._checkParams(self, params) |
|---|
| 684 | self._scId = params.get("subContId", "") |
|---|
| 685 | |
|---|
| 686 | def _process(self): |
|---|
| 687 | sc = self._target.getSubContributionById(self._scId) |
|---|
| 688 | self._target.downSubContribution(sc) |
|---|
| 689 | self._redirect(urlHandlers.UHContribModifSubCont.getURL(self._target)) |
|---|
| 690 | |
|---|
| 691 | |
|---|
| 692 | class RHContributionTools(RHContribModifBaseSpecialSesCoordRights): |
|---|
| 693 | _uh = urlHandlers.UHContribModifTools |
|---|
| 694 | |
|---|
| 695 | def _process(self): |
|---|
| 696 | if self._target.getOwner().isClosed(): |
|---|
| 697 | p = contributions.WPContributionModificationClosed(self, self._target) |
|---|
| 698 | else: |
|---|
| 699 | p = contributions.WPContributionModifTools(self, self._target) |
|---|
| 700 | wf = self.getWebFactory() |
|---|
| 701 | if wf != None: |
|---|
| 702 | p = wf.getContributionModifTools(self, self._target) |
|---|
| 703 | return p.display() |
|---|
| 704 | |
|---|
| 705 | |
|---|
| 706 | class RHContributionData( RoomBookingDBMixin, RHContribModifBaseSpecialSesCoordRights ): |
|---|
| 707 | _uh = urlHandlers.UHContributionDataModif |
|---|
| 708 | |
|---|
| 709 | def _checkParams( self, params ): |
|---|
| 710 | RHContribModifBaseSpecialSesCoordRights._checkParams(self, params) |
|---|
| 711 | |
|---|
| 712 | self._evt = self._target |
|---|
| 713 | |
|---|
| 714 | def _process(self): |
|---|
| 715 | if self._target.getOwner().isClosed(): |
|---|
| 716 | p = contributions.WPContributionModificationClosed(self, self._target) |
|---|
| 717 | else: |
|---|
| 718 | p = contributions.WPEditData(self, self._target) |
|---|
| 719 | wf = self.getWebFactory() |
|---|
| 720 | if wf != None: |
|---|
| 721 | p = wf.getContributionEditData(self, self._target) |
|---|
| 722 | return p.display(**self._getRequestParams()) |
|---|
| 723 | |
|---|
| 724 | |
|---|
| 725 | class RHContributionModifData(RHContribModifBaseSpecialSesCoordRights): |
|---|
| 726 | _uh = urlHandlers.UHContributionDataModification |
|---|
| 727 | |
|---|
| 728 | def _checkParams(self, params): |
|---|
| 729 | RHContribModifBaseSpecialSesCoordRights._checkParams(self, params) |
|---|
| 730 | self._type=None |
|---|
| 731 | self._check = int(params.get("check", 1)) |
|---|
| 732 | if params.has_key("type") and params["type"].strip()!="": |
|---|
| 733 | self._type=self._target.getConference().getContribTypeById(params["type"]) |
|---|
| 734 | self._cancel = params.has_key("cancel") |
|---|
| 735 | |
|---|
| 736 | def _process(self): |
|---|
| 737 | if not self._cancel: |
|---|
| 738 | params = self._getRequestParams() |
|---|
| 739 | |
|---|
| 740 | if params.has_key("dateTime"): |
|---|
| 741 | dateTime = parseDateTime(params["dateTime"]) |
|---|
| 742 | params["sYear"] = dateTime.year |
|---|
| 743 | params["sMonth"] = dateTime.month |
|---|
| 744 | params["sDay"] = dateTime.day |
|---|
| 745 | params["sHour"] = dateTime.hour |
|---|
| 746 | params["sMinute"] = dateTime.minute |
|---|
| 747 | else: |
|---|
| 748 | params["sYear"] = "" |
|---|
| 749 | params["sMonth"] = "" |
|---|
| 750 | params["sDay"] = "" |
|---|
| 751 | params["sHour"] = "" |
|---|
| 752 | params["sMinute"] = "" |
|---|
| 753 | |
|---|
| 754 | if params.has_key("duration"): |
|---|
| 755 | params["durMins"] = params["duration"]; |
|---|
| 756 | else: |
|---|
| 757 | params["durMins"] = "" |
|---|
| 758 | self._target.setValues(params) |
|---|
| 759 | self._target.setType(self._type) |
|---|
| 760 | self._redirect(urlHandlers.UHContributionModification.getURL(self._target)) |
|---|
| 761 | |
|---|
| 762 | |
|---|
| 763 | class RHSearchPrimaryAuthor (RHContribModifBaseSpecialSesCoordRights): |
|---|
| 764 | def _process(self): |
|---|
| 765 | p=contributions.WPModSearchPrimAuthor(self, self._target) |
|---|
| 766 | return p.display(**self._getRequestParams()) |
|---|
| 767 | |
|---|
| 768 | class RHSearchAddPrimaryAuthor (RHContribModifBaseSpecialSesCoordRights): |
|---|
| 769 | |
|---|
| 770 | def _newPrimAuthor(self, a): |
|---|
| 771 | auth = conference.ContributionParticipation() |
|---|
| 772 | p = self._getRequestParams() |
|---|
| 773 | auth.setTitle(a.getTitle()) |
|---|
| 774 | auth.setFirstName(a.getName()) |
|---|
| 775 | auth.setFamilyName(a.getSurName()) |
|---|
| 776 | auth.setAffiliation(a.getOrganisation()) |
|---|
| 777 | auth.setEmail(a.getEmail()) |
|---|
| 778 | auth.setAddress(a.getAddress()) |
|---|
| 779 | auth.setPhone(a.getTelephone()) |
|---|
| 780 | auth.setFax(a.getFax()) |
|---|
| 781 | self._target.addPrimaryAuthor(auth) |
|---|
| 782 | return auth |
|---|
| 783 | |
|---|
| 784 | def _newPrimAuthorFromAuthor(self, a): |
|---|
| 785 | auth = conference.ContributionParticipation() |
|---|
| 786 | p = self._getRequestParams() |
|---|
| 787 | auth.setTitle(a.getTitle()) |
|---|
| 788 | auth.setFirstName(a.getName()) |
|---|
| 789 | auth.setFamilyName(a.getSurName()) |
|---|
| 790 | auth.setAffiliation(a.getAffiliation()) |
|---|
| 791 | auth.setEmail(a.getEmail()) |
|---|
| 792 | auth.setAddress(a.getAddress()) |
|---|
| 793 | auth.setPhone(a.getPhone()) |
|---|
| 794 | auth.setFax(a.getFax()) |
|---|
| 795 | self._target.addPrimaryAuthor(auth) |
|---|
| 796 | return auth |
|---|
| 797 | |
|---|
| 798 | def _process(self): |
|---|
| 799 | params=self._getRequestParams() |
|---|
| 800 | if "selectedPrincipals" in params and not "cancel" in params: |
|---|
| 801 | ah=user.AvatarHolder() |
|---|
| 802 | authIndex = self._target.getConference().getAuthorIndex() |
|---|
| 803 | for id in self._normaliseListParam(params["selectedPrincipals"]): |
|---|
| 804 | if id[:9] == "*author*:": |
|---|
| 805 | id = id[9:] |
|---|
| 806 | auth=self._newPrimAuthorFromAuthor(authIndex.getById(id)[0]) |
|---|
| 807 | else: |
|---|
| 808 | auth=self._newPrimAuthor(ah.getById(id)) |
|---|
| 809 | if self._getRequestParams().has_key("submissionControl"): |
|---|
| 810 | self._target.grantSubmission(auth) |
|---|
| 811 | self._redirect(urlHandlers.UHContributionModification.getURL(self._target)) |
|---|
| 812 | |
|---|
| 813 | class RHSearchCoAuthor (RHContribModifBaseSpecialSesCoordRights): |
|---|
| 814 | def _process(self): |
|---|
| 815 | p=contributions.WPModSearchCoAuthor(self, self._target) |
|---|
| 816 | return p.display(**self._getRequestParams()) |
|---|
| 817 | |
|---|
| 818 | class RHSearchAddCoAuthor (RHContribModifBaseSpecialSesCoordRights): |
|---|
| 819 | |
|---|
| 820 | def _newCoAuthor(self, a): |
|---|
| 821 | auth = conference.ContributionParticipation() |
|---|
| 822 | p = self._getRequestParams() |
|---|
| 823 | auth.setTitle(a.getTitle()) |
|---|
| 824 | auth.setFirstName(a.getName()) |
|---|
| 825 | auth.setFamilyName(a.getSurName()) |
|---|
| 826 | auth.setAffiliation(a.getOrganisation()) |
|---|
| 827 | auth.setEmail(a.getEmail()) |
|---|
| 828 | auth.setAddress(a.getAddress()) |
|---|
| 829 | auth.setPhone(a.getTelephone()) |
|---|
| 830 | auth.setFax(a.getFax()) |
|---|
| 831 | self._target.addCoAuthor(auth) |
|---|
| 832 | return auth |
|---|
| 833 | |
|---|
| 834 | def _newCoAuthorFromAuthor(self, a): |
|---|
| 835 | auth = conference.ContributionParticipation() |
|---|
| 836 | p = self._getRequestParams() |
|---|
| 837 | auth.setTitle(a.getTitle()) |
|---|
| 838 | auth.setFirstName(a.getName()) |
|---|
| 839 | auth.setFamilyName(a.getSurName()) |
|---|
| 840 | auth.setAffiliation(a.getAffiliation()) |
|---|
| 841 | auth.setEmail(a.getEmail()) |
|---|
| 842 | auth.setAddress(a.getAddress()) |
|---|
| 843 | auth.setPhone(a.getPhone()) |
|---|
| 844 | auth.setFax(a.getFax()) |
|---|
| 845 | self._target.addCoAuthor(auth) |
|---|
| 846 | return auth |
|---|
| 847 | |
|---|
| 848 | def _process(self): |
|---|
| 849 | params=self._getRequestParams() |
|---|
| 850 | if "selectedPrincipals" in params and not "cancel" in params: |
|---|
| 851 | ah=user.AvatarHolder() |
|---|
| 852 | authIndex = self._target.getConference().getAuthorIndex() |
|---|
| 853 | for id in self._normaliseListParam(params["selectedPrincipals"]): |
|---|
| 854 | if id[:9] == "*author*:": |
|---|
| 855 | id = id[9:] |
|---|
| 856 | auth=self._newCoAuthorFromAuthor(authIndex.getById(id)[0]) |
|---|
| 857 | else: |
|---|
| 858 | auth=self._newCoAuthor(ah.getById(id)) |
|---|
| 859 | if self._getRequestParams().has_key("submissionControl"): |
|---|
| 860 | self._target.grantSubmission(auth) |
|---|
| 861 | self._redirect(urlHandlers.UHContributionModification.getURL(self._target)) |
|---|
| 862 | |
|---|
| 863 | |
|---|
| 864 | class RHSearchSpeakers (RHContribModifBaseSpecialSesCoordRights): |
|---|
| 865 | def _process(self): |
|---|
| 866 | p=contributions.WPModSearchSpeaker(self, self._target) |
|---|
| 867 | return p.display(**self._getRequestParams()) |
|---|
| 868 | |
|---|
| 869 | class RHSearchAddSpeakers (RHContribModifBaseSpecialSesCoordRights): |
|---|
| 870 | |
|---|
| 871 | def _newSpeaker(self, a): |
|---|
| 872 | auth = conference.ContributionParticipation() |
|---|
| 873 | p = self._getRequestParams() |
|---|
| 874 | auth.setTitle(a.getTitle()) |
|---|
| 875 | auth.setFirstName(a.getName()) |
|---|
| 876 | auth.setFamilyName(a.getSurName()) |
|---|
| 877 | auth.setAffiliation(a.getOrganisation()) |
|---|
| 878 | auth.setEmail(a.getEmail()) |
|---|
| 879 | auth.setAddress(a.getAddress()) |
|---|
| 880 | auth.setPhone(a.getTelephone()) |
|---|
| 881 | auth.setFax(a.getFax()) |
|---|
| 882 | self._target.newSpeaker(auth) |
|---|
| 883 | return auth |
|---|
| 884 | |
|---|
| 885 | def _newSpeakerFromAuthor(self, a): |
|---|
| 886 | auth = conference.ContributionParticipation() |
|---|
| 887 | p = self._getRequestParams() |
|---|
| 888 | auth.setTitle(a.getTitle()) |
|---|
| 889 | auth.setFirstName(a.getName()) |
|---|
| 890 | auth.setFamilyName(a.getSurName()) |
|---|
| 891 | auth.setAffiliation(a.getAffiliation()) |
|---|
| 892 | auth.setEmail(a.getEmail()) |
|---|
| 893 | auth.setAddress(a.getAddress()) |
|---|
| 894 | auth.setPhone(a.getPhone()) |
|---|
| 895 | auth.setFax(a.getFax()) |
|---|
| 896 | self._target.newSpeaker(auth) |
|---|
| 897 | return auth |
|---|
| 898 | |
|---|
| 899 | def _process(self): |
|---|
| 900 | params=self._getRequestParams() |
|---|
| 901 | if "selectedPrincipals" in params and not "cancel" in params: |
|---|
| 902 | ah=user.AvatarHolder() |
|---|
| 903 | authIndex = self._target.getConference().getAuthorIndex() |
|---|
| 904 | for id in self._normaliseListParam(params["selectedPrincipals"]): |
|---|
| 905 | if id[:9] == "*author*:": |
|---|
| 906 | id = id[9:] |
|---|
| 907 | auth=self._newSpeakerFromAuthor(authIndex.getById(id)[0]) |
|---|
| 908 | else: |
|---|
| 909 | auth=self._newSpeaker(ah.getById(id)) |
|---|
| 910 | if self._getRequestParams().has_key("submissionControl"): |
|---|
| 911 | self._target.grantSubmission(auth) |
|---|
| 912 | self._redirect(urlHandlers.UHContributionModification.getURL(self._target)) |
|---|
| 913 | |
|---|
| 914 | class RHNewPrimaryAuthor(RHContribModifBaseSpecialSesCoordRights): |
|---|
| 915 | |
|---|
| 916 | def _checkParams(self, params): |
|---|
| 917 | RHContribModifBaseSpecialSesCoordRights._checkParams(self, params) |
|---|
| 918 | self._action, self._new="", False |
|---|
| 919 | if params.has_key("ok"): |
|---|
| 920 | self._action = "perform" |
|---|
| 921 | elif params.has_key("ok_and_new"): |
|---|
| 922 | self._action = "perform" |
|---|
| 923 | self._new=True |
|---|
| 924 | elif params.has_key("cancel"): |
|---|
| 925 | self._action = "cancel" |
|---|
| 926 | |
|---|
| 927 | def _newPrimAuthor(self): |
|---|
| 928 | auth = conference.ContributionParticipation() |
|---|
| 929 | p = self._getRequestParams() |
|---|
| 930 | auth.setTitle(p.get("title", "")) |
|---|
| 931 | auth.setFirstName(p.get("name", "")) |
|---|
| 932 | auth.setFamilyName(p.get("surName", "")) |
|---|
| 933 | auth.setAffiliation(p.get("affiliation", "")) |
|---|
| 934 | auth.setEmail(p.get("email", "")) |
|---|
| 935 | auth.setAddress(p.get("address", "")) |
|---|
| 936 | auth.setPhone(p.get("phone", "")) |
|---|
| 937 | auth.setFax(p.get("fax", "")) |
|---|
| 938 | self._target.addPrimaryAuthor(auth) |
|---|
| 939 | return auth |
|---|
| 940 | |
|---|
| 941 | |
|---|
| 942 | def _process(self): |
|---|
| 943 | url=urlHandlers.UHContributionModification.getURL(self._target) |
|---|
| 944 | if self._action=="cancel": |
|---|
| 945 | self._redirect(url) |
|---|
| 946 | return |
|---|
| 947 | elif self._action == "perform": |
|---|
| 948 | auth=self._newPrimAuthor() |
|---|
| 949 | if self._getRequestParams().has_key("submissionControl"): |
|---|
| 950 | if self._getRequestParams().get("email", "").strip() == "": |
|---|
| 951 | raise FormValuesError("If you want to add the author as submitter, please enter their email") |
|---|
| 952 | self._target.grantSubmission(auth) |
|---|
| 953 | if not self._new: |
|---|
| 954 | self._redirect(url) |
|---|
| 955 | return |
|---|
| 956 | p = contributions.WPModNewPrimAuthor(self, self._target) |
|---|
| 957 | return p.display() |
|---|
| 958 | |
|---|
| 959 | |
|---|
| 960 | class RHPrimaryAuthorsActions: |
|---|
| 961 | """ |
|---|
| 962 | class to select the action to do with the selected authors |
|---|
| 963 | """ |
|---|
| 964 | def __init__(self, req): |
|---|
| 965 | self._req = req |
|---|
| 966 | |
|---|
| 967 | def process(self, params): |
|---|
| 968 | if params.has_key("REMOVE"): |
|---|
| 969 | return RHRemPrimaryAuthors(self._req).process(params) |
|---|
| 970 | elif params.has_key("MOVE"): |
|---|
| 971 | return RHMovePrimaryToCoAuthors(self._req).process(params) |
|---|
| 972 | return "no action to do" |
|---|
| 973 | |
|---|
| 974 | |
|---|
| 975 | class RHRemPrimaryAuthors(RHContribModifBaseSpecialSesCoordRights): |
|---|
| 976 | def _checkParams(self, params): |
|---|
| 977 | RHContribModifBaseSpecialSesCoordRights._checkParams(self, params) |
|---|
| 978 | self._list = [] |
|---|
| 979 | for id in self._normaliseListParam(params.get("selAuthor", [])): |
|---|
| 980 | self._list.append(self._target.getAuthorById(id)) |
|---|
| 981 | |
|---|
| 982 | def _process(self): |
|---|
| 983 | for auth in self._list: |
|---|
| 984 | self._target.removePrimaryAuthor(auth) |
|---|
| 985 | url=urlHandlers.UHContributionModification.getURL(self._target) |
|---|
| 986 | self._redirect(url) |
|---|
| 987 | |
|---|
| 988 | class RHMovePrimaryToCoAuthors(RHContribModifBaseSpecialSesCoordRights): |
|---|
| 989 | def _checkParams(self, params): |
|---|
| 990 | RHContribModifBaseSpecialSesCoordRights._checkParams(self, params) |
|---|
| 991 | self._list = [] |
|---|
| 992 | for id in self._normaliseListParam(params.get("selAuthor", [])): |
|---|
| 993 | self._list.append(self._target.getAuthorById(id)) |
|---|
| 994 | |
|---|
| 995 | def _process(self): |
|---|
| 996 | for auth in self._list: |
|---|
| 997 | self._target.removePrimaryAuthor(auth, 0, False) |
|---|
| 998 | self._target.addCoAuthor(auth) |
|---|
| 999 | url=urlHandlers.UHContributionModification.getURL(self._target) |
|---|
| 1000 | self._redirect(url) |
|---|
| 1001 | |
|---|
| 1002 | |
|---|
| 1003 | class RHEditPrimaryAuthor(RHContribModifBaseSpecialSesCoordRights): |
|---|
| 1004 | |
|---|
| 1005 | def _checkParams(self, params): |
|---|
| 1006 | RHContribModifBaseSpecialSesCoordRights._checkParams(self, params) |
|---|
| 1007 | self._authorId=params["authorId"] |
|---|
| 1008 | self._action="" |
|---|
| 1009 | if params.has_key("ok"): |
|---|
| 1010 | self._action = "perform" |
|---|
| 1011 | elif params.has_key("cancel"): |
|---|
| 1012 | self._action = "cancel" |
|---|
| 1013 | |
|---|
| 1014 | def _setPrimAuthorData(self): |
|---|
| 1015 | auth=self._target.getAuthorById(self._authorId) |
|---|
| 1016 | p = self._getRequestParams() |
|---|
| 1017 | auth.setTitle(p.get("title", "")) |
|---|
| 1018 | auth.setFirstName(p.get("name", "")) |
|---|
| 1019 | auth.setFamilyName(p.get("surName", "")) |
|---|
| 1020 | auth.setAffiliation(p.get("affiliation", "")) |
|---|
| 1021 | auth.setAddress(p.get("address", "")) |
|---|
| 1022 | auth.setPhone(p.get("phone", "")) |
|---|
| 1023 | auth.setFax(p.get("fax", "")) |
|---|
| 1024 | |
|---|
| 1025 | grantSubm=False |
|---|
| 1026 | if auth.getEmail().lower().strip() != p.get("email", "").lower().strip(): |
|---|
| 1027 | #----If it's already in the pending queue in order to grant |
|---|
| 1028 | # submission rights we must unindex and after the modification of the email, |
|---|
| 1029 | # index again... |
|---|
| 1030 | if self._target.getConference().getPendingQueuesMgr().isPendingSubmitter(auth): |
|---|
| 1031 | self._target.getConference().getPendingQueuesMgr().removePendingSubmitter(auth) |
|---|
| 1032 | grantSubm=True |
|---|
| 1033 | #----- |
|---|
| 1034 | |
|---|
| 1035 | auth.setEmail(p.get("email", "")) |
|---|
| 1036 | |
|---|
| 1037 | if grantSubm: |
|---|
| 1038 | self._target.grantSubmission(auth) |
|---|
| 1039 | |
|---|
| 1040 | def _process(self): |
|---|
| 1041 | if self._action != "": |
|---|
| 1042 | if self._action == "perform": |
|---|
| 1043 | self._setPrimAuthorData() |
|---|
| 1044 | url=urlHandlers.UHContributionModification.getURL(self._target) |
|---|
| 1045 | self._redirect(url) |
|---|
| 1046 | else: |
|---|
| 1047 | auth=self._target.getAuthorById(self._authorId) |
|---|
| 1048 | p = contributions.WPModPrimAuthor(self, self._target) |
|---|
| 1049 | return p.display(author=auth) |
|---|
| 1050 | |
|---|
| 1051 | |
|---|
| 1052 | class RHNewCoAuthor(RHContribModifBaseSpecialSesCoordRights): |
|---|
| 1053 | |
|---|
| 1054 | def _checkParams(self, params): |
|---|
| 1055 | RHContribModifBaseSpecialSesCoordRights._checkParams(self, params) |
|---|
| 1056 | self._action, self._new="", False |
|---|
| 1057 | if params.has_key("ok"): |
|---|
| 1058 | self._action = "perform" |
|---|
| 1059 | elif params.has_key("ok_and_new"): |
|---|
| 1060 | self._action = "perform" |
|---|
| 1061 | self._new=True |
|---|
| 1062 | elif params.has_key("cancel"): |
|---|
| 1063 | self._action = "cancel" |
|---|
| 1064 | |
|---|
| 1065 | def _newCoAuthor(self): |
|---|
| 1066 | auth = conference.ContributionParticipation() |
|---|
| 1067 | p = self._getRequestParams() |
|---|
| 1068 | auth.setTitle(p.get("title", "")) |
|---|
| 1069 | auth.setFirstName(p.get("name", "")) |
|---|
| 1070 | auth.setFamilyName(p.get("surName", "")) |
|---|
| 1071 | auth.setAffiliation(p.get("affiliation", "")) |
|---|
| 1072 | auth.setEmail(p.get("email", "")) |
|---|
| 1073 | auth.setAddress(p.get("address", "")) |
|---|
| 1074 | auth.setPhone(p.get("phone", "")) |
|---|
| 1075 | auth.setFax(p.get("fax", "")) |
|---|
| 1076 | self._target.addCoAuthor(auth) |
|---|
| 1077 | return auth |
|---|
| 1078 | |
|---|
| 1079 | def _process(self): |
|---|
| 1080 | url=urlHandlers.UHContributionModification.getURL(self._target) |
|---|
| 1081 | if self._action=="cancel": |
|---|
| 1082 | self._redirect(url) |
|---|
| 1083 | return |
|---|
| 1084 | elif self._action=="perform": |
|---|
| 1085 | auth=self._newCoAuthor() |
|---|
| 1086 | if self._getRequestParams().has_key("submissionControl"): |
|---|
| 1087 | if self._getRequestParams().get("email", "").strip() == "": |
|---|
| 1088 | raise FormValuesError("If you want to add the author as submitter, please enter their email") |
|---|
| 1089 | self._target.grantSubmission(auth) |
|---|
| 1090 | if not self._new: |
|---|
| 1091 | self._redirect(url) |
|---|
| 1092 | return |
|---|
| 1093 | p=contributions.WPModNewCoAuthor(self, self._target) |
|---|
| 1094 | return p.display() |
|---|
| 1095 | |
|---|
| 1096 | |
|---|
| 1097 | class RHCoAuthorsActions: |
|---|
| 1098 | """ |
|---|
| 1099 | class to select the action to do with the selected authors |
|---|
| 1100 | """ |
|---|
| 1101 | def __init__(self, req): |
|---|
| 1102 | self._req = req |
|---|
| 1103 | |
|---|
| 1104 | def process(self, params): |
|---|
| 1105 | if params.has_key("REMOVE"): |
|---|
| 1106 | return RHRemCoAuthors(self._req).process(params) |
|---|
| 1107 | elif params.has_key("MOVE"): |
|---|
| 1108 | return RHMoveCoToPrimaryAuthors(self._req).process(params) |
|---|
| 1109 | return "no action to do" |
|---|
| 1110 | |
|---|
| 1111 | |
|---|
| 1112 | class RHRemCoAuthors(RHContribModifBaseSpecialSesCoordRights): |
|---|
| 1113 | |
|---|
| 1114 | def _checkParams(self, params): |
|---|
| 1115 | RHContribModifBaseSpecialSesCoordRights._checkParams(self, params) |
|---|
| 1116 | self._list = [] |
|---|
| 1117 | for id in self._normaliseListParam(params.get("selAuthor", [])): |
|---|
| 1118 | self._list.append(self._target.getAuthorById(id)) |
|---|
| 1119 | |
|---|
| 1120 | def _process(self): |
|---|
| 1121 | for auth in self._list: |
|---|
| 1122 | self._target.removeCoAuthor(auth) |
|---|
| 1123 | url=urlHandlers.UHContributionModification.getURL(self._target) |
|---|
| 1124 | self._redirect(url) |
|---|
| 1125 | |
|---|
| 1126 | class RHMoveCoToPrimaryAuthors(RHContribModifBaseSpecialSesCoordRights): |
|---|
| 1127 | def _checkParams(self, params): |
|---|
| 1128 | RHContribModifBaseSpecialSesCoordRights._checkParams(self, params) |
|---|
| 1129 | self._list = [] |
|---|
| 1130 | for id in self._normaliseListParam(params.get("selAuthor", [])): |
|---|
| 1131 | self._list.append(self._target.getAuthorById(id)) |
|---|
| 1132 | |
|---|
| 1133 | def _process(self): |
|---|
| 1134 | for auth in self._list: |
|---|
| 1135 | self._target.removeCoAuthor(auth, 0, False) |
|---|
| 1136 | self._target.addPrimaryAuthor(auth) |
|---|
| 1137 | url=urlHandlers.UHContributionModification.getURL(self._target) |
|---|
| 1138 | self._redirect(url) |
|---|
| 1139 | |
|---|
| 1140 | class RHEditCoAuthor(RHContribModifBaseSpecialSesCoordRights): |
|---|
| 1141 | |
|---|
| 1142 | def _checkParams(self, params): |
|---|
| 1143 | RHContribModifBaseSpecialSesCoordRights._checkParams(self, params) |
|---|
| 1144 | self._authorId=params["authorId"] |
|---|
| 1145 | self._action="" |
|---|
| 1146 | if params.has_key("ok"): |
|---|
| 1147 | self._action = "perform" |
|---|
| 1148 | elif params.has_key("cancel"): |
|---|
| 1149 | self._action = "cancel" |
|---|
| 1150 | |
|---|
| 1151 | def _setCoAuthorData(self): |
|---|
| 1152 | auth=self._target.getAuthorById(self._authorId) |
|---|
| 1153 | p = self._getRequestParams() |
|---|
| 1154 | auth.setTitle(p.get("title", "")) |
|---|
| 1155 | auth.setFirstName(p.get("name", "")) |
|---|
| 1156 | auth.setFamilyName(p.get("surName", "")) |
|---|
| 1157 | auth.setAffiliation(p.get("affiliation", "")) |
|---|
| 1158 | auth.setAddress(p.get("address", "")) |
|---|
| 1159 | auth.setPhone(p.get("phone", "")) |
|---|
| 1160 | auth.setFax(p.get("fax", "")) |
|---|
| 1161 | |
|---|
| 1162 | grantSubm=False |
|---|
| 1163 | if auth.getEmail().lower().strip() != p.get("email", "").lower().strip(): |
|---|
| 1164 | #----If it's already in the pending queue in order to grant |
|---|
| 1165 | # submission rights we must unindex and after the modification of the email, |
|---|
| 1166 | # index again... |
|---|
| 1167 | if self._target.getConference().getPendingQueuesMgr().isPendingSubmitter(auth): |
|---|
| 1168 | self._target.getConference().getPendingQueuesMgr().removePendingSubmitter(auth) |
|---|
| 1169 | grantSubm=True |
|---|
| 1170 | #----- |
|---|
| 1171 | |
|---|
| 1172 | auth.setEmail(p.get("email", "")) |
|---|
| 1173 | |
|---|
| 1174 | if grantSubm: |
|---|
| 1175 | self._target.grantSubmission(auth) |
|---|
| 1176 | |
|---|
| 1177 | def _process(self): |
|---|
| 1178 | if self._action != "": |
|---|
| 1179 | if self._action == "perform": |
|---|
| 1180 | self._setCoAuthorData() |
|---|
| 1181 | url=urlHandlers.UHContributionModification.getURL(self._target) |
|---|
| 1182 | self._redirect(url) |
|---|
| 1183 | else: |
|---|
| 1184 | auth=self._target.getAuthorById(self._authorId) |
|---|
| 1185 | p = contributions.WPModCoAuthor(self, self._target) |
|---|
| 1186 | return p.display(author=auth) |
|---|
| 1187 | |
|---|
| 1188 | |
|---|
| 1189 | class RHRemSpeakers(RHContribModifBaseSpecialSesCoordRights): |
|---|
| 1190 | |
|---|
| 1191 | def _checkParams(self, params): |
|---|
| 1192 | RHContribModifBaseSpecialSesCoordRights._checkParams(self, params) |
|---|
| 1193 | self._list = [] |
|---|
| 1194 | for id in self._normaliseListParam(params.get("selSpeaker", [])): |
|---|
| 1195 | self._list.append(self._target.getSpeakerById(id)) |
|---|
| 1196 | |
|---|
| 1197 | def _process(self): |
|---|
| 1198 | for auth in self._list: |
|---|
| 1199 | if auth is None: |
|---|
| 1200 | continue |
|---|
| 1201 | self._target.removeSpeaker(auth) |
|---|
| 1202 | url=urlHandlers.UHContributionModification.getURL(self._target) |
|---|
| 1203 | self._redirect(url) |
|---|
| 1204 | |
|---|
| 1205 | |
|---|
| 1206 | class RHAddSpeakers(RHContribModifBaseSpecialSesCoordRights): |
|---|
| 1207 | |
|---|
| 1208 | def _checkParams(self, params): |
|---|
| 1209 | RHContribModifBaseSpecialSesCoordRights._checkParams(self, params) |
|---|
| 1210 | self._list = [] |
|---|
| 1211 | for id in self._normaliseListParam(params.get("selAuthor", [])): |
|---|
| 1212 | self._list.append(self._target.getAuthorById(id)) |
|---|
| 1213 | |
|---|
| 1214 | def _process(self): |
|---|
| 1215 | for auth in self._list: |
|---|
| 1216 | if auth is None: |
|---|
| 1217 | continue |
|---|
| 1218 | self._target.addSpeaker(auth) |
|---|
| 1219 | url=urlHandlers.UHContributionModification.getURL(self._target) |
|---|
| 1220 | self._redirect(url) |
|---|
| 1221 | |
|---|
| 1222 | |
|---|
| 1223 | class RHSetTrack(RHContribModifBase): |
|---|
| 1224 | |
|---|
| 1225 | def _checkParams(self, params): |
|---|
| 1226 | RHContribModifBase._checkParams(self, params) |
|---|
| 1227 | self._track=None |
|---|
| 1228 | if params.has_key("selTrack") and params["selTrack"].strip() != "": |
|---|
| 1229 | self._track = self._target.getConference().getTrackById(params["selTrack"]) |
|---|
| 1230 | |
|---|
| 1231 | def _process(self): |
|---|
| 1232 | self._target.setTrack(self._track) |
|---|
| 1233 | url=urlHandlers.UHContributionModification.getURL(self._target) |
|---|
| 1234 | self._redirect(url) |
|---|
| 1235 | |
|---|
| 1236 | |
|---|
| 1237 | class RHSetSession(RHContribModifBase): |
|---|
| 1238 | |
|---|
| 1239 | def _checkParams(self, params): |
|---|
| 1240 | RHContribModifBase._checkParams(self, params) |
|---|
| 1241 | self._session=None |
|---|
| 1242 | if params.has_key("selSession") and params["selSession"].strip() != "": |
|---|
| 1243 | self._session=self._target.getConference().getSessionById(params["selSession"]) |
|---|
| 1244 | |
|---|
| 1245 | def _process(self): |
|---|
| 1246 | self._target.setSession(self._session) |
|---|
| 1247 | url=urlHandlers.UHContributionModification.getURL(self._target) |
|---|
| 1248 | self._redirect(url) |
|---|
| 1249 | |
|---|
| 1250 | class RHContribModifMaterialBrowse( RHContribModifBase, RHMaterialDisplayCommon ): |
|---|
| 1251 | _uh = urlHandlers.UHContribModifMaterialBrowse |
|---|
| 1252 | |
|---|
| 1253 | def _checkParams(self, params): |
|---|
| 1254 | RHContribModifBase._checkParams(self, params) |
|---|
| 1255 | self._contrib = self._target |
|---|
| 1256 | materialId = params["materialId"] |
|---|
| 1257 | |
|---|
| 1258 | self._material = self._target = self._contrib.getMaterialById(materialId) |
|---|
| 1259 | |
|---|
| 1260 | def _process(self): |
|---|
| 1261 | return RHMaterialDisplayCommon._process(self) |
|---|
| 1262 | |
|---|
| 1263 | def _processManyMaterials( self ): |
|---|
| 1264 | self._redirect( urlHandlers.UHContribModifMaterials.getURL( self._material )) |
|---|
| 1265 | |
|---|
| 1266 | |
|---|
| 1267 | class RHContributionAddMaterial(RHContribModifBaseSpecialSesCoordRights): |
|---|
| 1268 | _uh = urlHandlers.UHContributionAddMaterial |
|---|
| 1269 | |
|---|
| 1270 | def _checkParams(self, params): |
|---|
| 1271 | RHContribModifBaseSpecialSesCoordRights._checkParams(self, params) |
|---|
| 1272 | typeMat = params.get("typeMaterial", "notype") |
|---|
| 1273 | if typeMat=="notype" or typeMat.strip()=="": |
|---|
| 1274 | raise FormValuesError("Please choose a material type") |
|---|
| 1275 | self._mf = materialFactories.ContribMFRegistry().getById(typeMat) |
|---|
| 1276 | |
|---|
| 1277 | def _process(self): |
|---|
| 1278 | if self._mf: |
|---|
| 1279 | if not self._mf.needsCreationPage(): |
|---|
| 1280 | m = RHContributionPerformAddMaterial.create(self._target, self._mf, self._getRequestParams()) |
|---|
| 1281 | self._redirect(urlHandlers.UHMaterialModification.getURL(m)) |
|---|
| 1282 | return |
|---|
| 1283 | p = contributions.WPContribAddMaterial(self, self._target, self._mf) |
|---|
| 1284 | wf = self.getWebFactory() |
|---|
| 1285 | if wf != None: |
|---|
| 1286 | p = wf.getContribAddMaterial(self, self._target, self._mf) |
|---|
| 1287 | return p.display() |
|---|
| 1288 | |
|---|
| 1289 | |
|---|
| 1290 | class RHContributionPerformAddMaterial(RHContribModifBaseSpecialSesCoordRights): |
|---|
| 1291 | _uh = urlHandlers.UHContributionPerformAddMaterial |
|---|
| 1292 | |
|---|
| 1293 | def _checkParams(self, params): |
|---|
| 1294 | RHContribModifBaseSpecialSesCoordRights._checkParams(self, params) |
|---|
| 1295 | typeMat = params.get("typeMaterial", "") |
|---|
| 1296 | self._mf = materialFactories.ContribMFRegistry.getById(typeMat) |
|---|
| 1297 | |
|---|
| 1298 | @staticmethod |
|---|
| 1299 | def create(contrib, matFactory, matData): |
|---|
| 1300 | if matFactory: |
|---|
| 1301 | m = matFactory.create(contrib) |
|---|
| 1302 | else: |
|---|
| 1303 | m = conference.Material() |
|---|
| 1304 | contrib.addMaterial(m) |
|---|
| 1305 | m.setValues(matData) |
|---|
| 1306 | return m |
|---|
| 1307 | |
|---|
| 1308 | def _process(self): |
|---|
| 1309 | m = self.create(self._target, self._mf, self._getRequestParams()) |
|---|
| 1310 | self._redirect(urlHandlers.UHMaterialModification.getURL(m)) |
|---|
| 1311 | |
|---|
| 1312 | |
|---|
| 1313 | class RHContributionRemoveMaterials(RHContribModifBaseSpecialSesCoordRights): |
|---|
| 1314 | _uh = urlHandlers.UHContributionRemoveMaterials |
|---|
| 1315 | |
|---|
| 1316 | def _checkParams(self, params): |
|---|
| 1317 | RHContribModifBaseSpecialSesCoordRights._checkParams(self, params) |
|---|
| 1318 | #typeMat = params.get( "typeMaterial", "" ) |
|---|
| 1319 | #self._mf = materialFactories.ConfMFRegistry().getById( typeMat ) |
|---|
| 1320 | self._materialIds = self._normaliseListParam(params.get("deleteMaterial", [])) |
|---|
| 1321 | self._materialIds = self._normaliseListParam( params.get("materialId", []) ) |
|---|
| 1322 | self._returnURL = params.get("returnURL","") |
|---|
| 1323 | |
|---|
| 1324 | def _process(self): |
|---|
| 1325 | for id in self._materialIds: |
|---|
| 1326 | #Performing the deletion of special material types |
|---|
| 1327 | f = materialFactories.ContribMFRegistry().getById(id) |
|---|
| 1328 | if f: |
|---|
| 1329 | f.remove(self._target) |
|---|
| 1330 | else: |
|---|
| 1331 | #Performs the deletion of additional material types |
|---|
| 1332 | mat = self._target.getMaterialById( id ) |
|---|
| 1333 | self._target.removeMaterial( mat ) |
|---|
| 1334 | if self._returnURL != "": |
|---|
| 1335 | url = self._returnURL |
|---|
| 1336 | else: |
|---|
| 1337 | url = urlHandlers.UHContribModifMaterials.getURL( self._target ) |
|---|
| 1338 | self._redirect( url ) |
|---|
| 1339 | |
|---|
| 1340 | |
|---|
| 1341 | class RHMaterialsAdd(RHContribModifBaseSpecialSesCoordRights): |
|---|
| 1342 | _uh = urlHandlers.UHContribModifAddMaterials |
|---|
| 1343 | |
|---|
| 1344 | def _checkProtection(self): |
|---|
| 1345 | material, _ = self._rhSubmitMaterial._getMaterial(forceCreate = False) |
|---|
| 1346 | if self._target.canUserSubmit(self._aw.getUser()) \ |
|---|
| 1347 | and (not material or material.getReviewingState() < 3): |
|---|
| 1348 | return |
|---|
| 1349 | if not (RCContributionPaperReviewingStaff.hasRights(self) and not self._target.getReviewManager().getLastReview().isAuthorSubmitted()): |
|---|
| 1350 | RHContribModifBaseSpecialSesCoordRights._checkProtection(self) |
|---|
| 1351 | |
|---|
| 1352 | def _checkParams(self, params): |
|---|
| 1353 | RHContribModifBase._checkParams(self, params) |
|---|
| 1354 | if not hasattr(self,"_rhSubmitMaterial"): |
|---|
| 1355 | self._rhSubmitMaterial=RHSubmitMaterialBase(self._target, self) |
|---|
| 1356 | self._rhSubmitMaterial._checkParams(params) |
|---|
| 1357 | |
|---|
| 1358 | def _process( self ): |
|---|
| 1359 | if self._target.getConference().isClosed(): |
|---|
| 1360 | p = WPConferenceModificationClosed( self, self._target ) |
|---|
| 1361 | return p.display() |
|---|
| 1362 | else: |
|---|
| 1363 | r=self._rhSubmitMaterial._process(self, self._getRequestParams()) |
|---|
| 1364 | if r is None: |
|---|
| 1365 | self._redirect(self._uh.getURL(self._target)) |
|---|
| 1366 | |
|---|
| 1367 | return r |
|---|
| 1368 | |
|---|
| 1369 | class RHContributionSelectManagers(RHContribModifBaseSpecialSesCoordRights): |
|---|
| 1370 | _uh = urlHandlers.UHContributionSelectManagers |
|---|
| 1371 | |
|---|
| 1372 | def _process(self): |
|---|
| 1373 | p = contributions.WPContributionSelectManagers(self, self._target) |
|---|
| 1374 | return p.display(**self._getRequestParams()) |
|---|
| 1375 | |
|---|
| 1376 | |
|---|
| 1377 | class RHContributionAddManagers(RHContribModifBaseSpecialSesCoordRights): |
|---|
| 1378 | _uh = urlHandlers.UHContributionAddManagers |
|---|
| 1379 | |
|---|
| 1380 | def _process(self): |
|---|
| 1381 | params = self._getRequestParams() |
|---|
| 1382 | if "selectedPrincipals" in params and not "cancel" in params: |
|---|
| 1383 | ph = user.PrincipalHolder() |
|---|
| 1384 | for id in self._normaliseListParam(params["selectedPrincipals"]): |
|---|
| 1385 | self._target.grantModification(ph.getById(id)) |
|---|
| 1386 | self._redirect(urlHandlers.UHContribModifAC.getURL(self._target)) |
|---|
| 1387 | |
|---|
| 1388 | |
|---|
| 1389 | class RHContributionRemoveManagers(RHContribModifBaseSpecialSesCoordRights): |
|---|
| 1390 | _uh = urlHandlers.UHContributionRemoveManagers |
|---|
| 1391 | |
|---|
| 1392 | def _process(self): |
|---|
| 1393 | params = self._getRequestParams() |
|---|
| 1394 | if ("selectedPrincipals" in params) and \ |
|---|
| 1395 | (len(params["selectedPrincipals"])!=0): |
|---|
| 1396 | ph = user.PrincipalHolder() |
|---|
| 1397 | for id in self._normaliseListParam(params["selectedPrincipals"]): |
|---|
| 1398 | self._target.revokeModification(ph.getById(id)) |
|---|
| 1399 | self._redirect(urlHandlers.UHContribModifAC.getURL(self._target)) |
|---|
| 1400 | |
|---|
| 1401 | |
|---|
| 1402 | class RHContributionSetVisibility(RHContribModifBaseSpecialSesCoordRights): |
|---|
| 1403 | _uh = urlHandlers.UHContributionSetVisibility |
|---|
| 1404 | |
|---|
| 1405 | def _process(self): |
|---|
| 1406 | params = self._getRequestParams() |
|---|
| 1407 | if params.has_key("changeToPrivate"): |
|---|
| 1408 | self._protect = 1 |
|---|
| 1409 | elif params.has_key("changeToInheriting"): |
|---|
| 1410 | self._protect = 0 |
|---|
| 1411 | elif params.has_key("changeToPublic"): |
|---|
| 1412 | self._protect = -1 |
|---|
| 1413 | self._target.setProtection(self._protect) |
|---|
| 1414 | self._redirect(urlHandlers.UHContribModifAC.getURL(self._target)) |
|---|
| 1415 | |
|---|
| 1416 | |
|---|
| 1417 | class RHContributionSelectAllowed(RHContribModifBaseSpecialSesCoordRights): |
|---|
| 1418 | _uh = urlHandlers.UHContributionSelectAllowed |
|---|
| 1419 | |
|---|
| 1420 | def _process(self): |
|---|
| 1421 | p = contributions.WPContributionSelectAllowed(self, self._target) |
|---|
| 1422 | return p.display(**self._getRequestParams()) |
|---|
| 1423 | |
|---|
| 1424 | |
|---|
| 1425 | class RHContributionAddAllowed(RHContribModifBaseSpecialSesCoordRights): |
|---|
| 1426 | _uh = urlHandlers.UHContributionAddAllowed |
|---|
| 1427 | |
|---|
| 1428 | def _process(self): |
|---|
| 1429 | params = self._getRequestParams() |
|---|
| 1430 | if "selectedPrincipals" in params and not "cancel" in params: |
|---|
| 1431 | ph = user.PrincipalHolder() |
|---|
| 1432 | for id in self._normaliseListParam(params["selectedPrincipals"]): |
|---|
| 1433 | self._target.grantAccess(ph.getById(id)) |
|---|
| 1434 | self._redirect(urlHandlers.UHContribModifAC.getURL(self._target)) |
|---|
| 1435 | |
|---|
| 1436 | |
|---|
| 1437 | class RHContributionRemoveAllowed(RHContribModifBaseSpecialSesCoordRights): |
|---|
| 1438 | _uh = urlHandlers.UHContributionRemoveAllowed |
|---|
| 1439 | |
|---|
| 1440 | def _process(self): |
|---|
| 1441 | params = self._getRequestParams() |
|---|
| 1442 | if ("selectedPrincipals" in params) and \ |
|---|
| 1443 | (len(params["selectedPrincipals"])!=0): |
|---|
| 1444 | ph = user.PrincipalHolder() |
|---|
| 1445 | for id in self._normaliseListParam(params["selectedPrincipals"]): |
|---|
| 1446 | self._target.revokeAccess(ph.getById(id)) |
|---|
| 1447 | self._redirect(urlHandlers.UHContribModifAC.getURL(self._target)) |
|---|
| 1448 | |
|---|
| 1449 | |
|---|
| 1450 | class RHContributionAddDomains(RHContribModifBaseSpecialSesCoordRights): |
|---|
| 1451 | _uh = urlHandlers.UHContributionAddDomain |
|---|
| 1452 | |
|---|
| 1453 | def _process(self): |
|---|
| 1454 | params = self._getRequestParams() |
|---|
| 1455 | if ("addDomain" in params) and (len(params["addDomain"])!=0): |
|---|
| 1456 | dh = domain.DomainHolder() |
|---|
| 1457 | for domId in self._normaliseListParam(params["addDomain"]): |
|---|
| 1458 | self._target.requireDomain(dh.getById(domId)) |
|---|
| 1459 | self._redirect(urlHandlers.UHContribModifAC.getURL(self._target)) |
|---|
| 1460 | |
|---|
| 1461 | |
|---|
| 1462 | class RHContributionRemoveDomains(RHContribModifBaseSpecialSesCoordRights): |
|---|
| 1463 | _uh = urlHandlers.UHContributionRemoveDomain |
|---|
| 1464 | |
|---|
| 1465 | def _process(self): |
|---|
| 1466 | params = self._getRequestParams() |
|---|
| 1467 | if ("selectedDomain" in params) and (len(params["selectedDomain"])!=0): |
|---|
| 1468 | dh = domain.DomainHolder() |
|---|
| 1469 | for domId in self._normaliseListParam(params["selectedDomain"]): |
|---|
| 1470 | self._target.freeDomain(dh.getById(domId)) |
|---|
| 1471 | #self._endRequest() |
|---|
| 1472 | self._redirect(urlHandlers.UHContribModifAC.getURL(self._target)) |
|---|
| 1473 | |
|---|
| 1474 | |
|---|
| 1475 | class RHContributionDeletion(RHContribModifBaseSpecialSesCoordRights): |
|---|
| 1476 | _uh = urlHandlers.UHContributionDelete |
|---|
| 1477 | |
|---|
| 1478 | def _checkParams(self, params): |
|---|
| 1479 | RHContribModifBaseSpecialSesCoordRights._checkParams(self, params) |
|---|
| 1480 | self._cancel = False |
|---|
| 1481 | if "cancel" in params: |
|---|
| 1482 | self._cancel = True |
|---|
| 1483 | self._confirmation = params.has_key("confirm") |
|---|
| 1484 | |
|---|
| 1485 | def _perform(self): |
|---|
| 1486 | conf = self._target.getConference() |
|---|
| 1487 | self._target.getOwner().getSchedule().removeEntry(self._target.getSchEntry()) |
|---|
| 1488 | #self._target.getOwner().removeContribution(self._target) |
|---|
| 1489 | self._target.delete() |
|---|
| 1490 | #conf.removeContribution(self._target) |
|---|
| 1491 | |
|---|
| 1492 | def _process(self): |
|---|
| 1493 | if self._cancel: |
|---|
| 1494 | self._redirect(urlHandlers.UHContribModifTools.getURL(self._target)) |
|---|
| 1495 | elif self._confirmation: |
|---|
| 1496 | owner = self._target.getOwner() |
|---|
| 1497 | self._perform() |
|---|
| 1498 | if self._target.getSession(): |
|---|
| 1499 | self._redirect(urlHandlers.UHsessionModification.getURL(owner)) |
|---|
| 1500 | else: |
|---|
| 1501 | self._redirect(urlHandlers.UHConferenceModification.getURL(owner)) |
|---|
| 1502 | else: |
|---|
| 1503 | p = contributions.WPContributionDeletion(self, self._target) |
|---|
| 1504 | return p.display() |
|---|
| 1505 | |
|---|
| 1506 | |
|---|
| 1507 | class RHContributionMove(RHContribModifBaseSpecialSesCoordRights): |
|---|
| 1508 | _uh = urlHandlers.UHContributionMove |
|---|
| 1509 | |
|---|
| 1510 | def _process(self): |
|---|
| 1511 | p = contributions.WPcontribMove(self, self._target) |
|---|
| 1512 | return p.display(**self._getRequestParams()) |
|---|
| 1513 | |
|---|
| 1514 | |
|---|
| 1515 | class RHContributionPerformMove(RHContribModifBaseSpecialSesCoordRights): |
|---|
| 1516 | _uh = urlHandlers.UHContributionPerformMove |
|---|
| 1517 | |
|---|
| 1518 | def _checkParams(self, params): |
|---|
| 1519 | RHContribModifBaseSpecialSesCoordRights._checkParams(self, params) |
|---|
| 1520 | self._dest = params["Destination"] |
|---|
| 1521 | if self._dest == "--no-sessions--": |
|---|
| 1522 | raise MaKaCError( _("Undefined destination for the contribution.")) |
|---|
| 1523 | |
|---|
| 1524 | def _process(self): |
|---|
| 1525 | conf = self._target.getConference() |
|---|
| 1526 | if self._dest == 'CONF': |
|---|
| 1527 | newOwner = conf |
|---|
| 1528 | else: |
|---|
| 1529 | newOwner = conf.getSessionById(self._dest) |
|---|
| 1530 | self._moveContrib(newOwner) |
|---|
| 1531 | self._redirect(urlHandlers.UHContribModifTools.getURL(self._target)) |
|---|
| 1532 | |
|---|
| 1533 | return "done" |
|---|
| 1534 | |
|---|
| 1535 | def _moveContrib(self, newOwner): |
|---|
| 1536 | owner = self._target.getOwner() |
|---|
| 1537 | owner.removeContribution(self._target) |
|---|
| 1538 | newOwner.addContribution(self._target) |
|---|
| 1539 | |
|---|
| 1540 | |
|---|
| 1541 | class RHContributionWriteMinutes(RHContribModifBaseSpecialSesCoordRights): |
|---|
| 1542 | _uh = urlHandlers.UHContributionWriteMinutes |
|---|
| 1543 | |
|---|
| 1544 | def _checkParams(self, params): |
|---|
| 1545 | RHContribModifBaseSpecialSesCoordRights._checkParams(self, params) |
|---|
| 1546 | self._cancel = params.has_key("cancel") |
|---|
| 1547 | self._save = params.has_key("OK") |
|---|
| 1548 | self._text = params.get("text", "")#.strip() |
|---|
| 1549 | |
|---|
| 1550 | def _process(self): |
|---|
| 1551 | if self._cancel: |
|---|
| 1552 | self._redirect(urlHandlers.UHContribModifTools.getURL(self._target)) |
|---|
| 1553 | elif self._save: |
|---|
| 1554 | #if self._text!="": |
|---|
| 1555 | minutes = self._target.getMinutes() |
|---|
| 1556 | if not minutes: |
|---|
| 1557 | minutes = self._target.createMinutes() |
|---|
| 1558 | minutes.setText(self._text) |
|---|
| 1559 | self._redirect(urlHandlers.UHContribModifTools.getURL(self._target)) |
|---|
| 1560 | else: |
|---|
| 1561 | p = contributions.WPContributionWriteMinutes(self, self._target) |
|---|
| 1562 | return p.display() |
|---|
| 1563 | |
|---|
| 1564 | class RHContributionToXML(RHContributionModification): |
|---|
| 1565 | _uh = urlHandlers.UHContribToXMLConfManager |
|---|
| 1566 | |
|---|
| 1567 | def _process(self): |
|---|
| 1568 | filename = "%s - contribution.xml"%self._target.getTitle() |
|---|
| 1569 | x = XMLGen() |
|---|
| 1570 | x.openTag("contribution") |
|---|
| 1571 | x.writeTag("Id", self._target.getId()) |
|---|
| 1572 | x.writeTag("Title", self._target.getTitle()) |
|---|
| 1573 | x.writeTag("Description", self._target.getDescription()) |
|---|
| 1574 | afm = self._target.getConference().getAbstractMgr().getAbstractFieldsMgr() |
|---|
| 1575 | for f in afm.getFields(): |
|---|
| 1576 | id = f.getId() |
|---|
| 1577 | if f.isActive() and self._target.getField(id).strip() != "": |
|---|
| 1578 | x.writeTag(f.getName().replace(" ","_"),self._target.getField(id)) |
|---|
| 1579 | x.writeTag("Conference", self._target.getConference().getTitle()) |
|---|
| 1580 | session = self._target.getSession() |
|---|
| 1581 | if session!=None: |
|---|
| 1582 | x.writeTag("Session", self._target.getSession().getTitle()) |
|---|
| 1583 | l = [] |
|---|
| 1584 | for au in self._target.getAuthorList(): |
|---|
| 1585 | if self._target.isPrimaryAuthor(au): |
|---|
| 1586 | x.openTag("PrimaryAuthor") |
|---|
| 1587 | x.writeTag("FirstName", au.getFirstName()) |
|---|
| 1588 | x.writeTag("FamilyName", au.getFamilyName()) |
|---|
| 1589 | x.writeTag("Email", au.getEmail()) |
|---|
| 1590 | x.writeTag("Affiliation", au.getAffiliation()) |
|---|
| 1591 | x.closeTag("PrimaryAuthor") |
|---|
| 1592 | else: |
|---|
| 1593 | l.append(au) |
|---|
| 1594 | |
|---|
| 1595 | for au in l: |
|---|
| 1596 | x.openTag("Co-Author") |
|---|
| 1597 | x.writeTag("FirstName", au.getFirstName()) |
|---|
| 1598 | x.writeTag("FamilyName", au.getFamilyName()) |
|---|
| 1599 | x.writeTag("Email", au.getEmail()) |
|---|
| 1600 | x.writeTag("Affiliation", au.getAffiliation()) |
|---|
| 1601 | x.closeTag("Co-Author") |
|---|
| 1602 | |
|---|
| 1603 | for au in self._target.getSpeakerList(): |
|---|
| 1604 | x.openTag("Speaker") |
|---|
| 1605 | x.writeTag("FirstName", au.getFirstName ()) |
|---|
| 1606 | x.writeTag("FamilyName", au.getFamilyName()) |
|---|
| 1607 | x.writeTag("Email", au.getEmail()) |
|---|
| 1608 | x.writeTag("Affiliation", au.getAffiliation()) |
|---|
| 1609 | x.closeTag("Speaker") |
|---|
| 1610 | |
|---|
| 1611 | #To change for the new contribution type system to: |
|---|
| 1612 | typeName = "" |
|---|
| 1613 | if self._target.getType(): |
|---|
| 1614 | typeName = self._target.getType().getName() |
|---|
| 1615 | x.writeTag("ContributionType", typeName) |
|---|
| 1616 | |
|---|
| 1617 | t = self._target.getTrack() |
|---|
| 1618 | if t!=None: |
|---|
| 1619 | x.writeTag("Track", t.getTitle()) |
|---|
| 1620 | |
|---|
| 1621 | x.closeTag("contribution") |
|---|
| 1622 | |
|---|
| 1623 | data = x.getXml() |
|---|
| 1624 | |
|---|
| 1625 | cfg = Config.getInstance() |
|---|
| 1626 | mimetype = cfg.getFileTypeMimeType("XML") |
|---|
| 1627 | self._req.content_type = """%s"""%(mimetype) |
|---|
| 1628 | self._req.headers_out["Content-Length"] = "%s"%len(data) |
|---|
| 1629 | self._req.headers_out["Content-Disposition"] = """inline; filename="%s\""""%filename |
|---|
| 1630 | return data |
|---|
| 1631 | |
|---|
| 1632 | |
|---|
| 1633 | class RHContributionToPDF(RHContributionModification): |
|---|
| 1634 | _uh = urlHandlers.UHContribToPDFConfManager |
|---|
| 1635 | |
|---|
| 1636 | def _process(self): |
|---|
| 1637 | tz = self._target.getConference().getTimezone() |
|---|
| 1638 | filename = "%s - Contribution.pdf"%self._target.getTitle() |
|---|
| 1639 | pdf = ConfManagerContribToPDF(self._target.getConference(), self._target, tz=tz) |
|---|
| 1640 | data = pdf.getPDFBin() |
|---|
| 1641 | self._req.headers_out["Content-Length"] = "%s"%len(data) |
|---|
| 1642 | cfg = Config.getInstance() |
|---|
| 1643 | mimetype = cfg.getFileTypeMimeType("PDF") |
|---|
| 1644 | self._req.content_type = """%s"""%(mimetype) |
|---|
| 1645 | self._req.headers_out["Content-Disposition"] = """inline; filename="%s\""""%filename |
|---|
| 1646 | return data |
|---|
| 1647 | |
|---|
| 1648 | |
|---|
| 1649 | class RHAuthBase(RHContribModifBaseSpecialSesCoordRights): |
|---|
| 1650 | |
|---|
| 1651 | def _checkParams(self, params): |
|---|
| 1652 | RHContribModifBaseSpecialSesCoordRights._checkParams(self, params) |
|---|
| 1653 | self._auth=self._target.getAuthorById(params.get("authId", "")) |
|---|
| 1654 | |
|---|
| 1655 | |
|---|
| 1656 | class RHPrimAuthUp(RHAuthBase): |
|---|
| 1657 | |
|---|
| 1658 | def _process(self): |
|---|
| 1659 | contrib=self._target |
|---|
| 1660 | contrib.upPrimaryAuthor(self._auth) |
|---|
| 1661 | self._redirect(urlHandlers.UHContributionModification.getURL(contrib)) |
|---|
| 1662 | |
|---|
| 1663 | |
|---|
| 1664 | class RHPrimAuthDown(RHAuthBase): |
|---|
| 1665 | |
|---|
| 1666 | def _process(self): |
|---|
| 1667 | contrib=self._target |
|---|
| 1668 | contrib.downPrimaryAuthor(self._auth) |
|---|
| 1669 | self._redirect(urlHandlers.UHContributionModification.getURL(contrib)) |
|---|
| 1670 | |
|---|
| 1671 | |
|---|
| 1672 | class RHCoAuthUp(RHAuthBase): |
|---|
| 1673 | |
|---|
| 1674 | def _process(self): |
|---|
| 1675 | contrib=self._target |
|---|
| 1676 | contrib.upCoAuthor(self._auth) |
|---|
| 1677 | self._redirect(urlHandlers.UHContributionModification.getURL(contrib)) |
|---|
| 1678 | |
|---|
| 1679 | |
|---|
| 1680 | class RHCoAuthDown(RHAuthBase): |
|---|
| 1681 | |
|---|
| 1682 | def _process(self): |
|---|
| 1683 | contrib=self._target |
|---|
| 1684 | contrib.downCoAuthor(self._auth) |
|---|
| 1685 | self._redirect(urlHandlers.UHContributionModification.getURL(contrib)) |
|---|
| 1686 | |
|---|
| 1687 | class RHNewSpeaker(RHContribModifBaseSpecialSesCoordRights): |
|---|
| 1688 | |
|---|
| 1689 | def _checkParams(self, params): |
|---|
| 1690 | RHContribModifBaseSpecialSesCoordRights._checkParams(self, params) |
|---|
| 1691 | self._action="" |
|---|
| 1692 | if params.has_key("ok"): |
|---|
| 1693 | self._action = "perform" |
|---|
| 1694 | elif params.has_key("cancel"): |
|---|
| 1695 | self._action = "cancel" |
|---|
| 1696 | |
|---|
| 1697 | def _newSpeaker(self): |
|---|
| 1698 | auth = conference.ContributionParticipation() |
|---|
| 1699 | p = self._getRequestParams() |
|---|
| 1700 | auth.setTitle(p.get("title", "")) |
|---|
| 1701 | auth.setFirstName(p.get("name", "")) |
|---|
| 1702 | auth.setFamilyName(p.get("surName", "")) |
|---|
| 1703 | auth.setAffiliation(p.get("affiliation", "")) |
|---|
| 1704 | auth.setEmail(p.get("email", "")) |
|---|
| 1705 | auth.setAddress(p.get("address", "")) |
|---|
| 1706 | auth.setPhone(p.get("phone", "")) |
|---|
| 1707 | auth.setFax(p.get("fax", "")) |
|---|
| 1708 | self._target.newSpeaker(auth) |
|---|
| 1709 | return auth |
|---|
| 1710 | |
|---|
| 1711 | def _process(self): |
|---|
| 1712 | if self._action != "": |
|---|
| 1713 | if self._action == "perform": |
|---|
| 1714 | auth=self._newSpeaker() |
|---|
| 1715 | if self._getRequestParams().has_key("submissionControl"): |
|---|
| 1716 | if self._getRequestParams().get("email", "").strip() != "": |
|---|
| 1717 | #raise FormValuesError("If you want to add the author as submitter, please enter their email") |
|---|
| 1718 | self._target.grantSubmission(auth) |
|---|
| 1719 | url=urlHandlers.UHContributionModification.getURL(self._target) |
|---|
| 1720 | self._redirect(url) |
|---|
| 1721 | else: |
|---|
| 1722 | p = contributions.WPModNewSpeaker(self, self._target) |
|---|
| 1723 | wf = self.getWebFactory() |
|---|
| 1724 | if wf != None: |
|---|
| 1725 | p = wf.getContributionNewspeaker(self, self._target) |
|---|
| 1726 | return p.display() |
|---|
| 1727 | |
|---|
| 1728 | class RHEditSpeaker(RHContribModifBaseSpecialSesCoordRights): |
|---|
| 1729 | |
|---|
| 1730 | def _checkParams(self, params): |
|---|
| 1731 | RHContribModifBaseSpecialSesCoordRights._checkParams(self, params) |
|---|
| 1732 | self._authorId=params["authorId"] |
|---|
| 1733 | self._action="" |
|---|
| 1734 | if params.has_key("ok"): |
|---|
| 1735 | self._action = "perform" |
|---|
| 1736 | elif params.has_key("cancel"): |
|---|
| 1737 | self._action = "cancel" |
|---|
| 1738 | |
|---|
| 1739 | def _setSpeakerData(self): |
|---|
| 1740 | auth=self._target.getSpeakerById(self._authorId) |
|---|
| 1741 | if auth is not None: |
|---|
| 1742 | p = self._getRequestParams() |
|---|
| 1743 | auth.setTitle(p.get("title", "")) |
|---|
| 1744 | auth.setFirstName(p.get("name", "")) |
|---|
| 1745 | auth.setFamilyName(p.get("surName", "")) |
|---|
| 1746 | auth.setAffiliation(p.get("affiliation", "")) |
|---|
| 1747 | auth.setAddress(p.get("address", "")) |
|---|
| 1748 | auth.setPhone(p.get("phone", "")) |
|---|
| 1749 | auth.setFax(p.get("fax", "")) |
|---|
| 1750 | |
|---|
| 1751 | grantSubm=False |
|---|
| 1752 | if auth.getEmail().lower().strip() != p.get("email", "").lower().strip(): |
|---|
| 1753 | #----If it's already in the pending queue in order to grant |
|---|
| 1754 | # submission rights we must unindex and after the modification of the email, |
|---|
| 1755 | # index again... |
|---|
| 1756 | if self._target.getConference().getPendingQueuesMgr().isPendingSubmitter(auth): |
|---|
| 1757 | self._target.getConference().getPendingQueuesMgr().removePendingSubmitter(auth) |
|---|
| 1758 | grantSubm=True |
|---|
| 1759 | #----- |
|---|
| 1760 | |
|---|
| 1761 | auth.setEmail(p.get("email", "")) |
|---|
| 1762 | |
|---|
| 1763 | if grantSubm: |
|---|
| 1764 | if p.get("email", "").strip() == "": |
|---|
| 1765 | raise FormValuesError("This speaker is in a pending queue waiting to become submitter therefore the email address cannot be empty, please enter their email") |
|---|
| 1766 | self._target.grantSubmission(auth) |
|---|
| 1767 | elif p.has_key("submissionControl"): |
|---|
| 1768 | if p.get("email", "").strip() == "": |
|---|
| 1769 | raise FormValuesError("If you want to add the speaker as submitter, please enter their email") |
|---|
| 1770 | self._target.grantSubmission(auth) |
|---|
| 1771 | |
|---|
| 1772 | def _process(self): |
|---|
| 1773 | if self._action != "": |
|---|
| 1774 | if self._action == "perform": |
|---|
| 1775 | self._setSpeakerData() |
|---|
| 1776 | url=urlHandlers.UHContributionModification.getURL(self._target) |
|---|
| 1777 | self._redirect(url) |
|---|
| 1778 | else: |
|---|
| 1779 | auth=self._target.getSpeakerById(self._authorId) |
|---|
| 1780 | p = contributions.WPModSpeaker(self, self._target) |
|---|
| 1781 | wf = self.getWebFactory() |
|---|
| 1782 | if wf != None: |
|---|
| 1783 | p = wf.getModSpeaker(self, self._target) |
|---|
| 1784 | return p.display(author=auth) |
|---|
| 1785 | |
|---|
| 1786 | |
|---|
| 1787 | class RHSubmittersRem(RHContribModifBaseSpecialSesCoordRights): |
|---|
| 1788 | _uh=urlHandlers.UHContribModSubmittersRem |
|---|
| 1789 | |
|---|
| 1790 | def _checkParams(self, params): |
|---|
| 1791 | RHContribModifBaseSpecialSesCoordRights._checkParams(self, params) |
|---|
| 1792 | self._submitters=[] |
|---|
| 1793 | self._pendings=[] |
|---|
| 1794 | ah=user.PrincipalHolder() |
|---|
| 1795 | for id in self._normaliseListParam(params.get("selUsers", [])): |
|---|
| 1796 | av=ah.getById(id) |
|---|
| 1797 | if av is None: |
|---|
| 1798 | self._pendings.append(id) |
|---|
| 1799 | else: |
|---|
| 1800 | self._submitters.append(av) |
|---|
| 1801 | |
|---|
| 1802 | def _process(self): |
|---|
| 1803 | for sub in self._submitters: |
|---|
| 1804 | self._target.revokeSubmission(sub) |
|---|
| 1805 | for email in self._pendings: |
|---|
| 1806 | self._target.revokeSubmissionEmail(email) |
|---|
| 1807 | self._redirect(urlHandlers.UHContribModifAC.getURL(self._target)) |
|---|
| 1808 | |
|---|
| 1809 | |
|---|
| 1810 | class RHSubmittersSel(RHContribModifBaseSpecialSesCoordRights): |
|---|
| 1811 | _uh=urlHandlers.UHContribModSubmittersSel |
|---|
| 1812 | |
|---|
| 1813 | def _process(self): |
|---|
| 1814 | p=contributions.WPModSubmittersSel(self, self._target) |
|---|
| 1815 | return p.display(**self._getRequestParams()) |
|---|
| 1816 | |
|---|
| 1817 | |
|---|
| 1818 | class RHSubmittersAdd(RHContribModifBaseSpecialSesCoordRights): |
|---|
| 1819 | _uh=urlHandlers.UHContribModSubmittersAdd |
|---|
| 1820 | |
|---|
| 1821 | def _checkParams(self, params): |
|---|
| 1822 | RHContribModifBaseSpecialSesCoordRights._checkParams(self, params) |
|---|
| 1823 | self._submitterRole=self._normaliseListParam(params.get("submitterRole", [])) |
|---|
| 1824 | |
|---|
| 1825 | def _process(self): |
|---|
| 1826 | params=self._getRequestParams() |
|---|
| 1827 | if "selectedPrincipals" in params and not "cancel" in params: |
|---|
| 1828 | ah=user.PrincipalHolder() |
|---|
| 1829 | for id in self._normaliseListParam(params["selectedPrincipals"]): |
|---|
| 1830 | av=ah.getById(id) |
|---|
| 1831 | self._target.grantSubmission(av) |
|---|
| 1832 | if self._submitterRole!=[] and not isinstance(av, user.Group): |
|---|
| 1833 | cp=conference.ContributionParticipation() |
|---|
| 1834 | cp.setDataFromAvatar(av) |
|---|
| 1835 | if "primaryAuthor" in self._submitterRole: |
|---|
| 1836 | self._target.addPrimaryAuthor(cp) |
|---|
| 1837 | elif "coAuthor" in self._submitterRole: |
|---|
| 1838 | self._target.addCoAuthor(cp) |
|---|
| 1839 | if "speaker" in self._submitterRole: |
|---|
| 1840 | if self._submitterRole in ["primaryAuthor", "coAuthor"]: |
|---|
| 1841 | self._target.addSpeaker(cp) |
|---|
| 1842 | else: |
|---|
| 1843 | self._target.newSpeaker(cp) |
|---|
| 1844 | self._redirect(urlHandlers.UHContribModifAC.getURL(self._target)) |
|---|
| 1845 | |
|---|
| 1846 | class RHMaterials(RHContribModifBaseSpecialSesCoordAndReviewingStaffRights): |
|---|
| 1847 | _uh = urlHandlers.UHContribModifMaterials |
|---|
| 1848 | |
|---|
| 1849 | def _checkProtection(self): |
|---|
| 1850 | """ This disables people that are not conference managers or track coordinators to |
|---|
| 1851 | delete files from a contribution. |
|---|
| 1852 | """ |
|---|
| 1853 | RHContribModifBaseSpecialSesCoordAndReviewingStaffRights._checkProtection(self) |
|---|
| 1854 | for key in self._paramsForCheckProtection.keys(): |
|---|
| 1855 | if key.find("delete")!=-1: |
|---|
| 1856 | RHContribModifBaseSpecialSesCoordRights._checkProtection(self) |
|---|
| 1857 | |
|---|
| 1858 | def _checkParams(self, params): |
|---|
| 1859 | RHContribModifBaseSpecialSesCoordAndReviewingStaffRights._checkParams(self, params) |
|---|
| 1860 | #if not hasattr(self, "_rhSubmitMaterial"): |
|---|
| 1861 | # self._rhSubmitMaterial=RHSubmitMaterialBase(self._target, self) |
|---|
| 1862 | #self._rhSubmitMaterial._checkParams(params) |
|---|
| 1863 | params["days"] = params.get("day", "all") |
|---|
| 1864 | if params.get("day", None) is not None : |
|---|
| 1865 | del params["day"] |
|---|
| 1866 | # note from DavidMC: i wrote this long parameter name in order |
|---|
| 1867 | # not to overwrite a possibly existing _params in a base class |
|---|
| 1868 | # we need to store the params so that _checkProtection can know |
|---|
| 1869 | # if the action is to upload a file, delete etc. |
|---|
| 1870 | self._paramsForCheckProtection = params |
|---|
| 1871 | |
|---|
| 1872 | def _process(self): |
|---|
| 1873 | if self._target.getOwner().isClosed(): |
|---|
| 1874 | p = WPConferenceModificationClosed( self, self._target ) |
|---|
| 1875 | return p.display() |
|---|
| 1876 | |
|---|
| 1877 | p = contributions.WPContributionModifMaterials( self, self._target ) |
|---|
| 1878 | return p.display(**self._getRequestParams()) |
|---|
| 1879 | |
|---|
| 1880 | |
|---|
| 1881 | |
|---|
| 1882 | class RHContributionReportNumberEdit(RHContribModifBase): |
|---|
| 1883 | |
|---|
| 1884 | def _checkParams(self, params): |
|---|
| 1885 | RHContribModifBase._checkParams(self, params) |
|---|
| 1886 | self._reportNumberSystem=params.get("reportNumberSystem","") |
|---|
| 1887 | |
|---|
| 1888 | def _process(self): |
|---|
| 1889 | if self._reportNumberSystem!="": |
|---|
| 1890 | p=contributions.WPContributionReportNumberEdit(self,self._target, self._reportNumberSystem) |
|---|
| 1891 | return p.display() |
|---|
| 1892 | else: |
|---|
| 1893 | self._redirect(urlHandlers.UHContributionModification.getURL( self._target )) |
|---|
| 1894 | |
|---|
| 1895 | class RHContributionReportNumberPerformEdit(RHContribModifBase): |
|---|
| 1896 | |
|---|
| 1897 | def _checkParams(self, params): |
|---|
| 1898 | RHContribModifBase._checkParams(self, params) |
|---|
| 1899 | self._reportNumberSystem=params.get("reportNumberSystem","") |
|---|
| 1900 | self._reportNumber=params.get("reportNumber","") |
|---|
| 1901 | |
|---|
| 1902 | def _process(self): |
|---|
| 1903 | if self._reportNumberSystem!="" and self._reportNumber!="": |
|---|
| 1904 | self._target.getReportNumberHolder().addReportNumber(self._reportNumberSystem, self._reportNumber) |
|---|
| 1905 | self._redirect("%s#reportNumber"%urlHandlers.UHContributionModification.getURL( self._target )) |
|---|
| 1906 | |
|---|
| 1907 | |
|---|
| 1908 | class RHContributionReportNumberRemove(RHContribModifBase): |
|---|
| 1909 | |
|---|
| 1910 | def _checkParams(self, params): |
|---|
| 1911 | RHContribModifBase._checkParams(self, params) |
|---|
| 1912 | self._reportNumberIdsToBeDeleted=self._normaliseListParam( params.get("deleteReportNumber",[])) |
|---|
| 1913 | |
|---|
| 1914 | def _process(self): |
|---|
| 1915 | nbDeleted = 0 |
|---|
| 1916 | for id in self._reportNumberIdsToBeDeleted: |
|---|
| 1917 | self._target.getReportNumberHolder().removeReportNumberById(int(id)-nbDeleted) |
|---|
| 1918 | nbDeleted += 1 |
|---|
| 1919 | self._redirect("%s#reportNumber"%urlHandlers.UHContributionModification.getURL( self._target )) |
|---|
| 1920 | |
|---|
| 1921 | |
|---|
| 1922 | |
|---|