Skip to content

Commit

Permalink
Merge pull request #3043 from uw-it-aca/qa
Browse files Browse the repository at this point in the history
Qa
  • Loading branch information
fanglinfang authored Dec 24, 2023
2 parents ea3c236 + dcb5104 commit 48fae26
Show file tree
Hide file tree
Showing 26 changed files with 642 additions and 105 deletions.
10 changes: 5 additions & 5 deletions docker/prod-values.yml
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ cronjob:
cpu: 25m
memory: 32Mi
- name: course-cleanup
schedule: "1 3 * 1,4,7,9 1"
schedule: "21 20 * * 5"
command: ["/scripts/management_command.sh"]
args: ["db_cleanup", "course"]
resources:
Expand All @@ -189,7 +189,7 @@ cronjob:
cpu: 25m
memory: 128Mi
- name: seenreg-cleanup
schedule: "1 3 * 1,4,7,9 2"
schedule: "1 23 * * 5"
command: ["/scripts/management_command.sh"]
args: ["db_cleanup", "seenreg"]
resources:
Expand All @@ -200,7 +200,7 @@ cronjob:
cpu: 25m
memory: 128Mi
- name: notice-cleanup
schedule: "1 3 * * 3"
schedule: "1 21 * * 5"
command: ["/scripts/management_command.sh"]
args: ["db_cleanup", "notice"]
resources:
Expand All @@ -211,7 +211,7 @@ cronjob:
cpu: 25m
memory: 512Mi
- name: linkvisit-cleanup
schedule: "1 3 * * 4"
schedule: "1 22 * * 5"
command: ["/scripts/management_command.sh"]
args: ["db_cleanup", "linkvisit"]
resources:
Expand All @@ -231,7 +231,7 @@ environmentVariables:
- name: BOOKSTORE_ENV
value: PROD
- name: BOOK_POOL_SIZE
value: "25"
value: "40"
- name: BOOK_TIMEOUT
value: "15"

Expand Down
15 changes: 14 additions & 1 deletion myuw/dao/textbook.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
encapsulates the interactions with the Bookstore web service.
"""

from uw_bookstore import Bookstore
from uw_bookstore.digital_material import IACoursesStatus as Bookstore
from myuw.dao.pws import get_regid_of_current_user

bookstore = Bookstore()

Expand All @@ -22,3 +23,15 @@ def get_order_url_by_schedule(schedule):
returns a link to the bookstore ordering page for a given schedule
"""
return bookstore.get_url_for_schedule(schedule)


