| 1 | from MaKaC.services.implementation.base import ProtectedModificationService |
|---|
| 2 | from MaKaC.services.implementation.base import ProtectedDisplayService |
|---|
| 3 | from MaKaC.services.implementation.base import ParameterManager |
|---|
| 4 | from MaKaC.services.implementation.roomBooking import GetBookingBase |
|---|
| 5 | |
|---|
| 6 | from MaKaC.services.interface.rpc.common import ServiceError, ServiceAccessError |
|---|
| 7 | |
|---|
| 8 | from MaKaC.common.PickleJar import DictPickler |
|---|
| 9 | |
|---|
| 10 | import MaKaC.conference as conference |
|---|
| 11 | from MaKaC.services.implementation.base import TextModificationBase |
|---|
| 12 | from MaKaC.services.implementation.base import HTMLModificationBase |
|---|
| 13 | from MaKaC.services.implementation.base import DateTimeModificationBase |
|---|
| 14 | from MaKaC.common.fossilize import fossilize |
|---|
| 15 | from MaKaC.fossils.subcontribution import ISubContribParticipationFullFossil |
|---|
| 16 | from MaKaC.user import PrincipalHolder, Avatar, Group, AvatarHolder |
|---|
| 17 | |
|---|
| 18 | class ContributionBase(object): |
|---|
| 19 | |
|---|
| 20 | def _checkParams( self ): |
|---|
| 21 | try: |
|---|
| 22 | self._target = self._conf = conference.ConferenceHolder().getById(self._params["conference"]); |
|---|
| 23 | except: |
|---|
| 24 | try: |
|---|
| 25 | self._target = self._conf = conference.ConferenceHolder().getById(self._params["confId"]); |
|---|
| 26 | except: |
|---|
| 27 | raise ServiceError("ERR-E4", "Invalid conference id.") |
|---|
| 28 | |
|---|
| 29 | if self._conf == None: |
|---|
| 30 | raise Exception("Conference id not specified.") |
|---|
| 31 | |
|---|
| 32 | try: |
|---|
| 33 | self._target = self._contribution = self._conf.getContributionById(self._params["contribution"]) |
|---|
| 34 | except: |
|---|
| 35 | try: |
|---|
| 36 | self._target = self._contribution = self._conf.getContributionById(self._params["contribId"]) |
|---|
| 37 | except: |
|---|
| 38 | raise ServiceError("ERR-C0", "Invalid contribution id.") |
|---|
| 39 | |
|---|
| 40 | if self._target == None: |
|---|
| 41 | raise Exception("Contribution id not specified.") |
|---|
| 42 | |
|---|
| 43 | # create a parameter manager that checks the consistency of passed parameters |
|---|
| 44 | self._pm = ParameterManager(self._params) |
|---|
| 45 | |
|---|
| 46 | class ContributionDisplayBase(ProtectedDisplayService, ContributionBase): |
|---|
| 47 | |
|---|
| 48 | def _checkParams(self): |
|---|
| 49 | ContributionBase._checkParams(self) |
|---|
| 50 | ProtectedDisplayService._checkParams(self) |
|---|
| 51 | |
|---|
| 52 | class ContributionModifBase(ProtectedModificationService, ContributionBase): |
|---|
| 53 | |
|---|
| 54 | def _checkParams(self): |
|---|
| 55 | ContributionBase._checkParams(self) |
|---|
| 56 | ProtectedModificationService._checkParams(self) |
|---|
| 57 | |
|---|
| 58 | def _checkProtection(self): |
|---|
| 59 | if self._target.getSession() != None: |
|---|
| 60 | if self._target.getSession().canCoordinate(self.getAW(), "modifContribs"): |
|---|
| 61 | return |
|---|
| 62 | ProtectedModificationService._checkProtection(self) |
|---|
| 63 | |
|---|
| 64 | class ContributionTextModificationBase(TextModificationBase, ContributionBase): |
|---|
| 65 | pass |
|---|
| 66 | |
|---|
| 67 | class ContributionHTMLModificationBase(HTMLModificationBase, ContributionBase): |
|---|
| 68 | pass |
|---|
| 69 | |
|---|
| 70 | class ContributionDateTimeModificationBase (DateTimeModificationBase, ContributionBase): |
|---|
| 71 | pass |
|---|
| 72 | |
|---|
| 73 | class ContributionAddSubContribution(ContributionModifBase): |
|---|
| 74 | def _checkParams(self): |
|---|
| 75 | ContributionModifBase._checkParams(self) |
|---|
| 76 | |
|---|
| 77 | # "presenters" and "keywords" are not required. they can be empty |
|---|
| 78 | self._presenters = self._pm.extract("presenters", pType=list, allowEmpty=True) |
|---|
| 79 | self._keywords = self._pm.extract("keywords", pType=list, allowEmpty=True) |
|---|
| 80 | self._description = self._pm.extract("description", pType=str, allowEmpty=True, defaultValue="") |
|---|
| 81 | self._reportNumbers = self._pm.extract("reportNumbers", pType=list, allowEmpty=True, defaultValue=[]) |
|---|
| 82 | self._materials = self._pm.extract("materials", pType=dict, allowEmpty=True) |
|---|
| 83 | |
|---|
| 84 | # these are required |
|---|
| 85 | self._duration = self._pm.extract("duration", pType=int) |
|---|
| 86 | self._title = self._pm.extract("title", pType=str) |
|---|
| 87 | |
|---|
| 88 | def __addPresenters(self, subcontrib): |
|---|
| 89 | |
|---|
| 90 | # add each presenter |
|---|
| 91 | for presenterValues in self._presenters: |
|---|
| 92 | |
|---|
| 93 | # magically update a new ContributionParticipation with JSON data, using the DictPickler |
|---|
| 94 | presenter = conference.SubContribParticipation() |
|---|
| 95 | DictPickler.update(presenter, presenterValues) |
|---|
| 96 | |
|---|
| 97 | subcontrib.newSpeaker(presenter) |
|---|
| 98 | |
|---|
| 99 | def __addMaterials(self, subcontrib): |
|---|
| 100 | if self._materials: |
|---|
| 101 | for material in self._materials.keys(): |
|---|
| 102 | newMaterial = conference.Material() |
|---|
| 103 | newMaterial.setTitle(material) |
|---|
| 104 | for resource in self._materials[material]: |
|---|
| 105 | newLink = conference.Link() |
|---|
| 106 | newLink.setURL(resource) |
|---|
| 107 | newLink.setName(resource) |
|---|
| 108 | newMaterial.addResource(newLink) |
|---|
| 109 | subcontrib.addMaterial(newMaterial) |
|---|
| 110 | |
|---|
| 111 | def __addReportNumbers(self, subcontrib): |
|---|
| 112 | if self._reportNumbers: |
|---|
| 113 | for reportTuple in self._reportNumbers: |
|---|
| 114 | for recordNumber in reportTuple[1]: |
|---|
| 115 | subcontrib.getReportNumberHolder().addReportNumber(reportTuple[0], recordNumber) |
|---|
| 116 | |
|---|
| 117 | def _getAnswer(self): |
|---|
| 118 | # create the sub contribution |
|---|
| 119 | sc = self._target.newSubContribution() |
|---|
| 120 | |
|---|
| 121 | sc.setTitle( self._title ) |
|---|
| 122 | sc.setDescription( self._description ) |
|---|
| 123 | # separate the keywords using newlines |
|---|
| 124 | sc.setKeywords('\n'.join(self._keywords)) |
|---|
| 125 | sc.setDuration( self._duration / 60, \ |
|---|
| 126 | self._duration % 60 ) |
|---|
| 127 | |
|---|
| 128 | self.__addMaterials(sc) |
|---|
| 129 | self.__addReportNumbers(sc) |
|---|
| 130 | self.__addPresenters(sc) |
|---|
| 131 | |
|---|
| 132 | # log the event |
|---|
| 133 | logInfo = sc.getLogInfo() |
|---|
| 134 | logInfo["subject"] = "Create new subcontribution: %s"%sc.getTitle() |
|---|
| 135 | self._target.getConference().getLogHandler().logAction(logInfo, "Timetable/SubContribution", self._getUser()) |
|---|
| 136 | |
|---|
| 137 | class ContributionDeleteSubContribution(ContributionModifBase): |
|---|
| 138 | |
|---|
| 139 | # contribution.deleteSubContribution |
|---|
| 140 | |
|---|
| 141 | _asyndicoDoc = { |
|---|
| 142 | 'summary': 'Deletes a subcontribution, given the conference, contribution and subcontribution IDs.', |
|---|
| 143 | 'params': [{'name': 'conference', 'type': 'str'}, |
|---|
| 144 | {'name': 'contribution', 'type': 'str'}, |
|---|
| 145 | {'name': 'subcontribution', 'type': 'str'}], |
|---|
| 146 | 'return': None |
|---|
| 147 | } |
|---|
| 148 | |
|---|
| 149 | def _checkParams(self): |
|---|
| 150 | ContributionModifBase._checkParams(self) |
|---|
| 151 | |
|---|
| 152 | subContId = self._pm.extract("subcontribution", pType=str, allowEmpty=False) |
|---|
| 153 | |
|---|
| 154 | self._subContribution = self._contribution.getSubContributionById(subContId) |
|---|
| 155 | |
|---|
| 156 | def _getAnswer(self): |
|---|
| 157 | self._subContribution.getOwner().removeSubContribution(self._subContribution) |
|---|
| 158 | |
|---|
| 159 | class ContributionGetBooking(ContributionDisplayBase, GetBookingBase): |
|---|
| 160 | pass |
|---|
| 161 | |
|---|
| 162 | class ContributionProtectionUserList(ContributionModifBase): |
|---|
| 163 | |
|---|
| 164 | def _getAnswer(self): |
|---|
| 165 | #will use IAvatarFossil or IGroupFossil |
|---|
| 166 | return fossilize(self._contribution.getAllowedToAccessList()) |
|---|
| 167 | |
|---|
| 168 | class ContributionProtectionAddUsers(ContributionModifBase): |
|---|
| 169 | |
|---|
| 170 | def _checkParams(self): |
|---|
| 171 | ContributionModifBase._checkParams(self) |
|---|
| 172 | |
|---|
| 173 | self._usersData = self._params['value'] |
|---|
| 174 | self._user = self.getAW().getUser() |
|---|
| 175 | |
|---|
| 176 | def _getAnswer(self): |
|---|
| 177 | |
|---|
| 178 | for user in self._usersData : |
|---|
| 179 | |
|---|
| 180 | userToAdd = PrincipalHolder().getById(user['id']) |
|---|
| 181 | |
|---|
| 182 | if not userToAdd : |
|---|
| 183 | raise ServiceError("ERR-U0","User does not exist!") |
|---|
| 184 | |
|---|
| 185 | self._contribution.grantAccess(userToAdd) |
|---|
| 186 | |
|---|
| 187 | class ContributionProtectionRemoveUser(ContributionModifBase): |
|---|
| 188 | |
|---|
| 189 | def _checkParams(self): |
|---|
| 190 | ContributionModifBase._checkParams(self) |
|---|
| 191 | |
|---|
| 192 | self._userData = self._params['value'] |
|---|
| 193 | |
|---|
| 194 | self._user = self.getAW().getUser() |
|---|
| 195 | |
|---|
| 196 | def _getAnswer(self): |
|---|
| 197 | |
|---|
| 198 | userToRemove = PrincipalHolder().getById(self._userData['id']) |
|---|
| 199 | |
|---|
| 200 | if not userToRemove : |
|---|
| 201 | raise ServiceError("ERR-U0","User does not exist!") |
|---|
| 202 | elif isinstance(userToRemove, Avatar) or isinstance(userToRemove, Group) : |
|---|
| 203 | self._contribution.revokeAccess(userToRemove) |
|---|
| 204 | |
|---|
| 205 | |
|---|
| 206 | class ContributionParticipantsBase(ContributionModifBase): |
|---|
| 207 | |
|---|
| 208 | def _checkParams(self): |
|---|
| 209 | ContributionModifBase._checkParams(self) |
|---|
| 210 | self._pm = ParameterManager(self._params) |
|---|
| 211 | self._kindOfList = self._pm.extract("kindOfList", pType=str, allowEmpty=False) |
|---|
| 212 | |
|---|
| 213 | def _isEmailAlreadyUsed(self, email): |
|---|
| 214 | participantList = [] |
|---|
| 215 | if self._kindOfList in ("prAuthor", "coAuthor"): |
|---|
| 216 | participantList = self._contribution.getPrimaryAuthorList() + self._contribution.getCoAuthorList() |
|---|
| 217 | elif self._kindOfList == "speaker": |
|---|
| 218 | participantList = self._contribution.getSpeakerList() |
|---|
| 219 | |
|---|
| 220 | for part in participantList: |
|---|
| 221 | if email == part.getEmail(): |
|---|
| 222 | return True |
|---|
| 223 | return False |
|---|
| 224 | |
|---|
| 225 | def _getParticipantsList(self, participantList): |
|---|
| 226 | result = [] |
|---|
| 227 | for part in participantList: |
|---|
| 228 | partFossil = fossilize(part) |
|---|
| 229 | # var to control if we have to show the entry in the author menu to allow add submission rights |
|---|
| 230 | isSubmitter = False |
|---|
| 231 | av = AvatarHolder().match({"email": part.getEmail()}, forceWithoutExtAuth=True, exact=True) |
|---|
| 232 | if not av: |
|---|
| 233 | if part.getEmail() in self._contribution.getSubmitterEmailList(): |
|---|
| 234 | isSubmitter = True |
|---|
| 235 | elif (av[0] in self._contribution.getSubmitterList() or self._conf.getPendingQueuesMgr().isPendingSubmitter(part)): |
|---|
| 236 | isSubmitter = True |
|---|
| 237 | partFossil["showSubmitterCB"] = not isSubmitter |
|---|
| 238 | result.append(partFossil) |
|---|
| 239 | return result |
|---|
| 240 | |
|---|
| 241 | |
|---|
| 242 | |
|---|
| 243 | class ContributionParticipantsUserBase(ContributionParticipantsBase): |
|---|
| 244 | |
|---|
| 245 | def _checkParams(self): |
|---|
| 246 | ContributionParticipantsBase._checkParams(self) |
|---|
| 247 | if self._kindOfList == "speaker": |
|---|
| 248 | self._participant = self._contribution.getSpeakerById(self._pm.extract("userId", pType=str, allowEmpty=False)) |
|---|
| 249 | else: |
|---|
| 250 | self._participant = self._contribution.getAuthorById(self._pm.extract("userId", pType=str, allowEmpty=False)) |
|---|
| 251 | if self._participant == None: |
|---|
| 252 | raise ServiceError("ERR-U0", _("User does not exist.")) |
|---|
| 253 | |
|---|
| 254 | |
|---|
| 255 | class ContributionAddExistingParticipant(ContributionParticipantsBase): |
|---|
| 256 | |
|---|
| 257 | def _checkParams(self): |
|---|
| 258 | ContributionParticipantsBase._checkParams(self) |
|---|
| 259 | self._submissionRights = self._pm.extract("presenter-grant-submission", pType=bool, allowEmpty=False) |
|---|
| 260 | self._userList = self._pm.extract("userList", pType=list, allowEmpty=False) |
|---|
| 261 | # Check if there is already a user with the same email |
|---|
| 262 | for user in self._userList: |
|---|
| 263 | if self._isEmailAlreadyUsed(user["email"]): |
|---|
| 264 | if self._kindOfList == "speaker": |
|---|
| 265 | raise ServiceAccessError(_("The email address %s (belonging to a user you are adding) is already used by another speaker in the current speaker list. Speaker(s) not added.") % user["email"]) |
|---|
| 266 | else: |
|---|
| 267 | raise ServiceAccessError(_("The email address %s (belonging to a user you are adding) is already used by another author in the list of primary authors or co-authors. Author(s) not added.") % user["email"]) |
|---|
| 268 | |
|---|
| 269 | def _newParticipant(self, a): |
|---|
| 270 | part = conference.ContributionParticipation() |
|---|
| 271 | part.setTitle(a.getTitle()) |
|---|
| 272 | part.setFirstName(a.getName()) |
|---|
| 273 | part.setFamilyName(a.getSurName()) |
|---|
| 274 | part.setAffiliation(a.getOrganisation()) |
|---|
| 275 | part.setEmail(a.getEmail()) |
|---|
| 276 | part.setAddress(a.getAddress()) |
|---|
| 277 | part.setPhone(a.getTelephone()) |
|---|
| 278 | part.setFax(a.getFax()) |
|---|
| 279 | if self._kindOfList == "prAuthor": |
|---|
| 280 | self._contribution.addPrimaryAuthor(part) |
|---|
| 281 | elif self._kindOfList == "coAuthor": |
|---|
| 282 | self._contribution.addCoAuthor(part) |
|---|
| 283 | elif self._kindOfList == "speaker": |
|---|
| 284 | self._contribution.newSpeaker(part) |
|---|
| 285 | return part |
|---|
| 286 | |
|---|
| 287 | def _getAnswer(self): |
|---|
| 288 | for user in self._userList: |
|---|
| 289 | if user["_type"] == "Avatar": # new speaker |
|---|
| 290 | ah = AvatarHolder() |
|---|
| 291 | av = ah.getById(user["id"]) |
|---|
| 292 | part = self._newParticipant(av) |
|---|
| 293 | elif user["_type"] == "ContributionParticipation": # adding existing author to speaker |
|---|
| 294 | part = self._contribution.getAuthorById(user["id"]) |
|---|
| 295 | self._contribution.addSpeaker(part) |
|---|
| 296 | if self._submissionRights and part: |
|---|
| 297 | self._contribution.grantSubmission(part) |
|---|
| 298 | |
|---|
| 299 | if self._kindOfList == "prAuthor": |
|---|
| 300 | return self._getParticipantsList(self._contribution.getPrimaryAuthorList()) |
|---|
| 301 | elif self._kindOfList == "coAuthor": |
|---|
| 302 | return self._getParticipantsList(self._contribution.getCoAuthorList()) |
|---|
| 303 | elif self._kindOfList == "speaker": |
|---|
| 304 | return self._getParticipantsList(self._contribution.getSpeakerList()) |
|---|
| 305 | else: |
|---|
| 306 | raise ServiceError("ERR-UK0", _("Invalid kind of list of users.")) |
|---|
| 307 | |
|---|
| 308 | |
|---|
| 309 | class ContributionAddNewParticipant(ContributionParticipantsBase): |
|---|
| 310 | |
|---|
| 311 | def _checkParams(self): |
|---|
| 312 | ContributionParticipantsBase._checkParams(self) |
|---|
| 313 | self._userData = self._pm.extract("userData", pType=dict, allowEmpty=False) |
|---|
| 314 | email = self._userData.get("email", "") |
|---|
| 315 | if email != "" and self._isEmailAlreadyUsed(email): |
|---|
| 316 | raise ServiceAccessError(_("The email address is already used by another %s. %s not added.") % (self._kindOfList, self._kindOfList)) |
|---|
| 317 | |
|---|
| 318 | def _newParticipant(self): |
|---|
| 319 | part = conference.ContributionParticipation() |
|---|
| 320 | part.setTitle(self._userData.get("title", "")) |
|---|
| 321 | part.setFirstName(self._userData.get("firstName", "")) |
|---|
| 322 | part.setFamilyName(self._userData.get("familyName", "")) |
|---|
| 323 | part.setAffiliation(self._userData.get("affiliation", "")) |
|---|
| 324 | part.setEmail(self._userData.get("email", "")) |
|---|
| 325 | part.setAddress(self._userData.get("address", "")) |
|---|
| 326 | part.setPhone(self._userData.get("phone", "")) |
|---|
| 327 | part.setFax(self._userData.get("fax", "")) |
|---|
| 328 | if self._kindOfList == "prAuthor": |
|---|
| 329 | self._contribution.addPrimaryAuthor(part) |
|---|
| 330 | elif self._kindOfList == "coAuthor": |
|---|
| 331 | self._contribution.addCoAuthor(part) |
|---|
| 332 | elif self._kindOfList == "speaker": |
|---|
| 333 | self._contribution.newSpeaker(part) |
|---|
| 334 | #If the participant needs to be given submission rights |
|---|
| 335 | if self._userData.get("submission", False): |
|---|
| 336 | if self._userData.get("email", "") == "": |
|---|
| 337 | raise ServiceAccessError(_("It is necessary to enter the email of the %s if you want to add him as submitter.") % self._kindOfList) |
|---|
| 338 | self._contribution.grantSubmission(part) |
|---|
| 339 | |
|---|
| 340 | def _getAnswer(self): |
|---|
| 341 | self._newParticipant() |
|---|
| 342 | if self._kindOfList == "prAuthor": |
|---|
| 343 | return self._getParticipantsList(self._contribution.getPrimaryAuthorList()) |
|---|
| 344 | elif self._kindOfList == "coAuthor": |
|---|
| 345 | return self._getParticipantsList(self._contribution.getCoAuthorList()) |
|---|
| 346 | elif self._kindOfList == "speaker": |
|---|
| 347 | return self._getParticipantsList(self._contribution.getSpeakerList()) |
|---|
| 348 | else: |
|---|
| 349 | raise ServiceError("ERR-UK0", _("Invalid kind of list of users.")) |
|---|
| 350 | |
|---|
| 351 | |
|---|
| 352 | class ContributionRemoveParticipant(ContributionParticipantsUserBase): |
|---|
| 353 | |
|---|
| 354 | def _getAnswer(self): |
|---|
| 355 | if self._kindOfList == "prAuthor": |
|---|
| 356 | self._contribution.removePrimaryAuthor(self._participant, removeSpeaker=0) |
|---|
| 357 | #return [self._getParticipantsList(self._contribution.getPrimaryAuthorList()), self._getParticipantsList(self._contribution.getSpeakerList())] |
|---|
| 358 | return self._getParticipantsList(self._contribution.getPrimaryAuthorList()) |
|---|
| 359 | elif self._kindOfList == "coAuthor": |
|---|
| 360 | self._contribution.removeCoAuthor(self._participant, removeSpeaker=0) |
|---|
| 361 | #return [self._getParticipantsList(self._contribution.getCoAuthorList()), self._getParticipantsList(self._contribution.getSpeakerList())] |
|---|
| 362 | return self._getParticipantsList(self._contribution.getCoAuthorList()) |
|---|
| 363 | elif self._kindOfList == "speaker": |
|---|
| 364 | self._contribution.removeSpeaker(self._participant) |
|---|
| 365 | return self._getParticipantsList(self._contribution.getSpeakerList()) |
|---|
| 366 | else: |
|---|
| 367 | raise ServiceError("ERR-UK0", _("Invalid kind of list of users.")) |
|---|
| 368 | |
|---|
| 369 | |
|---|
| 370 | class ContributionEditParticipantData(ContributionParticipantsBase): |
|---|
| 371 | |
|---|
| 372 | def _checkParams(self): |
|---|
| 373 | ContributionParticipantsBase._checkParams(self) |
|---|
| 374 | self._userData = self._pm.extract("userData", pType=dict, allowEmpty=False) |
|---|
| 375 | self._userId = self._pm.extract("userId", pType=str, allowEmpty=False) |
|---|
| 376 | if (self._kindOfList == "speaker"): |
|---|
| 377 | self._participant = self._contribution.getSpeakerById(self._pm.extract("userId", pType=str, allowEmpty=False)) |
|---|
| 378 | else: |
|---|
| 379 | self._participant = self._contribution.getAuthorById(self._pm.extract("userId", pType=str, allowEmpty=False)) |
|---|
| 380 | if self._participant == None: |
|---|
| 381 | raise ServiceError("ERR-U0", _("User does not exist.")) |
|---|
| 382 | if self._userData.get("email", "") != "" and self._isEmailAlreadyUsed(): |
|---|
| 383 | raise ServiceAccessError(_("The email address is already used by another participant. Participant not modified.")) |
|---|
| 384 | #self._eventType = self._pm.extract("eventType", pType=str, allowEmpty=False) |
|---|
| 385 | |
|---|
| 386 | def _isEmailAlreadyUsed(self): |
|---|
| 387 | participantList = [] |
|---|
| 388 | if self._kindOfList in ("prAuthor", "coAuthor"): |
|---|
| 389 | participantList = self._contribution.getPrimaryAuthorList() + self._contribution.getCoAuthorList() |
|---|
| 390 | elif self._kindOfList == "speaker": |
|---|
| 391 | participantList = self._contribution.getSpeakerList() |
|---|
| 392 | for auth in participantList: |
|---|
| 393 | # check if the email is already used by other different author |
|---|
| 394 | if self._userData.get("email", "") == auth.getEmail() and self._userId != str(auth.getId()): |
|---|
| 395 | return True |
|---|
| 396 | return False |
|---|
| 397 | |
|---|
| 398 | def _editParticipant(self): |
|---|
| 399 | self._participant.setTitle(self._userData.get("title", "")) |
|---|
| 400 | self._participant.setFirstName(self._userData.get("firstName", "")) |
|---|
| 401 | self._participant.setFamilyName(self._userData.get("familyName", "")) |
|---|
| 402 | self._participant.setAffiliation(self._userData.get("affiliation", "")) |
|---|
| 403 | self._participant.setAddress(self._userData.get("address", "")) |
|---|
| 404 | self._participant.setPhone(self._userData.get("phone", "")) |
|---|
| 405 | self._participant.setFax(self._userData.get("fax", "")) |
|---|
| 406 | |
|---|
| 407 | grantSubm = False |
|---|
| 408 | if self._participant.getEmail().lower().strip() != self._userData.get("email", "").lower().strip(): |
|---|
| 409 | #----If it's already in the pending queue in order to grant |
|---|
| 410 | # submission rights we must unindex and after the modification of the email, |
|---|
| 411 | # index again... |
|---|
| 412 | if self._conf.getPendingQueuesMgr().isPendingSubmitter(self._participant): |
|---|
| 413 | self._conf.getPendingQueuesMgr().removePendingSubmitter(self._participant) |
|---|
| 414 | grantSubm = True |
|---|
| 415 | #----- |
|---|
| 416 | self._participant.setEmail(self._userData.get("email", "")) |
|---|
| 417 | #If the author needs to be given submission rights because the checkbox is selected |
|---|
| 418 | if self._userData.get("submission", False): |
|---|
| 419 | if self._userData.get("email", "") == "": |
|---|
| 420 | raise ServiceAccessError(_("It is necessary to enter the email of the user if you want to add him as submitter.")) |
|---|
| 421 | grantSubm = True |
|---|
| 422 | if grantSubm: |
|---|
| 423 | self._contribution.grantSubmission(self._participant) |
|---|
| 424 | |
|---|
| 425 | def _getAnswer(self): |
|---|
| 426 | self._editParticipant() |
|---|
| 427 | if self._kindOfList == "prAuthor": |
|---|
| 428 | return self._getParticipantsList(self._contribution.getPrimaryAuthorList()) |
|---|
| 429 | elif self._kindOfList == "coAuthor": |
|---|
| 430 | return self._getParticipantsList(self._contribution.getCoAuthorList()) |
|---|
| 431 | elif self._kindOfList == "speaker": |
|---|
| 432 | return self._getParticipantsList(self._contribution.getSpeakerList()) |
|---|
| 433 | else: |
|---|
| 434 | raise ServiceError("ERR-UK0", _("Invalid kind of list of users.")) |
|---|
| 435 | |
|---|
| 436 | |
|---|
| 437 | class ContributionSendEmailData(ContributionParticipantsUserBase): |
|---|
| 438 | |
|---|
| 439 | def _getAnswer(self): |
|---|
| 440 | return {"confTitle": self._conf.getTitle(), |
|---|
| 441 | "contribTitle": self._contribution.getTitle(), |
|---|
| 442 | "contribId": str(self._contribution.getId()), |
|---|
| 443 | "email": self._participant.getEmail() |
|---|
| 444 | } |
|---|
| 445 | |
|---|
| 446 | |
|---|
| 447 | class ContributionChangeSubmissionRights(ContributionParticipantsUserBase): |
|---|
| 448 | |
|---|
| 449 | def _checkParams(self): |
|---|
| 450 | ContributionParticipantsUserBase._checkParams(self) |
|---|
| 451 | if self._participant.getEmail() == "": |
|---|
| 452 | raise ServiceAccessError(_("It is not possible to grant submission rights to a participant without an email address. Please edit participant details and set an email address.")) |
|---|
| 453 | self._action = self._pm.extract("action", pType=str, allowEmpty=False) |
|---|
| 454 | self._eventType = self._pm.extract("eventType", pType=str, allowEmpty=False) |
|---|
| 455 | |
|---|
| 456 | def _getAnswer(self): |
|---|
| 457 | if self._action == "grant": |
|---|
| 458 | self._contribution.grantSubmission(self._participant) |
|---|
| 459 | elif self._action == "remove": |
|---|
| 460 | av = AvatarHolder().match({"email": self._participant.getEmail()}, exact=True, forceWithoutExtAuth=True) |
|---|
| 461 | if not av: |
|---|
| 462 | self._contribution.revokeSubmissionEmail(self._participant.getEmail()) |
|---|
| 463 | else: |
|---|
| 464 | self._contribution.revokeSubmission(av[0]) |
|---|
| 465 | if self._eventType == "conference": |
|---|
| 466 | return [self._getParticipantsList(self._contribution.getPrimaryAuthorList()), |
|---|
| 467 | self._getParticipantsList(self._contribution.getCoAuthorList()), |
|---|
| 468 | self._getParticipantsList(self._contribution.getSpeakerList())] |
|---|
| 469 | else: |
|---|
| 470 | return self._getParticipantsList(self._contribution.getSpeakerList()) |
|---|
| 471 | |
|---|
| 472 | class ContributionUpdateAuthorList(ContributionModifBase): |
|---|
| 473 | |
|---|
| 474 | def _checkParams(self): |
|---|
| 475 | ContributionModifBase._checkParams(self) |
|---|
| 476 | self._from= self._pm.extract("from", pType=str, allowEmpty=False) |
|---|
| 477 | self._to= self._pm.extract("to", pType=str, allowEmpty=False) |
|---|
| 478 | self._item = self._pm.extract("item", pType=str, allowEmpty=False) |
|---|
| 479 | self._index = self._pm.extract("index", pType=int, allowEmpty=False) |
|---|
| 480 | |
|---|
| 481 | |
|---|
| 482 | def _getAnswer(self): |
|---|
| 483 | |
|---|
| 484 | getAuthor = {'inPlacePrimaryAuthors': self._contribution.getPrimaryAuthorById, |
|---|
| 485 | 'inPlaceCoAuthors': self._contribution.getCoAuthorById, |
|---|
| 486 | 'inPlaceSpeakers': self._contribution.getSpeakerById} |
|---|
| 487 | addAuthor = {'inPlacePrimaryAuthors': self._contribution.addPrimaryAuthor, |
|---|
| 488 | 'inPlaceCoAuthors': self._contribution.addCoAuthor, |
|---|
| 489 | 'inPlaceSpeakers': self._contribution.addSpeaker} |
|---|
| 490 | remAuthor = {'inPlacePrimaryAuthors': self._contribution.removePrimaryAuthor, |
|---|
| 491 | 'inPlaceCoAuthors': self._contribution.removeCoAuthor} |
|---|
| 492 | |
|---|
| 493 | author = getAuthor[self._from](self._item) |
|---|
| 494 | |
|---|
| 495 | if self._to != 'inPlaceSpeakers' and self._from != 'inPlaceSpeakers': |
|---|
| 496 | remAuthor[self._from](author, removeSpeaker=0) |
|---|
| 497 | |
|---|
| 498 | addAuthor[self._to](author, index=self._index) |
|---|
| 499 | # IF we want to update all the lists (to update the possible repeated authors (e.g. in speakers list) |
|---|
| 500 | # if self._contribution.getConference().getType() == "conference": |
|---|
| 501 | # return [self._getParticipantsList(self._contribution.getPrimaryAuthorList()), |
|---|
| 502 | # self._getParticipantsList(self._contribution.getCoAuthorList()), |
|---|
| 503 | # self._getParticipantsList(self._contribution.getSpeakerList())] |
|---|
| 504 | # else: |
|---|
| 505 | # return self._getParticipantsList(self._contribution.getSpeakerList()) |
|---|
| 506 | return True |
|---|
| 507 | |
|---|
| 508 | |
|---|
| 509 | class ContributionReorderAuthorList(ContributionModifBase): |
|---|
| 510 | |
|---|
| 511 | def _checkParams(self): |
|---|
| 512 | ContributionModifBase._checkParams(self) |
|---|
| 513 | self._list= self._pm.extract("list", pType=str, allowEmpty=False) |
|---|
| 514 | self._item = self._pm.extract("item", pType=str, allowEmpty=False) |
|---|
| 515 | self._index = self._pm.extract("index", pType=int, allowEmpty=False) |
|---|
| 516 | |
|---|
| 517 | |
|---|
| 518 | def _getAnswer(self): |
|---|
| 519 | changePos = {'inPlacePrimaryAuthors': self._contribution.changePosPrimaryAuthor, |
|---|
| 520 | 'inPlaceCoAuthors': self._contribution.changePosCoAuthor, |
|---|
| 521 | 'inPlaceSpeakers': self._contribution.changePosSpeaker} |
|---|
| 522 | getAuthor = {'inPlacePrimaryAuthors': self._contribution.getPrimaryAuthorById, |
|---|
| 523 | 'inPlaceCoAuthors': self._contribution.getCoAuthorById, |
|---|
| 524 | 'inPlaceSpeakers': self._contribution.getSpeakerById} |
|---|
| 525 | |
|---|
| 526 | author = getAuthor[self._list](self._item) |
|---|
| 527 | changePos[self._list](author, self._index) |
|---|
| 528 | |
|---|
| 529 | return True |
|---|
| 530 | |
|---|
| 531 | class SubContributionParticipantsBase(ContributionModifBase): |
|---|
| 532 | |
|---|
| 533 | def _checkParams(self): |
|---|
| 534 | ContributionModifBase._checkParams(self) |
|---|
| 535 | self._pm = ParameterManager(self._params) |
|---|
| 536 | subContribId = self._pm.extract("subContribId", pType=str, allowEmpty=False) |
|---|
| 537 | self._subContrib = None |
|---|
| 538 | for subContrib in self._contribution.getSubContributionList(): |
|---|
| 539 | if subContribId == subContrib.getId(): |
|---|
| 540 | self._subContrib = subContrib |
|---|
| 541 | if self._subContrib == None: |
|---|
| 542 | raise ServiceError("ERR-SC0", _("Invalid subcontribution id.")) |
|---|
| 543 | |
|---|
| 544 | def _isEmailAlreadyUsed(self, email): |
|---|
| 545 | for part in self._subContrib.getSpeakerList(): |
|---|
| 546 | if email == part.getEmail(): |
|---|
| 547 | return True |
|---|
| 548 | return False |
|---|
| 549 | |
|---|
| 550 | |
|---|
| 551 | class SubContributionAddNewParticipant(SubContributionParticipantsBase): |
|---|
| 552 | |
|---|
| 553 | def _checkParams(self): |
|---|
| 554 | SubContributionParticipantsBase._checkParams(self) |
|---|
| 555 | self._userData = self._pm.extract("userData", pType=dict, allowEmpty=False) |
|---|
| 556 | email = self._userData.get("email", "") |
|---|
| 557 | if email != "" and self._isEmailAlreadyUsed(email): |
|---|
| 558 | raise ServiceAccessError(_("The email address is already used by another participant or the user is already added to the list. Participant not added.")) |
|---|
| 559 | |
|---|
| 560 | def _newParticipant(self): |
|---|
| 561 | spk = conference.SubContribParticipation() |
|---|
| 562 | spk.setTitle(self._userData.get("title", "")) |
|---|
| 563 | spk.setFirstName(self._userData.get("firstName", "")) |
|---|
| 564 | spk.setFamilyName(self._userData.get("familyName", "")) |
|---|
| 565 | spk.setAffiliation(self._userData.get("affiliation", "")) |
|---|
| 566 | spk.setEmail(self._userData.get("email", "")) |
|---|
| 567 | spk.setAddress(self._userData.get("address", "")) |
|---|
| 568 | spk.setPhone(self._userData.get("phone", "")) |
|---|
| 569 | spk.setFax(self._userData.get("fax", "")) |
|---|
| 570 | self._subContrib.newSpeaker(spk) |
|---|
| 571 | |
|---|
| 572 | |
|---|
| 573 | def _getAnswer(self): |
|---|
| 574 | self._newParticipant() |
|---|
| 575 | return fossilize(self._subContrib.getSpeakerList(), ISubContribParticipationFullFossil) |
|---|
| 576 | |
|---|
| 577 | |
|---|
| 578 | class SubContributionAddExistingParticipant(SubContributionParticipantsBase): |
|---|
| 579 | |
|---|
| 580 | def _checkParams(self): |
|---|
| 581 | SubContributionParticipantsBase._checkParams(self) |
|---|
| 582 | self._userList = self._pm.extract("userList", pType=list, allowEmpty=False) |
|---|
| 583 | # Check if there is already a user with the same email |
|---|
| 584 | for user in self._userList: |
|---|
| 585 | if user["email"] != "" and self._isEmailAlreadyUsed(user["email"]): |
|---|
| 586 | raise ServiceAccessError(_("The email address (%s) of a user you are trying to add is already used by another participant or the user is already added to the list. Participant(s) not added.") % user["email"]) |
|---|
| 587 | |
|---|
| 588 | def _getAnswer(self): |
|---|
| 589 | ah = AvatarHolder() |
|---|
| 590 | for user in self._userList: |
|---|
| 591 | spk = conference.SubContribParticipation() |
|---|
| 592 | spk.setDataFromAvatar(ah.getById(user["id"])) |
|---|
| 593 | self._subContrib.newSpeaker(spk) |
|---|
| 594 | return fossilize(self._subContrib.getSpeakerList(), ISubContribParticipationFullFossil) |
|---|
| 595 | |
|---|
| 596 | |
|---|
| 597 | class SubContributionRemoveParticipant(SubContributionParticipantsBase): |
|---|
| 598 | |
|---|
| 599 | def _checkParams(self): |
|---|
| 600 | SubContributionParticipantsBase._checkParams(self) |
|---|
| 601 | self._participant = self._subContrib.getSpeakerById(self._pm.extract("userId", pType=str, allowEmpty=False)) |
|---|
| 602 | if self._participant == None: |
|---|
| 603 | raise ServiceError("ERR-U0", _("User does not exist.")) |
|---|
| 604 | |
|---|
| 605 | def _getAnswer(self): |
|---|
| 606 | self._subContrib.removeSpeaker(self._participant) |
|---|
| 607 | return fossilize(self._subContrib.getSpeakerList(), ISubContribParticipationFullFossil) |
|---|
| 608 | |
|---|
| 609 | |
|---|
| 610 | class SubContributionAddAuthorAsPresenter(SubContributionAddExistingParticipant): |
|---|
| 611 | |
|---|
| 612 | def _newSpeaker(self, author): |
|---|
| 613 | spk = conference.SubContribParticipation() |
|---|
| 614 | spk.setTitle(author.getTitle()) |
|---|
| 615 | spk.setFirstName(author.getFirstName()) |
|---|
| 616 | spk.setFamilyName(author.getFamilyName()) |
|---|
| 617 | spk.setAffiliation(author.getAffiliation()) |
|---|
| 618 | spk.setEmail(author.getEmail()) |
|---|
| 619 | spk.setAddress(author.getAddress()) |
|---|
| 620 | spk.setPhone(author.getPhone()) |
|---|
| 621 | spk.setFax(author.getFax()) |
|---|
| 622 | self._subContrib.newSpeaker(spk) |
|---|
| 623 | |
|---|
| 624 | def _getAnswer(self): |
|---|
| 625 | for author in self._userList: |
|---|
| 626 | self._newSpeaker(self._contribution.getAuthorById(author["id"])) |
|---|
| 627 | return fossilize(self._subContrib.getSpeakerList(), ISubContribParticipationFullFossil) |
|---|
| 628 | |
|---|
| 629 | |
|---|
| 630 | class SubContributionEditParticipantData(SubContributionParticipantsBase): |
|---|
| 631 | |
|---|
| 632 | def _checkParams(self): |
|---|
| 633 | SubContributionParticipantsBase._checkParams(self) |
|---|
| 634 | self._userData = self._pm.extract("userData", pType=dict, allowEmpty=False) |
|---|
| 635 | self._userId = self._userData.get("id") |
|---|
| 636 | self._participant = self._subContrib.getSpeakerById(self._userId) |
|---|
| 637 | if self._participant == None: |
|---|
| 638 | raise ServiceError("ERR-U0", _("User does not exist.")) |
|---|
| 639 | if self._userData.get("email", "") != "" and self._isEmailAlreadyUsed(): |
|---|
| 640 | raise ServiceAccessError(_("The email address is already used by another participant. Participant not modified.")) |
|---|
| 641 | |
|---|
| 642 | def _isEmailAlreadyUsed(self): |
|---|
| 643 | for auth in self._subContrib.getSpeakerList(): |
|---|
| 644 | # check if the email is already used by other different speaker |
|---|
| 645 | if self._userData.get("email", "") == auth.getEmail() and self._userId != str(auth.getId()): |
|---|
| 646 | return True |
|---|
| 647 | return False |
|---|
| 648 | |
|---|
| 649 | def _editParticipant(self): |
|---|
| 650 | self._participant.setTitle(self._userData.get("title", "")) |
|---|
| 651 | self._participant.setFirstName(self._userData.get("firstName", "")) |
|---|
| 652 | self._participant.setFamilyName(self._userData.get("familyName", "")) |
|---|
| 653 | self._participant.setEmail(self._userData.get("email", "")) |
|---|
| 654 | self._participant.setAffiliation(self._userData.get("affiliation", "")) |
|---|
| 655 | self._participant.setAddress(self._userData.get("address", "")) |
|---|
| 656 | self._participant.setPhone(self._userData.get("phone", "")) |
|---|
| 657 | self._participant.setFax(self._userData.get("fax", "")) |
|---|
| 658 | |
|---|
| 659 | def _getAnswer(self): |
|---|
| 660 | self._editParticipant() |
|---|
| 661 | return fossilize(self._subContrib.getSpeakerList(), ISubContribParticipationFullFossil) |
|---|
| 662 | |
|---|
| 663 | |
|---|
| 664 | class ContributionSubmittersBase(ContributionModifBase): |
|---|
| 665 | |
|---|
| 666 | def _checkParams(self): |
|---|
| 667 | ContributionModifBase._checkParams(self) |
|---|
| 668 | self._pm = ParameterManager(self._params) |
|---|
| 669 | |
|---|
| 670 | def _getSubmittersList(self): |
|---|
| 671 | result = [] |
|---|
| 672 | for submitter in self._contribution.getSubmitterList(): |
|---|
| 673 | submitterFossil = fossilize(submitter) |
|---|
| 674 | if isinstance(submitter, Avatar): |
|---|
| 675 | isSpeaker = False |
|---|
| 676 | if self._conf.getType() == "conference": |
|---|
| 677 | isPrAuthor = False |
|---|
| 678 | isCoAuthor = False |
|---|
| 679 | if self._contribution.isPrimaryAuthorByEmail(submitter.getEmail()): |
|---|
| 680 | isPrAuthor = True |
|---|
| 681 | if self._contribution.isCoAuthorByEmail(submitter.getEmail()): |
|---|
| 682 | isCoAuthor = True |
|---|
| 683 | submitterFossil["isPrAuthor"] = isPrAuthor |
|---|
| 684 | submitterFossil["isCoAuthor"] = isCoAuthor |
|---|
| 685 | if self._contribution.isSpeakerByEmail(submitter.getEmail()): |
|---|
| 686 | isSpeaker = True |
|---|
| 687 | submitterFossil["isSpeaker"] = isSpeaker |
|---|
| 688 | result.append(submitterFossil) |
|---|
| 689 | # get pending users |
|---|
| 690 | for email in self._contribution.getSubmitterEmailList(): |
|---|
| 691 | pendingUser = {} |
|---|
| 692 | pendingUser["email"] = email |
|---|
| 693 | pendingUser["pending"] = True |
|---|
| 694 | result.append(pendingUser) |
|---|
| 695 | return result |
|---|
| 696 | |
|---|
| 697 | |
|---|
| 698 | class ContributionAddExistingSubmitter(ContributionSubmittersBase): |
|---|
| 699 | |
|---|
| 700 | def _checkParams(self): |
|---|
| 701 | ContributionSubmittersBase._checkParams(self) |
|---|
| 702 | self._userList = self._pm.extract("userList", pType=list, allowEmpty=False) |
|---|
| 703 | |
|---|
| 704 | def _getAnswer(self): |
|---|
| 705 | ah = PrincipalHolder() |
|---|
| 706 | for user in self._userList: |
|---|
| 707 | av = ah.getById(user["id"]) |
|---|
| 708 | self._contribution.grantSubmission(av) |
|---|
| 709 | return self._getSubmittersList() |
|---|
| 710 | |
|---|
| 711 | |
|---|
| 712 | class ContributionRemoveSubmitter(ContributionSubmittersBase): |
|---|
| 713 | |
|---|
| 714 | def _checkParams(self): |
|---|
| 715 | ContributionSubmittersBase._checkParams(self) |
|---|
| 716 | self._submitterId = self._pm.extract("userId", pType=str, allowEmpty=False) |
|---|
| 717 | self._kindOfUser = self._pm.extract("kindOfUser", pType=str, allowEmpty=True, defaultValue=None) |
|---|
| 718 | |
|---|
| 719 | def _getAnswer(self): |
|---|
| 720 | if self._kindOfUser == "pending": |
|---|
| 721 | # remove pending email, self._submitterId is an email address |
|---|
| 722 | self._contribution.revokeSubmissionEmail(self._submitterId) |
|---|
| 723 | else: |
|---|
| 724 | ah = PrincipalHolder() |
|---|
| 725 | av = ah.getById(self._submitterId) |
|---|
| 726 | if av is not None: |
|---|
| 727 | # remove submitter |
|---|
| 728 | self._contribution.revokeSubmission(av) |
|---|
| 729 | else: |
|---|
| 730 | raise ServiceError("ERR-U0", _("User does not exist.")) |
|---|
| 731 | return self._getSubmittersList() |
|---|
| 732 | |
|---|
| 733 | |
|---|
| 734 | class ContributionSumissionControlModifyUserRol(ContributionSubmittersBase): |
|---|
| 735 | |
|---|
| 736 | def _checkParams(self): |
|---|
| 737 | ContributionSubmittersBase._checkParams(self) |
|---|
| 738 | self._submitterId = self._pm.extract("userId", pType=str, allowEmpty=False) |
|---|
| 739 | self._kindOfList = self._pm.extract("kindOfList", pType=str, allowEmpty=False) |
|---|
| 740 | |
|---|
| 741 | |
|---|
| 742 | class ContributionSumissionControlAddAsAuthor(ContributionSumissionControlModifyUserRol): |
|---|
| 743 | |
|---|
| 744 | def _newParticipant(self, a): |
|---|
| 745 | part = conference.ContributionParticipation() |
|---|
| 746 | part.setTitle(a.getTitle()) |
|---|
| 747 | part.setFirstName(a.getName()) |
|---|
| 748 | part.setFamilyName(a.getSurName()) |
|---|
| 749 | part.setAffiliation(a.getOrganisation()) |
|---|
| 750 | part.setEmail(a.getEmail()) |
|---|
| 751 | part.setAddress(a.getAddress()) |
|---|
| 752 | part.setPhone(a.getTelephone()) |
|---|
| 753 | part.setFax(a.getFax()) |
|---|
| 754 | if self._kindOfList == "prAuthor": |
|---|
| 755 | self._contribution.addPrimaryAuthor(part) |
|---|
| 756 | elif self._kindOfList == "coAuthor": |
|---|
| 757 | self._contribution.addCoAuthor(part) |
|---|
| 758 | elif self._kindOfList == "speaker": |
|---|
| 759 | self._contribution.newSpeaker(part) |
|---|
| 760 | |
|---|
| 761 | def _getAnswer(self): |
|---|
| 762 | ah = AvatarHolder() |
|---|
| 763 | av = ah.getById(self._submitterId) |
|---|
| 764 | self._newParticipant(av) |
|---|
| 765 | return self._getSubmittersList() |
|---|
| 766 | |
|---|
| 767 | |
|---|
| 768 | class ContributionSumissionControlRemoveAsAuthor(ContributionSumissionControlModifyUserRol): |
|---|
| 769 | |
|---|
| 770 | def _getParticipantByEmail(self, email): |
|---|
| 771 | if self._kindOfList == "prAuthor": |
|---|
| 772 | for prAuthor in self._contribution.getPrimaryAuthorList(): |
|---|
| 773 | if prAuthor.getEmail() == email: |
|---|
| 774 | return prAuthor |
|---|
| 775 | elif self._kindOfList == "coAuthor": |
|---|
| 776 | for coAuthor in self._contribution.getCoAuthorList(): |
|---|
| 777 | if coAuthor.getEmail() == email: |
|---|
| 778 | return coAuthor |
|---|
| 779 | elif self._kindOfList == "speaker": |
|---|
| 780 | for speaker in self._contribution.getSpeakerList(): |
|---|
| 781 | if speaker.getEmail() == email: |
|---|
| 782 | return speaker |
|---|
| 783 | else: |
|---|
| 784 | raise ServiceError("ERR-UK0", _("Invalid kind of list of users.")) |
|---|
| 785 | # user not found |
|---|
| 786 | raise ServiceError("ERR-USC", _("User not found in the list.")) |
|---|
| 787 | |
|---|
| 788 | |
|---|
| 789 | def _getAnswer(self): |
|---|
| 790 | ah = AvatarHolder() |
|---|
| 791 | av = ah.getById(self._submitterId) |
|---|
| 792 | participant = self._getParticipantByEmail(av.getEmail()) |
|---|
| 793 | |
|---|
| 794 | if self._kindOfList == "prAuthor": |
|---|
| 795 | self._contribution.removePrimaryAuthor(participant, removeSpeaker=0) |
|---|
| 796 | elif self._kindOfList == "coAuthor": |
|---|
| 797 | self._contribution.removeCoAuthor(participant, removeSpeaker=0) |
|---|
| 798 | elif self._kindOfList == "speaker": |
|---|
| 799 | self._contribution.removeSpeaker(participant) |
|---|
| 800 | return self._getSubmittersList() |
|---|
| 801 | |
|---|
| 802 | |
|---|
| 803 | class ContributionManagerListBase(ContributionModifBase): |
|---|
| 804 | |
|---|
| 805 | def _getManagersList(self): |
|---|
| 806 | result = fossilize(self._contribution.getManagerList()) |
|---|
| 807 | # get pending users |
|---|
| 808 | for email in self._contribution.getAccessController().getModificationEmail(): |
|---|
| 809 | pendingUser = {} |
|---|
| 810 | pendingUser["email"] = email |
|---|
| 811 | pendingUser["pending"] = True |
|---|
| 812 | result.append(pendingUser) |
|---|
| 813 | return result |
|---|
| 814 | |
|---|
| 815 | |
|---|
| 816 | class ContributionAddExistingManager(ContributionManagerListBase): |
|---|
| 817 | |
|---|
| 818 | def _checkParams(self): |
|---|
| 819 | ContributionManagerListBase._checkParams(self) |
|---|
| 820 | self._userList = self._pm.extract("userList", pType=list, allowEmpty=False) |
|---|
| 821 | |
|---|
| 822 | def _getAnswer(self): |
|---|
| 823 | ph = PrincipalHolder() |
|---|
| 824 | for user in self._userList: |
|---|
| 825 | self._contribution.grantModification(ph.getById(user["id"])) |
|---|
| 826 | return self._getManagersList() |
|---|
| 827 | |
|---|
| 828 | |
|---|
| 829 | class ContributionRemoveManager(ContributionManagerListBase): |
|---|
| 830 | |
|---|
| 831 | def _checkParams(self): |
|---|
| 832 | ContributionManagerListBase._checkParams(self) |
|---|
| 833 | self._managerId = self._pm.extract("userId", pType=str, allowEmpty=False) |
|---|
| 834 | |
|---|
| 835 | def _getAnswer(self): |
|---|
| 836 | ph = PrincipalHolder() |
|---|
| 837 | self._contribution.revokeModification(ph.getById(self._managerId)) |
|---|
| 838 | return self._getManagersList() |
|---|
| 839 | |
|---|
| 840 | |
|---|
| 841 | |
|---|
| 842 | methodMap = { |
|---|
| 843 | "addSubContribution": ContributionAddSubContribution, |
|---|
| 844 | "deleteSubContribution": ContributionDeleteSubContribution, |
|---|
| 845 | "getBooking": ContributionGetBooking, |
|---|
| 846 | "protection.getAllowedUsersList": ContributionProtectionUserList, |
|---|
| 847 | "protection.addAllowedUsers": ContributionProtectionAddUsers, |
|---|
| 848 | "protection.removeAllowedUser": ContributionProtectionRemoveUser, |
|---|
| 849 | |
|---|
| 850 | "participants.addNewParticipant": ContributionAddNewParticipant, |
|---|
| 851 | "participants.addExistingParticipant": ContributionAddExistingParticipant, |
|---|
| 852 | "participants.editParticipantData": ContributionEditParticipantData, |
|---|
| 853 | "participants.removeParticipant": ContributionRemoveParticipant, |
|---|
| 854 | "participants.sendEmailData": ContributionSendEmailData, |
|---|
| 855 | "participants.changeSubmissionRights": ContributionChangeSubmissionRights, |
|---|
| 856 | "participants.updateAuthorList": ContributionUpdateAuthorList, |
|---|
| 857 | "participants.reorderAuthorList": ContributionReorderAuthorList, |
|---|
| 858 | |
|---|
| 859 | "participants.subContribution.addNewParticipant": SubContributionAddNewParticipant, |
|---|
| 860 | "participants.subContribution.addExistingParticipant": SubContributionAddExistingParticipant, |
|---|
| 861 | "participants.subContribution.editParticipantData": SubContributionEditParticipantData, |
|---|
| 862 | "participants.subContribution.removeParticipant": SubContributionRemoveParticipant, |
|---|
| 863 | "participants.subContribution.addAuthorAsPresenter": SubContributionAddAuthorAsPresenter, |
|---|
| 864 | |
|---|
| 865 | "protection.submissionControl.addExistingSubmitter": ContributionAddExistingSubmitter, |
|---|
| 866 | "protection.submissionControl.removeSubmitter": ContributionRemoveSubmitter, |
|---|
| 867 | "protection.submissionControl.addAsAuthor": ContributionSumissionControlAddAsAuthor, |
|---|
| 868 | "protection.submissionControl.removeAsAuthor": ContributionSumissionControlRemoveAsAuthor, |
|---|
| 869 | |
|---|
| 870 | "protection.addExistingManager": ContributionAddExistingManager, |
|---|
| 871 | "protection.removeManager": ContributionRemoveManager |
|---|
| 872 | } |
|---|