Changeset f78b0c in indico
- Timestamp:
- 02/18/10 18:21:33 (3 years ago)
- Branches:
- master, burotel, hello-world-walkthrough, ipv6, new-webex, prov-dual-interface, v0.97-series, v0.98-series, v0.98.2, v0.98.3, v0.98b1, v0.98b2, v0.99, 051b2622c51afb171a1dedb46a0df4fbb0cbd02e, d9941f8582b36b24821a11ea5ba16fda6a457fb1
- Children:
- d73a0b
- Parents:
- b7c7c8
- Location:
- indico/MaKaC
- Files:
-
- 3 edited
-
services/implementation/base.py (modified) (6 diffs)
-
services/implementation/user.py (modified) (6 diffs)
-
webinterface/wcomponents.py (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
indico/MaKaC/services/implementation/base.py
r12296f rf78b0c 249 249 250 250 251 252 251 class ProtectedService(ServiceBase): 253 252 """ 254 A ProtectedService can only be accessed by authenticated users 255 """ 256 257 def _checkSessionUser(self): 258 """ 259 Checks that the current user exists (is authenticated) 260 """ 261 if self._getUser() == None: 262 self._doProcess = False 263 raise ServiceAccessError("ERR-P4", "You are currently not authenticated. Please log in again.") 264 265 def _checkProtection(self): 266 """ 267 Overloads ServiceBase._checkProtection, assuring that the user 268 is authenticated 269 """ 270 ServiceBase._checkProtection(self) 271 self._checkSessionUser() 253 ProtectedService is a parent class for ProtectedDisplayService and ProtectedModificationService 254 """ 272 255 273 256 … … 277 260 are authorized to "see" the target resource 278 261 """ 279 262 280 263 def _checkProtection( self ): 281 264 """ … … 284 267 """ 285 268 if not self._target.canView( self.getAW() ): 286 269 287 270 from MaKaC.conference import Link, LocalFile 288 271 … … 304 287 class LoggedOnlyService(ProtectedService): 305 288 """ 306 Nothing new relating to ProtectedService, 307 but the name is nicer, and didn't want to break 308 the Protected(.*)Service name scheme 309 """ 310 pass 311 312 289 Only accessible to users who are logged in (access keys not allowed) 290 """ 291 292 def _checkProtection( self ): 293 self._checkSessionUser() 294 295 def _checkSessionUser(self): 296 """ 297 Checks that the current user exists (is authenticated) 298 """ 299 300 if self._getUser() == None: 301 self._doProcess = False 302 raise ServiceAccessError("ERR-P4", "You are currently not authenticated. Please log in again.") 303 304 313 305 314 306 class ProtectedModificationService(ProtectedService): … … 338 330 raise ServiceAccessError("ERR-P6", "Conference %s is closed"%target.getConference().getId()) 339 331 340 class AdminService( ProtectedService):332 class AdminService(LoggedOnlyService): 341 333 """ 342 334 A AdminService can only be accessed by administrators … … 347 339 """ 348 340 349 ProtectedService._checkProtection(self)341 LoggedOnlyService._checkProtection(self) 350 342 351 343 if not self._getUser().isAdmin(): -
indico/MaKaC/services/implementation/user.py
rd0a51f rf78b0c 1 1 from MaKaC.services.implementation.base import ProtectedDisplayService 2 from MaKaC.services.implementation.base import LoggedOnlyService 2 from MaKaC.services.implementation.base import LoggedOnlyService, ProtectedService 3 3 from MaKaC.services.implementation.base import ServiceBase 4 4 … … 13 13 14 14 class UserListEvents(LoggedOnlyService): 15 16 def _checkParams(self): 17 LoggedOnlyService._checkParams(self) 18 19 self._time = self._params.get('time',None) 20 self._target = self.getAW().getUser() 21 15 16 def _checkParams(self): 17 LoggedOnlyService._checkParams(self) 18 19 self._time = self._params.get('time',None) 20 self._target = self.getAW().getUser() 21 22 22 def __exportElemDataFactory(self, moment): 23 23 return lambda elem: { … … 33 33 'evtType': elem[0].getVerboseType() 34 34 } 35 36 def _getAnswer( self): 37 35 36 def _getAnswer( self): 37 38 38 events = [] 39 39 40 40 self._target.getTimedLinkedEvents().sync() 41 41 42 42 if (not self._time) or self._time == 'past': 43 43 events.extend( map( self.__exportElemDataFactory('past'), 44 44 self._target.getTimedLinkedEvents().getPast())) 45 45 46 46 if (not self._time) or self._time == 'present': 47 events.extend( map(self.__exportElemDataFactory('present'), 47 events.extend( map(self.__exportElemDataFactory('present'), 48 48 self._target.getTimedLinkedEvents().getPresent())) 49 49 50 50 if (not self._time) or self._time == 'future': 51 events.extend( map(self.__exportElemDataFactory('future'), 51 events.extend( map(self.__exportElemDataFactory('future'), 52 52 self._target.getTimedLinkedEvents().getFuture())) 53 53 54 54 jsonData = {} 55 55 56 56 for event in events: 57 57 if jsonData.has_key(event['id']): … … 59 59 else: 60 60 jsonData[event['id']] = event 61 61 62 62 return jsonData; 63 63 … … 105 105 else: 106 106 raise ServiceError("ERR-U2","Element not in list!") 107 108 109 class UserListBasket(LoggedOnlyService): 110 111 def _checkParams(self): 112 LoggedOnlyService._checkParams(self) 113 114 self._target = self.getAW().getUser() 115 116 def _getAnswer( self): 117 118 users = [] 119 120 userDict = self._target.getPersonalInfo().getBasket().getUsers() 121 122 for user in userDict.itervalues(): 123 users.append(DictPickler.pickle(user)) 124 125 return users 126 107 108 class UserListBasket(ProtectedService): 109 110 """ 111 Service that lists the users belonging to the the user's "favorites" 112 Should return None in case the user is not logged in. 113 """ 114 115 def _checkParams(self): 116 ProtectedService._checkParams(self) 117 118 self._target = self.getAW().getUser() 119 120 def _getAnswer( self): 121 122 if self._target: 123 users = self._target.getPersonalInfo().getBasket().getUsers().values() 124 return DictPickler.pickle(users) 125 else: 126 return None 127 128 127 129 class UserGetPersonalInfo(LoggedOnlyService): 128 129 def _checkParams(self): 130 LoggedOnlyService._checkParams(self) 131 132 self._target = self.getAW().getUser() 133 134 135 def _getAnswer( self): 130 131 def _checkParams(self): 132 LoggedOnlyService._checkParams(self) 133 134 self._target = self.getAW().getUser() 135 136 137 def _getAnswer( self): 136 138 return DictPickler.pickle(self._target.getPersonalInfo()) 137 139 138 140 class UserGetEmail(LoggedOnlyService): 139 140 def _checkParams(self): 141 LoggedOnlyService._checkParams(self) 142 self._target = self.getAW().getUser() 143 141 142 def _checkParams(self): 143 LoggedOnlyService._checkParams(self) 144 self._target = self.getAW().getUser() 145 144 146 145 147 def _getAnswer( self): … … 150 152 151 153 class UserSetPersonalInfo(LoggedOnlyService): 152 153 def _checkParams(self): 154 LoggedOnlyService._checkParams(self) 155 154 155 def _checkParams(self): 156 LoggedOnlyService._checkParams(self) 157 156 158 self._target = self.getAW().getUser() 157 159 self._info = self._params.get("value",None) 158 160 159 161 def _getAnswer( self): 160 162 161 163 if self._info == None: 162 164 return UserGetPersonalInfo(self._params, self._aw.getIP(), self._aw.getSession()).process() 163 165 164 166 pInfo = self._target.getPersonalInfo() 165 167 166 168 DictPickler.update(pInfo, self._info) 167 169 return DictPickler.pickle(pInfo) -
indico/MaKaC/webinterface/wcomponents.py
r24a4db rf78b0c 4331 4331 def __addBasketPeople(self, peopleList): 4332 4332 4333 basket = self._rh._getUser().getPersonalInfo().getBasket().getUsers() 4334 4335 peopleList += """<option value=""></option>""" 4336 4337 for userId in basket: 4338 peopleList += """<option class="favoriteItem" value="%s">%s</option>"""%(userId,basket[userId].getStraightFullName()) 4339 4340 return peopleList 4333 user = self._rh._getUser() 4334 4335 # add extra options if the user is logged in 4336 if user: 4337 basket = user.getPersonalInfo().getBasket().getUsers() 4338 4339 peopleList += """<option value=""></option>""" 4340 4341 for userId in basket: 4342 peopleList += """<option class="favoriteItem" value="%s">%s</option>"""%(userId,basket[userId].getStraightFullName()) 4343 4344 return peopleList 4345 # just add nothing if the user is not logged in 4346 else: 4347 return "" 4341 4348 4342 4349 def __init__(self,personType, displayName=""):
Note: See TracChangeset
for help on using the changeset viewer.
