Skip to content

Commit 13fbbda

Browse files
authored
Merge pull request #814 from uw-it-aca/qa
Qa
2 parents fd09677 + 4b59f12 commit 13fbbda

File tree

276 files changed

+7432
-2051
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

276 files changed

+7432
-2051
lines changed

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -67,3 +67,6 @@ db.sqlite3
6767

6868
# Mac OS
6969
*.DS_Store
70+
71+
pip-selfcheck.json
72+
share/

.travis.yml

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
sudo: false
22
language: python
3+
dist: precise
34
services:
45
- memcached
56
- mysql
@@ -10,7 +11,7 @@ env:
1011
- DB=sqlite3
1112
- DB=mysql
1213
global:
13-
- TRAVIS_NODE_VERSION="4"
14+
- TRAVIS_NODE_VERSION="6"
1415
install:
1516
- pip install -r requirements.txt
1617
before_script:

myuw/dao/__init__.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
import os
22
from django.conf import settings
3-
from restclients.dao import SWS_DAO
3+
from uw_sws.dao import SWS_DAO
44
from userservice.user import UserService
55
from myuw.models import User
6+
from uw_pws import PWS
67

78

89
def get_netid_of_current_user():

myuw/dao/affiliation.py

+68-2
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
is_pce_student, is_student_employee, is_employee, is_faculty,\
1515
is_seattle_student, is_bothell_student, is_tacoma_student,\
1616
is_staff_employee
17+
from myuw.dao.instructor_schedule import is_instructor
1718
from myuw.dao.uwnetid import is_clinician
1819
from myuw.dao.enrollment import get_main_campus
1920
from myuw.dao.exceptions import IndeterminateCampusException
@@ -44,6 +45,8 @@ def get_all_affiliations(request):
4445
according to the SWS Enrollment.
4546
["official_tacoma"]: True if the user is an UW Tacoma student
4647
according to the SWS Enrollment.
48+
["official_pce"]: True if the user is an UW PCE student
49+
according to the SWS Enrollment.
4750
"""
4851

4952
if hasattr(request, 'myuw_user_affiliations'):
@@ -60,11 +63,13 @@ def get_all_affiliations(request):
6063
"undergrad": is_undergrad_student(),
6164
"student": is_student(),
6265
"pce": is_pce_student(),
66+
"staff_employee": is_staff_employee(),
6367
"stud_employee": is_student_employee(),
6468
"employee": is_employee(),
6569
"fyp": is_fyp,
6670
"faculty": is_faculty(),
6771
"clinician": is_clinician(),
72+
"instructor": is_instructor(request),
6873
"seattle": is_seattle_student(),
6974
"bothell": is_bothell_student(),
7075
"tacoma": is_tacoma_student(),
@@ -105,7 +110,8 @@ def _get_campuses_by_schedule(schedule):
105110
"""
106111
campuses = {"seattle": False,
107112
"bothell": False,
108-
"tacoma": False}
113+
"tacoma": False,
114+
"pce": False}
109115

110116
if schedule is not None and len(schedule.sections) > 0:
111117
for section in schedule.sections:
@@ -115,6 +121,8 @@ def _get_campuses_by_schedule(schedule):
115121
campuses["bothell"] = True
116122
elif section.course_campus == "Tacoma":
117123
campuses["tacoma"] = True
124+
elif section.course_campus == "PCE":
125+
campuses["pce"] = True
118126
else:
119127
pass
120128
return campuses
@@ -123,14 +131,17 @@ def _get_campuses_by_schedule(schedule):
123131
def _get_official_campuses(campuses):
124132
official_campuses = {'official_seattle': False,
125133
'official_bothell': False,
126-
'official_tacoma': False}
134+
'official_tacoma': False,
135+
'official_pce': False}
127136
for campus in campuses:
128137
if campus.lower() == "seattle":
129138
official_campuses['official_seattle'] = True
130139
if campus.lower() == "tacoma":
131140
official_campuses['official_tacoma'] = True
132141
if campus.lower() == "bothell":
133142
official_campuses['official_bothell'] = True
143+
if campus.lower() == "pce":
144+
official_campuses['official_pce'] = True
134145
return official_campuses
135146

136147

@@ -148,6 +159,8 @@ def get_base_campus(request):
148159
campus = "bothell"
149160
if affiliations["official_tacoma"]:
150161
campus = "tacoma"
162+
if affiliations["official_pce"]:
163+
campus = "pce"
151164
except KeyError:
152165
try:
153166
if affiliations["seattle"]:
@@ -189,6 +202,7 @@ def generated(request):
189202
request_cached_is_pce_student = _build_cache_method("pce_student",
190203
is_pce_student)
191204

