Skip to content

Commit

Permalink
Merge pull request #34 from layuplist/develop
Browse files Browse the repository at this point in the history
Syncing #30, #32, #33 to master
  • Loading branch information
ziruihao authored Sep 11, 2020
2 parents fd873cb + 1dd53b7 commit 66cf0d1
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 5 deletions.
15 changes: 13 additions & 2 deletions apps/spider/crawlers/timetable.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
from lib.terms import split_term
from lib.constants import CURRENT_TERM


TIMETABLE_URL = (
"http://oracle-www.dartmouth.edu/dart/groucho/timetable.display_courses")

Expand All @@ -29,6 +30,9 @@
"&terms={term}"
)

COURSE_TITLE_REGEX = re.compile(
"(.*?)(?:\s\(((?:Remote|On Campus|Individualized)[^\)]*)\))?(\(.*\))?$")


def crawl_timetable(term):
"""
Expand Down Expand Up @@ -64,6 +68,13 @@ def crawl_timetable(term):
crosslisted_courses = _parse_crosslisted_courses(
tds[7].get_text(strip=True))

title_match = COURSE_TITLE_REGEX.match(tds[5].get_text(strip=True)
.encode('ascii', 'ignore').decode('ascii'))

title = title_match.group(1)
if title_match.group(3):
title += " " + title_match.group(3)

course_data.append({
"term": _convert_timetable_term_to_term(
tds[0].get_text(strip=True)),
Expand All @@ -72,8 +83,8 @@ def crawl_timetable(term):
"number": number,
"subnumber": subnumber,
"section": int(tds[4].get_text(strip=True)),
"title": tds[5].get_text(strip=True).encode(
'ascii', 'ignore').decode('ascii'),
"title": title,
"delivery_mode": title_match.group(2),
"crosslisted": crosslisted_courses,
"period": tds[8].get_text(strip=True),
"room": tds[10].get_text(strip=True),
Expand Down
3 changes: 2 additions & 1 deletion apps/web/models/student.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ def is_valid_dartmouth_student_email(self, email):
return (
domain == "dartmouth.edu" and
len(year) == 2 and
(year.isdigit() or year.lower() == "ug" or year.lower() == "gr")
(year.isdigit() or year.lower() == "ug" or year.lower() == "gr"
or year.lower() == "mt")
)


Expand Down
2 changes: 1 addition & 1 deletion apps/web/templates/instructions.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
</div>
<div class="row">
<div class="col-md-12">
<p id="medium">Registration successful. Please check your email for a confirmation link and follow the instructions to activate your account.</p>
<p id="medium">Registration successful. Please check your email (and in spam folder) for a confirmation link and follow the instructions to activate your account.</p>
</div>
</div>
<br>
Expand Down
2 changes: 1 addition & 1 deletion layup_list/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
BASE_DIR = os.path.dirname(os.path.abspath(__file__))
SECRET_KEY = os.environ['SECRET_KEY']
DEBUG = os.environ['DEBUG'] == "True"
ALLOWED_HOSTS = ['.layuplist.com'] if not DEBUG else ['0.0.0.0']
ALLOWED_HOSTS = ['.layuplist.com'] if not DEBUG else ['0.0.0.0', 'localhost']
AUTO_IMPORT_CRAWLED_DATA = os.environ.get('AUTO_IMPORT_CRAWLED_DATA') == "True"

INSTALLED_APPS = [
Expand Down

0 comments on commit 66cf0d1

Please sign in to comment.