230 |
230 |
231 Raises: |
231 Raises: |
232 AccessViolationResponse: |
232 AccessViolationResponse: |
233 * if no User exists for the logged-in Google Account, or |
233 * if no User exists for the logged-in Google Account, or |
234 * if no Google Account is logged in at all |
234 * if no Google Account is logged in at all |
|
235 * if User has not agreed to the site-wide ToS, if one exists |
235 """ |
236 """ |
236 |
237 |
237 self.checkIsLoggedIn(django_args) |
238 self.checkIsLoggedIn(django_args) |
238 |
239 |
239 user = user_logic.getForCurrentAccount() |
240 user = user_logic.getForCurrentAccount() |
240 |
241 |
241 if user: |
242 if not user: |
242 return |
243 raise out_of_band.LoginRequest(message_fmt=DEF_NO_USER_LOGIN_MSG_FMT) |
243 |
|
244 raise out_of_band.LoginRequest(message_fmt=DEF_NO_USER_LOGIN_MSG_FMT) |
|
245 |
|
246 def checkAgreesToSiteToS(self, django_args): |
|
247 """Raises an alternate HTTP response if User has not agreed to site-wide ToS. |
|
248 |
|
249 Args: |
|
250 django_args: a dictionary with django's arguments |
|
251 |
|
252 Raises: |
|
253 AccessViolationResponse: |
|
254 * if User has not agreed to the site-wide ToS, or |
|
255 * if no User exists for the logged-in Google Account, or |
|
256 * if no Google Account is logged in at all |
|
257 """ |
|
258 |
|
259 self.checkIsUser(django_args) |
|
260 |
|
261 user = user_logic.getForCurrentAccount() |
|
262 |
244 |
263 if user_logic.agreesToSiteToS(user): |
245 if user_logic.agreesToSiteToS(user): |
264 return |
246 return |
265 |
247 |
266 # Would not reach this point of site-wide ToS did not exist, since |
248 # Would not reach this point of site-wide ToS did not exist, since |
281 * if User is not a Developer, or |
263 * if User is not a Developer, or |
282 * if no User exists for the logged-in Google Account, or |
264 * if no User exists for the logged-in Google Account, or |
283 * if no Google Account is logged in at all |
265 * if no Google Account is logged in at all |
284 """ |
266 """ |
285 |
267 |
286 self.checkAgreesToSiteToS(django_args) |
268 self.checkIsUser(django_args) |
287 |
269 |
288 if accounts.isDeveloper(account=self.id): |
270 if accounts.isDeveloper(account=self.id): |
289 return |
271 return |
290 |
272 |
291 login_message_fmt = DEF_DEV_LOGOUT_LOGIN_MSG_FMT % { |
273 login_message_fmt = DEF_DEV_LOGOUT_LOGIN_MSG_FMT % { |
315 def checkCanCreateFromRequest(self, django_args, role_name): |
297 def checkCanCreateFromRequest(self, django_args, role_name): |
316 """Raises an alternate HTTP response if the specified request does not exist |
298 """Raises an alternate HTTP response if the specified request does not exist |
317 or if it's state is not group_accepted. |
299 or if it's state is not group_accepted. |
318 """ |
300 """ |
319 |
301 |
320 self.checkAgreesToSiteToS(django_args) |
302 self.checkIsUser(django_args) |
321 |
303 |
322 user_entity = user_logic.getForCurrentAccount() |
304 user_entity = user_logic.getForCurrentAccount() |
323 |
305 |
324 if user_entity.link_id != django_args['link_id']: |
306 if user_entity.link_id != django_args['link_id']: |
325 deny(django_args) |
307 deny(django_args) |
356 def checkIsMyGroupAcceptedRequest(self, django_args): |
338 def checkIsMyGroupAcceptedRequest(self, django_args): |
357 """Raises an alternate HTTP response if the specified request does not exist |
339 """Raises an alternate HTTP response if the specified request does not exist |
358 or if it's state is not group_accepted. |
340 or if it's state is not group_accepted. |
359 """ |
341 """ |
360 |
342 |
361 self.checkAgreesToSiteToS(django_args) |
343 self.checkIsUser(django_args) |
362 |
344 |
363 user_entity = user_logic.getForCurrentAccount() |
345 user_entity = user_logic.getForCurrentAccount() |
364 |
346 |
365 if user_entity.link_id != django_args['link_id']: |
347 if user_entity.link_id != django_args['link_id']: |
366 # not the current user's request |
348 # not the current user's request |
401 self.checkIsDeveloper(django_args) |
383 self.checkIsDeveloper(django_args) |
402 return |
384 return |
403 except out_of_band.Error: |
385 except out_of_band.Error: |
404 pass |
386 pass |
405 |
387 |
406 self.checkAgreesToSiteToS(django_args) |
388 self.checkIsUser(django_args) |
407 |
389 |
408 user = user_logic.getForCurrentAccount() |
390 user = user_logic.getForCurrentAccount() |
409 |
391 |
410 if django_args.get('scope_path'): |
392 if django_args.get('scope_path'): |
411 scope_path = django_args['scope_path'] |
393 scope_path = django_args['scope_path'] |
416 'scope_path': scope_path, |
398 'scope_path': scope_path, |
417 'state': 'active'} |
399 'state': 'active'} |
418 |
400 |
419 host = host_logic.getForFields(fields, unique=True) |
401 host = host_logic.getForFields(fields, unique=True) |
420 |
402 |
421 self.checkAgreesToSiteToS(django_args) |
403 self.checkIsUser(django_args) |
422 |
404 |
423 user = user_logic.getForCurrentAccount() |
405 user = user_logic.getForCurrentAccount() |
424 |
406 |
425 fields = {'user': user, |
407 fields = {'user': user, |
426 'state': 'active'} |
408 'state': 'active'} |
448 * if User has not agreed to the site-wide ToS, or |
430 * if User has not agreed to the site-wide ToS, or |
449 * if no User exists for the logged-in Google Account, or |
431 * if no User exists for the logged-in Google Account, or |
450 * if the user is not even logged in |
432 * if the user is not even logged in |
451 """ |
433 """ |
452 |
434 |
453 self.checkAgreesToSiteToS(django_args) |
435 self.checkIsUser(django_args) |
454 |
436 |
455 user = user_logic.getForCurrentAccount() |
437 user = user_logic.getForCurrentAccount() |
456 |
438 |
457 if django_args.get('scope_path'): |
439 if django_args.get('scope_path'): |
458 scope_path = django_args['scope_path'] |
440 scope_path = django_args['scope_path'] |
494 checkIsDeveloper(django_args) |
476 checkIsDeveloper(django_args) |
495 return |
477 return |
496 except out_of_band.Error: |
478 except out_of_band.Error: |
497 pass |
479 pass |
498 |
480 |
499 self.checkAgreesToSiteToS(django_args) |
481 self.checkIsUser(django_args) |
500 |
482 |
501 user = user_logic.getForCurrentAccount() |
483 user = user_logic.getForCurrentAccount() |
502 |
484 |
503 if django_args.get('scope_path'): |
485 if django_args.get('scope_path'): |
504 scope_path = django_args['scope_path'] |
486 scope_path = django_args['scope_path'] |
578 checkIsDeveloper(django_args) |
560 checkIsDeveloper(django_args) |
579 return |
561 return |
580 except out_of_band.Error: |
562 except out_of_band.Error: |
581 pass |
563 pass |
582 |
564 |
583 self.checkAgreesToSiteToS(django_args) |
565 self.checkIsUser(django_args) |
584 |
566 |
585 properties = dicts.filter(django_args, ['link_id', 'scope_path']) |
567 properties = dicts.filter(django_args, ['link_id', 'scope_path']) |
586 |
568 |
587 notification = notification_logic.getForFields(properties, unique=True) |
569 notification = notification_logic.getForFields(properties, unique=True) |
588 user = user_logic.getForCurrentAccount() |
570 user = user_logic.getForCurrentAccount() |
615 self.checkIsDeveloper(django_args) |
597 self.checkIsDeveloper(django_args) |
616 return |
598 return |
617 except out_of_band.Error: |
599 except out_of_band.Error: |
618 pass |
600 pass |
619 |
601 |
620 self.checkAgreesToSiteToS(django_args) |
602 self.checkIsUser(django_args) |
621 |
603 |
622 properties = dicts.filter(django_args, ['link_id']) |
604 properties = dicts.filter(django_args, ['link_id']) |
623 |
605 |
624 application = app_logic.logic.getForFields(properties, unique=True) |
606 application = app_logic.logic.getForFields(properties, unique=True) |
625 |
607 |