Skip to content

Commit a3fa220

Browse files
authored
Merge pull request #3172 from uw-it-aca/qa
Release 9.26
2 parents bc1d874 + 27b955a commit a3fa220

File tree

7 files changed

+41
-21
lines changed

7 files changed

+41
-21
lines changed

Dockerfile

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
ARG DJANGO_CONTAINER_VERSION=2.0.3
2-
FROM us-docker.pkg.dev/uwit-mci-axdd/containers/django-container:${DJANGO_CONTAINER_VERSION} as app-prewebpack-container
1+
ARG DJANGO_CONTAINER_VERSION=2.0.5
2+
FROM us-docker.pkg.dev/uwit-mci-axdd/containers/django-container:${DJANGO_CONTAINER_VERSION} AS app-prewebpack-container
33

44
USER root
55
RUN apt-get update && apt-get install -y postgresql-client libpq-dev
@@ -29,12 +29,12 @@ ARG VUE_DEVTOOLS
2929
ENV VUE_DEVTOOLS=$VUE_DEVTOOLS
3030
RUN npx webpack --mode=production
3131

32-
FROM app-prewebpack-container as app-container
32+
FROM app-prewebpack-container AS app-container
3333

3434
COPY --chown=acait:acait --from=node-bundler /app/myuw/static /app/myuw/static
3535
RUN /app/bin/python manage.py collectstatic --noinput
3636

37-
FROM us-docker.pkg.dev/uwit-mci-axdd/containers/django-test-container:${DJANGO_CONTAINER_VERSION} as app-test-container
37+
FROM us-docker.pkg.dev/uwit-mci-axdd/containers/django-test-container:${DJANGO_CONTAINER_VERSION} AS app-test-container
3838

3939
ENV NODE_PATH=/app/lib/node_modules
4040
COPY --from=app-container /app/ /app/

myuw/dao/notice.py

+8-6
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
import logging
1010
from django.db import IntegrityError
11+
from restclients_core.exceptions import DataFailureException
1112
from uw_sws.notice import get_notices_by_regid
1213
from myuw.models import UserNotices
1314
from myuw.dao.category_notice import get_category_notices
@@ -28,13 +29,14 @@ def _get_notices_by_regid(user_regid):
2829
returns SWS notices for a given regid with
2930
myuw specific categories
3031
"""
31-
32-
if user_regid is None:
33-
return None
34-
35-
notices = get_notices_by_regid(user_regid)
32+
try:
33+
notices = get_notices_by_regid(user_regid)
34+
except DataFailureException as ex:
35+
if ex.status == 404: # MUWM-5375
36+
return []
37+
raise
3638
if notices is None:
37-
return None
39+
return []
3840
return categorize_notices(notices)
3941

4042

myuw/test/dao/test_notice.py

+6-4
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,16 @@ def setUp(self):
1515
get_request()
1616

1717
def test_get_notice_by_regid(self):
18-
# no regid
19-
notices = _get_notices_by_regid(None)
20-
self.assertEqual(notices, None)
21-
2218
# bad regid
2319
notices = _get_notices_by_regid("99999678901234567890123456789012")
2420
self.assertEqual(len(notices), 0)
2521

22+
# MUWM-5375
23+
regid = "99999999999999999999999999999999"
24+
notices = _get_notices_by_regid(regid)
25+
self.assertIsNotNone(notices)
26+
self.assertEqual(len(notices), 0)
27+
2628
regid = "9136CCB8F66711D5BE060004AC494FFE"
2729
notices = _get_notices_by_regid(regid)
2830
self.assertIsNotNone(notices)

myuw/views/api/notices.py

-2
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44
import json
55
import logging
66
import traceback
7-
from datetime import datetime
8-
from restclients_core.exceptions import DataFailureException
97
from myuw.dao import is_action_disabled
108
from myuw.dao.notice import (
119
get_notices_for_current_user, mark_notices_read_for_current_user)

myuw_vue/components/home/notice/notices.vue

+9-5
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
<template>
2-
<uw-card v-if="!isReady || hasAnyNotices" :loaded="isReady" :errored="isErrored">
2+
<uw-card v-if="showCard" :loaded="isReady" :errored="isErrored">
33
<template #card-heading>
44
<h2 class="h4 mb-3 text-dark-beige myuw-font-encode-sans">Notices</h2>
55
</template>
6-
<template v-if="!isErrored" #card-body>
7-
<p v-if="notices.length == 0">You do not have any notices at this time.</p>
6+
<template v-if="isReady" #card-body>
7+
<p v-if="noDisplayableNotices">You do not have any notices at this time.</p>
88
<uw-notice-list v-else :notices="sortNotices(notices)" />
99
</template>
1010
<template v-else #card-body>
@@ -36,8 +36,8 @@ export default {
3636
...mapState('notices', {
3737
allNotices: (state) => state.value,
3838
}),
39-
hasAnyNotices() {
40-
return this.allNotices.length > 0;
39+
showCard() {
40+
return this.isFetching || this.isReady && this.allNotices;
4141
},
4242
notices() {
4343
return this.allNotices.filter(
@@ -48,7 +48,11 @@ export default {
4848
notice.location_tags.includes('notice_banner')
4949
);
5050
},
51+
noDisplayableNotices() {
52+
return this.notices && this.notices.length == 0;
53+
},
5154
...mapGetters('notices', {
55+
isFetching: 'isFetching',
5256
isReady: 'isReady',
5357
isErrored: 'isErrored',
5458
}),
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
[]

myuw_vue/tests/notices.test.js

+13
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import CollapsedItem from '../components/_common/collapsed-notice.vue';
1111

1212
import javgNotices from './mock_data/notice/javerage.json';
1313
import jnewNotices from './mock_data/notice/jnew.json';
14+
import noNotices from './mock_data/notice/none.json';
1415

1516
const localVue = createLocalVue(Vuex);
1617

@@ -161,9 +162,21 @@ describe('Notice Card', () => {
161162
axios.get.mockResolvedValue({ data: javgNotices, status: 200 });
162163
const wrapper = mount(NoticeCard, { store, localVue });
163164
await new Promise(setImmediate);
165+
expect(wrapper.vm.showCard).toBeTruthy;
164166
expect(wrapper.vm.notices.length).toBe(9);
167+
expect(wrapper.vm.noDisplayableNotices).toBe(false);
165168
expect(wrapper.findComponent(NoticeCard).exists()).toBe(true);
166169
expect(wrapper.findComponent(NoticeList).exists()).toBe(true);
167170
expect(wrapper.findComponent(CollapsedItem).exists()).toBe(true);
168171
});
172+
173+
it('Check display do not have any notices', async () => {
174+
axios.get.mockResolvedValue({ data: noNotices, status: 200 });
175+
const wrapper = mount(NoticeCard, { store, localVue });
176+
await new Promise(setImmediate);
177+
expect(wrapper.vm.showCard).toBeTruthy;
178+
expect(wrapper.vm.isErrored).toBe(false);
179+
expect(wrapper.vm.noDisplayableNotices).toBe(true);
180+
expect(wrapper.findComponent(NoticeCard).exists()).toBe(true);
181+
});
169182
});

0 commit comments

Comments
 (0)