|
2 | 2 | This module provides affiliations of the current user
|
3 | 3 | """
|
4 | 4 |
|
5 |
| -import os |
6 |
| -import json |
7 | 5 | import logging
|
8 | 6 | import traceback
|
9 | 7 | from django.conf import settings
|
10 | 8 | from myuw.logger.logback import log_info, log_exception
|
| 9 | +from myuw.dao import is_fyp_thrive_viewer, get_netid_of_current_user |
11 | 10 | from myuw.dao.schedule import get_current_quarter_schedule
|
12 |
| -from myuw.dao.pws import get_netid_of_current_user |
13 | 11 | from myuw.dao.gws import is_grad_student, is_student,\
|
14 | 12 | is_current_graduate_student, is_undergrad_student,\
|
15 | 13 | is_pce_student, is_student_employee, is_employee, is_faculty,\
|
16 | 14 | is_seattle_student, is_bothell_student, is_tacoma_student,\
|
17 | 15 | is_staff_employee
|
18 | 16 | from myuw.dao.enrollment import get_main_campus
|
19 |
| -from myuw.models import UserMigrationPreference |
20 | 17 |
|
21 | 18 |
|
22 |
| -THRIVE = "thrive" |
23 |
| -OPTIN = "optin" |
24 | 19 | logger = logging.getLogger(__name__)
|
25 | 20 |
|
26 | 21 |
|
@@ -83,6 +78,10 @@ def get_all_affiliations(request):
|
83 | 78 | return data
|
84 | 79 |
|
85 | 80 |
|
| 81 | +def is_thrive_viewer(): |
| 82 | + return is_fyp_thrive_viewer(get_netid_of_current_user()) |
| 83 | + |
| 84 | + |
86 | 85 | def _get_campuses_by_schedule(schedule):
|
87 | 86 | """
|
88 | 87 | Returns a dictionary indicating the campuses that the student
|
@@ -164,68 +163,3 @@ def get_base_campus(request):
|
164 | 163 | campus = ""
|
165 | 164 | pass
|
166 | 165 | return campus
|
167 |
| - |
168 |
| - |
169 |
| -def is_oldmyuw_user(): |
170 |
| - if has_legacy_preference(): |
171 |
| - return True |
172 |
| - if is_optin_user(): |
173 |
| - return False |
174 |
| - if is_staff_employee(): |
175 |
| - return True |
176 |
| - if is_faculty(): |
177 |
| - return True |
178 |
| - if is_current_graduate_student(): |
179 |
| - return True |
180 |
| - if is_undergrad_student(): |
181 |
| - return False |
182 |
| - return True |
183 |
| - |
184 |
| - |
185 |
| -def has_legacy_preference(): |
186 |
| - username = get_netid_of_current_user() |
187 |
| - |
188 |
| - try: |
189 |
| - saved = UserMigrationPreference.objects.get(username=username) |
190 |
| - if saved.use_legacy_site: |
191 |
| - return True |
192 |
| - except UserMigrationPreference.DoesNotExist: |
193 |
| - return False |
194 |
| - return False |
195 |
| - |
196 |
| - |
197 |
| -def is_optin_user(): |
198 |
| - return _is_user_in_list( |
199 |
| - get_netid_of_current_user(), OPTIN) |
200 |
| - |
201 |
| - |
202 |
| -def is_thrive_viewer(): |
203 |
| - return _is_user_in_list( |
204 |
| - get_netid_of_current_user(), THRIVE) |
205 |
| - |
206 |
| - |
207 |
| -def _is_user_in_list(username, user_type): |
208 |
| - if THRIVE == user_type: |
209 |
| - file_path = getattr(settings, "MYUW_MANDATORY_SWITCH_PATH", None) |
210 |
| - if not file_path: |
211 |
| - current_dir = os.path.dirname(os.path.realpath(__file__)) |
212 |
| - |
213 |
| - file_path = os.path.abspath(os.path.join(current_dir, |
214 |
| - "..", "data", |
215 |
| - "thrive-viewer-list.txt")) |
216 |
| - |
217 |
| - else: |
218 |
| - file_path = getattr(settings, "MYUW_OPTIN_SWITCH_PATH", None) |
219 |
| - if not file_path: |
220 |
| - current_dir = os.path.dirname(os.path.realpath(__file__)) |
221 |
| - |
222 |
| - file_path = os.path.abspath(os.path.join(current_dir, |
223 |
| - "..", "data", |
224 |
| - "optin-list.txt")) |
225 |
| - |
226 |
| - with open(file_path) as data_source: |
227 |
| - for line in data_source: |
228 |
| - if line.rstrip() == username: |
229 |
| - return True |
230 |
| - |
231 |
| - return False |
0 commit comments