205+
192206
request_cached_is_student_employee = _build_cache_method("student_employee",
193207
is_student_employee)
194208

@@ -197,6 +211,10 @@ def generated(request):
197211
is_employee)
198212

199213

214+
request_cached_is_staff_employee = _build_cache_method("staff_employee",
215+
is_staff_employee)
216+
217+
200218
request_cached_is_faculty = _build_cache_method("faculty",
201219
is_faculty)
202220

@@ -217,16 +235,64 @@ def wrapped_is_clinician(request):
217235
return is_clinician()
218236

219237

238+
def wrapped_is_instructor(request):
239+
return is_instructor(request)
240+
241+
220242
def affiliation_prefetch():
221243
return [request_cached_is_grad_student,
222244
request_cached_is_undergrad,
223245
request_cached_is_student,
224246
request_cached_is_pce_student,
225247
request_cached_is_student_employee,
248+
request_cached_is_staff_employee,
226249
request_cached_is_employee,
227250
request_cached_is_faculty,
228251
wrapped_is_seattle,
229252
wrapped_is_tacoma,
230253
wrapped_is_bothell,
231254
wrapped_is_clinician,
255+
wrapped_is_instructor,
232256
]
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

myuw/dao/calendar.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from django.conf import settings
66
from django.utils import timezone
77
from restclients_core.exceptions import DataFailureException
8-
from restclients.trumba import get_calendar_by_name
8+
from uw_trumba import get_calendar_by_name
99
from myuw.dao.term import get_comparison_date
1010
from myuw.dao.calendar_mapping import get_calendars_for_current_user
1111

myuw/dao/canvas.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import logging
2-
from restclients.canvas.enrollments import Enrollments
3-
from restclients.canvas.courses import Courses
2+
from uw_canvas.enrollments import Enrollments
3+
from uw_canvas.courses import Courses
44
from restclients_core.exceptions import DataFailureException
55
from myuw.dao.pws import get_regid_of_current_user
66
from myuw.dao.exceptions import CanvasNonSWSException

myuw/dao/category_links.py

