608 deny(kwargs) |
608 deny(kwargs) |
609 |
609 |
610 return wrapper |
610 return wrapper |
611 |
611 |
612 |
612 |
613 def checkCanInvite(kwargs): |
|
614 """Checks to see if the current user can create an invite. |
|
615 |
|
616 Note that if the current url is not in the default 'request' form |
|
617 this method either deny()s or performs the wrong access check. |
|
618 |
|
619 Args: |
|
620 request: a Django HTTP request |
|
621 """ |
|
622 |
|
623 try: |
|
624 # if the current user is a developer we allow access |
|
625 checkIsDeveloper(kwargs) |
|
626 return |
|
627 except out_of_band.Error: |
|
628 pass |
|
629 |
|
630 # Construct a new url by reshufling the kwargs |
|
631 order = ['role', 'access_type', 'scope_path', 'link_id'] |
|
632 url_params = dicts.unzip(kwargs, order) |
|
633 url = '/'.join([''] + list(url_params)) |
|
634 |
|
635 # Mine the reshufled url |
|
636 try: |
|
637 callback, args, kwargs = urlresolvers.resolve(url) |
|
638 except Exception: |
|
639 deny(kwargs) |
|
640 |
|
641 # Get the everything we need for the access check |
|
642 params = callback.im_self.getParams() |
|
643 access_type = kwargs['access_type'] |
|
644 |
|
645 # Perform the access check |
|
646 checkAccess(access_type, rights=params['rights'], kwargs=kwargs) |
|
647 |
|
648 |
|
649 def checkHasPickGetArgs(kwargs): |
613 def checkHasPickGetArgs(kwargs): |
650 """Raises an alternate HTTP response if the request misses get args. |
614 """Raises an alternate HTTP response if the request misses get args. |
651 |
615 |
652 Args: |
616 Args: |
653 kwargs: a dictionary with django's arguments |
617 kwargs: a dictionary with django's arguments |