API for Penn Course Review Data.
Used by the PennCourseReview frontend and others.
The PCR API is composed of two parts. The scripts which pull the course data from the registrar and the legacy PCR database, and the site which powers the API itself.
The api itself consists of five apps-- apiconsumer, course_descriptions, courses, static_content, and testconsole.
Sets permission levels for developers who wish to use our API. This is mainly in place because the data should only be accessible to Penn students and faculty.
Parses the course register. (Probably should be moved to /scripts)
Powers the actual API.
Responsible for powering the static pages on the PCR site. It's basically a very simple version of a CMS and exists solely so that admins only have to manage one admin site.
testconsole is a simple javascript interface for the api.
Responsible for scraping new data from the registrar and grabbing old data from the legacy PCR site.
- Change your directory to Penn-Course-API/scripts
- Run "python download.py"
- This scrapes the registrar, cleans up the data, and dumps it into /registrardata.
- Run "python uploadcourses.py YEAR SEMESTER registrardata/*.txt"
- uploadcourses.py [YEAR] [SEMESTER] [*FILES] parses the data scraped from download.py and uses it to update the PCR API database.
- SEMESTER accepts either 'a', 'b', or 'c'
- (ie, run "python uploadcourses.py 2009 a registrardata/econ.txt")
- Since the registrar data changes every year, YEAR should be the current year, and SEMESTER the current semester.
- Run "python import_from_pcr.py YEAR SEMESTER"
- import_from_pcr.py [YEAR] [SEMESTER] reads from an external database-- assumed to have the original PCR records --and creates or updates course and review data in the new PCR API database.
- (This can take a while.)
- Connect to the production server.
- Go to the directory containing
pcr-api
and runsource venv/bin/activate
. - Perform a
git pull
,pip install -r requirements.txt
, and./manage.py migrate
. - Set any necessary environment variables in
api/django.wsgi
. - Run
sudo apachectl -k graceful
to restart the server.
API_DEBUG
- Set this totrue
to enable Django debug mode.API_DISPLAY_NAME
- Prepended before every api endpoint url, default is/
.API_SECRET_KEY
- The secret key for the Django application.API_IMPORT_DATABASE_NAME
- The database to import from when using the import script.API_IMPORT_DATABASE_USER
- The username for the database to import from when using the import script.API_IMPORT_DATABASE_PWD
- The password for the database to import from when using the import script.API_TEST_TOKEN
- The token used for live tests when running unit tests.DATABASE_URL
- The location of the database.SENTRY_DSN
- Set this to the Sentry DSN to enable error reporting.