+6-2
Original file line numberDiff line numberDiff line change
@@ -130,8 +130,12 @@ def _get_links_by_category_and_campus(search_category_id,
130130
continue
131131

132132
if link.campus_matched(campus) and\
133-
affiliations["undergrad"] and\
134-
(link.for_undergrad() or link.for_fyp()):
133+
affiliations["undergrad"] and link.for_undergrad():
134+
selected_links.append(link)
135+
continue
136+
137+
if link.campus_matched(campus) and\
138+
affiliations["fyp"] and link.for_fyp():
135139
selected_links.append(link)
136140
continue
137141

myuw/dao/class_website.py

+19-9
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,24 @@
55
import logging
66
from urlparse import urlparse
77
from BeautifulSoup import BeautifulSoup
8-
from restclients.dao_implementation.live import get_con_pool, get_live_url
9-
from restclients.dao_implementation.mock import get_mockdata_url
10-
from restclients.exceptions import DataFailureException
8+
from restclients_core.exceptions import DataFailureException
119
from myuw.dao import is_using_file_dao
10+
from restclients_core.dao import DAO
11+
from os.path import abspath, dirname
12+
import os
1213
import re
1314

1415
logger = logging.getLogger(__name__)
1516

1617

18+
class CLASS_WEBSITE_DAO(DAO):
19+
def service_name(self):
20+
return "www"
21+
22+
def service_mock_paths(self):
23+
return [abspath(os.path.join(dirname(__file__), "resources"))]
24+
25+
1726
def _fetch_url(method, url):
1827
try:
1928
p = urlparse(url)
@@ -22,13 +31,14 @@ def _fetch_url(method, url):
2231
return None
2332

2433
headers = {'ACCEPT': 'text/html'}
25-
if is_using_file_dao():
26-
response = get_mockdata_url(
27-
'www', 'file', "/%s%s" % (p.netloc, p.path), headers)
34+
dao = CLASS_WEBSITE_DAO()
35+
36+
if dao.get_implementation().is_live():
37+
url = "%s://%s" % (p.scheme, p.netloc)
2838
else:
29-
pool = get_con_pool("%s://%s" % (p.scheme, p.netloc), socket_timeout=2)
30-
response = get_live_url(
31-
pool, method, p.hostname, url, headers)
39+
url = "/%s%s" % (p.netloc, p.path)
40+
41+
response = dao.getURL(url, headers)
3242

3343
if response.status != 200:
3444
raise DataFailureException(url, response.status, response.data)

myuw/dao/enrollment.py

+13-7
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@
1111
from myuw.dao import is_using_file_dao
1212
from myuw.dao.pws import get_regid_of_current_user
1313
from myuw.dao.term import (get_current_quarter,
14-
get_prev_num_terms,
14+
get_current_and_next_quarters,
15+
get_previous_number_quarters,
1516
get_comparison_date)
1617
from restclients_core.exceptions import DataFailureException
1718
from myuw.dao.exceptions import IndeterminateCampusException
@@ -73,22 +74,27 @@ def get_prev_enrollments_with_open_sections(request, num_of_prev_terms):
7374
:return: the dictionary of {Term: Enrollment} of the given
7475
number of previous terms with unfinished sections
7576
"""
76-
terms = get_prev_num_terms(request, num_of_prev_terms)
77+
terms = get_previous_number_quarters(request, num_of_prev_terms)
7778
result_dict = get_enrollments_of_terms(terms)
7879
return remove_finished(request, result_dict)
7980

8081

8182
def get_main_campus(request):
8283
campuses = []
8384
try:
84-
enrollment = get_current_quarter_enrollment(request)
85-
for major in enrollment.majors:
86-
campuses.append(major.campus)
85+
result_dict = get_enrollments_of_terms(
86+
get_current_and_next_quarters(request, 2))
87+
88+
for term in result_dict.keys():
89+
enrollment = result_dict.get(term)
90+
for major in enrollment.majors:
91+
if major.campus and major.campus not in campuses:
92+
campuses.append(major.campus)
8793
except DataFailureException as ex:
88-
logger.error("get_current_quarter_enrollment: %s" % ex)
94+
logger.error("get_main_campus: %s" % ex)
8995
raise IndeterminateCampusException()
9096
except Exception as ex:
91-
logger.error("get_current_quarter_enrollment: %s" % ex)
97+
logger.error("get_main_campus: %s" % ex)
9298
pass
9399

94100
return campuses

myuw/dao/grad.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55

66
import logging
77
from datetime import date, datetime, timedelta
8-
from restclients.grad.degree import get_degree_by_regid
9-
from restclients.grad.committee import get_committee_by_regid
10-
from restclients.grad.leave import get_leave_by_regid
11-
from restclients.grad.petition import get_petition_by_regid
8+
from uw_grad.degree import get_degree_by_regid
9+
from uw_grad.committee import get_committee_by_regid
10+
from uw_grad.leave import get_leave_by_regid
11+
from uw_grad.petition import get_petition_by_regid
1212
from myuw.logger.logback import log_exception
1313
from myuw.dao.pws import get_regid_of_current_user
1414
from myuw.dao.gws import is_grad_student

myuw/dao/hfs.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
def get_account_balances_by_uwnetid(uwnetid):
1717
"""
18-
returns restclients.models.hfs.HfsAccouts
18+
returns uw_hfs.models.HfsAccouts
1919
for the given uwnetid
2020
"""
2121
if uwnetid is None:

myuw/dao/iasystem.py

+15-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
from django.utils import timezone
99
from uw_pws import PWS
1010
from restclients_core.exceptions import DataFailureException
11-
from restclients.iasystem import evaluation
11+
from uw_iasystem import evaluation
1212
from myuw.logger.logback import log_exception
1313
from myuw.dao.student_profile import get_profile_of_current_user
1414
from myuw.dao.term import get_comparison_datetime, is_b_term,\
@@ -35,6 +35,17 @@ def _get_evaluations_by_section_and_student(section, student_number):
3535
**search_params)
3636

3737

38+
def get_evaluation_by_section_and_instructor(section, instructor_id):
39+
search_params = {'year': section.term.year,
40+
'term_name': section.term.quarter.capitalize(),
41+
'curriculum_abbreviation': section.curriculum_abbr,
42+
'course_number': section.course_number,
43+
'section_id': section.section_id,
44+
'instructor_id': instructor_id}
45+
return evaluation.search_evaluations(section.course_campus.lower(),
46+
**search_params)
47+
48+
3849
def summer_term_overlaped(request, given_section):
3950
"""
4051
@return true if:
@@ -102,6 +113,9 @@ def json_for_evaluation(request, evaluations, section):
102113
json_data = []
103114
for evaluation in evaluations:
104115

116+
if not evaluation.is_online():
117+
continue
118+
105119
if summer_term_overlaped(request, section):
106120

107121
logger.debug(

0 commit comments

Comments
 (0)