Skip to content

Commit

Permalink
Merge branch 'qa' into feature/MUWM-5233
Browse files Browse the repository at this point in the history
  • Loading branch information
fanglinfang authored Sep 27, 2024
2 parents 340f7d2 + 4491413 commit b392460
Show file tree
Hide file tree
Showing 9 changed files with 57 additions and 17 deletions.
12 changes: 6 additions & 6 deletions myuw/test/util/test_cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,21 +54,21 @@ def test_get_cache_time(self):
self.assertEqual(cache.get_cache_expiration_time(
"sws", "/student/v5/section", status=404), 60 * 7)
self.assertEqual(cache.get_cache_expiration_time(
"sws", "/student/v5/section", status=503), 60 * 15)
"sws", "/student/v5/section", status=503), 60 * 7)

self.assertEqual(cache.get_cache_expiration_time(
"gws", "/group_sws/v3"), HALF_HOUR)
self.assertEqual(cache.get_cache_expiration_time(
"gws", "/group_sws/v3", status=404), 60 * 7)
self.assertEqual(cache.get_cache_expiration_time(
"gws", "/group_sws/v3", status=500), 60 * 15)
"gws", "/group_sws/v3", status=500), 60 * 7)

self.assertEqual(cache.get_cache_expiration_time(
"pws", "/identity/v2/person"), ONE_HOUR)
self.assertEqual(cache.get_cache_expiration_time(
"pws", "/identity/v2/person", status=404), 60 * 7)
self.assertEqual(cache.get_cache_expiration_time(
"pws", "/identity/v2/person", status=503), 60 * 15)
"pws", "/identity/v2/person", status=503), 60 * 7)

self.assertEqual(cache.get_cache_expiration_time(
"uwnetid", "/nws/v1/uwnetid"), FOUR_HOURS)
Expand All @@ -77,7 +77,7 @@ def test_get_cache_time(self):
self.assertEqual(cache.get_cache_expiration_time(
"uwnetid", "/nws/v1/uwnetid", status=409), 60 * 7)
self.assertEqual(cache.get_cache_expiration_time(
"uwnetid", "/nws/v1/uwnetid", status=500), 60 * 15)
"uwnetid", "/nws/v1/uwnetid", status=500), 60 * 7)

self.assertEqual(cache.get_cache_expiration_time(
"grad", "/services/students"), FOUR_HOURS)
Expand All @@ -99,12 +99,12 @@ def test_get_cache_time(self):
self.assertEqual(cache.get_cache_expiration_time(
"mailman", "/uw_list_manager/api/v1/list/", status=404), 60 * 7)
self.assertEqual(cache.get_cache_expiration_time(
"mailman", "/uw_list_manager/api/v1/list/", status=500), 60 * 15)
"mailman", "/uw_list_manager/api/v1/list/", status=500), 60 * 7)

self.assertEqual(cache.get_cache_expiration_time(
"uwidp", "/idp/profile/oidc/keyset", status=404), 60 * 7)
self.assertEqual(cache.get_cache_expiration_time(
"uwidp", "/idp/profile/oidc/keyset", status=500), 60 * 15)
"uwidp", "/idp/profile/oidc/keyset", status=500), 60 * 7)


class TestMyUWCache(TestCase):
Expand Down
13 changes: 13 additions & 0 deletions myuw/test/views/test_teaching.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,19 @@ def test_instrucor_access(self):
HTTP_USER_AGENT="Lynx/2.8.2rel.1 libwww-FM/2.14")
self.assertEqual(response.status_code, 200)

@skipIf(missing_url("myuw_teaching_page",
kwargs={}), "myuw urls not configured")
def test_current_quarter_access(self):
url = reverse("myuw_teaching_page", kwargs={})
self.set_user('bill')
response = self.client.get(
url,
HTTP_USER_AGENT="Lynx/2.8.2rel.1 libwww-FM/2.14")
self.assertEqual(response.status_code, 200)
self.assertEqual(response.context['display_term']["year"], 2013)
self.assertEqual(
response.context['display_term']["quarter"], 'spring')