def get_iacourse_status(request, term):
"""
MUWM-5272
returns a TermIACourse object if has data, otherwith return None
"""
terms_iacourses = bookstore.get_iacourse_status(
get_regid_of_current_user(request)
)
key = "{}{}".format(term.quarter, term.year)
return terms_iacourses.get(key)
8 changes: 3 additions & 5 deletions myuw/data/resource_link_import.csv
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ Campus Life,Campus Retail,all,,,http://www.bookstore.washington.edu/student_facu
Campus Life,Campus Safety,all,,,https://www.washington.edu/safety/,Campus Safety,https://www.uwb.edu/safety,Campus Safety Department,https://www.tacoma.uw.edu/uwt/fa/safety/,Campus Safety & Security,no
Campus Life,Campus Safety,all,http://www.washington.edu/safecampus/,SafeCampus,,,,,,,no
Campus Life,Campus Safety,all,,,https://www.ehs.washington.edu/,Environmental Health & Safety,https://www.uwb.edu/safety/ehs-emergency/environment-health-safety,Environmental Health & Safety,https://www.tacoma.uw.edu/fa/environmental-health-safety,Environmental Health & Safety,no
Campus Life,Campus Safety,all,https://cspc.admin.uw.edu/mychem,MyChem,,,,,,,no
Campus Life,Campus Safety,all,https://mychem.ehs.washington.edu/,MyChem,,,,,,,no
Campus Life,Campus Safety,all,,,https://www.washington.edu/uwem/,UW Emergency Management,https://www.uwb.edu/emergency,UW Bothell Emergency Page,https://www.tacoma.uw.edu/fa/safety/emergency-preparedness,UW Tacoma Emergency Response,no
Campus Life,Campus Safety,all,https://www.washington.edu/titleix/report/,Make a Title IX report,,,,,,,no
Campus Life,Getting Around Campus,all,,,http://www.washington.edu/maps/,Campus Map,https://www.uwb.edu/wp-content/uploads/2023/09/uw-bothell-campus-map.pdf,Campus Map,http://www.tacoma.uw.edu/campus-map/campus-map,Campus Map,no
Expand All @@ -78,7 +78,7 @@ Campus Life,Health & Wellness,all,https://wellbeing.uw.edu/,Husky Health & Well-
Campus Life,Health & Wellness,all,,,http://www.washington.edu/counseling/,Counseling Center,https://www.uwb.edu/student-affairs/counseling,Counseling Services,https://www.tacoma.uw.edu/uwt/caps,Counseling & Psychological Services,no
Campus Life,Health & Wellness,all,,,https://wellbeing.uw.edu/unit/hall-health/,Hall Health Center,https://www.uwb.edu/arc/hawrc,Health and Wellness Resource Center,https://www.tacoma.uw.edu/sh,Student Health Services (SHS),no
Campus Life,Health & Wellness,all,,,https://wellbeing.uw.edu/unit/livewell/,LiveWell Office,,,,,no
Campus Life,Health & Wellness,all,,,http://www.washington.edu/ima/,Recreational Sports Programs (IMA),http://www.uwb.edu/recwell,Recreation and Wellness,http://www.tacoma.uw.edu/uwy/,Recreation & Fitness,no
Campus Life,Health & Wellness,all,,,http://www.washington.edu/ima/,Recreational Sports Programs (IMA),https://www.uwb.edu/arc/,Activities and Recreation Center(ARC),http://www.tacoma.uw.edu/uwy/,Recreation & Fitness,no
Campus Life,Health & Wellness,all,https://www.washington.edu/wholeu/,Whole U (for staff and faculty),,,,,,,no
Campus Life,Housing & Dining,all,,,https://www.hfs.washington.edu/olco/Secure/AccountSummary.aspx,Husky Card Account,https://www.hfs.washington.edu/olco/Secure/AccountSummary.aspx,Husky Card Account,http://apps.tacoma.uw.edu/dawgdollars/,Tacoma Dawg Dollars Account,no
Campus Life,Housing & Dining,all,,,https://www.hfs.washington.edu/dining/,Campus Dining,http://www.uwb.edu/food,Campus Dining,https://www.tacoma.uw.edu/uwt/fa/facilities/food-services,Campus Dining,no
Expand All @@ -90,7 +90,6 @@ Campus Life,Rules and Regulations,all,http://www.washington.edu/students/reg/fer
Campus Life,Rules and Regulations,all,,,https://ap.washington.edu/ormp/,Office of Research Misconduct Proceedings,https://www.uwb.edu/student-affairs/studentconduct/student-guide,Student Guide to Academic Integrity,https://ap.washington.edu/ormp/,Office of Research Misconduct Proceedings,no
Campus Life,Rules and Regulations,all,,,http://www.washington.edu/cssc/student-conduct-overview/student-code-of-conduct/,Student Conduct Code,https://www.uwb.edu/student-affairs/studentconduct,Student Conduct and Responsibility,https://www.tacoma.uw.edu/student-conduct/student-code,Student Conduct Code,no
Campus Life,Support Services,all,https://www.washington.edu/circle/,Center for International Relations & Cultural Leadership Exchange (CIRCLE),,,,,,,no
Campus Life,Support Services,all,,,,,https://www.uwb.edu/cie,Center for International Studies,,,no
Campus Life,Support Services,all,http://www.fiuts.org/,Foundation for International Understanding Through Students (FIUTS),,,,,,,no
Campus Life,Support Services,all,https://grad.uw.edu/current-students/student-success/,Graduate School Student Success,,,,,,,no
Campus Life,Support Services,all,,,http://www.washington.edu/admin/dso/uw-resources.html,Disability Resources,https://www.uwb.edu/student-affairs/drs,Disability Resources for Students (DRS),http://www.tacoma.uw.edu/drsuwt,Disability Resources for Students,no
Expand Down Expand Up @@ -121,7 +120,7 @@ Events and Activities,Stay Connected,all,,,http://www.youtube.com/user/uwhuskies
Events and Activities,Stay Connected,all,,,https://www.instagram.com/uofwa/,UW Instagram,https://instagram.com/UW_BOTHELL,UW Bothell Instagram,https://www.instagram.com/uwtacoma,UW Tacoma Instagram,no
Events and Activities,Stay Connected,all,,,https://twitter.com/UW,UW Twitter,https://twitter.com/UWBothell,UW Bothell Twitter,https://twitter.com/uwtacoma,UW Tacoma Twitter,no
Events and Activities,Stay Connected,all,,,https://www.linkedin.com/company/university-of-washington,UW LinkedIn,https://www.linkedin.com/groups/University-Washington-Bothell-92858?home=&gid=92858,UW Bothell LinkedIn,https://www.linkedin.com/school/university-of-washington-tacoma/,UW Tacoma LinkedIn,no
Events and Activities,Student Clubs and Organizations,all,,,https://hub.washington.edu/sao/rso-directory/,Registered Student Organizations (RSO) Directory,http://www.bothell.washington.edu/sea/clubs/join,Club Directory,https://dawgden.tacoma.uw.edu/Organizations,UW Tacoma Clubs and Organizations,no
Events and Activities,Student Clubs and Organizations,all,,,https://hub.washington.edu/sao/rso-directory/,Registered Student Organizations (RSO) Directory,https://uwb.presence.io/organizations,Club Directory,https://dawgden.tacoma.uw.edu/Organizations,UW Tacoma Clubs and Organizations,no
Libraries,Library Resources,all,,,http://lib.washington.edu/,UW Libraries,http://library.uwb.edu/,UW Bothell Library,http://www.tacoma.uw.edu/library,UW Tacoma Library,no
Libraries,Library Resources,all,http://search.lib.uw.edu/account,Your Library Account,,,,,,,no
Libraries,Library Resources,all,http://guides.lib.uw.edu/az.php,Articles and Research Databases,,,,,,,no
Expand Down Expand Up @@ -165,7 +164,6 @@ Research,"Research Centers, Shared Facilities, and Equipment",all,https://escien
Research,Research Data and Publishing,all,https://www.lib.washington.edu/services/faculty,Getting Started with Library Research,,,,,,,no
Research,Research Data and Publishing,all,https://www.lib.washington.edu/dataservices/tools/services,Tools for Data-Related Research,,,,,,,no
Research,Research Data and Publishing,all,https://guides.lib.uw.edu/research/dmg,Research Data Services,,,,,,,no
Research,Research Data and Publishing,all,https://hsl.uw.edu/trail/,Translational Research and Information Lab (TRAIL),,,,,,,no
Research,Research Data and Publishing,all,,,https://www.lib.washington.edu/openscholarship,"Open Scholarship Commons: Tools, Services, Consultations",https://guides.lib.uw.edu/bothell/digitalscholarship,Digital Scholarship,https://guides.lib.uw.edu/tacdigitalscholarship,Digital Scholarship,no
Research,Research Data and Publishing,all,https://guides.lib.uw.edu/research/spoa,Scholarly Publishing and Open Access,,,,,,,no
Research,Technical Support,all,https://itconnect.uw.edu/help/,UW-IT Technical Support,,,,,,,no
Expand Down
18 changes: 13 additions & 5 deletions myuw/management/commands/db_cleanup.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from uw_sws import sws_now, SWS_TIMEZONE
from myuw.models import (
VisitedLinkNew, SeenRegistration, UserNotices, UserCourseDisplay)
from myuw.dao.term import get_term_by_date, get_term_before
from myuw.dao.term import get_term_by_date, get_term_before, get_term_after
from myuw.util.settings import get_cronjob_recipient, get_cronjob_sender
from myuw.logger.timer import Timer

