equal
deleted
inserted
replaced
32 |
32 |
33 from google.appengine.api import users |
33 from google.appengine.api import users |
34 |
34 |
35 from django.utils.translation import ugettext_lazy |
35 from django.utils.translation import ugettext_lazy |
36 |
36 |
|
37 from soc.logic import accounts |
37 from soc.logic import models |
38 from soc.logic import models |
38 from soc.logic.site import id_user |
|
39 from soc.views.simple import requestLogin |
39 from soc.views.simple import requestLogin |
40 |
40 |
41 import soc.views.out_of_band |
41 import soc.views.out_of_band |
42 |
42 |
43 |
43 |
88 |
88 |
89 Raises: |
89 Raises: |
90 AccessViolationResponse: If the required authorization is not met. |
90 AccessViolationResponse: If the required authorization is not met. |
91 |
91 |
92 Returns: |
92 Returns: |
93 None if User exists for id, or a subclass of |
93 None if User exists for a Google Account, or a subclass of |
94 django.http.HttpResponse which contains the alternate response |
94 django.http.HttpResponse which contains the alternate response |
95 should be returned by the calling view. |
95 should be returned by the calling view. |
96 """ |
96 """ |
97 |
97 |
98 checkIsLoggedIn(request) |
98 checkIsLoggedIn(request) |
99 |
99 |
100 id = users.get_current_user() |
100 user = models.user.logic.getForFields( |
101 user = models.user.logic.getForFields({'id': id}, unique=True) |
101 {'account': users.get_current_user()}, unique=True) |
102 |
102 |
103 if user: |
103 if user: |
104 return |
104 return |
105 |
105 |
106 login_response = requestLogin(request, None, DEF_LOGIN_TMPL, |
106 login_response = requestLogin(request, None, DEF_LOGIN_TMPL, |
117 |
117 |
118 Raises: |
118 Raises: |
119 AccessViolationResponse: If the required authorization is not met. |
119 AccessViolationResponse: If the required authorization is not met. |
120 |
120 |
121 Returns: |
121 Returns: |
122 None if id is logged in and logged-in user is a Developer, or a |
122 None if Google Account is logged in and logged-in user is a Developer, |
123 subclass of django.http.HttpResponse which contains the alternate |
123 or a subclass of django.http.HttpResponse which contains the alternate |
124 response should be returned by the calling view. |
124 response should be returned by the calling view. |
125 """ |
125 """ |
126 |
126 |
127 checkIsUser(request) |
127 checkIsUser(request) |
128 |
128 |
129 id = users.get_current_user() |
129 if accounts.isDeveloper(account=users.get_current_user()): |
130 |
|
131 if id_user.isIdDeveloper(id=id): |
|
132 return None |
130 return None |
133 |
131 |
134 login_message_fmt = DEF_DEV_LOGOUT_LOGIN_MSG_FMT % { |
132 login_message_fmt = DEF_DEV_LOGOUT_LOGIN_MSG_FMT % { |
135 'role' : 'a site developer ', |
133 'role' : 'a site developer ', |
136 } |
134 } |
157 should be returned by the calling view. |
155 should be returned by the calling view. |
158 """ |
156 """ |
159 |
157 |
160 checkIsUser(request) |
158 checkIsUser(request) |
161 |
159 |
162 id = users.get_current_user() |
160 # TODO(alturin): the soc.logic.host module does not seem to exist... |
163 host = soc.logic.host.getHostFromProgram(id, program) |
161 host = soc.logic.host.getHostFromProgram( |
|
162 users.get_current_user(), program) |
164 |
163 |
165 if host: |
164 if host: |
166 return |
165 return |
167 |
166 |
168 login_message_fmt = DEF_DEV_LOGOUT_LOGIN_MSG_FMT % { |
167 login_message_fmt = DEF_DEV_LOGOUT_LOGIN_MSG_FMT % { |