14
14
is_pce_student , is_student_employee , is_employee , is_faculty ,\
15
15
is_seattle_student , is_bothell_student , is_tacoma_student ,\
16
16
is_staff_employee
17
+ from myuw .dao .instructor_schedule import is_instructor
17
18
from myuw .dao .uwnetid import is_clinician
18
19
from myuw .dao .enrollment import get_main_campus
19
20
from myuw .dao .exceptions import IndeterminateCampusException
@@ -44,6 +45,8 @@ def get_all_affiliations(request):
44
45
according to the SWS Enrollment.
45
46
["official_tacoma"]: True if the user is an UW Tacoma student
46
47
according to the SWS Enrollment.
48
+ ["official_pce"]: True if the user is an UW PCE student
49
+ according to the SWS Enrollment.
47
50
"""
48
51
49
52
if hasattr (request , 'myuw_user_affiliations' ):
@@ -60,11 +63,13 @@ def get_all_affiliations(request):
60
63
"undergrad" : is_undergrad_student (),
61
64
"student" : is_student (),
62
65
"pce" : is_pce_student (),
66
+ "staff_employee" : is_staff_employee (),
63
67
"stud_employee" : is_student_employee (),
64
68
"employee" : is_employee (),
65
69
"fyp" : is_fyp ,
66
70
"faculty" : is_faculty (),
67
71
"clinician" : is_clinician (),
72
+ "instructor" : is_instructor (request ),
68
73
"seattle" : is_seattle_student (),
69
74
"bothell" : is_bothell_student (),
70
75
"tacoma" : is_tacoma_student (),
@@ -105,7 +110,8 @@ def _get_campuses_by_schedule(schedule):
105
110
"""
106
111
campuses = {"seattle" : False ,
107
112
"bothell" : False ,
108
- "tacoma" : False }
113
+ "tacoma" : False ,
114
+ "pce" : False }
109
115
110
116
if schedule is not None and len (schedule .sections ) > 0 :
111
117
for section in schedule .sections :
@@ -115,6 +121,8 @@ def _get_campuses_by_schedule(schedule):
115
121
campuses ["bothell" ] = True
116
122
elif section .course_campus == "Tacoma" :
117
123
campuses ["tacoma" ] = True
124
+ elif section .course_campus == "PCE" :
125
+ campuses ["pce" ] = True
118
126
else :
119
127
pass
120
128
return campuses
@@ -123,14 +131,17 @@ def _get_campuses_by_schedule(schedule):
123
131
def _get_official_campuses (campuses ):
124
132
official_campuses = {'official_seattle' : False ,
125
133
'official_bothell' : False ,
126
- 'official_tacoma' : False }
134
+ 'official_tacoma' : False ,
135
+ 'official_pce' : False }
127
136
for campus in campuses :
128
137
if campus .lower () == "seattle" :
129
138
official_campuses ['official_seattle' ] = True
130
139
if campus .lower () == "tacoma" :
131
140
official_campuses ['official_tacoma' ] = True
132
141
if campus .lower () == "bothell" :
133
142
official_campuses ['official_bothell' ] = True
143
+ if campus .lower () == "pce" :
144
+ official_campuses ['official_pce' ] = True
134
145
return official_campuses
135
146
136
147
@@ -148,6 +159,8 @@ def get_base_campus(request):
148
159
campus = "bothell"
149
160
if affiliations ["official_tacoma" ]:
150
161
campus = "tacoma"
162
+ if affiliations ["official_pce" ]:
163
+ campus = "pce"
151
164
except KeyError :
152
165
try :
153
166
if affiliations ["seattle" ]:
@@ -189,6 +202,7 @@ def generated(request):
189
202
request_cached_is_pce_student = _build_cache_method ("pce_student" ,
190
203
is_pce_student )
191
204
205
+
192
206
request_cached_is_student_employee = _build_cache_method ("student_employee" ,
193
207
is_student_employee )
194
208
@@ -197,6 +211,10 @@ def generated(request):
197
211
is_employee )
198
212
199
213
214
+ request_cached_is_staff_employee = _build_cache_method ("staff_employee" ,
215
+ is_staff_employee )
216
+
217
+
200
218
request_cached_is_faculty = _build_cache_method ("faculty" ,
201
219
is_faculty )
202
220
@@ -217,16 +235,64 @@ def wrapped_is_clinician(request):
217
235
return is_clinician ()
218
236
219
237
238
+ def wrapped_is_instructor (request ):
239
+ return is_instructor (request )
240
+
241
+
220
242
def affiliation_prefetch ():
221
243
return [request_cached_is_grad_student ,
222
244
request_cached_is_undergrad ,
223
245
request_cached_is_student ,
224
246
request_cached_is_pce_student ,
225
247
request_cached_is_student_employee ,
248
+ request_cached_is_staff_employee ,
226
249
request_cached_is_employee ,
227
250
request_cached_is_faculty ,
228
251
wrapped_is_seattle ,
229
252
wrapped_is_tacoma ,
230
253
wrapped_is_bothell ,
231
254
wrapped_is_clinician ,
255
+ wrapped_is_instructor ,
232
256
]
257
+
258
+
259
+ def get_identity_log_str (request ):
260
+ """
261
+ Return "(Affiliations: <affiliations>, <campus codes>)"
262
+ """
263
+ res = "(Affiliations:"
264
+ no_affiliation_lengthmark = len (res )
265
+ affi = get_all_affiliations (request )
266
+ if affi ["grad" ]:
267
+ res += ' Grad'
268
+ if affi ["undergrad" ]:
269
+ res += ' Undergrad'
270
+ if affi ["pce" ]:
271
+ res += ' PCE-student'
272
+ if affi ["faculty" ]:
273
+ res += ' Faculty'
274
+ if affi ["staff_employee" ]:
275
+ res += ' Staff'
276
+ if affi ["instructor" ]:
277
+ res += ' Instructor'
278
+ if affi ["clinician" ]:
279
+ res += 'Clinician'
280
+ if affi ["employee" ]:
281
+ res += ' Employee'
282
+ if len (res ) == no_affiliation_lengthmark :
283
+ res += 'None'
284
+
285
+ res += ', Campuses:'
286
+ no_campus_lengthmark = len (res )
287
+ if affi ["seattle" ] or affi ["official_seattle" ]:
288
+ res += ' Seattle'
289
+ if affi ["bothell" ] or affi ["official_bothell" ]:
290
+ res += ' Bothell'
291
+ if affi ["tacoma" ] or affi ["official_tacoma" ]:
292
+ res += ' Tacoma'
293
+ if affi ["official_pce" ]:
294
+ res += ' PCE'
295
+ if len (res ) == no_campus_lengthmark :
296
+ res += 'None'
297
+ res += ') '
298
+ return res
0 commit comments