Expand Down Expand Up @@ -65,11 +65,19 @@ def deletion(self, ids_to_delete, queryf):
["{}@uw.edu".format(get_cronjob_recipient())])
raise CommandError(msg)

def get_cur_term(self):
comparison_date = sws_now().date()
term = get_term_by_date(comparison_date)
# Match MyUW quarter switchS
if comparison_date > term.grade_submission_deadline.date():
return get_term_after(term)
return term

def course_display(self):
# clean up after one year
timer = Timer()
queryf = "DELETE FROM user_course_display_pref WHERE id IN ({})"
term = get_term_by_date(sws_now().date())
term = self.get_cur_term()
y = term.year - 1
q = term.quarter
qset = UserCourseDisplay.objects.filter(year=y, quarter=q)
Expand All @@ -88,7 +96,7 @@ def notice_read(self):
# clean up after 180 days
timer = Timer()
queryf = "DELETE FROM myuw_mobile_usernotices WHERE id IN ({})"
cut_off_dt = self.get_cut_off_date()
cut_off_dt = self.get_cut_off_date(90)
qset = UserNotices.objects.filter(first_viewed__lt=cut_off_dt)
if qset.exists():
ids_to_delete = qset.values_list('id', flat=True)
Expand All @@ -105,7 +113,7 @@ def registration_seen(self):
# clean up previous quarters'
timer = Timer()
queryf = "DELETE FROM myuw_mobile_seenregistration WHERE id IN ({})"
term = get_term_before(get_term_by_date(sws_now().date()))
term = get_term_before(self.get_cur_term())
qset = SeenRegistration.objects.filter(
year=term.year, quarter=term.quarter)
if qset.exists():
Expand All @@ -123,7 +131,7 @@ def link_visited(self):
# clean up after 180 days
timer = Timer()
queryf = "DELETE FROM myuw_visitedlinknew WHERE id IN ({})"
cut_off_dt = self.get_cut_off_date()
cut_off_dt = self.get_cut_off_date(90)
qset = VisitedLinkNew.objects.filter(visit_date__lt=cut_off_dt)
if qset.exists():
ids_to_delete = qset.values_list('id', flat=True)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
[
{
"Year": 2013,
"Quarter": "spring",
"IACourses": [
{
"SLN": 13833,
"BookstoreCourseID": 1000111,
"DigitalItems": [
{
"ISBN": "9781256396362",
"ItemInternalID": 500555,
"OptsOutStatus": false,
"Paid": true,
"Price": 99.00
}
]
},
{
"SLN": 18532,
"BookstoreCourseID": 1000133,
"DigitalItems": [
{
"ISBN": "9780878935970",
"ItemInternalID": 3000366,
"OptsOutStatus": true,
"Paid": false,
"Price": 96.59
}
]
},
{
"SLN": 13830,
"BookstoreCourseID": 1000157,
"DigitalItems": [
{
"ISBN": "9781256396362",
"ItemInternalID": 2000268,
"OptsOutStatus": false,
"Paid": false,
"Price": 24.26
}
]
}
],
"BalanceToPay": 219.85,
"PaymentDeadline": "2013-04-19",
"BookstoreDigitalMaterialLink": "https://www.ubookstore.com/materials?idset=500555,3000366,2000268",
"BookstoreCheckOutLink": "https://www.ubookstore.com/app/site/query/additemtocart.nl?n=3&buyid=multi&multi=500555,1;3000366,1;2000268,1;",
"LastUpdated": "2013-2-09T00:51:09.769370-08:00"
},
{
"Year": 2013,
"Quarter": "summer",
"IACourses": [
{
"SLN": 13833,
"BookstoreCourseID": 1000111,
"DigitalItems": [
{
"ISBN": "9781256396062",
"ItemInternalID": 500555,
"OptsOutStatus": false,
"Paid": true,
"Price": 99.00
}
]
}
],
"BalanceToPay": 99.00,
"PaymentDeadline": "2013-07-12",
"BookstoreDigitalMaterialLink": "https://www.ubookstore.com/materials?idset=500555",
"BookstoreCheckOutLink": "https://www.ubookstore.com/app/site/query/additemtocart.nl?n=3&buyid=multi&multi=500555,1;",
"LastUpdated": "2013-2-09T00:51:09.769370-08:00"
}
]
11 changes: 11 additions & 0 deletions myuw/templates/restclients/customform/book/iacourse.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<h1>University Bookstore Inclusive Access Course Materials</h1>
{% include "restclients/customform/_common/regid.html" %}

