author | Sverre Rabbelier <srabbelier@gmail.com> |
Sun, 25 Jan 2009 11:44:25 +0000 | |
changeset 977 | d212d5f4c41a |
parent 974 | 2f86cbc90b65 |
child 979 | 789e70941055 |
permissions | -rw-r--r-- |
293
1edd01373e71
Add an access control module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
1 |
#!/usr/bin/python2.5 |
1edd01373e71
Add an access control module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
2 |
# |
1edd01373e71
Add an access control module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
3 |
# Copyright 2008 the Melange authors. |
1edd01373e71
Add an access control module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
4 |
# |
1edd01373e71
Add an access control module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
5 |
# Licensed under the Apache License, Version 2.0 (the "License"); |
1edd01373e71
Add an access control module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
6 |
# you may not use this file except in compliance with the License. |
1edd01373e71
Add an access control module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
7 |
# You may obtain a copy of the License at |
1edd01373e71
Add an access control module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
8 |
# |
1edd01373e71
Add an access control module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
9 |
# http://www.apache.org/licenses/LICENSE-2.0 |
1edd01373e71
Add an access control module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
10 |
# |
1edd01373e71
Add an access control module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
11 |
# Unless required by applicable law or agreed to in writing, software |
1edd01373e71
Add an access control module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
12 |
# distributed under the License is distributed on an "AS IS" BASIS, |
1edd01373e71
Add an access control module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
13 |
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
1edd01373e71
Add an access control module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
14 |
# See the License for the specific language governing permissions and |
1edd01373e71
Add an access control module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
15 |
# limitations under the License. |
1edd01373e71
Add an access control module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
16 |
|
1edd01373e71
Add an access control module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
17 |
"""Access control helper. |
1edd01373e71
Add an access control module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
18 |
|
1edd01373e71
Add an access control module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
19 |
The functions in this module can be used to check access control |
1edd01373e71
Add an access control module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
20 |
related requirements. When the specified required conditions are not |
1edd01373e71
Add an access control module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
21 |
met, an exception is raised. This exception contains a views that |
1edd01373e71
Add an access control module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
22 |
either prompts for authentication, or informs the user that they |
1edd01373e71
Add an access control module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
23 |
do not meet the required criteria. |
1edd01373e71
Add an access control module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
24 |
""" |
1edd01373e71
Add an access control module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
25 |
|
1edd01373e71
Add an access control module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
26 |
__authors__ = [ |
1edd01373e71
Add an access control module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
27 |
'"Todd Larsen" <tlarsen@google.com>', |
1edd01373e71
Add an access control module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
28 |
'"Sverre Rabbelier" <sverre@rabbelier.nl>', |
726 | 29 |
'"Lennard de Rijk" <ljvderijk@gmail.com>', |
293
1edd01373e71
Add an access control module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
30 |
'"Pawel Solyga" <pawel.solyga@gmail.com>', |
1edd01373e71
Add an access control module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
31 |
] |
1edd01373e71
Add an access control module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
32 |
|
1edd01373e71
Add an access control module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
33 |
|
1edd01373e71
Add an access control module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
34 |
from google.appengine.api import users |
315
c4f1a07ee340
Add missing blank lines between imports in access.py module.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
309
diff
changeset
|
35 |
|
746
018efb9863dc
Fix import sorting in soc.views.helper.access module and rename 'host' to 'Program Administrator'.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
729
diff
changeset
|
36 |
from django.core import urlresolvers |
970
8b5611d5b053
Use ugettext instead of ugettext_lazy
Sverre Rabbelier <srabbelier@gmail.com>
parents:
965
diff
changeset
|
37 |
from django.utils.translation import ugettext |
293
1edd01373e71
Add an access control module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
38 |
|
481
94834a1e6c01
Attempt to rename User.id to User.account, in preparation for making User be
Todd Larsen <tlarsen@google.com>
parents:
448
diff
changeset
|
39 |
from soc.logic import accounts |
720
9eb2522dfa83
Make it possible to invite another Host as Host
Sverre Rabbelier <srabbelier@gmail.com>
parents:
714
diff
changeset
|
40 |
from soc.logic import dicts |
914
6ec8dd2a73b3
Added various access methods in preperation for the new request system.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
895
diff
changeset
|
41 |
from soc.logic.models.club_admin import logic as club_admin_logic |
887
b8c1a6bc913e
Take advantage of new "from ... import ... as ..." rules in the style guide.
Todd Larsen <tlarsen@google.com>
parents:
884
diff
changeset
|
42 |
from soc.logic.models.host import logic as host_logic |
b8c1a6bc913e
Take advantage of new "from ... import ... as ..." rules in the style guide.
Todd Larsen <tlarsen@google.com>
parents:
884
diff
changeset
|
43 |
from soc.logic.models.notification import logic as notification_logic |
b8c1a6bc913e
Take advantage of new "from ... import ... as ..." rules in the style guide.
Todd Larsen <tlarsen@google.com>
parents:
884
diff
changeset
|
44 |
from soc.logic.models.request import logic as request_logic |
891
3d40190f35b6
Move getToSLink() to soc.views.helper.redirects.getToSRedirect().
Todd Larsen <tlarsen@google.com>
parents:
890
diff
changeset
|
45 |
from soc.logic.models.site import logic as site_logic |
887
b8c1a6bc913e
Take advantage of new "from ... import ... as ..." rules in the style guide.
Todd Larsen <tlarsen@google.com>
parents:
884
diff
changeset
|
46 |
from soc.logic.models.user import logic as user_logic |
508
2b90baceac88
Add a access.deny and access.allow method
Sverre Rabbelier <srabbelier@gmail.com>
parents:
481
diff
changeset
|
47 |
from soc.views import helper |
543
280a1ac6bcc1
Merge soc/logic/out_of_band.py into soc/views/out_of_band.py. Merge
Todd Larsen <tlarsen@google.com>
parents:
525
diff
changeset
|
48 |
from soc.views import out_of_band |
891
3d40190f35b6
Move getToSLink() to soc.views.helper.redirects.getToSRedirect().
Todd Larsen <tlarsen@google.com>
parents:
890
diff
changeset
|
49 |
from soc.views.helper import redirects |
293
1edd01373e71
Add an access control module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
50 |
|
1edd01373e71
Add an access control module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
51 |
|
970
8b5611d5b053
Use ugettext instead of ugettext_lazy
Sverre Rabbelier <srabbelier@gmail.com>
parents:
965
diff
changeset
|
52 |
DEF_NO_USER_LOGIN_MSG_FMT = ugettext( |
446
0b479d573a4c
Refactoring of {site/home}_settings to make them use base.View
Sverre Rabbelier <srabbelier@gmail.com>
parents:
389
diff
changeset
|
53 |
'Please create <a href="/user/edit">User Profile</a>' |
293
1edd01373e71
Add an access control module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
54 |
' in order to view this page.') |
1edd01373e71
Add an access control module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
55 |
|
970
8b5611d5b053
Use ugettext instead of ugettext_lazy
Sverre Rabbelier <srabbelier@gmail.com>
parents:
965
diff
changeset
|
56 |
DEF_AGREE_TO_TOS_MSG_FMT = ugettext( |
888
a75ae24f04cb
Add checkAgreesToSiteToS() (partially implemented until circular import fixed).
Todd Larsen <tlarsen@google.com>
parents:
887
diff
changeset
|
57 |
'You must agree to the <a href="%(tos_link)s">site-wide Terms of' |
a75ae24f04cb
Add checkAgreesToSiteToS() (partially implemented until circular import fixed).
Todd Larsen <tlarsen@google.com>
parents:
887
diff
changeset
|
58 |
' Service</a> in your <a href="/user/edit">User Profile</a>' |
a75ae24f04cb
Add checkAgreesToSiteToS() (partially implemented until circular import fixed).
Todd Larsen <tlarsen@google.com>
parents:
887
diff
changeset
|
59 |
' in order to view this page.') |
a75ae24f04cb
Add checkAgreesToSiteToS() (partially implemented until circular import fixed).
Todd Larsen <tlarsen@google.com>
parents:
887
diff
changeset
|
60 |
|
970
8b5611d5b053
Use ugettext instead of ugettext_lazy
Sverre Rabbelier <srabbelier@gmail.com>
parents:
965
diff
changeset
|
61 |
DEF_DEV_LOGOUT_LOGIN_MSG_FMT = ugettext( |
293
1edd01373e71
Add an access control module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
62 |
'Please <a href="%%(sign_out)s">sign out</a>' |
1edd01373e71
Add an access control module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
63 |
' and <a href="%%(sign_in)s">sign in</a>' |
1edd01373e71
Add an access control module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
64 |
' again as %(role)s to view this page.') |
1edd01373e71
Add an access control module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
65 |
|
970
8b5611d5b053
Use ugettext instead of ugettext_lazy
Sverre Rabbelier <srabbelier@gmail.com>
parents:
965
diff
changeset
|
66 |
DEF_PAGE_DENIED_MSG = ugettext( |
508
2b90baceac88
Add a access.deny and access.allow method
Sverre Rabbelier <srabbelier@gmail.com>
parents:
481
diff
changeset
|
67 |
'Access to this page has been restricted') |
2b90baceac88
Add a access.deny and access.allow method
Sverre Rabbelier <srabbelier@gmail.com>
parents:
481
diff
changeset
|
68 |
|
970
8b5611d5b053
Use ugettext instead of ugettext_lazy
Sverre Rabbelier <srabbelier@gmail.com>
parents:
965
diff
changeset
|
69 |
DEF_LOGOUT_MSG_FMT = ugettext( |
590
37735d97b541
Created a seperate module for editSelf things
Sverre Rabbelier <srabbelier@gmail.com>
parents:
543
diff
changeset
|
70 |
'Please <a href="%(sign_out)s">sign out</a> in order to view this page') |
37735d97b541
Created a seperate module for editSelf things
Sverre Rabbelier <srabbelier@gmail.com>
parents:
543
diff
changeset
|
71 |
|
508
2b90baceac88
Add a access.deny and access.allow method
Sverre Rabbelier <srabbelier@gmail.com>
parents:
481
diff
changeset
|
72 |
|
972
43018f61b481
Remove the request and arg parameter from the checkAccess call
Sverre Rabbelier <srabbelier@gmail.com>
parents:
970
diff
changeset
|
73 |
def checkAccess(access_type, rights, kwargs=None): |
639
1f92bd41b914
Some docstring fixes in few modules (soc.views.helper soc.views.models.base).
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
633
diff
changeset
|
74 |
"""Runs all the defined checks for the specified type. |
612
3cca81b1e5a1
Moved checkAccess and getCleanedFields into access and forms
Sverre Rabbelier <srabbelier@gmail.com>
parents:
590
diff
changeset
|
75 |
|
3cca81b1e5a1
Moved checkAccess and getCleanedFields into access and forms
Sverre Rabbelier <srabbelier@gmail.com>
parents:
590
diff
changeset
|
76 |
Args: |
3cca81b1e5a1
Moved checkAccess and getCleanedFields into access and forms
Sverre Rabbelier <srabbelier@gmail.com>
parents:
590
diff
changeset
|
77 |
access_type: the type of request (such as 'list' or 'edit') |
639
1f92bd41b914
Some docstring fixes in few modules (soc.views.helper soc.views.models.base).
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
633
diff
changeset
|
78 |
rights: a dictionary containing access check functions |
972
43018f61b481
Remove the request and arg parameter from the checkAccess call
Sverre Rabbelier <srabbelier@gmail.com>
parents:
970
diff
changeset
|
79 |
kwargs: a dictionary with django's arguments |
612
3cca81b1e5a1
Moved checkAccess and getCleanedFields into access and forms
Sverre Rabbelier <srabbelier@gmail.com>
parents:
590
diff
changeset
|
80 |
|
639
1f92bd41b914
Some docstring fixes in few modules (soc.views.helper soc.views.models.base).
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
633
diff
changeset
|
81 |
Rights usage: |
1f92bd41b914
Some docstring fixes in few modules (soc.views.helper soc.views.models.base).
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
633
diff
changeset
|
82 |
The rights dictionary is used to check if the current user is allowed |
1f92bd41b914
Some docstring fixes in few modules (soc.views.helper soc.views.models.base).
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
633
diff
changeset
|
83 |
to view the page specified. The functions defined in this dictionary |
972
43018f61b481
Remove the request and arg parameter from the checkAccess call
Sverre Rabbelier <srabbelier@gmail.com>
parents:
970
diff
changeset
|
84 |
are always called with the provided kwargs dictionary as argument. On any |
43018f61b481
Remove the request and arg parameter from the checkAccess call
Sverre Rabbelier <srabbelier@gmail.com>
parents:
970
diff
changeset
|
85 |
request, regardless of what type, the functions in the 'any_access' value |
43018f61b481
Remove the request and arg parameter from the checkAccess call
Sverre Rabbelier <srabbelier@gmail.com>
parents:
970
diff
changeset
|
86 |
are called. If the specified type is not in the rights dictionary, all |
43018f61b481
Remove the request and arg parameter from the checkAccess call
Sverre Rabbelier <srabbelier@gmail.com>
parents:
970
diff
changeset
|
87 |
the functions in the 'unspecified' value are called. When the specified |
43018f61b481
Remove the request and arg parameter from the checkAccess call
Sverre Rabbelier <srabbelier@gmail.com>
parents:
970
diff
changeset
|
88 |
type _is_ in the rights dictionary, all the functions in that access_type's |
639
1f92bd41b914
Some docstring fixes in few modules (soc.views.helper soc.views.models.base).
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
633
diff
changeset
|
89 |
value are called. |
612
3cca81b1e5a1
Moved checkAccess and getCleanedFields into access and forms
Sverre Rabbelier <srabbelier@gmail.com>
parents:
590
diff
changeset
|
90 |
""" |
3cca81b1e5a1
Moved checkAccess and getCleanedFields into access and forms
Sverre Rabbelier <srabbelier@gmail.com>
parents:
590
diff
changeset
|
91 |
|
3cca81b1e5a1
Moved checkAccess and getCleanedFields into access and forms
Sverre Rabbelier <srabbelier@gmail.com>
parents:
590
diff
changeset
|
92 |
# Call each access checker |
3cca81b1e5a1
Moved checkAccess and getCleanedFields into access and forms
Sverre Rabbelier <srabbelier@gmail.com>
parents:
590
diff
changeset
|
93 |
for check in rights['any_access']: |
972
43018f61b481
Remove the request and arg parameter from the checkAccess call
Sverre Rabbelier <srabbelier@gmail.com>
parents:
970
diff
changeset
|
94 |
check(kwargs) |
612
3cca81b1e5a1
Moved checkAccess and getCleanedFields into access and forms
Sverre Rabbelier <srabbelier@gmail.com>
parents:
590
diff
changeset
|
95 |
|
3cca81b1e5a1
Moved checkAccess and getCleanedFields into access and forms
Sverre Rabbelier <srabbelier@gmail.com>
parents:
590
diff
changeset
|
96 |
if access_type not in rights: |
3cca81b1e5a1
Moved checkAccess and getCleanedFields into access and forms
Sverre Rabbelier <srabbelier@gmail.com>
parents:
590
diff
changeset
|
97 |
for check in rights['unspecified']: |
3cca81b1e5a1
Moved checkAccess and getCleanedFields into access and forms
Sverre Rabbelier <srabbelier@gmail.com>
parents:
590
diff
changeset
|
98 |
# No checks defined, so do the 'generic' checks and bail out |
972
43018f61b481
Remove the request and arg parameter from the checkAccess call
Sverre Rabbelier <srabbelier@gmail.com>
parents:
970
diff
changeset
|
99 |
check(kwargs) |
612
3cca81b1e5a1
Moved checkAccess and getCleanedFields into access and forms
Sverre Rabbelier <srabbelier@gmail.com>
parents:
590
diff
changeset
|
100 |
return |
3cca81b1e5a1
Moved checkAccess and getCleanedFields into access and forms
Sverre Rabbelier <srabbelier@gmail.com>
parents:
590
diff
changeset
|
101 |
|
3cca81b1e5a1
Moved checkAccess and getCleanedFields into access and forms
Sverre Rabbelier <srabbelier@gmail.com>
parents:
590
diff
changeset
|
102 |
for check in rights[access_type]: |
972
43018f61b481
Remove the request and arg parameter from the checkAccess call
Sverre Rabbelier <srabbelier@gmail.com>
parents:
970
diff
changeset
|
103 |
check(kwargs) |
612
3cca81b1e5a1
Moved checkAccess and getCleanedFields into access and forms
Sverre Rabbelier <srabbelier@gmail.com>
parents:
590
diff
changeset
|
104 |
|
3cca81b1e5a1
Moved checkAccess and getCleanedFields into access and forms
Sverre Rabbelier <srabbelier@gmail.com>
parents:
590
diff
changeset
|
105 |
|
972
43018f61b481
Remove the request and arg parameter from the checkAccess call
Sverre Rabbelier <srabbelier@gmail.com>
parents:
970
diff
changeset
|
106 |
def allow(kwargs): |
958
b4309e3cb899
Fix some missing dots in access and club_admin modules.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
950
diff
changeset
|
107 |
"""Never raises an alternate HTTP response. (an access no-op, basically). |
508
2b90baceac88
Add a access.deny and access.allow method
Sverre Rabbelier <srabbelier@gmail.com>
parents:
481
diff
changeset
|
108 |
|
2b90baceac88
Add a access.deny and access.allow method
Sverre Rabbelier <srabbelier@gmail.com>
parents:
481
diff
changeset
|
109 |
Args: |
972
43018f61b481
Remove the request and arg parameter from the checkAccess call
Sverre Rabbelier <srabbelier@gmail.com>
parents:
970
diff
changeset
|
110 |
kwargs: a dictionary with django's arguments |
508
2b90baceac88
Add a access.deny and access.allow method
Sverre Rabbelier <srabbelier@gmail.com>
parents:
481
diff
changeset
|
111 |
""" |
972
43018f61b481
Remove the request and arg parameter from the checkAccess call
Sverre Rabbelier <srabbelier@gmail.com>
parents:
970
diff
changeset
|
112 |
|
508
2b90baceac88
Add a access.deny and access.allow method
Sverre Rabbelier <srabbelier@gmail.com>
parents:
481
diff
changeset
|
113 |
return |
2b90baceac88
Add a access.deny and access.allow method
Sverre Rabbelier <srabbelier@gmail.com>
parents:
481
diff
changeset
|
114 |
|
872
70e0b6d8ff73
Prepare access to receive args and kwargs as argument
Sverre Rabbelier <srabbelier@gmail.com>
parents:
814
diff
changeset
|
115 |
|
972
43018f61b481
Remove the request and arg parameter from the checkAccess call
Sverre Rabbelier <srabbelier@gmail.com>
parents:
970
diff
changeset
|
116 |
def deny(kwargs): |
888
a75ae24f04cb
Add checkAgreesToSiteToS() (partially implemented until circular import fixed).
Todd Larsen <tlarsen@google.com>
parents:
887
diff
changeset
|
117 |
"""Always raises an alternate HTTP response. |
508
2b90baceac88
Add a access.deny and access.allow method
Sverre Rabbelier <srabbelier@gmail.com>
parents:
481
diff
changeset
|
118 |
|
2b90baceac88
Add a access.deny and access.allow method
Sverre Rabbelier <srabbelier@gmail.com>
parents:
481
diff
changeset
|
119 |
Args: |
972
43018f61b481
Remove the request and arg parameter from the checkAccess call
Sverre Rabbelier <srabbelier@gmail.com>
parents:
970
diff
changeset
|
120 |
kwargs: a dictionary with django's arguments |
508
2b90baceac88
Add a access.deny and access.allow method
Sverre Rabbelier <srabbelier@gmail.com>
parents:
481
diff
changeset
|
121 |
|
888
a75ae24f04cb
Add checkAgreesToSiteToS() (partially implemented until circular import fixed).
Todd Larsen <tlarsen@google.com>
parents:
887
diff
changeset
|
122 |
Raises: |
a75ae24f04cb
Add checkAgreesToSiteToS() (partially implemented until circular import fixed).
Todd Larsen <tlarsen@google.com>
parents:
887
diff
changeset
|
123 |
always raises AccessViolationResponse if called |
508
2b90baceac88
Add a access.deny and access.allow method
Sverre Rabbelier <srabbelier@gmail.com>
parents:
481
diff
changeset
|
124 |
""" |
927
f790f77ba6b7
Restore context in deny() page
Sverre Rabbelier <srabbelier@gmail.com>
parents:
914
diff
changeset
|
125 |
|
f790f77ba6b7
Restore context in deny() page
Sverre Rabbelier <srabbelier@gmail.com>
parents:
914
diff
changeset
|
126 |
import soc.views.helper.responses |
f790f77ba6b7
Restore context in deny() page
Sverre Rabbelier <srabbelier@gmail.com>
parents:
914
diff
changeset
|
127 |
|
972
43018f61b481
Remove the request and arg parameter from the checkAccess call
Sverre Rabbelier <srabbelier@gmail.com>
parents:
970
diff
changeset
|
128 |
kwargs.get('context', {}) |
543
280a1ac6bcc1
Merge soc/logic/out_of_band.py into soc/views/out_of_band.py. Merge
Todd Larsen <tlarsen@google.com>
parents:
525
diff
changeset
|
129 |
context['title'] = 'Access denied' |
508
2b90baceac88
Add a access.deny and access.allow method
Sverre Rabbelier <srabbelier@gmail.com>
parents:
481
diff
changeset
|
130 |
|
543
280a1ac6bcc1
Merge soc/logic/out_of_band.py into soc/views/out_of_band.py. Merge
Todd Larsen <tlarsen@google.com>
parents:
525
diff
changeset
|
131 |
raise out_of_band.AccessViolation(DEF_PAGE_DENIED_MSG, context=context) |
508
2b90baceac88
Add a access.deny and access.allow method
Sverre Rabbelier <srabbelier@gmail.com>
parents:
481
diff
changeset
|
132 |
|
293
1edd01373e71
Add an access control module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
133 |
|
972
43018f61b481
Remove the request and arg parameter from the checkAccess call
Sverre Rabbelier <srabbelier@gmail.com>
parents:
970
diff
changeset
|
134 |
def checkIsLoggedIn(kwargs): |
888
a75ae24f04cb
Add checkAgreesToSiteToS() (partially implemented until circular import fixed).
Todd Larsen <tlarsen@google.com>
parents:
887
diff
changeset
|
135 |
"""Raises an alternate HTTP response if Google Account is not logged in. |
293
1edd01373e71
Add an access control module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
136 |
|
1edd01373e71
Add an access control module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
137 |
Args: |
972
43018f61b481
Remove the request and arg parameter from the checkAccess call
Sverre Rabbelier <srabbelier@gmail.com>
parents:
970
diff
changeset
|
138 |
kwargs: a dictionary with django's arguments |
293
1edd01373e71
Add an access control module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
139 |
|
888
a75ae24f04cb
Add checkAgreesToSiteToS() (partially implemented until circular import fixed).
Todd Larsen <tlarsen@google.com>
parents:
887
diff
changeset
|
140 |
Raises: |
a75ae24f04cb
Add checkAgreesToSiteToS() (partially implemented until circular import fixed).
Todd Larsen <tlarsen@google.com>
parents:
887
diff
changeset
|
141 |
AccessViolationResponse: |
a75ae24f04cb
Add checkAgreesToSiteToS() (partially implemented until circular import fixed).
Todd Larsen <tlarsen@google.com>
parents:
887
diff
changeset
|
142 |
* if no Google Account is even logged in |
293
1edd01373e71
Add an access control module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
143 |
""" |
972
43018f61b481
Remove the request and arg parameter from the checkAccess call
Sverre Rabbelier <srabbelier@gmail.com>
parents:
970
diff
changeset
|
144 |
|
293
1edd01373e71
Add an access control module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
145 |
if users.get_current_user(): |
1edd01373e71
Add an access control module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
146 |
return |
1edd01373e71
Add an access control module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
147 |
|
543
280a1ac6bcc1
Merge soc/logic/out_of_band.py into soc/views/out_of_band.py. Merge
Todd Larsen <tlarsen@google.com>
parents:
525
diff
changeset
|
148 |
raise out_of_band.LoginRequest() |
293
1edd01373e71
Add an access control module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
149 |
|
1edd01373e71
Add an access control module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
150 |
|
972
43018f61b481
Remove the request and arg parameter from the checkAccess call
Sverre Rabbelier <srabbelier@gmail.com>
parents:
970
diff
changeset
|
151 |
def checkNotLoggedIn(kwargs): |
888
a75ae24f04cb
Add checkAgreesToSiteToS() (partially implemented until circular import fixed).
Todd Larsen <tlarsen@google.com>
parents:
887
diff
changeset
|
152 |
"""Raises an alternate HTTP response if Google Account is logged in. |
590
37735d97b541
Created a seperate module for editSelf things
Sverre Rabbelier <srabbelier@gmail.com>
parents:
543
diff
changeset
|
153 |
|
37735d97b541
Created a seperate module for editSelf things
Sverre Rabbelier <srabbelier@gmail.com>
parents:
543
diff
changeset
|
154 |
Args: |
972
43018f61b481
Remove the request and arg parameter from the checkAccess call
Sverre Rabbelier <srabbelier@gmail.com>
parents:
970
diff
changeset
|
155 |
kwargs: a dictionary with django's arguments |
590
37735d97b541
Created a seperate module for editSelf things
Sverre Rabbelier <srabbelier@gmail.com>
parents:
543
diff
changeset
|
156 |
|
888
a75ae24f04cb
Add checkAgreesToSiteToS() (partially implemented until circular import fixed).
Todd Larsen <tlarsen@google.com>
parents:
887
diff
changeset
|
157 |
Raises: |
a75ae24f04cb
Add checkAgreesToSiteToS() (partially implemented until circular import fixed).
Todd Larsen <tlarsen@google.com>
parents:
887
diff
changeset
|
158 |
AccessViolationResponse: |
a75ae24f04cb
Add checkAgreesToSiteToS() (partially implemented until circular import fixed).
Todd Larsen <tlarsen@google.com>
parents:
887
diff
changeset
|
159 |
* if a Google Account is currently logged in |
590
37735d97b541
Created a seperate module for editSelf things
Sverre Rabbelier <srabbelier@gmail.com>
parents:
543
diff
changeset
|
160 |
""" |
972
43018f61b481
Remove the request and arg parameter from the checkAccess call
Sverre Rabbelier <srabbelier@gmail.com>
parents:
970
diff
changeset
|
161 |
|
590
37735d97b541
Created a seperate module for editSelf things
Sverre Rabbelier <srabbelier@gmail.com>
parents:
543
diff
changeset
|
162 |
if not users.get_current_user(): |
37735d97b541
Created a seperate module for editSelf things
Sverre Rabbelier <srabbelier@gmail.com>
parents:
543
diff
changeset
|
163 |
return |
37735d97b541
Created a seperate module for editSelf things
Sverre Rabbelier <srabbelier@gmail.com>
parents:
543
diff
changeset
|
164 |
|
37735d97b541
Created a seperate module for editSelf things
Sverre Rabbelier <srabbelier@gmail.com>
parents:
543
diff
changeset
|
165 |
raise out_of_band.LoginRequest(message_fmt=DEF_LOGOUT_MSG_FMT) |
37735d97b541
Created a seperate module for editSelf things
Sverre Rabbelier <srabbelier@gmail.com>
parents:
543
diff
changeset
|
166 |
|
37735d97b541
Created a seperate module for editSelf things
Sverre Rabbelier <srabbelier@gmail.com>
parents:
543
diff
changeset
|
167 |
|
972
43018f61b481
Remove the request and arg parameter from the checkAccess call
Sverre Rabbelier <srabbelier@gmail.com>
parents:
970
diff
changeset
|
168 |
def checkIsUser(kwargs): |
888
a75ae24f04cb
Add checkAgreesToSiteToS() (partially implemented until circular import fixed).
Todd Larsen <tlarsen@google.com>
parents:
887
diff
changeset
|
169 |
"""Raises an alternate HTTP response if Google Account has no User entity. |
293
1edd01373e71
Add an access control module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
170 |
|
1edd01373e71
Add an access control module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
171 |
Args: |
972
43018f61b481
Remove the request and arg parameter from the checkAccess call
Sverre Rabbelier <srabbelier@gmail.com>
parents:
970
diff
changeset
|
172 |
kwargs: a dictionary with django's arguments |
293
1edd01373e71
Add an access control module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
173 |
|
888
a75ae24f04cb
Add checkAgreesToSiteToS() (partially implemented until circular import fixed).
Todd Larsen <tlarsen@google.com>
parents:
887
diff
changeset
|
174 |
Raises: |
a75ae24f04cb
Add checkAgreesToSiteToS() (partially implemented until circular import fixed).
Todd Larsen <tlarsen@google.com>
parents:
887
diff
changeset
|
175 |
AccessViolationResponse: |
a75ae24f04cb
Add checkAgreesToSiteToS() (partially implemented until circular import fixed).
Todd Larsen <tlarsen@google.com>
parents:
887
diff
changeset
|
176 |
* if no User exists for the logged-in Google Account, or |
a75ae24f04cb
Add checkAgreesToSiteToS() (partially implemented until circular import fixed).
Todd Larsen <tlarsen@google.com>
parents:
887
diff
changeset
|
177 |
* if no Google Account is logged in at all |
293
1edd01373e71
Add an access control module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
178 |
""" |
1edd01373e71
Add an access control module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
179 |
|
972
43018f61b481
Remove the request and arg parameter from the checkAccess call
Sverre Rabbelier <srabbelier@gmail.com>
parents:
970
diff
changeset
|
180 |
checkIsLoggedIn(kwargs) |
43018f61b481
Remove the request and arg parameter from the checkAccess call
Sverre Rabbelier <srabbelier@gmail.com>
parents:
970
diff
changeset
|
181 |
|
43018f61b481
Remove the request and arg parameter from the checkAccess call
Sverre Rabbelier <srabbelier@gmail.com>
parents:
970
diff
changeset
|
182 |
user = user_logic.getForCurrentAccount() |
293
1edd01373e71
Add an access control module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
183 |
|
1edd01373e71
Add an access control module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
184 |
if user: |
1edd01373e71
Add an access control module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
185 |
return |
1edd01373e71
Add an access control module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
186 |
|
543
280a1ac6bcc1
Merge soc/logic/out_of_band.py into soc/views/out_of_band.py. Merge
Todd Larsen <tlarsen@google.com>
parents:
525
diff
changeset
|
187 |
raise out_of_band.LoginRequest(message_fmt=DEF_NO_USER_LOGIN_MSG_FMT) |
293
1edd01373e71
Add an access control module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
188 |
|
1edd01373e71
Add an access control module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
189 |
|
972
43018f61b481
Remove the request and arg parameter from the checkAccess call
Sverre Rabbelier <srabbelier@gmail.com>
parents:
970
diff
changeset
|
190 |
def checkAgreesToSiteToS(kwargs): |
888
a75ae24f04cb
Add checkAgreesToSiteToS() (partially implemented until circular import fixed).
Todd Larsen <tlarsen@google.com>
parents:
887
diff
changeset
|
191 |
"""Raises an alternate HTTP response if User has not agreed to site-wide ToS. |
293
1edd01373e71
Add an access control module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
192 |
|
1edd01373e71
Add an access control module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
193 |
Args: |
972
43018f61b481
Remove the request and arg parameter from the checkAccess call
Sverre Rabbelier <srabbelier@gmail.com>
parents:
970
diff
changeset
|
194 |
kwargs: a dictionary with django's arguments |
293
1edd01373e71
Add an access control module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
195 |
|
888
a75ae24f04cb
Add checkAgreesToSiteToS() (partially implemented until circular import fixed).
Todd Larsen <tlarsen@google.com>
parents:
887
diff
changeset
|
196 |
Raises: |
a75ae24f04cb
Add checkAgreesToSiteToS() (partially implemented until circular import fixed).
Todd Larsen <tlarsen@google.com>
parents:
887
diff
changeset
|
197 |
AccessViolationResponse: |
a75ae24f04cb
Add checkAgreesToSiteToS() (partially implemented until circular import fixed).
Todd Larsen <tlarsen@google.com>
parents:
887
diff
changeset
|
198 |
* if User has not agreed to the site-wide ToS, or |
a75ae24f04cb
Add checkAgreesToSiteToS() (partially implemented until circular import fixed).
Todd Larsen <tlarsen@google.com>
parents:
887
diff
changeset
|
199 |
* if no User exists for the logged-in Google Account, or |
a75ae24f04cb
Add checkAgreesToSiteToS() (partially implemented until circular import fixed).
Todd Larsen <tlarsen@google.com>
parents:
887
diff
changeset
|
200 |
* if no Google Account is logged in at all |
a75ae24f04cb
Add checkAgreesToSiteToS() (partially implemented until circular import fixed).
Todd Larsen <tlarsen@google.com>
parents:
887
diff
changeset
|
201 |
""" |
972
43018f61b481
Remove the request and arg parameter from the checkAccess call
Sverre Rabbelier <srabbelier@gmail.com>
parents:
970
diff
changeset
|
202 |
|
43018f61b481
Remove the request and arg parameter from the checkAccess call
Sverre Rabbelier <srabbelier@gmail.com>
parents:
970
diff
changeset
|
203 |
checkIsUser(kwargs) |
888
a75ae24f04cb
Add checkAgreesToSiteToS() (partially implemented until circular import fixed).
Todd Larsen <tlarsen@google.com>
parents:
887
diff
changeset
|
204 |
|
965
f96cc3d6120f
Changed user_logic call to it's convenience function getForCurrentAccount.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
960
diff
changeset
|
205 |
user = user_logic.getForCurrentAccount() |
888
a75ae24f04cb
Add checkAgreesToSiteToS() (partially implemented until circular import fixed).
Todd Larsen <tlarsen@google.com>
parents:
887
diff
changeset
|
206 |
|
a75ae24f04cb
Add checkAgreesToSiteToS() (partially implemented until circular import fixed).
Todd Larsen <tlarsen@google.com>
parents:
887
diff
changeset
|
207 |
if user_logic.agreesToSiteToS(user): |
a75ae24f04cb
Add checkAgreesToSiteToS() (partially implemented until circular import fixed).
Todd Larsen <tlarsen@google.com>
parents:
887
diff
changeset
|
208 |
return |
293
1edd01373e71
Add an access control module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
209 |
|
888
a75ae24f04cb
Add checkAgreesToSiteToS() (partially implemented until circular import fixed).
Todd Larsen <tlarsen@google.com>
parents:
887
diff
changeset
|
210 |
# Would not reach this point of site-wide ToS did not exist, since |
a75ae24f04cb
Add checkAgreesToSiteToS() (partially implemented until circular import fixed).
Todd Larsen <tlarsen@google.com>
parents:
887
diff
changeset
|
211 |
# agreesToSiteToS() call above always returns True if no ToS is in effect. |
a75ae24f04cb
Add checkAgreesToSiteToS() (partially implemented until circular import fixed).
Todd Larsen <tlarsen@google.com>
parents:
887
diff
changeset
|
212 |
login_msg_fmt = DEF_AGREE_TO_TOS_MSG_FMT % { |
891
3d40190f35b6
Move getToSLink() to soc.views.helper.redirects.getToSRedirect().
Todd Larsen <tlarsen@google.com>
parents:
890
diff
changeset
|
213 |
'tos_link': redirects.getToSRedirect(site_logic.getSingleton())} |
888
a75ae24f04cb
Add checkAgreesToSiteToS() (partially implemented until circular import fixed).
Todd Larsen <tlarsen@google.com>
parents:
887
diff
changeset
|
214 |
|
a75ae24f04cb
Add checkAgreesToSiteToS() (partially implemented until circular import fixed).
Todd Larsen <tlarsen@google.com>
parents:
887
diff
changeset
|
215 |
raise out_of_band.LoginRequest(message_fmt=login_msg_fmt) |
a75ae24f04cb
Add checkAgreesToSiteToS() (partially implemented until circular import fixed).
Todd Larsen <tlarsen@google.com>
parents:
887
diff
changeset
|
216 |
|
a75ae24f04cb
Add checkAgreesToSiteToS() (partially implemented until circular import fixed).
Todd Larsen <tlarsen@google.com>
parents:
887
diff
changeset
|
217 |
|
972
43018f61b481
Remove the request and arg parameter from the checkAccess call
Sverre Rabbelier <srabbelier@gmail.com>
parents:
970
diff
changeset
|
218 |
def checkIsDeveloper(kwargs): |
888
a75ae24f04cb
Add checkAgreesToSiteToS() (partially implemented until circular import fixed).
Todd Larsen <tlarsen@google.com>
parents:
887
diff
changeset
|
219 |
"""Raises an alternate HTTP response if Google Account is not a Developer. |
a75ae24f04cb
Add checkAgreesToSiteToS() (partially implemented until circular import fixed).
Todd Larsen <tlarsen@google.com>
parents:
887
diff
changeset
|
220 |
|
a75ae24f04cb
Add checkAgreesToSiteToS() (partially implemented until circular import fixed).
Todd Larsen <tlarsen@google.com>
parents:
887
diff
changeset
|
221 |
Args: |
972
43018f61b481
Remove the request and arg parameter from the checkAccess call
Sverre Rabbelier <srabbelier@gmail.com>
parents:
970
diff
changeset
|
222 |
kwargs: a dictionary with django's arguments |
888
a75ae24f04cb
Add checkAgreesToSiteToS() (partially implemented until circular import fixed).
Todd Larsen <tlarsen@google.com>
parents:
887
diff
changeset
|
223 |
|
a75ae24f04cb
Add checkAgreesToSiteToS() (partially implemented until circular import fixed).
Todd Larsen <tlarsen@google.com>
parents:
887
diff
changeset
|
224 |
Raises: |
a75ae24f04cb
Add checkAgreesToSiteToS() (partially implemented until circular import fixed).
Todd Larsen <tlarsen@google.com>
parents:
887
diff
changeset
|
225 |
AccessViolationResponse: |
a75ae24f04cb
Add checkAgreesToSiteToS() (partially implemented until circular import fixed).
Todd Larsen <tlarsen@google.com>
parents:
887
diff
changeset
|
226 |
* if User is not a Developer, or |
a75ae24f04cb
Add checkAgreesToSiteToS() (partially implemented until circular import fixed).
Todd Larsen <tlarsen@google.com>
parents:
887
diff
changeset
|
227 |
* if no User exists for the logged-in Google Account, or |
a75ae24f04cb
Add checkAgreesToSiteToS() (partially implemented until circular import fixed).
Todd Larsen <tlarsen@google.com>
parents:
887
diff
changeset
|
228 |
* if no Google Account is logged in at all |
293
1edd01373e71
Add an access control module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
229 |
""" |
895
e70ffd079438
Even developers need to agree to the terms of service for Melange
Sverre Rabbelier <srabbelier@gmail.com>
parents:
892
diff
changeset
|
230 |
|
972
43018f61b481
Remove the request and arg parameter from the checkAccess call
Sverre Rabbelier <srabbelier@gmail.com>
parents:
970
diff
changeset
|
231 |
checkAgreesToSiteToS(kwargs) |
293
1edd01373e71
Add an access control module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
232 |
|
481
94834a1e6c01
Attempt to rename User.id to User.account, in preparation for making User be
Todd Larsen <tlarsen@google.com>
parents:
448
diff
changeset
|
233 |
if accounts.isDeveloper(account=users.get_current_user()): |
699
4e8eefe95748
Add and use a placeholder for checkIsDocumentPublic
Sverre Rabbelier <srabbelier@gmail.com>
parents:
639
diff
changeset
|
234 |
return |
293
1edd01373e71
Add an access control module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
235 |
|
1edd01373e71
Add an access control module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
236 |
login_message_fmt = DEF_DEV_LOGOUT_LOGIN_MSG_FMT % { |
746
018efb9863dc
Fix import sorting in soc.views.helper.access module and rename 'host' to 'Program Administrator'.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
729
diff
changeset
|
237 |
'role': 'a Site Developer '} |
293
1edd01373e71
Add an access control module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
238 |
|
543
280a1ac6bcc1
Merge soc/logic/out_of_band.py into soc/views/out_of_band.py. Merge
Todd Larsen <tlarsen@google.com>
parents:
525
diff
changeset
|
239 |
raise out_of_band.LoginRequest(message_fmt=login_message_fmt) |
293
1edd01373e71
Add an access control module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
240 |
|
948
bd956f419ad9
Add missing blank lines and remove unused checkIsInvited function from soc.views.helper.access module.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
943
diff
changeset
|
241 |
|
914
6ec8dd2a73b3
Added various access methods in preperation for the new request system.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
895
diff
changeset
|
242 |
def checkCanCreateFromRequest(role_name): |
940
a40056afef83
Changed the access checks to comply with state in request.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
931
diff
changeset
|
243 |
"""Raises an alternate HTTP response if the specified request does not exist |
a40056afef83
Changed the access checks to comply with state in request.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
931
diff
changeset
|
244 |
or if it's state is not group_accepted. |
914
6ec8dd2a73b3
Added various access methods in preperation for the new request system.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
895
diff
changeset
|
245 |
""" |
972
43018f61b481
Remove the request and arg parameter from the checkAccess call
Sverre Rabbelier <srabbelier@gmail.com>
parents:
970
diff
changeset
|
246 |
|
43018f61b481
Remove the request and arg parameter from the checkAccess call
Sverre Rabbelier <srabbelier@gmail.com>
parents:
970
diff
changeset
|
247 |
def wrapper(kwargs): |
43018f61b481
Remove the request and arg parameter from the checkAccess call
Sverre Rabbelier <srabbelier@gmail.com>
parents:
970
diff
changeset
|
248 |
checkAgreesToSiteToS(kwargs) |
914
6ec8dd2a73b3
Added various access methods in preperation for the new request system.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
895
diff
changeset
|
249 |
|
6ec8dd2a73b3
Added various access methods in preperation for the new request system.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
895
diff
changeset
|
250 |
user_entity = user_logic.getForCurrentAccount() |
6ec8dd2a73b3
Added various access methods in preperation for the new request system.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
895
diff
changeset
|
251 |
|
6ec8dd2a73b3
Added various access methods in preperation for the new request system.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
895
diff
changeset
|
252 |
if user_entity.link_id != kwargs['link_id']: |
972
43018f61b481
Remove the request and arg parameter from the checkAccess call
Sverre Rabbelier <srabbelier@gmail.com>
parents:
970
diff
changeset
|
253 |
deny(kwargs) |
914
6ec8dd2a73b3
Added various access methods in preperation for the new request system.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
895
diff
changeset
|
254 |
|
958
b4309e3cb899
Fix some missing dots in access and club_admin modules.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
950
diff
changeset
|
255 |
fields = {'link_id': kwargs['link_id'], |
b4309e3cb899
Fix some missing dots in access and club_admin modules.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
950
diff
changeset
|
256 |
'scope_path': kwargs['scope_path'], |
b4309e3cb899
Fix some missing dots in access and club_admin modules.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
950
diff
changeset
|
257 |
'role': role_name} |
914
6ec8dd2a73b3
Added various access methods in preperation for the new request system.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
895
diff
changeset
|
258 |
|
6ec8dd2a73b3
Added various access methods in preperation for the new request system.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
895
diff
changeset
|
259 |
request_entity = request_logic.getFromFieldsOr404(**fields) |
6ec8dd2a73b3
Added various access methods in preperation for the new request system.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
895
diff
changeset
|
260 |
|
940
a40056afef83
Changed the access checks to comply with state in request.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
931
diff
changeset
|
261 |
if request_entity.state != 'group_accepted': |
914
6ec8dd2a73b3
Added various access methods in preperation for the new request system.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
895
diff
changeset
|
262 |
# TODO tell the user that this request has not been accepted yet |
972
43018f61b481
Remove the request and arg parameter from the checkAccess call
Sverre Rabbelier <srabbelier@gmail.com>
parents:
970
diff
changeset
|
263 |
deny(kwargs) |
914
6ec8dd2a73b3
Added various access methods in preperation for the new request system.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
895
diff
changeset
|
264 |
|
6ec8dd2a73b3
Added various access methods in preperation for the new request system.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
895
diff
changeset
|
265 |
return |
972
43018f61b481
Remove the request and arg parameter from the checkAccess call
Sverre Rabbelier <srabbelier@gmail.com>
parents:
970
diff
changeset
|
266 |
|
914
6ec8dd2a73b3
Added various access methods in preperation for the new request system.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
895
diff
changeset
|
267 |
return wrapper |
6ec8dd2a73b3
Added various access methods in preperation for the new request system.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
895
diff
changeset
|
268 |
|
948
bd956f419ad9
Add missing blank lines and remove unused checkIsInvited function from soc.views.helper.access module.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
943
diff
changeset
|
269 |
|
960
129efa976d6d
Added checkCanProcessRequest in access.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
958
diff
changeset
|
270 |
def checkCanProcessRequest(role_name): |
129efa976d6d
Added checkCanProcessRequest in access.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
958
diff
changeset
|
271 |
"""Raises an alternate HTTP response if the specified request does not exist |
129efa976d6d
Added checkCanProcessRequest in access.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
958
diff
changeset
|
272 |
or if it's state is completed or denied. |
129efa976d6d
Added checkCanProcessRequest in access.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
958
diff
changeset
|
273 |
""" |
972
43018f61b481
Remove the request and arg parameter from the checkAccess call
Sverre Rabbelier <srabbelier@gmail.com>
parents:
970
diff
changeset
|
274 |
|
43018f61b481
Remove the request and arg parameter from the checkAccess call
Sverre Rabbelier <srabbelier@gmail.com>
parents:
970
diff
changeset
|
275 |
def wrapper(kwargs): |
960
129efa976d6d
Added checkCanProcessRequest in access.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
958
diff
changeset
|
276 |
|
129efa976d6d
Added checkCanProcessRequest in access.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
958
diff
changeset
|
277 |
fields = {'link_id': kwargs['link_id'], |
129efa976d6d
Added checkCanProcessRequest in access.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
958
diff
changeset
|
278 |
'scope_path': kwargs['scope_path'], |
129efa976d6d
Added checkCanProcessRequest in access.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
958
diff
changeset
|
279 |
'role': role_name} |
129efa976d6d
Added checkCanProcessRequest in access.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
958
diff
changeset
|
280 |
|
129efa976d6d
Added checkCanProcessRequest in access.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
958
diff
changeset
|
281 |
request_entity = request_logic.getFromFieldsOr404(**fields) |
129efa976d6d
Added checkCanProcessRequest in access.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
958
diff
changeset
|
282 |
|
129efa976d6d
Added checkCanProcessRequest in access.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
958
diff
changeset
|
283 |
if request_entity.state in ['completed', 'denied']: |
129efa976d6d
Added checkCanProcessRequest in access.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
958
diff
changeset
|
284 |
# TODO tell the user that this request has been processed |
972
43018f61b481
Remove the request and arg parameter from the checkAccess call
Sverre Rabbelier <srabbelier@gmail.com>
parents:
970
diff
changeset
|
285 |
deny(kwargs) |
960
129efa976d6d
Added checkCanProcessRequest in access.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
958
diff
changeset
|
286 |
|
129efa976d6d
Added checkCanProcessRequest in access.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
958
diff
changeset
|
287 |
return |
972
43018f61b481
Remove the request and arg parameter from the checkAccess call
Sverre Rabbelier <srabbelier@gmail.com>
parents:
970
diff
changeset
|
288 |
|
960
129efa976d6d
Added checkCanProcessRequest in access.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
958
diff
changeset
|
289 |
return wrapper |
129efa976d6d
Added checkCanProcessRequest in access.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
958
diff
changeset
|
290 |
|
129efa976d6d
Added checkCanProcessRequest in access.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
958
diff
changeset
|
291 |
|
972
43018f61b481
Remove the request and arg parameter from the checkAccess call
Sverre Rabbelier <srabbelier@gmail.com>
parents:
970
diff
changeset
|
292 |
def checkIsMyGroupAcceptedRequest(kwargs): |
940
a40056afef83
Changed the access checks to comply with state in request.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
931
diff
changeset
|
293 |
"""Raises an alternate HTTP response if the specified request does not exist |
950
8f59df49985b
Added missing dot to access.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
948
diff
changeset
|
294 |
or if it's state is not group_accepted. |
914
6ec8dd2a73b3
Added various access methods in preperation for the new request system.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
895
diff
changeset
|
295 |
""" |
972
43018f61b481
Remove the request and arg parameter from the checkAccess call
Sverre Rabbelier <srabbelier@gmail.com>
parents:
970
diff
changeset
|
296 |
|
43018f61b481
Remove the request and arg parameter from the checkAccess call
Sverre Rabbelier <srabbelier@gmail.com>
parents:
970
diff
changeset
|
297 |
checkAgreesToSiteToS(kwargs) |
914
6ec8dd2a73b3
Added various access methods in preperation for the new request system.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
895
diff
changeset
|
298 |
|
6ec8dd2a73b3
Added various access methods in preperation for the new request system.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
895
diff
changeset
|
299 |
user_entity = user_logic.getForCurrentAccount() |
6ec8dd2a73b3
Added various access methods in preperation for the new request system.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
895
diff
changeset
|
300 |
|
6ec8dd2a73b3
Added various access methods in preperation for the new request system.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
895
diff
changeset
|
301 |
if user_entity.link_id != kwargs['link_id']: |
6ec8dd2a73b3
Added various access methods in preperation for the new request system.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
895
diff
changeset
|
302 |
# not the current user's request |
972
43018f61b481
Remove the request and arg parameter from the checkAccess call
Sverre Rabbelier <srabbelier@gmail.com>
parents:
970
diff
changeset
|
303 |
return deny(kwargs) |
914
6ec8dd2a73b3
Added various access methods in preperation for the new request system.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
895
diff
changeset
|
304 |
|
958
b4309e3cb899
Fix some missing dots in access and club_admin modules.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
950
diff
changeset
|
305 |
fields = {'link_id': kwargs['link_id'], |
b4309e3cb899
Fix some missing dots in access and club_admin modules.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
950
diff
changeset
|
306 |
'scope_path': kwargs['scope_path'], |
b4309e3cb899
Fix some missing dots in access and club_admin modules.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
950
diff
changeset
|
307 |
'role': kwargs['role']} |
914
6ec8dd2a73b3
Added various access methods in preperation for the new request system.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
895
diff
changeset
|
308 |
|
6ec8dd2a73b3
Added various access methods in preperation for the new request system.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
895
diff
changeset
|
309 |
request_entity = request_logic.getForFields(fields, unique=True) |
6ec8dd2a73b3
Added various access methods in preperation for the new request system.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
895
diff
changeset
|
310 |
|
6ec8dd2a73b3
Added various access methods in preperation for the new request system.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
895
diff
changeset
|
311 |
if not request_entity: |
6ec8dd2a73b3
Added various access methods in preperation for the new request system.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
895
diff
changeset
|
312 |
# TODO return 404 |
972
43018f61b481
Remove the request and arg parameter from the checkAccess call
Sverre Rabbelier <srabbelier@gmail.com>
parents:
970
diff
changeset
|
313 |
return deny(kwargs) |
914
6ec8dd2a73b3
Added various access methods in preperation for the new request system.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
895
diff
changeset
|
314 |
|
940
a40056afef83
Changed the access checks to comply with state in request.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
931
diff
changeset
|
315 |
if request_entity.state != 'group_accepted': |
972
43018f61b481
Remove the request and arg parameter from the checkAccess call
Sverre Rabbelier <srabbelier@gmail.com>
parents:
970
diff
changeset
|
316 |
return deny(kwargs) |
940
a40056afef83
Changed the access checks to comply with state in request.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
931
diff
changeset
|
317 |
|
914
6ec8dd2a73b3
Added various access methods in preperation for the new request system.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
895
diff
changeset
|
318 |
return |
293
1edd01373e71
Add an access control module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
319 |
|
948
bd956f419ad9
Add missing blank lines and remove unused checkIsInvited function from soc.views.helper.access module.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
943
diff
changeset
|
320 |
|
972
43018f61b481
Remove the request and arg parameter from the checkAccess call
Sverre Rabbelier <srabbelier@gmail.com>
parents:
970
diff
changeset
|
321 |
def checkIsHost(kwargs): |
914
6ec8dd2a73b3
Added various access methods in preperation for the new request system.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
895
diff
changeset
|
322 |
"""Raises an alternate HTTP response if Google Account has no Host entity. |
6ec8dd2a73b3
Added various access methods in preperation for the new request system.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
895
diff
changeset
|
323 |
|
6ec8dd2a73b3
Added various access methods in preperation for the new request system.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
895
diff
changeset
|
324 |
Args: |
6ec8dd2a73b3
Added various access methods in preperation for the new request system.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
895
diff
changeset
|
325 |
request: a Django HTTP request |
6ec8dd2a73b3
Added various access methods in preperation for the new request system.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
895
diff
changeset
|
326 |
|
6ec8dd2a73b3
Added various access methods in preperation for the new request system.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
895
diff
changeset
|
327 |
Raises: |
6ec8dd2a73b3
Added various access methods in preperation for the new request system.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
895
diff
changeset
|
328 |
AccessViolationResponse: |
6ec8dd2a73b3
Added various access methods in preperation for the new request system.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
895
diff
changeset
|
329 |
* if User is not already a Host, or |
6ec8dd2a73b3
Added various access methods in preperation for the new request system.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
895
diff
changeset
|
330 |
* if User has not agreed to the site-wide ToS, or |
6ec8dd2a73b3
Added various access methods in preperation for the new request system.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
895
diff
changeset
|
331 |
* if no User exists for the logged-in Google Account, or |
6ec8dd2a73b3
Added various access methods in preperation for the new request system.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
895
diff
changeset
|
332 |
* if the user is not even logged in |
6ec8dd2a73b3
Added various access methods in preperation for the new request system.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
895
diff
changeset
|
333 |
""" |
940
a40056afef83
Changed the access checks to comply with state in request.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
931
diff
changeset
|
334 |
|
a40056afef83
Changed the access checks to comply with state in request.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
931
diff
changeset
|
335 |
try: |
a40056afef83
Changed the access checks to comply with state in request.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
931
diff
changeset
|
336 |
# if the current user is invited to create a host profile we allow access |
972
43018f61b481
Remove the request and arg parameter from the checkAccess call
Sverre Rabbelier <srabbelier@gmail.com>
parents:
970
diff
changeset
|
337 |
checkIsDeveloper(kwargs) |
940
a40056afef83
Changed the access checks to comply with state in request.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
931
diff
changeset
|
338 |
return |
a40056afef83
Changed the access checks to comply with state in request.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
931
diff
changeset
|
339 |
except out_of_band.Error: |
a40056afef83
Changed the access checks to comply with state in request.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
931
diff
changeset
|
340 |
pass |
a40056afef83
Changed the access checks to comply with state in request.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
931
diff
changeset
|
341 |
|
972
43018f61b481
Remove the request and arg parameter from the checkAccess call
Sverre Rabbelier <srabbelier@gmail.com>
parents:
970
diff
changeset
|
342 |
checkAgreesToSiteToS(kwargs) |
914
6ec8dd2a73b3
Added various access methods in preperation for the new request system.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
895
diff
changeset
|
343 |
|
972
43018f61b481
Remove the request and arg parameter from the checkAccess call
Sverre Rabbelier <srabbelier@gmail.com>
parents:
970
diff
changeset
|
344 |
user = user_logic.getForCurrentAccount() |
914
6ec8dd2a73b3
Added various access methods in preperation for the new request system.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
895
diff
changeset
|
345 |
|
958
b4309e3cb899
Fix some missing dots in access and club_admin modules.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
950
diff
changeset
|
346 |
fields = {'user': user, |
b4309e3cb899
Fix some missing dots in access and club_admin modules.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
950
diff
changeset
|
347 |
'state': 'active'} |
914
6ec8dd2a73b3
Added various access methods in preperation for the new request system.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
895
diff
changeset
|
348 |
|
6ec8dd2a73b3
Added various access methods in preperation for the new request system.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
895
diff
changeset
|
349 |
host = host_logic.getForFields(fields, unique=True) |
6ec8dd2a73b3
Added various access methods in preperation for the new request system.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
895
diff
changeset
|
350 |
|
6ec8dd2a73b3
Added various access methods in preperation for the new request system.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
895
diff
changeset
|
351 |
if host: |
6ec8dd2a73b3
Added various access methods in preperation for the new request system.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
895
diff
changeset
|
352 |
return |
6ec8dd2a73b3
Added various access methods in preperation for the new request system.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
895
diff
changeset
|
353 |
|
6ec8dd2a73b3
Added various access methods in preperation for the new request system.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
895
diff
changeset
|
354 |
login_message_fmt = DEF_DEV_LOGOUT_LOGIN_MSG_FMT % { |
6ec8dd2a73b3
Added various access methods in preperation for the new request system.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
895
diff
changeset
|
355 |
'role': 'a Program Administrator '} |
6ec8dd2a73b3
Added various access methods in preperation for the new request system.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
895
diff
changeset
|
356 |
|
6ec8dd2a73b3
Added various access methods in preperation for the new request system.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
895
diff
changeset
|
357 |
raise out_of_band.LoginRequest(message_fmt=login_message_fmt) |
6ec8dd2a73b3
Added various access methods in preperation for the new request system.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
895
diff
changeset
|
358 |
|
948
bd956f419ad9
Add missing blank lines and remove unused checkIsInvited function from soc.views.helper.access module.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
943
diff
changeset
|
359 |
|
972
43018f61b481
Remove the request and arg parameter from the checkAccess call
Sverre Rabbelier <srabbelier@gmail.com>
parents:
970
diff
changeset
|
360 |
def checkIsHostForProgram(kwargs): |
890
b3bf833c4580
Tighten more checkIsUser() access to checkAgreesToSiteToS() instead.
Todd Larsen <tlarsen@google.com>
parents:
889
diff
changeset
|
361 |
"""Raises an alternate HTTP response if Google Account has no Host entity |
709
e71b20847eb0
Add checkIsHost in access
Sverre Rabbelier <srabbelier@gmail.com>
parents:
699
diff
changeset
|
362 |
for the specified program. |
e71b20847eb0
Add checkIsHost in access
Sverre Rabbelier <srabbelier@gmail.com>
parents:
699
diff
changeset
|
363 |
|
e71b20847eb0
Add checkIsHost in access
Sverre Rabbelier <srabbelier@gmail.com>
parents:
699
diff
changeset
|
364 |
Args: |
e71b20847eb0
Add checkIsHost in access
Sverre Rabbelier <srabbelier@gmail.com>
parents:
699
diff
changeset
|
365 |
request: a Django HTTP request |
e71b20847eb0
Add checkIsHost in access
Sverre Rabbelier <srabbelier@gmail.com>
parents:
699
diff
changeset
|
366 |
|
890
b3bf833c4580
Tighten more checkIsUser() access to checkAgreesToSiteToS() instead.
Todd Larsen <tlarsen@google.com>
parents:
889
diff
changeset
|
367 |
Raises: |
b3bf833c4580
Tighten more checkIsUser() access to checkAgreesToSiteToS() instead.
Todd Larsen <tlarsen@google.com>
parents:
889
diff
changeset
|
368 |
AccessViolationResponse: |
914
6ec8dd2a73b3
Added various access methods in preperation for the new request system.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
895
diff
changeset
|
369 |
* if User is not already a Host for the specified program, or |
890
b3bf833c4580
Tighten more checkIsUser() access to checkAgreesToSiteToS() instead.
Todd Larsen <tlarsen@google.com>
parents:
889
diff
changeset
|
370 |
* if User has not agreed to the site-wide ToS, or |
b3bf833c4580
Tighten more checkIsUser() access to checkAgreesToSiteToS() instead.
Todd Larsen <tlarsen@google.com>
parents:
889
diff
changeset
|
371 |
* if no User exists for the logged-in Google Account, or |
b3bf833c4580
Tighten more checkIsUser() access to checkAgreesToSiteToS() instead.
Todd Larsen <tlarsen@google.com>
parents:
889
diff
changeset
|
372 |
* if the user is not even logged in |
709
e71b20847eb0
Add checkIsHost in access
Sverre Rabbelier <srabbelier@gmail.com>
parents:
699
diff
changeset
|
373 |
""" |
e71b20847eb0
Add checkIsHost in access
Sverre Rabbelier <srabbelier@gmail.com>
parents:
699
diff
changeset
|
374 |
|
972
43018f61b481
Remove the request and arg parameter from the checkAccess call
Sverre Rabbelier <srabbelier@gmail.com>
parents:
970
diff
changeset
|
375 |
checkAgreesToSiteToS(kwargs) |
43018f61b481
Remove the request and arg parameter from the checkAccess call
Sverre Rabbelier <srabbelier@gmail.com>
parents:
970
diff
changeset
|
376 |
|
43018f61b481
Remove the request and arg parameter from the checkAccess call
Sverre Rabbelier <srabbelier@gmail.com>
parents:
970
diff
changeset
|
377 |
user = user_logic.getForCurrentAccount() |
709
e71b20847eb0
Add checkIsHost in access
Sverre Rabbelier <srabbelier@gmail.com>
parents:
699
diff
changeset
|
378 |
|
958
b4309e3cb899
Fix some missing dots in access and club_admin modules.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
950
diff
changeset
|
379 |
fields = {'user': user, |
b4309e3cb899
Fix some missing dots in access and club_admin modules.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
950
diff
changeset
|
380 |
'scope_path': kwargs['scope_path'], |
b4309e3cb899
Fix some missing dots in access and club_admin modules.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
950
diff
changeset
|
381 |
'state': 'active'} |
914
6ec8dd2a73b3
Added various access methods in preperation for the new request system.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
895
diff
changeset
|
382 |
|
6ec8dd2a73b3
Added various access methods in preperation for the new request system.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
895
diff
changeset
|
383 |
host = host_logic.getForFields(fields, unique=True) |
709
e71b20847eb0
Add checkIsHost in access
Sverre Rabbelier <srabbelier@gmail.com>
parents:
699
diff
changeset
|
384 |
|
e71b20847eb0
Add checkIsHost in access
Sverre Rabbelier <srabbelier@gmail.com>
parents:
699
diff
changeset
|
385 |
if host: |
e71b20847eb0
Add checkIsHost in access
Sverre Rabbelier <srabbelier@gmail.com>
parents:
699
diff
changeset
|
386 |
return |
e71b20847eb0
Add checkIsHost in access
Sverre Rabbelier <srabbelier@gmail.com>
parents:
699
diff
changeset
|
387 |
|
e71b20847eb0
Add checkIsHost in access
Sverre Rabbelier <srabbelier@gmail.com>
parents:
699
diff
changeset
|
388 |
login_message_fmt = DEF_DEV_LOGOUT_LOGIN_MSG_FMT % { |
746
018efb9863dc
Fix import sorting in soc.views.helper.access module and rename 'host' to 'Program Administrator'.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
729
diff
changeset
|
389 |
'role': 'a Program Administrator '} |
709
e71b20847eb0
Add checkIsHost in access
Sverre Rabbelier <srabbelier@gmail.com>
parents:
699
diff
changeset
|
390 |
|
e71b20847eb0
Add checkIsHost in access
Sverre Rabbelier <srabbelier@gmail.com>
parents:
699
diff
changeset
|
391 |
raise out_of_band.LoginRequest(message_fmt=login_message_fmt) |
e71b20847eb0
Add checkIsHost in access
Sverre Rabbelier <srabbelier@gmail.com>
parents:
699
diff
changeset
|
392 |
|
e71b20847eb0
Add checkIsHost in access
Sverre Rabbelier <srabbelier@gmail.com>
parents:
699
diff
changeset
|
393 |
|
972
43018f61b481
Remove the request and arg parameter from the checkAccess call
Sverre Rabbelier <srabbelier@gmail.com>
parents:
970
diff
changeset
|
394 |
def checkIsClubAdminForClub(kwargs): |
814
25ffebd9fa8f
Implement the checkIsClubAppAccepted function
Sverre Rabbelier <srabbelier@gmail.com>
parents:
802
diff
changeset
|
395 |
"""Returns an alternate HTTP response if Google Account has no Club Admin |
25ffebd9fa8f
Implement the checkIsClubAppAccepted function
Sverre Rabbelier <srabbelier@gmail.com>
parents:
802
diff
changeset
|
396 |
entity for the specified club. |
25ffebd9fa8f
Implement the checkIsClubAppAccepted function
Sverre Rabbelier <srabbelier@gmail.com>
parents:
802
diff
changeset
|
397 |
|
25ffebd9fa8f
Implement the checkIsClubAppAccepted function
Sverre Rabbelier <srabbelier@gmail.com>
parents:
802
diff
changeset
|
398 |
Args: |
972
43018f61b481
Remove the request and arg parameter from the checkAccess call
Sverre Rabbelier <srabbelier@gmail.com>
parents:
970
diff
changeset
|
399 |
kwargs: a dictionary with django's arguments |
814
25ffebd9fa8f
Implement the checkIsClubAppAccepted function
Sverre Rabbelier <srabbelier@gmail.com>
parents:
802
diff
changeset
|
400 |
|
25ffebd9fa8f
Implement the checkIsClubAppAccepted function
Sverre Rabbelier <srabbelier@gmail.com>
parents:
802
diff
changeset
|
401 |
Raises: |
25ffebd9fa8f
Implement the checkIsClubAppAccepted function
Sverre Rabbelier <srabbelier@gmail.com>
parents:
802
diff
changeset
|
402 |
AccessViolationResponse: if the required authorization is not met |
25ffebd9fa8f
Implement the checkIsClubAppAccepted function
Sverre Rabbelier <srabbelier@gmail.com>
parents:
802
diff
changeset
|
403 |
|
25ffebd9fa8f
Implement the checkIsClubAppAccepted function
Sverre Rabbelier <srabbelier@gmail.com>
parents:
802
diff
changeset
|
404 |
Returns: |
25ffebd9fa8f
Implement the checkIsClubAppAccepted function
Sverre Rabbelier <srabbelier@gmail.com>
parents:
802
diff
changeset
|
405 |
None if Club Admin exists for the specified club, or a subclass of |
25ffebd9fa8f
Implement the checkIsClubAppAccepted function
Sverre Rabbelier <srabbelier@gmail.com>
parents:
802
diff
changeset
|
406 |
django.http.HttpResponse which contains the alternate response |
25ffebd9fa8f
Implement the checkIsClubAppAccepted function
Sverre Rabbelier <srabbelier@gmail.com>
parents:
802
diff
changeset
|
407 |
should be returned by the calling view. |
25ffebd9fa8f
Implement the checkIsClubAppAccepted function
Sverre Rabbelier <srabbelier@gmail.com>
parents:
802
diff
changeset
|
408 |
""" |
25ffebd9fa8f
Implement the checkIsClubAppAccepted function
Sverre Rabbelier <srabbelier@gmail.com>
parents:
802
diff
changeset
|
409 |
|
25ffebd9fa8f
Implement the checkIsClubAppAccepted function
Sverre Rabbelier <srabbelier@gmail.com>
parents:
802
diff
changeset
|
410 |
try: |
25ffebd9fa8f
Implement the checkIsClubAppAccepted function
Sverre Rabbelier <srabbelier@gmail.com>
parents:
802
diff
changeset
|
411 |
# if the current user is invited to create a host profile we allow access |
972
43018f61b481
Remove the request and arg parameter from the checkAccess call
Sverre Rabbelier <srabbelier@gmail.com>
parents:
970
diff
changeset
|
412 |
checkIsDeveloper(kwargs) |
814
25ffebd9fa8f
Implement the checkIsClubAppAccepted function
Sverre Rabbelier <srabbelier@gmail.com>
parents:
802
diff
changeset
|
413 |
return |
25ffebd9fa8f
Implement the checkIsClubAppAccepted function
Sverre Rabbelier <srabbelier@gmail.com>
parents:
802
diff
changeset
|
414 |
except out_of_band.Error: |
25ffebd9fa8f
Implement the checkIsClubAppAccepted function
Sverre Rabbelier <srabbelier@gmail.com>
parents:
802
diff
changeset
|
415 |
pass |
25ffebd9fa8f
Implement the checkIsClubAppAccepted function
Sverre Rabbelier <srabbelier@gmail.com>
parents:
802
diff
changeset
|
416 |
|
972
43018f61b481
Remove the request and arg parameter from the checkAccess call
Sverre Rabbelier <srabbelier@gmail.com>
parents:
970
diff
changeset
|
417 |
checkAgreesToSiteToS(kwargs) |
814
25ffebd9fa8f
Implement the checkIsClubAppAccepted function
Sverre Rabbelier <srabbelier@gmail.com>
parents:
802
diff
changeset
|
418 |
|
914
6ec8dd2a73b3
Added various access methods in preperation for the new request system.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
895
diff
changeset
|
419 |
user = user_logic.getForCurrentAccount() |
6ec8dd2a73b3
Added various access methods in preperation for the new request system.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
895
diff
changeset
|
420 |
|
943
897d9efdb728
Fixed an access related bug in checkIsClubAdminForClub.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
942
diff
changeset
|
421 |
if kwargs.get('scope_path'): |
897d9efdb728
Fixed an access related bug in checkIsClubAdminForClub.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
942
diff
changeset
|
422 |
scope_path = kwargs['scope_path'] |
897d9efdb728
Fixed an access related bug in checkIsClubAdminForClub.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
942
diff
changeset
|
423 |
else: |
897d9efdb728
Fixed an access related bug in checkIsClubAdminForClub.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
942
diff
changeset
|
424 |
scope_path = kwargs['link_id'] |
897d9efdb728
Fixed an access related bug in checkIsClubAdminForClub.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
942
diff
changeset
|
425 |
|
958
b4309e3cb899
Fix some missing dots in access and club_admin modules.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
950
diff
changeset
|
426 |
fields = {'user': user, |
b4309e3cb899
Fix some missing dots in access and club_admin modules.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
950
diff
changeset
|
427 |
'scope_path': scope_path, |
b4309e3cb899
Fix some missing dots in access and club_admin modules.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
950
diff
changeset
|
428 |
'state': 'active'} |
914
6ec8dd2a73b3
Added various access methods in preperation for the new request system.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
895
diff
changeset
|
429 |
|
6ec8dd2a73b3
Added various access methods in preperation for the new request system.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
895
diff
changeset
|
430 |
club_admin_entity = club_admin_logic.getForFields(fields, unique=True) |
6ec8dd2a73b3
Added various access methods in preperation for the new request system.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
895
diff
changeset
|
431 |
|
6ec8dd2a73b3
Added various access methods in preperation for the new request system.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
895
diff
changeset
|
432 |
if club_admin_entity: |
6ec8dd2a73b3
Added various access methods in preperation for the new request system.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
895
diff
changeset
|
433 |
return |
814
25ffebd9fa8f
Implement the checkIsClubAppAccepted function
Sverre Rabbelier <srabbelier@gmail.com>
parents:
802
diff
changeset
|
434 |
|
25ffebd9fa8f
Implement the checkIsClubAppAccepted function
Sverre Rabbelier <srabbelier@gmail.com>
parents:
802
diff
changeset
|
435 |
login_message_fmt = DEF_DEV_LOGOUT_LOGIN_MSG_FMT % { |
25ffebd9fa8f
Implement the checkIsClubAppAccepted function
Sverre Rabbelier <srabbelier@gmail.com>
parents:
802
diff
changeset
|
436 |
'role': 'a Club Admin for this Club'} |
25ffebd9fa8f
Implement the checkIsClubAppAccepted function
Sverre Rabbelier <srabbelier@gmail.com>
parents:
802
diff
changeset
|
437 |
|
25ffebd9fa8f
Implement the checkIsClubAppAccepted function
Sverre Rabbelier <srabbelier@gmail.com>
parents:
802
diff
changeset
|
438 |
raise out_of_band.LoginRequest(message_fmt=login_message_fmt) |
25ffebd9fa8f
Implement the checkIsClubAppAccepted function
Sverre Rabbelier <srabbelier@gmail.com>
parents:
802
diff
changeset
|
439 |
|
25ffebd9fa8f
Implement the checkIsClubAppAccepted function
Sverre Rabbelier <srabbelier@gmail.com>
parents:
802
diff
changeset
|
440 |
|
884
ded4850776c8
Changed checkIsClubAppAccepted into a more generic checkIsApplicationAccepted.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
882
diff
changeset
|
441 |
def checkIsApplicationAccepted(app_logic): |
802
95c534d02e39
Added Club Admin model, logic, and view
Sverre Rabbelier <srabbelier@gmail.com>
parents:
796
diff
changeset
|
442 |
"""Returns an alternate HTTP response if Google Account has no Club App |
95c534d02e39
Added Club Admin model, logic, and view
Sverre Rabbelier <srabbelier@gmail.com>
parents:
796
diff
changeset
|
443 |
entity for the specified Club. |
95c534d02e39
Added Club Admin model, logic, and view
Sverre Rabbelier <srabbelier@gmail.com>
parents:
796
diff
changeset
|
444 |
|
95c534d02e39
Added Club Admin model, logic, and view
Sverre Rabbelier <srabbelier@gmail.com>
parents:
796
diff
changeset
|
445 |
Args: |
972
43018f61b481
Remove the request and arg parameter from the checkAccess call
Sverre Rabbelier <srabbelier@gmail.com>
parents:
970
diff
changeset
|
446 |
kwargs: a dictionary with django's arguments |
802
95c534d02e39
Added Club Admin model, logic, and view
Sverre Rabbelier <srabbelier@gmail.com>
parents:
796
diff
changeset
|
447 |
|
95c534d02e39
Added Club Admin model, logic, and view
Sverre Rabbelier <srabbelier@gmail.com>
parents:
796
diff
changeset
|
448 |
Raises: |
95c534d02e39
Added Club Admin model, logic, and view
Sverre Rabbelier <srabbelier@gmail.com>
parents:
796
diff
changeset
|
449 |
AccessViolationResponse: if the required authorization is not met |
95c534d02e39
Added Club Admin model, logic, and view
Sverre Rabbelier <srabbelier@gmail.com>
parents:
796
diff
changeset
|
450 |
|
95c534d02e39
Added Club Admin model, logic, and view
Sverre Rabbelier <srabbelier@gmail.com>
parents:
796
diff
changeset
|
451 |
Returns: |
95c534d02e39
Added Club Admin model, logic, and view
Sverre Rabbelier <srabbelier@gmail.com>
parents:
796
diff
changeset
|
452 |
None if Club App exists for the specified program, or a subclass |
95c534d02e39
Added Club Admin model, logic, and view
Sverre Rabbelier <srabbelier@gmail.com>
parents:
796
diff
changeset
|
453 |
of django.http.HttpResponse which contains the alternate response |
95c534d02e39
Added Club Admin model, logic, and view
Sverre Rabbelier <srabbelier@gmail.com>
parents:
796
diff
changeset
|
454 |
should be returned by the calling view. |
95c534d02e39
Added Club Admin model, logic, and view
Sverre Rabbelier <srabbelier@gmail.com>
parents:
796
diff
changeset
|
455 |
""" |
95c534d02e39
Added Club Admin model, logic, and view
Sverre Rabbelier <srabbelier@gmail.com>
parents:
796
diff
changeset
|
456 |
|
972
43018f61b481
Remove the request and arg parameter from the checkAccess call
Sverre Rabbelier <srabbelier@gmail.com>
parents:
970
diff
changeset
|
457 |
def wrapper(kwargs): |
884
ded4850776c8
Changed checkIsClubAppAccepted into a more generic checkIsApplicationAccepted.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
882
diff
changeset
|
458 |
try: |
ded4850776c8
Changed checkIsClubAppAccepted into a more generic checkIsApplicationAccepted.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
882
diff
changeset
|
459 |
# if the current user is a developer we allow access |
972
43018f61b481
Remove the request and arg parameter from the checkAccess call
Sverre Rabbelier <srabbelier@gmail.com>
parents:
970
diff
changeset
|
460 |
checkIsDeveloper(kwargs) |
884
ded4850776c8
Changed checkIsClubAppAccepted into a more generic checkIsApplicationAccepted.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
882
diff
changeset
|
461 |
return |
ded4850776c8
Changed checkIsClubAppAccepted into a more generic checkIsApplicationAccepted.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
882
diff
changeset
|
462 |
except out_of_band.Error: |
ded4850776c8
Changed checkIsClubAppAccepted into a more generic checkIsApplicationAccepted.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
882
diff
changeset
|
463 |
pass |
814
25ffebd9fa8f
Implement the checkIsClubAppAccepted function
Sverre Rabbelier <srabbelier@gmail.com>
parents:
802
diff
changeset
|
464 |
|
972
43018f61b481
Remove the request and arg parameter from the checkAccess call
Sverre Rabbelier <srabbelier@gmail.com>
parents:
970
diff
changeset
|
465 |
checkAgreesToSiteToS(kwargs) |
814
25ffebd9fa8f
Implement the checkIsClubAppAccepted function
Sverre Rabbelier <srabbelier@gmail.com>
parents:
802
diff
changeset
|
466 |
|
887
b8c1a6bc913e
Take advantage of new "from ... import ... as ..." rules in the style guide.
Todd Larsen <tlarsen@google.com>
parents:
884
diff
changeset
|
467 |
user = user_logic.getForCurrentAccount() |
814
25ffebd9fa8f
Implement the checkIsClubAppAccepted function
Sverre Rabbelier <srabbelier@gmail.com>
parents:
802
diff
changeset
|
468 |
|
884
ded4850776c8
Changed checkIsClubAppAccepted into a more generic checkIsApplicationAccepted.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
882
diff
changeset
|
469 |
properties = { |
ded4850776c8
Changed checkIsClubAppAccepted into a more generic checkIsApplicationAccepted.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
882
diff
changeset
|
470 |
'applicant': user, |
892
c3cdb581ffd2
Replaced boolean properties in soc/models/group_app with status property.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
891
diff
changeset
|
471 |
'status': 'accepted' |
884
ded4850776c8
Changed checkIsClubAppAccepted into a more generic checkIsApplicationAccepted.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
882
diff
changeset
|
472 |
} |
814
25ffebd9fa8f
Implement the checkIsClubAppAccepted function
Sverre Rabbelier <srabbelier@gmail.com>
parents:
802
diff
changeset
|
473 |
|
884
ded4850776c8
Changed checkIsClubAppAccepted into a more generic checkIsApplicationAccepted.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
882
diff
changeset
|
474 |
application = app_logic.logic.getForFields(properties, unique=True) |
ded4850776c8
Changed checkIsClubAppAccepted into a more generic checkIsApplicationAccepted.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
882
diff
changeset
|
475 |
|
ded4850776c8
Changed checkIsClubAppAccepted into a more generic checkIsApplicationAccepted.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
882
diff
changeset
|
476 |
if application: |
ded4850776c8
Changed checkIsClubAppAccepted into a more generic checkIsApplicationAccepted.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
882
diff
changeset
|
477 |
return |
814
25ffebd9fa8f
Implement the checkIsClubAppAccepted function
Sverre Rabbelier <srabbelier@gmail.com>
parents:
802
diff
changeset
|
478 |
|
884
ded4850776c8
Changed checkIsClubAppAccepted into a more generic checkIsApplicationAccepted.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
882
diff
changeset
|
479 |
# TODO(srabbelier) Make this give a proper error message |
972
43018f61b481
Remove the request and arg parameter from the checkAccess call
Sverre Rabbelier <srabbelier@gmail.com>
parents:
970
diff
changeset
|
480 |
deny(kwargs) |
814
25ffebd9fa8f
Implement the checkIsClubAppAccepted function
Sverre Rabbelier <srabbelier@gmail.com>
parents:
802
diff
changeset
|
481 |
|
884
ded4850776c8
Changed checkIsClubAppAccepted into a more generic checkIsApplicationAccepted.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
882
diff
changeset
|
482 |
return wrapper |
814
25ffebd9fa8f
Implement the checkIsClubAppAccepted function
Sverre Rabbelier <srabbelier@gmail.com>
parents:
802
diff
changeset
|
483 |
|
802
95c534d02e39
Added Club Admin model, logic, and view
Sverre Rabbelier <srabbelier@gmail.com>
parents:
796
diff
changeset
|
484 |
|
972
43018f61b481
Remove the request and arg parameter from the checkAccess call
Sverre Rabbelier <srabbelier@gmail.com>
parents:
970
diff
changeset
|
485 |
def checkIsMyNotification(kwargs): |
958
b4309e3cb899
Fix some missing dots in access and club_admin modules.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
950
diff
changeset
|
486 |
"""Returns an alternate HTTP response if this request is for |
b4309e3cb899
Fix some missing dots in access and club_admin modules.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
950
diff
changeset
|
487 |
a Notification belonging to the current user. |
726 | 488 |
|
489 |
Args: |
|
972
43018f61b481
Remove the request and arg parameter from the checkAccess call
Sverre Rabbelier <srabbelier@gmail.com>
parents:
970
diff
changeset
|
490 |
kwargs: a dictionary with django's arguments |
726 | 491 |
|
492 |
Raises: |
|
493 |
AccessViolationResponse: if the required authorization is not met |
|
494 |
||
495 |
Returns: |
|
496 |
None if the current User is allowed to access this Notification. |
|
497 |
""" |
|
498 |
||
499 |
try: |
|
500 |
# if the current user is a developer we allow access |
|
972
43018f61b481
Remove the request and arg parameter from the checkAccess call
Sverre Rabbelier <srabbelier@gmail.com>
parents:
970
diff
changeset
|
501 |
checkIsDeveloper(kwargs) |
726 | 502 |
return |
503 |
except out_of_band.Error: |
|
504 |
pass |
|
505 |
||
972
43018f61b481
Remove the request and arg parameter from the checkAccess call
Sverre Rabbelier <srabbelier@gmail.com>
parents:
970
diff
changeset
|
506 |
checkAgreesToSiteToS(kwargs) |
729
7fe218e3d359
Make checkIsMyInvitation use Django to parse the URL
Sverre Rabbelier <srabbelier@gmail.com>
parents:
727
diff
changeset
|
507 |
|
7fe218e3d359
Make checkIsMyInvitation use Django to parse the URL
Sverre Rabbelier <srabbelier@gmail.com>
parents:
727
diff
changeset
|
508 |
properties = dicts.filter(kwargs, ['link_id', 'scope_path']) |
7fe218e3d359
Make checkIsMyInvitation use Django to parse the URL
Sverre Rabbelier <srabbelier@gmail.com>
parents:
727
diff
changeset
|
509 |
|
887
b8c1a6bc913e
Take advantage of new "from ... import ... as ..." rules in the style guide.
Todd Larsen <tlarsen@google.com>
parents:
884
diff
changeset
|
510 |
notification = notification_logic.getForFields(properties, unique=True) |
b8c1a6bc913e
Take advantage of new "from ... import ... as ..." rules in the style guide.
Todd Larsen <tlarsen@google.com>
parents:
884
diff
changeset
|
511 |
user = user_logic.getForCurrentAccount() |
729
7fe218e3d359
Make checkIsMyInvitation use Django to parse the URL
Sverre Rabbelier <srabbelier@gmail.com>
parents:
727
diff
changeset
|
512 |
|
7fe218e3d359
Make checkIsMyInvitation use Django to parse the URL
Sverre Rabbelier <srabbelier@gmail.com>
parents:
727
diff
changeset
|
513 |
# We need to check to see if the key's are equal since the User |
7fe218e3d359
Make checkIsMyInvitation use Django to parse the URL
Sverre Rabbelier <srabbelier@gmail.com>
parents:
727
diff
changeset
|
514 |
# objects are different and the default __eq__ method does not check |
7fe218e3d359
Make checkIsMyInvitation use Django to parse the URL
Sverre Rabbelier <srabbelier@gmail.com>
parents:
727
diff
changeset
|
515 |
# if the keys are equal (which is what we want). |
726 | 516 |
if user.key() == notification.scope.key(): |
517 |
return None |
|
729
7fe218e3d359
Make checkIsMyInvitation use Django to parse the URL
Sverre Rabbelier <srabbelier@gmail.com>
parents:
727
diff
changeset
|
518 |
|
7fe218e3d359
Make checkIsMyInvitation use Django to parse the URL
Sverre Rabbelier <srabbelier@gmail.com>
parents:
727
diff
changeset
|
519 |
# TODO(ljvderijk) Make this give a proper error message |
972
43018f61b481
Remove the request and arg parameter from the checkAccess call
Sverre Rabbelier <srabbelier@gmail.com>
parents:
970
diff
changeset
|
520 |
deny(kwargs) |
699
4e8eefe95748
Add and use a placeholder for checkIsDocumentPublic
Sverre Rabbelier <srabbelier@gmail.com>
parents:
639
diff
changeset
|
521 |
|
872
70e0b6d8ff73
Prepare access to receive args and kwargs as argument
Sverre Rabbelier <srabbelier@gmail.com>
parents:
814
diff
changeset
|
522 |
|
882
267e31f1a0b6
Added club_app model and logic.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
872
diff
changeset
|
523 |
def checkIsMyApplication(app_logic): |
958
b4309e3cb899
Fix some missing dots in access and club_admin modules.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
950
diff
changeset
|
524 |
"""Returns an alternate HTTP response if this request is for |
b4309e3cb899
Fix some missing dots in access and club_admin modules.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
950
diff
changeset
|
525 |
a Application belonging to the current user. |
791
30da180c4bca
Added the club_app view, logic and model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
746
diff
changeset
|
526 |
|
30da180c4bca
Added the club_app view, logic and model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
746
diff
changeset
|
527 |
Args: |
30da180c4bca
Added the club_app view, logic and model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
746
diff
changeset
|
528 |
request: a Django HTTP request |
30da180c4bca
Added the club_app view, logic and model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
746
diff
changeset
|
529 |
|
30da180c4bca
Added the club_app view, logic and model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
746
diff
changeset
|
530 |
Raises: |
30da180c4bca
Added the club_app view, logic and model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
746
diff
changeset
|
531 |
AccessViolationResponse: if the required authorization is not met |
30da180c4bca
Added the club_app view, logic and model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
746
diff
changeset
|
532 |
|
30da180c4bca
Added the club_app view, logic and model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
746
diff
changeset
|
533 |
Returns: |
796
126a1ef235ec
Fixed a typo in the comment in helper/access.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
791
diff
changeset
|
534 |
None if the current User is allowed to access this Application. |
791
30da180c4bca
Added the club_app view, logic and model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
746
diff
changeset
|
535 |
""" |
882
267e31f1a0b6
Added club_app model and logic.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
872
diff
changeset
|
536 |
|
972
43018f61b481
Remove the request and arg parameter from the checkAccess call
Sverre Rabbelier <srabbelier@gmail.com>
parents:
970
diff
changeset
|
537 |
def wrapper(kwargs): |
882
267e31f1a0b6
Added club_app model and logic.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
872
diff
changeset
|
538 |
try: |
267e31f1a0b6
Added club_app model and logic.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
872
diff
changeset
|
539 |
# if the current user is a developer we allow access |
972
43018f61b481
Remove the request and arg parameter from the checkAccess call
Sverre Rabbelier <srabbelier@gmail.com>
parents:
970
diff
changeset
|
540 |
checkIsDeveloper(kwargs) |
882
267e31f1a0b6
Added club_app model and logic.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
872
diff
changeset
|
541 |
return |
267e31f1a0b6
Added club_app model and logic.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
872
diff
changeset
|
542 |
except out_of_band.Error: |
267e31f1a0b6
Added club_app model and logic.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
872
diff
changeset
|
543 |
pass |
267e31f1a0b6
Added club_app model and logic.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
872
diff
changeset
|
544 |
|
972
43018f61b481
Remove the request and arg parameter from the checkAccess call
Sverre Rabbelier <srabbelier@gmail.com>
parents:
970
diff
changeset
|
545 |
checkAgreesToSiteToS(kwargs) |
791
30da180c4bca
Added the club_app view, logic and model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
746
diff
changeset
|
546 |
|
882
267e31f1a0b6
Added club_app model and logic.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
872
diff
changeset
|
547 |
properties = dicts.filter(kwargs, ['link_id']) |
267e31f1a0b6
Added club_app model and logic.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
872
diff
changeset
|
548 |
|
267e31f1a0b6
Added club_app model and logic.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
872
diff
changeset
|
549 |
application = app_logic.logic.getForFields(properties, unique=True) |
884
ded4850776c8
Changed checkIsClubAppAccepted into a more generic checkIsApplicationAccepted.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
882
diff
changeset
|
550 |
|
ded4850776c8
Changed checkIsClubAppAccepted into a more generic checkIsApplicationAccepted.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
882
diff
changeset
|
551 |
if not application: |
972
43018f61b481
Remove the request and arg parameter from the checkAccess call
Sverre Rabbelier <srabbelier@gmail.com>
parents:
970
diff
changeset
|
552 |
deny(kwargs) |
884
ded4850776c8
Changed checkIsClubAppAccepted into a more generic checkIsApplicationAccepted.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
882
diff
changeset
|
553 |
|
887
b8c1a6bc913e
Take advantage of new "from ... import ... as ..." rules in the style guide.
Todd Larsen <tlarsen@google.com>
parents:
884
diff
changeset
|
554 |
user = user_logic.getForCurrentAccount() |
791
30da180c4bca
Added the club_app view, logic and model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
746
diff
changeset
|
555 |
|
882
267e31f1a0b6
Added club_app model and logic.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
872
diff
changeset
|
556 |
# We need to check to see if the key's are equal since the User |
267e31f1a0b6
Added club_app model and logic.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
872
diff
changeset
|
557 |
# objects are different and the default __eq__ method does not check |
267e31f1a0b6
Added club_app model and logic.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
872
diff
changeset
|
558 |
# if the keys are equal (which is what we want). |
267e31f1a0b6
Added club_app model and logic.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
872
diff
changeset
|
559 |
if user.key() == application.applicant.key(): |
267e31f1a0b6
Added club_app model and logic.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
872
diff
changeset
|
560 |
return None |
267e31f1a0b6
Added club_app model and logic.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
872
diff
changeset
|
561 |
|
267e31f1a0b6
Added club_app model and logic.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
872
diff
changeset
|
562 |
# TODO(srabbelier) Make this give a proper error message |
972
43018f61b481
Remove the request and arg parameter from the checkAccess call
Sverre Rabbelier <srabbelier@gmail.com>
parents:
970
diff
changeset
|
563 |
deny(kwargs) |
791
30da180c4bca
Added the club_app view, logic and model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
746
diff
changeset
|
564 |
|
882
267e31f1a0b6
Added club_app model and logic.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
872
diff
changeset
|
565 |
return wrapper |
791
30da180c4bca
Added the club_app view, logic and model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
746
diff
changeset
|
566 |
|
948
bd956f419ad9
Add missing blank lines and remove unused checkIsInvited function from soc.views.helper.access module.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
943
diff
changeset
|
567 |
|
914
6ec8dd2a73b3
Added various access methods in preperation for the new request system.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
895
diff
changeset
|
568 |
def checkIsMyActiveRole(role_logic): |
6ec8dd2a73b3
Added various access methods in preperation for the new request system.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
895
diff
changeset
|
569 |
"""Returns an alternate HTTP response if there is no active role found for |
6ec8dd2a73b3
Added various access methods in preperation for the new request system.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
895
diff
changeset
|
570 |
the current user using the given role_logic. |
6ec8dd2a73b3
Added various access methods in preperation for the new request system.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
895
diff
changeset
|
571 |
|
6ec8dd2a73b3
Added various access methods in preperation for the new request system.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
895
diff
changeset
|
572 |
Raises: |
6ec8dd2a73b3
Added various access methods in preperation for the new request system.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
895
diff
changeset
|
573 |
AccessViolationResponse: if the required authorization is not met |
6ec8dd2a73b3
Added various access methods in preperation for the new request system.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
895
diff
changeset
|
574 |
|
6ec8dd2a73b3
Added various access methods in preperation for the new request system.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
895
diff
changeset
|
575 |
Returns: |
6ec8dd2a73b3
Added various access methods in preperation for the new request system.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
895
diff
changeset
|
576 |
None if the current User has no active role for the given role_logic. |
6ec8dd2a73b3
Added various access methods in preperation for the new request system.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
895
diff
changeset
|
577 |
""" |
6ec8dd2a73b3
Added various access methods in preperation for the new request system.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
895
diff
changeset
|
578 |
|
972
43018f61b481
Remove the request and arg parameter from the checkAccess call
Sverre Rabbelier <srabbelier@gmail.com>
parents:
970
diff
changeset
|
579 |
def wrapper(kwargs): |
914
6ec8dd2a73b3
Added various access methods in preperation for the new request system.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
895
diff
changeset
|
580 |
try: |
6ec8dd2a73b3
Added various access methods in preperation for the new request system.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
895
diff
changeset
|
581 |
# if the current user is a developer we allow access |
972
43018f61b481
Remove the request and arg parameter from the checkAccess call
Sverre Rabbelier <srabbelier@gmail.com>
parents:
970
diff
changeset
|
582 |
checkIsDeveloper(kwargs) |
914
6ec8dd2a73b3
Added various access methods in preperation for the new request system.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
895
diff
changeset
|
583 |
return |
6ec8dd2a73b3
Added various access methods in preperation for the new request system.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
895
diff
changeset
|
584 |
except out_of_band.Error: |
6ec8dd2a73b3
Added various access methods in preperation for the new request system.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
895
diff
changeset
|
585 |
pass |
6ec8dd2a73b3
Added various access methods in preperation for the new request system.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
895
diff
changeset
|
586 |
|
6ec8dd2a73b3
Added various access methods in preperation for the new request system.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
895
diff
changeset
|
587 |
user = user_logic.getForCurrentAccount() |
6ec8dd2a73b3
Added various access methods in preperation for the new request system.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
895
diff
changeset
|
588 |
|
6ec8dd2a73b3
Added various access methods in preperation for the new request system.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
895
diff
changeset
|
589 |
if not user or user.link_id != kwargs['link_id']: |
6ec8dd2a73b3
Added various access methods in preperation for the new request system.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
895
diff
changeset
|
590 |
# not my role |
972
43018f61b481
Remove the request and arg parameter from the checkAccess call
Sverre Rabbelier <srabbelier@gmail.com>
parents:
970
diff
changeset
|
591 |
deny(kwargs) |
914
6ec8dd2a73b3
Added various access methods in preperation for the new request system.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
895
diff
changeset
|
592 |
|
958
b4309e3cb899
Fix some missing dots in access and club_admin modules.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
950
diff
changeset
|
593 |
fields = {'link_id': kwargs['link_id'], |
b4309e3cb899
Fix some missing dots in access and club_admin modules.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
950
diff
changeset
|
594 |
'scope_path': kwargs['scope_path'] |
914
6ec8dd2a73b3
Added various access methods in preperation for the new request system.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
895
diff
changeset
|
595 |
} |
6ec8dd2a73b3
Added various access methods in preperation for the new request system.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
895
diff
changeset
|
596 |
|
6ec8dd2a73b3
Added various access methods in preperation for the new request system.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
895
diff
changeset
|
597 |
role_entity = role_logic.logic.getForFields(fields, unique=True) |
6ec8dd2a73b3
Added various access methods in preperation for the new request system.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
895
diff
changeset
|
598 |
|
6ec8dd2a73b3
Added various access methods in preperation for the new request system.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
895
diff
changeset
|
599 |
if not role_entity: |
6ec8dd2a73b3
Added various access methods in preperation for the new request system.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
895
diff
changeset
|
600 |
# no role found |
972
43018f61b481
Remove the request and arg parameter from the checkAccess call
Sverre Rabbelier <srabbelier@gmail.com>
parents:
970
diff
changeset
|
601 |
deny(kwargs) |
914
6ec8dd2a73b3
Added various access methods in preperation for the new request system.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
895
diff
changeset
|
602 |
|
6ec8dd2a73b3
Added various access methods in preperation for the new request system.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
895
diff
changeset
|
603 |
if role_entity.state == 'active': |
6ec8dd2a73b3
Added various access methods in preperation for the new request system.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
895
diff
changeset
|
604 |
# this role exist and is active |
6ec8dd2a73b3
Added various access methods in preperation for the new request system.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
895
diff
changeset
|
605 |
return |
6ec8dd2a73b3
Added various access methods in preperation for the new request system.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
895
diff
changeset
|
606 |
else: |
6ec8dd2a73b3
Added various access methods in preperation for the new request system.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
895
diff
changeset
|
607 |
# this role is not active |
972
43018f61b481
Remove the request and arg parameter from the checkAccess call
Sverre Rabbelier <srabbelier@gmail.com>
parents:
970
diff
changeset
|
608 |
deny(kwargs) |
914
6ec8dd2a73b3
Added various access methods in preperation for the new request system.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
895
diff
changeset
|
609 |
|
6ec8dd2a73b3
Added various access methods in preperation for the new request system.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
895
diff
changeset
|
610 |
return wrapper |
6ec8dd2a73b3
Added various access methods in preperation for the new request system.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
895
diff
changeset
|
611 |
|
791
30da180c4bca
Added the club_app view, logic and model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
746
diff
changeset
|
612 |
|
972
43018f61b481
Remove the request and arg parameter from the checkAccess call
Sverre Rabbelier <srabbelier@gmail.com>
parents:
970
diff
changeset
|
613 |
def checkHasPickGetArgs(kwargs): |
958
b4309e3cb899
Fix some missing dots in access and club_admin modules.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
950
diff
changeset
|
614 |
"""Raises an alternate HTTP response if the request misses get args. |
931
1131884c3c56
Add a simple access check for a picker
Sverre Rabbelier <srabbelier@gmail.com>
parents:
927
diff
changeset
|
615 |
|
1131884c3c56
Add a simple access check for a picker
Sverre Rabbelier <srabbelier@gmail.com>
parents:
927
diff
changeset
|
616 |
Args: |
972
43018f61b481
Remove the request and arg parameter from the checkAccess call
Sverre Rabbelier <srabbelier@gmail.com>
parents:
970
diff
changeset
|
617 |
kwargs: a dictionary with django's arguments |
931
1131884c3c56
Add a simple access check for a picker
Sverre Rabbelier <srabbelier@gmail.com>
parents:
927
diff
changeset
|
618 |
|
1131884c3c56
Add a simple access check for a picker
Sverre Rabbelier <srabbelier@gmail.com>
parents:
927
diff
changeset
|
619 |
Raises: |
1131884c3c56
Add a simple access check for a picker
Sverre Rabbelier <srabbelier@gmail.com>
parents:
927
diff
changeset
|
620 |
AccessViolationResponse: |
1131884c3c56
Add a simple access check for a picker
Sverre Rabbelier <srabbelier@gmail.com>
parents:
927
diff
changeset
|
621 |
* if continue is not in request.GET |
1131884c3c56
Add a simple access check for a picker
Sverre Rabbelier <srabbelier@gmail.com>
parents:
927
diff
changeset
|
622 |
* if field is not in request.GET |
1131884c3c56
Add a simple access check for a picker
Sverre Rabbelier <srabbelier@gmail.com>
parents:
927
diff
changeset
|
623 |
""" |
1131884c3c56
Add a simple access check for a picker
Sverre Rabbelier <srabbelier@gmail.com>
parents:
927
diff
changeset
|
624 |
|
972
43018f61b481
Remove the request and arg parameter from the checkAccess call
Sverre Rabbelier <srabbelier@gmail.com>
parents:
970
diff
changeset
|
625 |
get_args = kwargs.get('GET', {}) |
931
1131884c3c56
Add a simple access check for a picker
Sverre Rabbelier <srabbelier@gmail.com>
parents:
927
diff
changeset
|
626 |
|
1131884c3c56
Add a simple access check for a picker
Sverre Rabbelier <srabbelier@gmail.com>
parents:
927
diff
changeset
|
627 |
if 'continue' in get_args and 'field' in get_args: |
1131884c3c56
Add a simple access check for a picker
Sverre Rabbelier <srabbelier@gmail.com>
parents:
927
diff
changeset
|
628 |
return |
1131884c3c56
Add a simple access check for a picker
Sverre Rabbelier <srabbelier@gmail.com>
parents:
927
diff
changeset
|
629 |
|
1131884c3c56
Add a simple access check for a picker
Sverre Rabbelier <srabbelier@gmail.com>
parents:
927
diff
changeset
|
630 |
#TODO(SRabbelier) inform user that return_url and field are required |
972
43018f61b481
Remove the request and arg parameter from the checkAccess call
Sverre Rabbelier <srabbelier@gmail.com>
parents:
970
diff
changeset
|
631 |
deny(kwargs) |
931
1131884c3c56
Add a simple access check for a picker
Sverre Rabbelier <srabbelier@gmail.com>
parents:
927
diff
changeset
|
632 |
|
1131884c3c56
Add a simple access check for a picker
Sverre Rabbelier <srabbelier@gmail.com>
parents:
927
diff
changeset
|
633 |
|
972
43018f61b481
Remove the request and arg parameter from the checkAccess call
Sverre Rabbelier <srabbelier@gmail.com>
parents:
970
diff
changeset
|
634 |
def checkIsDocumentPublic(kwargs): |
714
3e2ce3d8057a
Add missing dots in docstrings, proper sorting of imports and small docstring typo fixes.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
713
diff
changeset
|
635 |
"""Checks whether a document is public. |
699
4e8eefe95748
Add and use a placeholder for checkIsDocumentPublic
Sverre Rabbelier <srabbelier@gmail.com>
parents:
639
diff
changeset
|
636 |
|
4e8eefe95748
Add and use a placeholder for checkIsDocumentPublic
Sverre Rabbelier <srabbelier@gmail.com>
parents:
639
diff
changeset
|
637 |
Args: |
972
43018f61b481
Remove the request and arg parameter from the checkAccess call
Sverre Rabbelier <srabbelier@gmail.com>
parents:
970
diff
changeset
|
638 |
kwargs: a dictionary with django's arguments |
699
4e8eefe95748
Add and use a placeholder for checkIsDocumentPublic
Sverre Rabbelier <srabbelier@gmail.com>
parents:
639
diff
changeset
|
639 |
""" |
4e8eefe95748
Add and use a placeholder for checkIsDocumentPublic
Sverre Rabbelier <srabbelier@gmail.com>
parents:
639
diff
changeset
|
640 |
|
714
3e2ce3d8057a
Add missing dots in docstrings, proper sorting of imports and small docstring typo fixes.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
713
diff
changeset
|
641 |
# TODO(srabbelier): A proper check needs to be done to see if the document |
699
4e8eefe95748
Add and use a placeholder for checkIsDocumentPublic
Sverre Rabbelier <srabbelier@gmail.com>
parents:
639
diff
changeset
|
642 |
# is public or not, probably involving analysing it's scope or such. |
972
43018f61b481
Remove the request and arg parameter from the checkAccess call
Sverre Rabbelier <srabbelier@gmail.com>
parents:
970
diff
changeset
|
643 |
allow(kwargs) |