243 'role': 'a Site Developer '} |
243 'role': 'a Site Developer '} |
244 |
244 |
245 raise out_of_band.LoginRequest(message_fmt=login_message_fmt) |
245 raise out_of_band.LoginRequest(message_fmt=login_message_fmt) |
246 |
246 |
247 def checkCanCreateFromRequest(role_name): |
247 def checkCanCreateFromRequest(role_name): |
248 """Raises an alternate HTTP response if the specified invite does not exist |
248 """Raises an alternate HTTP response if the specified request does not exist |
249 or if it has not been group_accepted. |
249 or if it's state is not group_accepted. |
250 """ |
250 """ |
251 def wrapper(request, args, kwargs): |
251 def wrapper(request, args, kwargs): |
252 checkAgreesToSiteToS(request, args, kwargs) |
252 checkAgreesToSiteToS(request, args, kwargs) |
253 |
253 |
254 user_entity = user_logic.getForCurrentAccount() |
254 user_entity = user_logic.getForCurrentAccount() |
260 'scope_path' : kwargs['scope_path'], |
260 'scope_path' : kwargs['scope_path'], |
261 'role' : role_name} |
261 'role' : role_name} |
262 |
262 |
263 request_entity = request_logic.getFromFieldsOr404(**fields) |
263 request_entity = request_logic.getFromFieldsOr404(**fields) |
264 |
264 |
265 if not request_entity.group_accepted: |
265 if request_entity.state != 'group_accepted': |
266 # TODO tell the user that this request has not been accepted yet |
266 # TODO tell the user that this request has not been accepted yet |
267 deny(request, args, kwargs) |
267 deny(request, args, kwargs) |
268 |
268 |
269 return |
269 return |
270 return wrapper |
270 return wrapper |
271 |
271 |
272 def checkIsMyUncompletedRequest(request, args, kwargs): |
272 def checkIsMyGroupAcceptedRequest(request, args, kwargs): |
273 """Raises an alternate HTTP response if the specified Request has been completed. |
273 """Raises an alternate HTTP response if the specified request does not exist |
|
274 or if it's state is not group_accepted |
274 """ |
275 """ |
275 checkAgreesToSiteToS(request, args, kwargs) |
276 checkAgreesToSiteToS(request, args, kwargs) |
276 |
277 |
277 user_entity = user_logic.getForCurrentAccount() |
278 user_entity = user_logic.getForCurrentAccount() |
278 |
279 |
280 # not the current user's request |
281 # not the current user's request |
281 return deny(request, args, kwargs) |
282 return deny(request, args, kwargs) |
282 |
283 |
283 fields = {'link_id' : kwargs['link_id'], |
284 fields = {'link_id' : kwargs['link_id'], |
284 'scope_path' : kwargs['scope_path'], |
285 'scope_path' : kwargs['scope_path'], |
285 'role' : kwargs['role'], |
286 'role' : kwargs['role']} |
286 'completed' : False} |
|
287 |
287 |
288 request_entity = request_logic.getForFields(fields, unique=True) |
288 request_entity = request_logic.getForFields(fields, unique=True) |
289 |
289 |
290 if not request_entity: |
290 if not request_entity: |
291 # TODO return 404 |
291 # TODO return 404 |
|
292 return deny(request, args, kwargs) |
|
293 |
|
294 if request_entity.state != 'group_accepted': |
292 return deny(request, args, kwargs) |
295 return deny(request, args, kwargs) |
293 |
296 |
294 return |
297 return |
295 |
298 |
296 def checkIsHost(request, args, kwargs): |
299 def checkIsHost(request, args, kwargs): |
304 * if User is not already a Host, or |
307 * if User is not already a Host, or |
305 * if User has not agreed to the site-wide ToS, or |
308 * if User has not agreed to the site-wide ToS, or |
306 * if no User exists for the logged-in Google Account, or |
309 * if no User exists for the logged-in Google Account, or |
307 * if the user is not even logged in |
310 * if the user is not even logged in |
308 """ |
311 """ |
|
312 |
|
313 try: |
|
314 # if the current user is invited to create a host profile we allow access |
|
315 checkIsDeveloper(request, args, kwargs) |
|
316 return |
|
317 except out_of_band.Error: |
|
318 pass |
|
319 |
309 checkAgreesToSiteToS(request, args, kwargs) |
320 checkAgreesToSiteToS(request, args, kwargs) |
310 |
321 |
311 user = user_logic.getForFields({'account': users.get_current_user()}, |
322 user = user_logic.getForFields({'account': users.get_current_user()}, |
312 unique=True) |
323 unique=True) |
313 |
324 |