<h2>Regids:</h2>
<ul>
<li>javerage: 9136CCB8F66711D5BE060004AC494FFE</li>
<li>jbothell: FE36CCB8F66711D5BE060004AC494FCD</li>
<li>jinter: 9136CCB8F66711D5BE060004AC494F31</li>
<li>jnew: FE36CCB8F66711D5BE060004AC494F31</li>
<li>eight: 12345678901234567890123456789012</li>
</ul>
7 changes: 7 additions & 0 deletions myuw/templates/supporttools/custom_sidebar_links.html
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,13 @@ <h3>Web Services</h3>
</li>
{% endif %}

{% url 'myuw_rest_search' 'book' 'iacourse.html' as iacourse_url %}
{% if iacourse_url %}
<li>
<a href="{{ iacourse_url }}">IA Courses</a>
</li>
{% endif %}

{% url 'myuw_rest_search' 'upass' 'index.html' as upass_url %}
{% if upass_url %}
<li>
Expand Down
2 changes: 1 addition & 1 deletion myuw/test/api/test_academic_calendar.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def test_muwm_2489(self):

# test MUWM_4485,
follow_link = urlopen(data[0]["event_url"])
self.assertEquals(follow_link.reason, "OK")
self.assertEquals(follow_link.reason, "")

def test_current_events(self):
self.set_user('javerage')
Expand Down
67 changes: 64 additions & 3 deletions myuw/test/api/test_textbook.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
# SPDX-License-Identifier: Apache-2.0

