From 18d476b3c9529f2f1479c95180b2b125204bb92f Mon Sep 17 00:00:00 2001 From: Fang Lin Date: Tue, 19 Nov 2024 14:53:44 -0800 Subject: [PATCH 01/11] convert sws notice 404 to empty list --- .github/workflows/cicd.yml | 8 ++++---- myuw/views/api/notices.py | 4 +++- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/.github/workflows/cicd.yml b/.github/workflows/cicd.yml index 1ed3128df..7a4008d6b 100644 --- a/.github/workflows/cicd.yml +++ b/.github/workflows/cicd.yml @@ -43,9 +43,9 @@ env: # defined in the "deploy" job on: push: - branches: [main, master, qa, develop, vue/dev] + branches: [main, master, qa, develop, f/notice404] pull_request: - branches: [main, master, qa, develop, vue/dev] + branches: [main, master, qa, develop, f/notice404] types: [opened, reopened, synchronize] release: branches: [main, master] @@ -304,7 +304,7 @@ jobs: app_instance: dev - name: Deploy Vue Branch - if: needs.context.outputs.git_repo_branch == 'vue/dev' + if: needs.context.outputs.git_repo_branch == 'f/notice404' uses: uw-it-aca/actions/cicd-deploy@main with: release_name: ${{ env.RELEASE_NAME }} @@ -322,7 +322,7 @@ jobs: if: github.event_name == 'push' && (endsWith(github.ref, '/main') || endsWith(github.ref, '/master') || endsWith(github.ref, '/qa') || endsWith(github.ref, '/develop') || - endsWith(github.ref, '/vue/dev')) + endsWith(github.ref, '/f/notice404')) needs: [context, build, deploy] diff --git a/myuw/views/api/notices.py b/myuw/views/api/notices.py index 325946532..ee2d078b5 100644 --- a/myuw/views/api/notices.py +++ b/myuw/views/api/notices.py @@ -36,7 +36,9 @@ def get(self, request, *args, **kwargs): log_api_call(timer, request, "Get Notices") return self.json_response(notice_json) - except Exception: + except Exception as ex: + if isinstance(ex, DataFailureException) and ex.status == 404: + return [] return handle_exception(logger, timer, traceback) def put(self, request, *args, **kwargs): From 663f0982b7c98d325dc003ddf82e4da5a346832e Mon Sep 17 00:00:00 2001 From: Fang Lin Date: Tue, 19 Nov 2024 16:03:08 -0800 Subject: [PATCH 02/11] Resolve MUWM-5375 --- myuw/views/api/notices.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/myuw/views/api/notices.py b/myuw/views/api/notices.py index ee2d078b5..69d6c67ef 100644 --- a/myuw/views/api/notices.py +++ b/myuw/views/api/notices.py @@ -38,7 +38,7 @@ def get(self, request, *args, **kwargs): return self.json_response(notice_json) except Exception as ex: if isinstance(ex, DataFailureException) and ex.status == 404: - return [] + return self.json_response([]) # MUWM-5375 return handle_exception(logger, timer, traceback) def put(self, request, *args, **kwargs): From cb9b7759e5cf11011dede194c27994e418f9acf1 Mon Sep 17 00:00:00 2001 From: Fang Lin Date: Tue, 19 Nov 2024 16:11:31 -0800 Subject: [PATCH 03/11] Resolve MUWM-5375 --- myuw/dao/notice.py | 13 ++++++++----- myuw/views/api/notices.py | 6 +----- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/myuw/dao/notice.py b/myuw/dao/notice.py index 870a57071..7166ab6f2 100644 --- a/myuw/dao/notice.py +++ b/myuw/dao/notice.py @@ -8,6 +8,7 @@ import logging from django.db import IntegrityError +from restclients_core.exceptions import DataFailureException from uw_sws.notice import get_notices_by_regid from myuw.models import UserNotices from myuw.dao.category_notice import get_category_notices @@ -29,12 +30,14 @@ def _get_notices_by_regid(user_regid): myuw specific categories """ - if user_regid is None: - return None - - notices = get_notices_by_regid(user_regid) + try: + notices = get_notices_by_regid(user_regid) + except DataFailureException as ex: + if ex.status == 404: # MUWM-5375 + return [] + raise if notices is None: - return None + return [] return categorize_notices(notices) diff --git a/myuw/views/api/notices.py b/myuw/views/api/notices.py index 69d6c67ef..3e884e135 100644 --- a/myuw/views/api/notices.py +++ b/myuw/views/api/notices.py @@ -4,8 +4,6 @@ import json import logging import traceback -from datetime import datetime -from restclients_core.exceptions import DataFailureException from myuw.dao import is_action_disabled from myuw.dao.notice import ( get_notices_for_current_user, mark_notices_read_for_current_user) @@ -36,9 +34,7 @@ def get(self, request, *args, **kwargs): log_api_call(timer, request, "Get Notices") return self.json_response(notice_json) - except Exception as ex: - if isinstance(ex, DataFailureException) and ex.status == 404: - return self.json_response([]) # MUWM-5375 + except Exception: return handle_exception(logger, timer, traceback) def put(self, request, *args, **kwargs): From ebd099f8f18496f773c42b343cafa8e4cc8b901a Mon Sep 17 00:00:00 2001 From: Fang Lin Date: Fri, 22 Nov 2024 12:23:33 -0800 Subject: [PATCH 04/11] MUWM-5375: add test --- Dockerfile | 2 +- myuw/dao/notice.py | 1 - myuw/test/dao/test_notice.py | 10 ++++++---- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/Dockerfile b/Dockerfile index d5fa96e3c..524d0fbf8 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -ARG DJANGO_CONTAINER_VERSION=2.0.3 +ARG DJANGO_CONTAINER_VERSION=2.0.5 FROM us-docker.pkg.dev/uwit-mci-axdd/containers/django-container:${DJANGO_CONTAINER_VERSION} as app-prewebpack-container USER root diff --git a/myuw/dao/notice.py b/myuw/dao/notice.py index 7166ab6f2..89e1f3727 100644 --- a/myuw/dao/notice.py +++ b/myuw/dao/notice.py @@ -29,7 +29,6 @@ def _get_notices_by_regid(user_regid): returns SWS notices for a given regid with myuw specific categories """ - try: notices = get_notices_by_regid(user_regid) except DataFailureException as ex: diff --git a/myuw/test/dao/test_notice.py b/myuw/test/dao/test_notice.py index 12ebcc8a7..7b2d279cf 100644 --- a/myuw/test/dao/test_notice.py +++ b/myuw/test/dao/test_notice.py @@ -15,14 +15,16 @@ def setUp(self): get_request() def test_get_notice_by_regid(self): - # no regid - notices = _get_notices_by_regid(None) - self.assertEqual(notices, None) - # bad regid notices = _get_notices_by_regid("99999678901234567890123456789012") self.assertEqual(len(notices), 0) + # MUWM-5375 + regid = "99999999999999999999999999999999" + notices = _get_notices_by_regid(regid) + self.assertIsNotNone(notices) + self.assertEqual(len(notices), 0) + regid = "9136CCB8F66711D5BE060004AC494FFE" notices = _get_notices_by_regid(regid) self.assertIsNotNone(notices) From 39c6054d0c3e89bacf968f57c660eea47eea589e Mon Sep 17 00:00:00 2001 From: Fang Lin Date: Fri, 22 Nov 2024 12:45:19 -0800 Subject: [PATCH 05/11] reset vue.my --- .github/workflows/cicd.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/cicd.yml b/.github/workflows/cicd.yml index 7a4008d6b..1ed3128df 100644 --- a/.github/workflows/cicd.yml +++ b/.github/workflows/cicd.yml @@ -43,9 +43,9 @@ env: # defined in the "deploy" job on: push: - branches: [main, master, qa, develop, f/notice404] + branches: [main, master, qa, develop, vue/dev] pull_request: - branches: [main, master, qa, develop, f/notice404] + branches: [main, master, qa, develop, vue/dev] types: [opened, reopened, synchronize] release: branches: [main, master] @@ -304,7 +304,7 @@ jobs: app_instance: dev - name: Deploy Vue Branch - if: needs.context.outputs.git_repo_branch == 'f/notice404' + if: needs.context.outputs.git_repo_branch == 'vue/dev' uses: uw-it-aca/actions/cicd-deploy@main with: release_name: ${{ env.RELEASE_NAME }} @@ -322,7 +322,7 @@ jobs: if: github.event_name == 'push' && (endsWith(github.ref, '/main') || endsWith(github.ref, '/master') || endsWith(github.ref, '/qa') || endsWith(github.ref, '/develop') || - endsWith(github.ref, '/f/notice404')) + endsWith(github.ref, '/vue/dev')) needs: [context, build, deploy] From 3cb4213949dec314aa58416a859bd5399edbcfe6 Mon Sep 17 00:00:00 2001 From: Fang Lin Date: Sun, 24 Nov 2024 19:37:18 -0800 Subject: [PATCH 06/11] To display do not have any notices --- myuw_vue/components/home/notice/notices.vue | 7 +++++-- myuw_vue/tests/mock_data/notice/none.json | 1 + myuw_vue/tests/notices.test.js | 11 +++++++++++ 3 files changed, 17 insertions(+), 2 deletions(-) create mode 100644 myuw_vue/tests/mock_data/notice/none.json diff --git a/myuw_vue/components/home/notice/notices.vue b/myuw_vue/components/home/notice/notices.vue index 8de759a38..435ddcc64 100644 --- a/myuw_vue/components/home/notice/notices.vue +++ b/myuw_vue/components/home/notice/notices.vue @@ -3,8 +3,8 @@ -