| 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.urlHandlers as urlHandlers |
|---|
| 22 | import MaKaC.webinterface.pages.abstracts as abstracts |
|---|
| 23 | import MaKaC.review as review |
|---|
| 24 | import MaKaC.user as user |
|---|
| 25 | from MaKaC.webinterface.rh.base import RHModificationBaseProtected |
|---|
| 26 | from MaKaC.webinterface.rh.conferenceBase import RHAbstractBase, RHConferenceBase |
|---|
| 27 | from MaKaC.PDFinterface.conference import ConfManagerAbstractToPDF, ConfManagerAbstractsToPDF |
|---|
| 28 | from MaKaC.common.xmlGen import XMLGen |
|---|
| 29 | from MaKaC.errors import MaKaCError,ModificationError, FormValuesError |
|---|
| 30 | from MaKaC.webinterface.common.abstractNotificator import EmailNotificator |
|---|
| 31 | from MaKaC.common import Config |
|---|
| 32 | import MaKaC.webinterface.common.abstractDataWrapper as abstractDataWrapper |
|---|
| 33 | from MaKaC.i18n import _ |
|---|
| 34 | from MaKaC.webinterface.rh.conferenceModif import CFAEnabled |
|---|
| 35 | from MaKaC.reviewing import ConferenceAbstractReview |
|---|
| 36 | |
|---|
| 37 | class RCAbstractReviewer(object): |
|---|
| 38 | @staticmethod |
|---|
| 39 | def hasRights(request): |
|---|
| 40 | """ Returns True if the user is an Abstract Reviewer of the given abstract |
|---|
| 41 | """ |
|---|
| 42 | #TODO: write this when the ReviewManager for abstracts class is implemented |
|---|
| 43 | return False |
|---|
| 44 | |
|---|
| 45 | |
|---|
| 46 | class RHAbstractModifBase( RHAbstractBase, RHModificationBaseProtected ): |
|---|
| 47 | """ Base class to be used for abstract modification in the admin interface, |
|---|
| 48 | when the request can only be performed by Conference managers. |
|---|
| 49 | """ |
|---|
| 50 | |
|---|
| 51 | def _checkParams( self, params ): |
|---|
| 52 | RHAbstractBase._checkParams( self, params ) |
|---|
| 53 | |
|---|
| 54 | def _checkProtection( self ): |
|---|
| 55 | RHModificationBaseProtected._checkProtection( self ) |
|---|
| 56 | CFAEnabled.checkEnabled(self) |
|---|
| 57 | |
|---|
| 58 | def _displayCustomPage( self, wf ): |
|---|
| 59 | return None |
|---|
| 60 | |
|---|
| 61 | def _displayDefaultPage( self ): |
|---|
| 62 | return None |
|---|
| 63 | |
|---|
| 64 | def _process( self ): |
|---|
| 65 | wf = self.getWebFactory() |
|---|
| 66 | if wf != None: |
|---|
| 67 | res = self._displayCustomPage( wf ) |
|---|
| 68 | if res != None: |
|---|
| 69 | return res |
|---|
| 70 | return self._displayDefaultPage() |
|---|
| 71 | |
|---|
| 72 | |
|---|
| 73 | class RHAbstractModifBaseAbstractManager(RHAbstractModifBase): |
|---|
| 74 | """ Base class to be used when the request can only be performed |
|---|
| 75 | by Abstract Managers OR by conference managers |
|---|
| 76 | """ |
|---|
| 77 | |
|---|
| 78 | def _checkProtection(self): |
|---|
| 79 | from MaKaC.webinterface.rh.reviewingModif import RCAbstractManager |
|---|
| 80 | if not RCAbstractManager.hasRights(self): |
|---|
| 81 | RHAbstractModifBase._checkProtection(self) |
|---|
| 82 | CFAEnabled.checkEnabled(self) |
|---|
| 83 | |
|---|
| 84 | class RHAbstractModifBaseAbstractReviewer(RHAbstractModifBase): |
|---|
| 85 | """ Base class to be used when the request can only be performed |
|---|
| 86 | by an Abstract Reviewer (and ONLY by an Abstract Reviewer) |
|---|
| 87 | """ |
|---|
| 88 | |
|---|
| 89 | def _checkProtection(self): |
|---|
| 90 | if not RCAbstractReviewer.hasRights(self): |
|---|
| 91 | raise MaKaCError("Only the reviewer of this abstract can access this page / perform this request") |
|---|
| 92 | CFAEnabled.checkEnabled(self) |
|---|
| 93 | |
|---|
| 94 | class RHRHAbstractModifBaseAbstractReviewingStaff(RHAbstractModifBase): |
|---|
| 95 | """ Base class to be used when the request can only be performed |
|---|
| 96 | by an AM, an AR, OR a Conference Manager |
|---|
| 97 | """ |
|---|
| 98 | |
|---|
| 99 | def _checkProtection(self): |
|---|
| 100 | from MaKaC.webinterface.rh.reviewingModif import RCAbstractManager |
|---|
| 101 | if not RCAbstractManager.hasRights(self) and not RCAbstractReviewer.hasRights(self): |
|---|
| 102 | RHAbstractModifBase._checkProtection(self) |
|---|
| 103 | CFAEnabled.checkEnabled(self) |
|---|
| 104 | |
|---|
| 105 | |
|---|
| 106 | class RHAbstractDelete(RHAbstractModifBase): |
|---|
| 107 | |
|---|
| 108 | def _checkParams( self, params ): |
|---|
| 109 | RHAbstractModifBase._checkParams( self, params ) |
|---|
| 110 | self._remove = params.has_key("confirm") |
|---|
| 111 | self._cancel = params.has_key("cancel") |
|---|
| 112 | |
|---|
| 113 | def _process( self ): |
|---|
| 114 | if self._cancel: |
|---|
| 115 | self._redirect( urlHandlers.UHAbstractModTools.getURL( self._abstract) ) |
|---|
| 116 | else: |
|---|
| 117 | if self._remove: |
|---|
| 118 | self._conf.getAbstractMgr().removeAbstract(self._target) |
|---|
| 119 | self._redirect( urlHandlers.UHConfAbstractManagment.getURL( self._conf) ) |
|---|
| 120 | else: |
|---|
| 121 | p = abstracts.WPModRemConfirmation( self, self._abstract ) |
|---|
| 122 | return p.display() |
|---|
| 123 | |
|---|
| 124 | |
|---|
| 125 | class RHAbstractManagment(RHRHAbstractModifBaseAbstractReviewingStaff): |
|---|
| 126 | |
|---|
| 127 | #def _checkProtection( self ): |
|---|
| 128 | # if len( self._conf.getCoordinatedTracks( self._getUser() ) ) == 0: |
|---|
| 129 | # RHAbstractModifBase._checkProtection( self ) |
|---|
| 130 | |
|---|
| 131 | def _process( self ): |
|---|
| 132 | p = abstracts.WPAbstractManagment( self, self._target ) |
|---|
| 133 | return p.display( **self._getRequestParams() ) |
|---|
| 134 | |
|---|
| 135 | |
|---|
| 136 | class RHAbstractSelectSubmitter(RHAbstractModifBase): |
|---|
| 137 | |
|---|
| 138 | def _process( self ): |
|---|
| 139 | p = abstracts.WPAbstractSelectSubmitter( self, self._target ) |
|---|
| 140 | return p.display( **self._getRequestParams() ) |
|---|
| 141 | |
|---|
| 142 | |
|---|
| 143 | class RHAbstractSetSubmitter(RHAbstractModifBase): |
|---|
| 144 | |
|---|
| 145 | def _process( self ): |
|---|
| 146 | params = self._getRequestParams() |
|---|
| 147 | if "selectedPrincipals" in params and not "cancel" in params: |
|---|
| 148 | ph = user.PrincipalHolder() |
|---|
| 149 | id = params["selectedPrincipals"] |
|---|
| 150 | self._target.setSubmitter( ph.getById( id ) ) |
|---|
| 151 | self._redirect( urlHandlers.UHAbstractManagment.getURL( self._target ) ) |
|---|
| 152 | |
|---|
| 153 | class RHAbstractDirectAccess(RHAbstractModifBase, RHConferenceBase): |
|---|
| 154 | |
|---|
| 155 | def _checkProtection( self ): |
|---|
| 156 | # if len( self._conf.getCoordinatedTracks( self._getUser() ) ) == 0: |
|---|
| 157 | RHAbstractModifBase._checkProtection( self ) |
|---|
| 158 | |
|---|
| 159 | def _checkParams(self, params): |
|---|
| 160 | RHConferenceBase._checkParams(self, params) |
|---|
| 161 | self._abstractId = params.get("abstractId","") |
|---|
| 162 | self._abstractExist = False |
|---|
| 163 | try: |
|---|
| 164 | abstract = self._conf.getAbstractMgr().getAbstractById(self._abstractId) |
|---|
| 165 | self._abstractExist = True |
|---|
| 166 | RHAbstractModifBase._checkParams(self, params) |
|---|
| 167 | except KeyError: |
|---|
| 168 | pass |
|---|
| 169 | |
|---|
| 170 | |
|---|
| 171 | def _process( self ): |
|---|
| 172 | if self._abstractExist and self._target is not None: |
|---|
| 173 | p = abstracts.WPAbstractManagment( self, self._target ) |
|---|
| 174 | return p.display( **self._getRequestParams() ) |
|---|
| 175 | else: |
|---|
| 176 | url = urlHandlers.UHConfAbstractManagment.getURL(self._conf) |
|---|
| 177 | #url.addParam("directAbstractMsg","There is no abstract number %s in this conference"%self._abstractId) |
|---|
| 178 | self._redirect(url) |
|---|
| 179 | return |
|---|
| 180 | |
|---|
| 181 | |
|---|
| 182 | class RHAbstractToPDF(RHAbstractModifBase): |
|---|
| 183 | |
|---|
| 184 | def _process( self ): |
|---|
| 185 | tz = self._conf.getTimezone() |
|---|
| 186 | filename = "%s - Abstract.pdf"%self._target.getTitle() |
|---|
| 187 | pdf = ConfManagerAbstractToPDF(self._conf, self._target, tz=tz) |
|---|
| 188 | data = pdf.getPDFBin() |
|---|
| 189 | self._req.headers_out["Content-Length"] = "%s"%len(data) |
|---|
| 190 | cfg = Config.getInstance() |
|---|
| 191 | mimetype = cfg.getFileTypeMimeType( "PDF" ) |
|---|
| 192 | self._req.content_type = """%s"""%(mimetype) |
|---|
| 193 | self._req.headers_out["Content-Disposition"] = """inline; filename="%s\""""%filename |
|---|
| 194 | return data |
|---|
| 195 | |
|---|
| 196 | |
|---|
| 197 | class RHAbstractToXML(RHAbstractModifBase): |
|---|
| 198 | |
|---|
| 199 | #def _checkProtection( self ): |
|---|
| 200 | # if len( self._conf.getCoordinatedTracks( self._getUser() ) ) == 0: |
|---|
| 201 | # RHAbstractModifBase._checkProtection( self ) |
|---|
| 202 | |
|---|
| 203 | def _process( self ): |
|---|
| 204 | filename = "%s - Abstract.xml"%self._target.getTitle() |
|---|
| 205 | |
|---|
| 206 | x = XMLGen() |
|---|
| 207 | x.openTag("abstract") |
|---|
| 208 | x.writeTag("Id", self._target.getId()) |
|---|
| 209 | x.writeTag("Title", self._target.getTitle()) |
|---|
| 210 | afm = self._target.getConference().getAbstractMgr().getAbstractFieldsMgr() |
|---|
| 211 | for f in afm.getFields(): |
|---|
| 212 | id = f.getId() |
|---|
| 213 | if f.isActive() and self._target.getField(id).strip() != "": |
|---|
| 214 | x.writeTag("field",self._target.getField(id),[("id",id)]) |
|---|
| 215 | x.writeTag("Conference", self._target.getConference().getTitle()) |
|---|
| 216 | l = [] |
|---|
| 217 | for au in self._target.getAuthorList(): |
|---|
| 218 | if self._target.isPrimaryAuthor(au): |
|---|
| 219 | x.openTag("PrimaryAuthor") |
|---|
| 220 | x.writeTag("FirstName", au.getFirstName()) |
|---|
| 221 | x.writeTag("FamilyName", au.getSurName()) |
|---|
| 222 | x.writeTag("Email", au.getEmail()) |
|---|
| 223 | x.writeTag("Affiliation", au.getAffiliation()) |
|---|
| 224 | x.closeTag("PrimaryAuthor") |
|---|
| 225 | else: |
|---|
| 226 | l.append(au) |
|---|
| 227 | |
|---|
| 228 | for au in l: |
|---|
| 229 | x.openTag("Co-Author") |
|---|
| 230 | x.writeTag("FirstName", au.getFirstName()) |
|---|
| 231 | x.writeTag("FamilyName", au.getSurName()) |
|---|
| 232 | x.writeTag("Email", au.getEmail()) |
|---|
| 233 | x.writeTag("Affiliation", au.getAffiliation()) |
|---|
| 234 | x.closeTag("Co-Author") |
|---|
| 235 | |
|---|
| 236 | for au in self._target.getSpeakerList(): |
|---|
| 237 | x.openTag("Speaker") |
|---|
| 238 | x.writeTag("FirstName", au.getFirstName ()) |
|---|
| 239 | x.writeTag("FamilyName", au.getSurName()) |
|---|
| 240 | x.writeTag("Email", au.getEmail()) |
|---|
| 241 | x.writeTag("Affiliation", au.getAffiliation()) |
|---|
| 242 | x.closeTag("Speaker") |
|---|
| 243 | |
|---|
| 244 | #To change for the new contribution type system to: |
|---|
| 245 | #x.writeTag("ContributionType", self._target.getContribType().getName()) |
|---|
| 246 | x.writeTag("ContributionType", self._target.getContribType()) |
|---|
| 247 | |
|---|
| 248 | for t in self._target.getTrackList(): |
|---|
| 249 | x.writeTag("Track", t.getTitle()) |
|---|
| 250 | |
|---|
| 251 | x.closeTag("abstract") |
|---|
| 252 | |
|---|
| 253 | data = x.getXml() |
|---|
| 254 | |
|---|
| 255 | self._req.headers_out["Content-Length"] = "%s"%len(data) |
|---|
| 256 | cfg = Config.getInstance() |
|---|
| 257 | mimetype = cfg.getFileTypeMimeType( "XML" ) |
|---|
| 258 | self._req.content_type = """%s"""%(mimetype) |
|---|
| 259 | self._req.headers_out["Content-Disposition"] = """inline; filename="%s\""""%filename |
|---|
| 260 | return data |
|---|
| 261 | |
|---|
| 262 | |
|---|
| 263 | class _AbstractWrapper: |
|---|
| 264 | |
|---|
| 265 | def __init__(self,status): |
|---|
| 266 | self._status=status |
|---|
| 267 | |
|---|
| 268 | def getCurrentStatus(self): |
|---|
| 269 | return self._status |
|---|
| 270 | |
|---|
| 271 | |
|---|
| 272 | class RHAbstractManagmentAccept(RHAbstractModifBase): |
|---|
| 273 | |
|---|
| 274 | def _checkParams( self, params ): |
|---|
| 275 | RHAbstractModifBase._checkParams( self, params ) |
|---|
| 276 | self._accept = params.get("accept", None) |
|---|
| 277 | self._warningShown=params.has_key("confirm") |
|---|
| 278 | self._trackId = params.get("track", "") |
|---|
| 279 | self._track=self._conf.getTrackById(params.get("track", "")) |
|---|
| 280 | self._sessionId = params.get("session", "") |
|---|
| 281 | self._session=self._conf.getSessionById(params.get("session", "")) |
|---|
| 282 | self._comments = params.get("comments", "") |
|---|
| 283 | self._typeId = params.get("type", "") |
|---|
| 284 | self._doNotify=params.has_key("notify") |
|---|
| 285 | |
|---|
| 286 | def _process( self ): |
|---|
| 287 | if self._accept: |
|---|
| 288 | cType=self._conf.getContribTypeById(self._typeId) |
|---|
| 289 | st=review.AbstractStatusAccepted(self._target,None,self._track,cType) |
|---|
| 290 | wrapper=_AbstractWrapper(st) |
|---|
| 291 | tpl=self._target.getOwner().getNotifTplForAbstract(wrapper) |
|---|
| 292 | if self._doNotify and not self._warningShown and tpl is None: |
|---|
| 293 | p=abstracts.WPModAcceptConfirmation(self,self._target) |
|---|
| 294 | return p.display(track=self._trackId,comments=self._comments,type=self._typeId,session=self._sessionId) |
|---|
| 295 | else: |
|---|
| 296 | self._target.accept(self._getUser(),self._track,cType,self._comments,self._session) |
|---|
| 297 | if self._doNotify: |
|---|
| 298 | n=EmailNotificator() |
|---|
| 299 | self._target.notify(n,self._getUser()) |
|---|
| 300 | self._redirect(urlHandlers.UHAbstractManagment.getURL(self._abstract)) |
|---|
| 301 | else: |
|---|
| 302 | p = abstracts.WPAbstractManagmentAccept( self, self._target ) |
|---|
| 303 | return p.display( **self._getRequestParams() ) |
|---|
| 304 | |
|---|
| 305 | |
|---|
| 306 | class RHAbstractManagmentReject(RHAbstractModifBase): |
|---|
| 307 | |
|---|
| 308 | def _checkParams( self, params ): |
|---|
| 309 | RHAbstractModifBase._checkParams( self, params ) |
|---|
| 310 | self._reject = params.get("reject", None) |
|---|
| 311 | self._comments = params.get("comments", "") |
|---|
| 312 | self._doNotify=params.has_key("notify") |
|---|
| 313 | self._warningShown=params.has_key("confirm") |
|---|
| 314 | |
|---|
| 315 | def _process( self ): |
|---|
| 316 | if self._reject: |
|---|
| 317 | st=review.AbstractStatusRejected(self._target,None,None) |
|---|
| 318 | wrapper=_AbstractWrapper(st) |
|---|
| 319 | tpl=self._target.getOwner().getNotifTplForAbstract(wrapper) |
|---|
| 320 | if self._doNotify and not self._warningShown and tpl is None: |
|---|
| 321 | p=abstracts.WPModRejectConfirmation(self,self._target) |
|---|
| 322 | return p.display(comments=self._comments) |
|---|
| 323 | else: |
|---|
| 324 | self._target.reject(self._getUser(), self._comments) |
|---|
| 325 | if self._doNotify: |
|---|
| 326 | n=EmailNotificator() |
|---|
| 327 | self._target.notify(n,self._getUser()) |
|---|
| 328 | self._redirect(urlHandlers.UHAbstractManagment.getURL(self._target)) |
|---|
| 329 | else: |
|---|
| 330 | p = abstracts.WPAbstractManagmentReject( self, self._target ) |
|---|
| 331 | return p.display( **self._getRequestParams() ) |
|---|
| 332 | |
|---|
| 333 | |
|---|
| 334 | class RHMarkAsDup(RHAbstractModifBase): |
|---|
| 335 | |
|---|
| 336 | def _checkParams( self, params ): |
|---|
| 337 | RHAbstractModifBase._checkParams( self, params ) |
|---|
| 338 | self._action,self._comments,self._original="","",None |
|---|
| 339 | self._originalId="" |
|---|
| 340 | if params.has_key("OK"): |
|---|
| 341 | self._action="MARK" |
|---|
| 342 | self._comments=params.get("comments","") |
|---|
| 343 | self._originalId=params.get("id","") |
|---|
| 344 | self._original=self._target.getOwner().getAbstractById(self._originalId) |
|---|
| 345 | |
|---|
| 346 | def _getErrorsInData(self): |
|---|
| 347 | res=[] |
|---|
| 348 | if self._original==None or self._target==self._original: |
|---|
| 349 | res.append( _("invalid original abstract id")) |
|---|
| 350 | return res |
|---|
| 351 | |
|---|
| 352 | def _process( self ): |
|---|
| 353 | errMsg="" |
|---|
| 354 | if self._action=="MARK": |
|---|
| 355 | errorList=self._getErrorsInData() |
|---|
| 356 | if len(errorList)==0: |
|---|
| 357 | self._target.markAsDuplicated(self._getUser(),self._original,self._comments) |
|---|
| 358 | self._redirect(urlHandlers.UHAbstractManagment.getURL(self._target)) |
|---|
| 359 | return |
|---|
| 360 | else: |
|---|
| 361 | errMsg="<br>".join(errorList) |
|---|
| 362 | p=abstracts.WPModMarkAsDup(self,self._target) |
|---|
| 363 | return p.display(comments=self._comments,originalId=self._originalId,errorMsg=errMsg) |
|---|
| 364 | |
|---|
| 365 | |
|---|
| 366 | class RHUnMarkAsDup(RHAbstractModifBase): |
|---|
| 367 | |
|---|
| 368 | def _checkParams( self, params ): |
|---|
| 369 | RHAbstractModifBase._checkParams( self, params ) |
|---|
| 370 | self._action,self._comments,self._original="","",None |
|---|
| 371 | self._originalId="" |
|---|
| 372 | if params.has_key("OK"): |
|---|
| 373 | self._action="UNMARK" |
|---|
| 374 | self._comments=params.get("comments","") |
|---|
| 375 | |
|---|
| 376 | |
|---|
| 377 | def _process( self ): |
|---|
| 378 | errMsg="" |
|---|
| 379 | if self._action=="UNMARK": |
|---|
| 380 | self._target.unMarkAsDuplicated(self._getUser(),self._comments) |
|---|
| 381 | self._redirect(urlHandlers.UHAbstractManagment.getURL(self._target)) |
|---|
| 382 | return |
|---|
| 383 | p=abstracts.WPModUnMarkAsDup(self,self._target) |
|---|
| 384 | return p.display(comments=self._comments,originalId=self._originalId,errorMsg=errMsg) |
|---|
| 385 | |
|---|
| 386 | |
|---|
| 387 | class RHMergeInto(RHAbstractModifBase): |
|---|
| 388 | |
|---|
| 389 | def _checkParams( self, params ): |
|---|
| 390 | RHAbstractModifBase._checkParams( self, params ) |
|---|
| 391 | self._action,self._comments,self._targetAbs="","",None |
|---|
| 392 | self._targetAbsId,self._includeAuthors,self._doNotify="",False,True |
|---|
| 393 | if params.has_key("OK"): |
|---|
| 394 | self._action="MERGE" |
|---|
| 395 | self._comments=params.get("comments","") |
|---|
| 396 | self._targetAbsId=params.get("id","") |
|---|
| 397 | self._includeAuthors=params.has_key("includeAuthors") |
|---|
| 398 | self._doNotify=params.has_key("notify") |
|---|
| 399 | self._targetAbs=self._target.getOwner().getAbstractById(self._targetAbsId) |
|---|
| 400 | |
|---|
| 401 | def _getErrorsInData(self): |
|---|
| 402 | res=[] |
|---|
| 403 | if self._targetAbs==None or self._target==self._targetAbs: |
|---|
| 404 | res.append("invalid target abstract id") |
|---|
| 405 | return res |
|---|
| 406 | |
|---|
| 407 | def _process( self ): |
|---|
| 408 | errMsg="" |
|---|
| 409 | if self._action=="MERGE": |
|---|
| 410 | errorList=self._getErrorsInData() |
|---|
| 411 | if len(errorList)==0: |
|---|
| 412 | self._target.mergeInto(self._getUser(),self._targetAbs,comments=self._comments,mergeAuthors=self._includeAuthors) |
|---|
| 413 | if self._doNotify: |
|---|
| 414 | self._target.notify(EmailNotificator(),self._getUser()) |
|---|
| 415 | self._redirect(urlHandlers.UHAbstractManagment.getURL(self._target)) |
|---|
| 416 | return |
|---|
| 417 | else: |
|---|
| 418 | errMsg="<br>".join(errorList) |
|---|
| 419 | p=abstracts.WPModMergeInto(self,self._target) |
|---|
| 420 | return p.display(comments=self._comments,targetId=self._targetAbsId,errorMsg=errMsg,includeAuthors=self._includeAuthors,notify=self._doNotify) |
|---|
| 421 | |
|---|
| 422 | |
|---|
| 423 | class RHUnMerge(RHAbstractModifBase): |
|---|
| 424 | |
|---|
| 425 | def _checkParams( self, params ): |
|---|
| 426 | RHAbstractModifBase._checkParams( self, params ) |
|---|
| 427 | self._action,self._comments="","" |
|---|
| 428 | if params.has_key("OK"): |
|---|
| 429 | self._action="UNMERGE" |
|---|
| 430 | self._comments=params.get("comments","") |
|---|
| 431 | |
|---|
| 432 | |
|---|
| 433 | def _process( self ): |
|---|
| 434 | if self._action=="UNMERGE": |
|---|
| 435 | self._target.unMerge(self._getUser(),self._comments) |
|---|
| 436 | self._redirect(urlHandlers.UHAbstractManagment.getURL(self._target)) |
|---|
| 437 | return |
|---|
| 438 | p=abstracts.WPModUnMerge(self,self._target) |
|---|
| 439 | return p.display(comments=self._comments) |
|---|
| 440 | |
|---|
| 441 | |
|---|
| 442 | class RHPropToAcc(RHAbstractModifBase): |
|---|
| 443 | |
|---|
| 444 | def _checkProtection(self): |
|---|
| 445 | try: |
|---|
| 446 | RHAbstractModifBase._checkProtection(self) |
|---|
| 447 | except ModificationError,e: |
|---|
| 448 | if self._target.isAllowedToCoordinate(self._getUser()): |
|---|
| 449 | return |
|---|
| 450 | raise e |
|---|
| 451 | |
|---|
| 452 | def _checkParams( self, params ): |
|---|
| 453 | RHAbstractModifBase._checkParams( self, params ) |
|---|
| 454 | self._action="" |
|---|
| 455 | self._answers = {} |
|---|
| 456 | if params.has_key("OK"): |
|---|
| 457 | self._action="GO" |
|---|
| 458 | conf=self._target.getConference() |
|---|
| 459 | self._track=conf.getTrackById(params.get("track","")) |
|---|
| 460 | if self._track is None: |
|---|
| 461 | raise FormValuesError( _("You have to choose a track in order to do the proposal. If there are not tracks to select, please change the track assignment of the abstract from its management page")) |
|---|
| 462 | self._contribType=self._conf.getContribTypeById(params.get("contribType","")) |
|---|
| 463 | self._comment=params.get("comment","") |
|---|
| 464 | # get answers and make the dictionary |
|---|
| 465 | c = 0 |
|---|
| 466 | for i in conf.getConfAbstractReview().getReviewingQuestions(): |
|---|
| 467 | c += 1 |
|---|
| 468 | self._answers[i.getId()] = int(params.get("_GID"+str(c),0)) |
|---|
| 469 | self._scaleLower = conf.getConfAbstractReview().getScaleLower() |
|---|
| 470 | self._scaleHigher = conf.getConfAbstractReview().getScaleHigher() |
|---|
| 471 | self._numberOfAnswers = conf.getConfAbstractReview().getNumberOfAnswers() |
|---|
| 472 | elif params.has_key("CANCEL"): |
|---|
| 473 | self._action="CANCEL" |
|---|
| 474 | |
|---|
| 475 | def _process( self ): |
|---|
| 476 | url=urlHandlers.UHAbstractManagment.getURL(self._target) |
|---|
| 477 | if self._action=="GO": |
|---|
| 478 | self._abstract.proposeToAccept(self._getUser(),\ |
|---|
| 479 | self._track,self._contribType,self._comment, self._answers, self._scaleLower, self._scaleHigher, self._numberOfAnswers) |
|---|
| 480 | self._redirect(url) |
|---|
| 481 | elif self._action=="CANCEL": |
|---|
| 482 | self._redirect(url) |
|---|
| 483 | else: |
|---|
| 484 | p=abstracts.WPModPropToAcc(self,self._target) |
|---|
| 485 | return p.display() |
|---|
| 486 | |
|---|
| 487 | |
|---|
| 488 | class RHPropToRej(RHAbstractModifBase): |
|---|
| 489 | |
|---|
| 490 | def _checkProtection(self): |
|---|
| 491 | try: |
|---|
| 492 | RHAbstractModifBase._checkProtection(self) |
|---|
| 493 | except ModificationError,e: |
|---|
| 494 | if self._target.isAllowedToCoordinate(self._getUser()): |
|---|
| 495 | return |
|---|
| 496 | raise e |
|---|
| 497 | |
|---|
| 498 | def _checkParams( self, params ): |
|---|
| 499 | RHAbstractModifBase._checkParams( self, params ) |
|---|
| 500 | self._action="" |
|---|
| 501 | self._answers = {} |
|---|
| 502 | if params.has_key("OK"): |
|---|
| 503 | self._action="GO" |
|---|
| 504 | conf=self._target.getConference() |
|---|
| 505 | self._track=conf.getTrackById(params.get("track","")) |
|---|
| 506 | if self._track is None: |
|---|
| 507 | raise FormValuesError( _("You have to choose a track in order to do the proposal. If there are not tracks to select, please change the track assignment of the abstract from its management page")) |
|---|
| 508 | self._contribType=self._conf.getContribTypeById(params.get("contribType","")) |
|---|
| 509 | self._comment=params.get("comment","") |
|---|
| 510 | # get answers and make the dictionary |
|---|
| 511 | c = 0 |
|---|
| 512 | for i in conf.getConfAbstractReview().getReviewingQuestions(): |
|---|
| 513 | c += 1 |
|---|
| 514 | self._answers[i.getId()] = int(params.get("_GID"+str(c),0)) |
|---|
| 515 | self._scaleLower = conf.getConfAbstractReview().getScaleLower() |
|---|
| 516 | self._scaleHigher = conf.getConfAbstractReview().getScaleHigher() |
|---|
| 517 | self._numberOfAnswers = conf.getConfAbstractReview().getNumberOfAnswers() |
|---|
| 518 | elif params.has_key("CANCEL"): |
|---|
| 519 | self._action="CANCEL" |
|---|
| 520 | |
|---|
| 521 | def _process( self ): |
|---|
| 522 | url=urlHandlers.UHAbstractManagment.getURL(self._target) |
|---|
| 523 | if self._action=="GO": |
|---|
| 524 | self._abstract.proposeToReject(self._getUser(),\ |
|---|
| 525 | self._track,self._comment, self._answers, self._scaleLower, self._scaleHigher, self._numberOfAnswers) |
|---|
| 526 | self._redirect(url) |
|---|
| 527 | elif self._action=="CANCEL": |
|---|
| 528 | self._redirect(url) |
|---|
| 529 | else: |
|---|
| 530 | p=abstracts.WPModPropToRej(self,self._target) |
|---|
| 531 | return p.display() |
|---|
| 532 | |
|---|
| 533 | |
|---|
| 534 | class RHWithdraw(RHAbstractModifBase): |
|---|
| 535 | |
|---|
| 536 | def _checkParams(self,params): |
|---|
| 537 | RHAbstractModifBase._checkParams(self,params) |
|---|
| 538 | self._action,self._comments="","" |
|---|
| 539 | if params.has_key("OK"): |
|---|
| 540 | self._action="WITHDRAW" |
|---|
| 541 | self._comment=params.get("comment","") |
|---|
| 542 | if params.has_key("CANCEL"): |
|---|
| 543 | self._action="CANCEL" |
|---|
| 544 | |
|---|
| 545 | def _process( self ): |
|---|
| 546 | url=urlHandlers.UHAbstractManagment.getURL(self._target) |
|---|
| 547 | if self._action=="WITHDRAW": |
|---|
| 548 | self._target.withdraw(self._getUser(),self._comment) |
|---|
| 549 | self._redirect(url) |
|---|
| 550 | return |
|---|
| 551 | elif self._action=="CANCEL": |
|---|
| 552 | self._redirect(url) |
|---|
| 553 | return |
|---|
| 554 | else: |
|---|
| 555 | p=abstracts.WPModWithdraw(self,self._target) |
|---|
| 556 | return p.display() |
|---|
| 557 | |
|---|
| 558 | class RHBackToSubmitted(RHAbstractModifBase): |
|---|
| 559 | |
|---|
| 560 | def _process( self ): |
|---|
| 561 | url=urlHandlers.UHAbstractManagment.getURL(self._target) |
|---|
| 562 | if isinstance(self._abstract.getCurrentStatus(), review.AbstractStatusWithdrawn): |
|---|
| 563 | self._abstract.setCurrentStatus(review.AbstractStatusSubmitted(self._abstract)) |
|---|
| 564 | self._redirect(url) |
|---|
| 565 | |
|---|
| 566 | |
|---|
| 567 | class RHAbstractManagmentChangeTrack(RHAbstractModifBase): |
|---|
| 568 | |
|---|
| 569 | def _checkParams( self, params ): |
|---|
| 570 | self._cancel = params.get("cancel", None) |
|---|
| 571 | self._save = params.get("save", None) |
|---|
| 572 | self._tracks = self._normaliseListParam(params.get("tracks", [])) |
|---|
| 573 | RHAbstractModifBase._checkParams( self, params ) |
|---|
| 574 | |
|---|
| 575 | def _process( self ): |
|---|
| 576 | if self._save: |
|---|
| 577 | tracks = [] |
|---|
| 578 | for trackId in self._tracks: |
|---|
| 579 | tracks.append( self._conf.getTrackById(trackId) ) |
|---|
| 580 | self._target.setTracks( tracks ) |
|---|
| 581 | self._redirect(urlHandlers.UHAbstractManagment.getURL(self._target)) |
|---|
| 582 | elif self._cancel: |
|---|
| 583 | self._redirect(urlHandlers.UHAbstractManagment.getURL(self._target)) |
|---|
| 584 | else: |
|---|
| 585 | p = abstracts.WPAbstractManagmentChangeTrack( self, self._target ) |
|---|
| 586 | return p.display( **self._getRequestParams() ) |
|---|
| 587 | |
|---|
| 588 | |
|---|
| 589 | class RHAbstractTrackManagment(RHAbstractModifBase): |
|---|
| 590 | |
|---|
| 591 | #def _checkProtection( self ): |
|---|
| 592 | # if len( self._conf.getCoordinatedTracks( self._getUser() ) ) == 0: |
|---|
| 593 | # RHAbstractModifBase._checkProtection( self ) |
|---|
| 594 | |
|---|
| 595 | def _process( self ): |
|---|
| 596 | p = abstracts.WPAbstractTrackManagment( self, self._target ) |
|---|
| 597 | return p.display( **self._getRequestParams() ) |
|---|
| 598 | |
|---|
| 599 | class RHAbstractTrackOrderByRating(RHAbstractModifBase): |
|---|
| 600 | |
|---|
| 601 | def _process( self ): |
|---|
| 602 | p = abstracts.WPAbstractTrackOrderByRating( self, self._target ) |
|---|
| 603 | return p.display( **self._getRequestParams() ) |
|---|
| 604 | |
|---|
| 605 | |
|---|
| 606 | class RHAC(RHAbstractModifBase): |
|---|
| 607 | |
|---|
| 608 | #def _checkProtection( self ): |
|---|
| 609 | # if len( self._conf.getCoordinatedTracks( self._getUser() ) ) == 0: |
|---|
| 610 | # RHAbstractModifBase._checkProtection( self ) |
|---|
| 611 | |
|---|
| 612 | def _process( self ): |
|---|
| 613 | p = abstracts.WPModAC(self,self._target) |
|---|
| 614 | return p.display() |
|---|
| 615 | |
|---|
| 616 | |
|---|
| 617 | class RHEditData(RHAbstractModifBase): |
|---|
| 618 | |
|---|
| 619 | def _getDirectionKey(self, params): |
|---|
| 620 | for key in params.keys(): |
|---|
| 621 | if key.startswith("upPA"): |
|---|
| 622 | return key.split("_") |
|---|
| 623 | elif key.startswith("downPA"): |
|---|
| 624 | return key.split("_") |
|---|
| 625 | elif key.startswith("upCA"): |
|---|
| 626 | return key.split("_") |
|---|
| 627 | elif key.startswith("downCA"): |
|---|
| 628 | return key.split("_") |
|---|
| 629 | return None |
|---|
| 630 | |
|---|
| 631 | def _checkParams(self,params): |
|---|
| 632 | RHAbstractModifBase._checkParams(self,params) |
|---|
| 633 | toNorm=["auth_prim_id","auth_prim_title", "auth_prim_first_name", |
|---|
| 634 | "auth_prim_family_name","auth_prim_affiliation", |
|---|
| 635 | "auth_prim_email", "auth_prim_phone", "auth_prim_speaker", |
|---|
| 636 | "auth_co_id","auth_co_title", "auth_co_first_name", |
|---|
| 637 | "auth_co_family_name","auth_co_affiliation", |
|---|
| 638 | "auth_co_email", "auth_co_phone", "auth_co_speaker"] |
|---|
| 639 | for k in toNorm: |
|---|
| 640 | params[k]=self._normaliseListParam(params.get(k,[])) |
|---|
| 641 | self._abstractData=abstractDataWrapper.Abstract(self._conf.getAbstractMgr().getAbstractFieldsMgr(), **params) |
|---|
| 642 | self._doNotSanitizeFields = self._abstractData.getFieldNames() |
|---|
| 643 | self._doNotSanitizeFields.append('title') |
|---|
| 644 | self._action="" |
|---|
| 645 | if params.has_key("OK"): |
|---|
| 646 | self._action="UPDATE" |
|---|
| 647 | elif params.has_key("CANCEL"): |
|---|
| 648 | self._action="CANCEL" |
|---|
| 649 | elif params.has_key("addPrimAuthor"): |
|---|
| 650 | self._abstractData.newPrimaryAuthor() |
|---|
| 651 | elif params.has_key("addCoAuthor"): |
|---|
| 652 | self._abstractData.newCoAuthor() |
|---|
| 653 | elif params.has_key("remPrimAuthors"): |
|---|
| 654 | idList=self._normaliseListParam(params.get("sel_prim_author",[])) |
|---|
| 655 | self._abstractData.removePrimaryAuthors(idList) |
|---|
| 656 | elif params.has_key("remCoAuthors"): |
|---|
| 657 | idList=self._normaliseListParam(params.get("sel_co_author",[])) |
|---|
| 658 | self._abstractData.removeCoAuthors(idList) |
|---|
| 659 | else: |
|---|
| 660 | arrowKey = self._getDirectionKey(params) |
|---|
| 661 | if arrowKey != None: |
|---|
| 662 | id = arrowKey[1] |
|---|
| 663 | if arrowKey[0] == "upPA": |
|---|
| 664 | self._abstractData.upPrimaryAuthors(id) |
|---|
| 665 | elif arrowKey[0] == "downPA": |
|---|
| 666 | self._abstractData.downPrimaryAuthors(id) |
|---|
| 667 | elif arrowKey[0] == "upCA": |
|---|
| 668 | self._abstractData.upCoAuthors(id) |
|---|
| 669 | elif arrowKey[0] == "downCA": |
|---|
| 670 | self._abstractData.downCoAuthors(id) |
|---|
| 671 | else: |
|---|
| 672 | self._abstractData=abstractDataWrapper.Abstract(self._conf.getAbstractMgr().getAbstractFieldsMgr()) |
|---|
| 673 | self._abstractData.mapAbstract(self._target) |
|---|
| 674 | |
|---|
| 675 | def _process( self ): |
|---|
| 676 | if self._action=="UPDATE": |
|---|
| 677 | if not self._abstractData.hasErrors(): |
|---|
| 678 | self._abstractData.updateAbstract(self._target) |
|---|
| 679 | self._redirect(urlHandlers.UHAbstractManagment.getURL(self._target)) |
|---|
| 680 | return |
|---|
| 681 | elif self._action=="CANCEL": |
|---|
| 682 | self._redirect(urlHandlers.UHAbstractManagment.getURL(self._target)) |
|---|
| 683 | return |
|---|
| 684 | p = abstracts.WPModEditData(self,self._target,self._abstractData) |
|---|
| 685 | return p.display() |
|---|
| 686 | |
|---|
| 687 | |
|---|
| 688 | class RHIntComments(RHAbstractModifBase): |
|---|
| 689 | |
|---|
| 690 | #def _checkProtection( self ): |
|---|
| 691 | # if len( self._conf.getCoordinatedTracks( self._getUser() ) ) == 0: |
|---|
| 692 | # RHAbstractModifBase._checkProtection( self ) |
|---|
| 693 | |
|---|
| 694 | def _process( self ): |
|---|
| 695 | p = abstracts.WPModIntComments(self,self._target) |
|---|
| 696 | return p.display() |
|---|
| 697 | |
|---|
| 698 | |
|---|
| 699 | class RHNewIntComment(RHIntComments): |
|---|
| 700 | |
|---|
| 701 | def _checkParams(self,params): |
|---|
| 702 | RHIntComments._checkParams(self,params) |
|---|
| 703 | self._action="" |
|---|
| 704 | if params.has_key("OK"): |
|---|
| 705 | self._action="UPDATE" |
|---|
| 706 | self._content=params.get("content","") |
|---|
| 707 | elif params.has_key("CANCEL"): |
|---|
| 708 | self._action="CANCEL" |
|---|
| 709 | |
|---|
| 710 | def _process( self ): |
|---|
| 711 | if self._action=="UPDATE": |
|---|
| 712 | c=review.Comment(self._getUser()) |
|---|
| 713 | c.setContent(self._content) |
|---|
| 714 | self._target.addIntComment(c) |
|---|
| 715 | self._redirect(urlHandlers.UHAbstractModIntComments.getURL(self._target)) |
|---|
| 716 | return |
|---|
| 717 | elif self._action=="CANCEL": |
|---|
| 718 | self._redirect(urlHandlers.UHAbstractModIntComments.getURL(self._target)) |
|---|
| 719 | return |
|---|
| 720 | p = abstracts.WPModNewIntComment(self,self._target) |
|---|
| 721 | return p.display() |
|---|
| 722 | |
|---|
| 723 | |
|---|
| 724 | class RHIntCommentBase(RHAbstractModifBase): |
|---|
| 725 | |
|---|
| 726 | def _checkParams(self,params): |
|---|
| 727 | RHAbstractModifBase._checkParams(self,params) |
|---|
| 728 | id=params.get("intCommentId","") |
|---|
| 729 | if id=="": |
|---|
| 730 | raise MaKaCError( _("the internal comment identifier hasn't been specified")) |
|---|
| 731 | abstract=self._target |
|---|
| 732 | self._target=abstract.getIntCommentById(id) |
|---|
| 733 | |
|---|
| 734 | |
|---|
| 735 | class RHIntCommentRem(RHIntCommentBase): |
|---|
| 736 | |
|---|
| 737 | def _process(self): |
|---|
| 738 | abstract=self._target.getAbstract() |
|---|
| 739 | abstract.removeIntComment(self._target) |
|---|
| 740 | self._redirect(urlHandlers.UHAbstractModIntComments.getURL(abstract)) |
|---|
| 741 | |
|---|
| 742 | |
|---|
| 743 | class RHIntCommentEdit(RHIntCommentBase): |
|---|
| 744 | |
|---|
| 745 | def _checkParams(self,params): |
|---|
| 746 | RHIntCommentBase._checkParams(self,params) |
|---|
| 747 | self._action="" |
|---|
| 748 | if params.has_key("OK"): |
|---|
| 749 | self._action="UPDATE" |
|---|
| 750 | self._content=params.get("content","") |
|---|
| 751 | elif params.has_key("CANCEL"): |
|---|
| 752 | self._action="CANCEL" |
|---|
| 753 | |
|---|
| 754 | def _process(self): |
|---|
| 755 | if self._action=="UPDATE": |
|---|
| 756 | self._target.setContent(self._content) |
|---|
| 757 | self._redirect(urlHandlers.UHAbstractModIntComments.getURL(self._target.getAbstract())) |
|---|
| 758 | return |
|---|
| 759 | elif self._action=="CANCEL": |
|---|
| 760 | self._redirect(urlHandlers.UHAbstractModIntComments.getURL(self._target.getAbstract())) |
|---|
| 761 | return |
|---|
| 762 | p=abstracts.WPModIntCommentEdit(self,self._target) |
|---|
| 763 | return p.display() |
|---|
| 764 | |
|---|
| 765 | |
|---|
| 766 | class RHNotifLog(RHAbstractModifBase): |
|---|
| 767 | |
|---|
| 768 | #def _checkProtection( self ): |
|---|
| 769 | # if len( self._conf.getCoordinatedTracks( self._getUser() ) ) == 0: |
|---|
| 770 | # RHAbstractModifBase._checkProtection( self ) |
|---|
| 771 | |
|---|
| 772 | def _process( self ): |
|---|
| 773 | p = abstracts.WPModNotifLog(self,self._target) |
|---|
| 774 | return p.display() |
|---|
| 775 | |
|---|
| 776 | class RHTools(RHAbstractModifBase): |
|---|
| 777 | |
|---|
| 778 | #def _checkProtection( self ): |
|---|
| 779 | # if len( self._conf.getCoordinatedTracks( self._getUser() ) ) == 0: |
|---|
| 780 | # RHAbstractModifBase._checkProtection( self ) |
|---|
| 781 | |
|---|
| 782 | def _process( self ): |
|---|
| 783 | p = abstracts.WPModTools(self,self._target) |
|---|
| 784 | return p.display() |
|---|
| 785 | |
|---|
| 786 | |
|---|
| 787 | |
|---|
| 788 | |
|---|
| 789 | |
|---|