import json
from myuw.views.api.textbook import get_payment_quarter
from myuw.test import get_request_with_date
from myuw.test.api import MyuwApiTest, require_url, fdao_bookstore_override
from myuw.test import get_request_with_user, get_request_with_date


VERBACOMPARE_URL_PREFIX = 'http://uw-seattle.verbacompare.com'
IMAGE_URL_PREFIX = 'www7.bookstore.washington.edu/MyUWImage.taf'
Expand All @@ -14,7 +14,7 @@
class TestApiBooks(MyuwApiTest):
'''Tests textbooks api'''

@require_url('myuw_home')
@require_url('myuw_book_api')
def test_javerage_books(self):
self.set_user('javerage')
response = self.get_response_by_reverse(
Expand Down Expand Up @@ -53,3 +53,64 @@ def test_no_sche_books(self):
'quarter': 'spring',
'summer_term': ''})
self.assertEquals(response.status_code, 200)

@require_url('myuw_iacourse_digital_material_api')
def test_digital_material_api(self):
self.set_user('javerage')
response = self.get_response_by_reverse(
'myuw_iacourse_digital_material')
self.assertEquals(response.status_code, 200)
data = json.loads(response.content)
self.assertEquals(data["quarter"], "spring")
self.assertEquals(data["year"], 2013)
self.assertEquals(data["balance"], 219.85)

response = self.get_response_by_reverse(
'myuw_iacourse_digital_material_api',
kwargs={'year': 2013,
'quarter': 'spring'})
self.assertEquals(response.status_code, 200)
data = json.loads(response.content)
self.assertEquals(data["quarter"], "spring")
self.assertEquals(data["year"], 2013)
self.assertEquals(data["balance"], 219.85)

response = self.get_response_by_reverse(
'myuw_iacourse_digital_material_api',
kwargs={'year': 2013,
'quarter': 'autumn'})
self.assertEquals(response.status_code, 404)

response = self.get_response_by_reverse(
'myuw_iacourse_digital_material_api',
kwargs={'year': 2013,
'quarter': 'winter'})
self.assertEquals(response.status_code, 404)

self.set_user('jbothell')
response = self.get_response_by_reverse(
'myuw_iacourse_digital_material_api',
kwargs={'year': 2013,
'quarter': 'spring'})
self.assertEquals(response.status_code, 404)

response = self.get_response_by_reverse(
'myuw_iacourse_digital_material')
self.assertEquals(response.status_code, 404)

def test_get_payment_quarter(self):
request = get_request_with_date('2013-06-18')
q = get_payment_quarter(request)
self.assertEquals(q.quarter, "spring")

request = get_request_with_date('2013-06-19')
q = get_payment_quarter(request)
self.assertEquals(q.quarter, "summer")

request = get_request_with_date('2013-09-19')
q = get_payment_quarter(request)
self.assertEquals(q.quarter, "autumn")

request = get_request_with_date('2013-12-27')
q = get_payment_quarter(request)
self.assertEquals(q.quarter, "winter")
Loading

0 comments on commit 48fae26

Please sign in to comment.