@skipIf(missing_url("myuw_teaching_page",
kwargs={'year': '2013', 'quarter': 'summer'}),
"myuw urls not configured")
Expand Down
2 changes: 2 additions & 0 deletions myuw/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,8 @@
student_photo_list, name="myuw_photo_list"),
re_path(r'^teaching/(?P<year>2[0-9]{3}),(?P<quarter>[a-z]+)$',
teaching, name="myuw_teaching_page"),
# MUWM-5363
re_path(r'^teaching/current$', teaching, name="myuw_teaching_page"),
re_path(r'^teaching/?$', teaching, name="myuw_teaching_page"),
re_path(r'^notices/?', notices, name="myuw_notices_page"),
re_path(r'^thrive_messages/?', thrive_messages,
Expand Down
2 changes: 0 additions & 2 deletions myuw/util/cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ def get_cache_expiration_time(self, service, url, status=None):
return FIVE_SECONDS

if status and status != 200:
if status >= 500:
return FIFTEEN_MINS
return SEVEN_MINS

if "sws" == service:
Expand Down
5 changes: 3 additions & 2 deletions myuw/views/rest_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,9 @@ def get_proxy_url(self, request, service, url):
elif service == "canvas":
regid = get_regid(get_input_value(request.POST, "uwregid"))
url = (
f"api/v1/users/sis_user_id:{regid}/enrollments?" +
f"state[]=active&type[]=StudentEnrollment")
f"api/v1/users/sis_user_id:{regid}/enrollments?state[]=active"
+ f"&type[]=StudentEnrollment&page=first&per_page=500"
)
elif service == "grad":
params = self.format_params(request)
params['id'] = get_student_system_key(params['id'])
Expand Down
8 changes: 7 additions & 1 deletion myuw/views/teaching.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Copyright 2024 UW-IT, University of Washington
# SPDX-License-Identifier: Apache-2.0

from myuw.dao.term import get_current_quarter
from myuw.views.page import page
from myuw.util.page_view import page_view

Expand All @@ -9,7 +10,12 @@
def teaching(request,
year=None,
quarter=None):
context = get_context(year, quarter)
if year is None and quarter is None:
# MUWM-5363
term = get_current_quarter(request)
context = get_context(term.year, term.quarter)
else:
context = get_context(year, quarter)
return page(request, 'teaching.html', context=context)


Expand Down
16 changes: 13 additions & 3 deletions myuw_vue/components/home/summaries.vue
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
</span>
</a>
</div>
<div v-if="isHfsReady || isLibraryReady" class="col-md-10">
<div v-if="loadData && (isHfsReady || isLibraryReady)" class="col-md-10">
<div class="row float-md-end" style="padding: 0 10px;">
<a
v-if="hfs && hfs.student_husky_card"
Expand Down Expand Up @@ -162,6 +162,11 @@ export default {
computed: {
...mapState({
termData: (state) => state.termData,
alum: (state) => state.user.affiliations.alumni,
student: (state) => state.user.affiliations.student,
employee: (state) => state.user.affiliations.all_employee,
past_stud: (state) => state.user.affiliations.past_stud,
past_emp: (state) => state.user.affiliations.past_employee,
}),
...mapState('hfs', {
hfs: (state) => state.value,
Expand All @@ -177,10 +182,15 @@ export default {
isLibraryReady: 'isReady',
isLibraryErrored: 'isErrored',
}),
loadData() {
return (this.alum || this.student || this.past_stud || this.employee || this.past_emp);
},
},
mounted() {
this.fetchHfs();
this.fetchLibrary();
if (this.loadData) {
this.fetchHfs();
this.fetchLibrary();
}
},
methods: {
...mapActions('hfs', {
Expand Down
4 changes: 2 additions & 2 deletions myuw_vue/components/teaching/classlist/photo-list.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<h3 class="visually-hidden">
Grid of Student Photos
</h3>
<div class="sort-buttons myuw-text-md">
<!--div class="sort-buttons myuw-text-md">
<span class="py-1" style=""><strong>Sort by:</strong></span><button
v-for="field in fields"
:key="field.key"
Expand All @@ -16,7 +16,7 @@
>
{{ field.label }}
</button>
</div>
</div -->
<ol class="list-unstyled d-flex flex-wrap">
<li v-for="(reg, i) in sortedRegistrations"
:id="`student-photo-${reg.regid}`"
Expand Down
12 changes: 11 additions & 1 deletion myuw_vue/tests/summaries.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,17 @@ describe('Summaries', () => {
hfs,
library,
},
state: {},
state: {
user: {
affiliations: {
alumni: false,
student: false,
past_stud: false,
all_employee: false,
past_employee: false,
}
}
},
});
});

Expand Down

0 comments on commit b392460

Please sign in to comment.