Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Course audit feature #520

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 9 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions backend/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ COPY Pipfile* /app/
# Install project dependencies
RUN pipenv install --system --deploy


# Install system dependencies to support GeoDjango
RUN apt-get update && apt-get install -y gdal-bin libgdal-dev python3-gdal binutils libproj-dev

# Copy project files
COPY . /app/

Expand Down
4 changes: 4 additions & 0 deletions backend/Dockerfile.dev
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,12 @@ WORKDIR /backend
# Copy project dependencies
COPY Pipfile* ./


# Install backend dependencies
RUN pipenv install --dev

# Install system dependencies for GeoDjango
RUN apt-get update && apt-get install -y gdal-bin libgdal-dev python3-gdal binutils libproj-dev

# Alias runserver command
RUN echo 'alias runserver="python manage.py runserver 0.0.0.0:8000"' >> ~/.bashrc
5 changes: 4 additions & 1 deletion backend/PennCourses/docs_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,10 @@


def get_url_by_name(name):
path = get_resolver().reverse_dict[name][0][0][0]
reverse = get_resolver().reverse_dict
if name not in reverse:
raise ValueError(f"Tried to get URL by name '{reverse}', but no such URL exists.")
path = reverse[name][0][0][0]
path = path.replace(r"%(pk)s", r"{id}")
return "/" + re.sub(r"%\(([^)]+)\)s", r"{\1}", path)

Expand Down
6 changes: 5 additions & 1 deletion backend/PennCourses/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
"django.contrib.sessions",
"django.contrib.messages",
"django.contrib.staticfiles",
"django.contrib.gis",
"rest_framework",
"corsheaders",
"shortener.apps.ShortenerConfig",
Expand Down Expand Up @@ -93,7 +94,7 @@
DATABASES = {
"default": dj_database_url.config(
# this is overriden by the DATABASE_URL env var
default="postgres://penn-courses:postgres@localhost:5432/postgres"
default="postgis://penn-courses:postgres@localhost:5432/postgres"
)
}

Expand Down Expand Up @@ -228,3 +229,6 @@
ROUGH_MINIMUM_DEMAND_DISTRIBUTION_ESTIMATES = (
200 # Aim for at least 200 demand distribution estimates over the course of a semester
)

# GeoDjango GDAL Settings
GDAL_LIBRARY_PATH = os.environ.get("GDAL_LIBRARY_PATH", "")
1 change: 0 additions & 1 deletion backend/Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ black = "==22.3.0"
[packages]
click = "==8.0.4"
django = ">=3.2"
psycopg2 = "*"
requests = "*"
twilio = "*"
channels = "<3"
Expand Down
1,804 changes: 964 additions & 840 deletions backend/Pipfile.lock

Large diffs are not rendered by default.

8 changes: 5 additions & 3 deletions backend/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -142,25 +142,27 @@ If you don't want to use docker alone, you can also set up and run the dev envir
- Python 3.10 ([`pyenv`](https://github.com/pyenv/pyenv) is recommended)
- [`pipenv`](https://pipenv.pypa.io/en/latest/)
- [`docker` and `docker-compose`](https://docs.docker.com/get-docker/)
- Dependencies for GeoDjango: `GEOS`, `PROJ`, `GDAL` (see [GeoDjango installation docs](https://docs.djangoproject.com/en/3.2/ref/contrib/gis/install/))

`psql` is required to load data into the db, but it should be installed when you install `postgres`/`psycopg2`.

1. `cd backend`
2. Compiling postgres (`psycopg2`)

- **Mac**
> :warning: NOTE: If your computer runs on Apple silicon and you use Rosetta to run Python as an x86 program, use `arch -x86_64 brew <rest of command>` for all `brew` commands.

<!-- > :warning: NOTE: If your computer runs on Apple silicon and you use Rosetta to run Python as an x86 program, use `arch -x86_64 brew <rest of command>` for all `brew` commands. -->
1. `brew install postgresql`
2. `brew install openssl`
3. `brew unlink openssl && brew link openssl --force`
4. Follow the instructions printed by the previous command to add openssl to your PATH and export flags for compilers, e.g.:
4. `brew install gdal; brew install libgeoip`
5. Follow the instructions printed by the previous command to add openssl to your PATH and export flags for compilers, e.g.:
- `echo 'export PATH="/usr/local/opt/openssl@3/bin:$PATH"' >> ~/.zshrc`
- `export LDFLAGS="-L/usr/local/opt/openssl@3/lib"`
- `export CPPFLAGS="-I/usr/local/opt/openssl@3/include"`

- **Windows (WSL) or Linux:**
- `apt-get install gcc python3-dev libpq-dev`
- `apt-get install gdal-bin libgdal-dev python3-gdal binutils libproj-dev`

3. Running Docker
1. Open a new terminal window (also in the `backend` directory) and run `docker-compose up`
Expand Down
1 change: 0 additions & 1 deletion backend/alert/migrations/0001_initial.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@


class Migration(migrations.Migration):

initial = True

dependencies = [
Expand Down
1 change: 0 additions & 1 deletion backend/alert/migrations/0002_delete_registration.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@


class Migration(migrations.Migration):

dependencies = [
("alert", "0001_initial"),
]
Expand Down
1 change: 0 additions & 1 deletion backend/alert/migrations/0003_courseupdate_registration.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@


class Migration(migrations.Migration):

initial = True

dependencies = [
Expand Down
1 change: 0 additions & 1 deletion backend/alert/migrations/0004_auto_20190926_0549.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@


class Migration(migrations.Migration):

dependencies = [
("courses", "0019_apikey_apiprivilege"),
("alert", "0003_courseupdate_registration"),
Expand Down
1 change: 0 additions & 1 deletion backend/alert/migrations/0005_delete_courseupdate.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ def backwards(apps, schema_editor):


class Migration(migrations.Migration):

dependencies = [
("alert", "0004_auto_20190926_0549"),
]
Expand Down
1 change: 0 additions & 1 deletion backend/alert/migrations/0006_auto_20191110_1357.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@


class Migration(migrations.Migration):

dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
("alert", "0005_delete_courseupdate"),
Expand Down
1 change: 0 additions & 1 deletion backend/alert/migrations/0007_auto_20200131_1619.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@


class Migration(migrations.Migration):

dependencies = [
("alert", "0006_auto_20191110_1357"),
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@


class Migration(migrations.Migration):

dependencies = [
("alert", "0007_auto_20200131_1619"),
]
Expand Down
1 change: 0 additions & 1 deletion backend/alert/migrations/0009_auto_20200419_2112.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@


class Migration(migrations.Migration):

dependencies = [
("alert", "0008_registration_original_created_at"),
]
Expand Down
1 change: 0 additions & 1 deletion backend/alert/migrations/0010_auto_20201002_0714.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@


class Migration(migrations.Migration):

dependencies = [
("courses", "0030_auto_20201002_0714"),
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
Expand Down
1 change: 0 additions & 1 deletion backend/alert/migrations/0011_auto_20201108_1535.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@


class Migration(migrations.Migration):

dependencies = [
("alert", "0010_auto_20201002_0714"),
]
Expand Down
1 change: 0 additions & 1 deletion backend/alert/migrations/0012_auto_20210418_0343.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@


class Migration(migrations.Migration):

dependencies = [
("courses", "0032_auto_20210418_0343"),
("alert", "0011_auto_20201108_1535"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@


class Migration(migrations.Migration):

dependencies = [
("alert", "0012_auto_20210418_0343"),
]
Expand Down
1 change: 0 additions & 1 deletion backend/alert/migrations/0014_auto_20210418_0847.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@


class Migration(migrations.Migration):

dependencies = [
("alert", "0013_pcademanddistributionestimate_csdv_gamma_fit_log_likelihood"),
]
Expand Down
1 change: 0 additions & 1 deletion backend/alert/migrations/0015_auto_20211010_1235.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@


class Migration(migrations.Migration):

dependencies = [
("alert", "0014_auto_20210418_0847"),
]
Expand Down
1 change: 0 additions & 1 deletion backend/alert/migrations/0016_auto_20211113_1537.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@


class Migration(migrations.Migration):

dependencies = [
("alert", "0015_auto_20211010_1235"),
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ def reverse_func(apps, schema_editor):


class Migration(migrations.Migration):

dependencies = [
("alert", "0016_auto_20211113_1537"),
]
Expand Down
7 changes: 6 additions & 1 deletion backend/courses/admin.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from django.contrib import admin
from django.contrib.auth.admin import UserAdmin
from django.contrib.auth.models import User
from django.contrib.gis import admin as gis_admin
from django.template import loader
from django.urls import reverse
from django.utils.html import format_html, format_html_join
Expand Down Expand Up @@ -203,13 +204,17 @@ class StatusUpdateAdmin(admin.ModelAdmin):
search_fields = ("section__full_code",)


class BuildingAdmin(gis_admin.OSMGeoAdmin):
pass


admin.site.register(APIKey)
admin.site.register(APIPrivilege)
admin.site.register(Department, DepartmentAdmin)
admin.site.register(Course, CourseAdmin)
admin.site.register(Topic, TopicAdmin)
admin.site.register(Section, SectionAdmin)
admin.site.register(Building)
admin.site.register(Building, BuildingAdmin)
admin.site.register(Room)
admin.site.register(PreNGSSRequirement, PreNGSSRequirementAdmin)
admin.site.register(PreNGSSRestriction)
Expand Down
1 change: 0 additions & 1 deletion backend/courses/migrations/0001_initial.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@


class Migration(migrations.Migration):

initial = True

dependencies = []
Expand Down
1 change: 0 additions & 1 deletion backend/courses/migrations/0002_auto_20190426_2158.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@


class Migration(migrations.Migration):

dependencies = [
("courses", "0001_initial"),
]
Expand Down
1 change: 0 additions & 1 deletion backend/courses/migrations/0003_auto_20190428_1707.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@


class Migration(migrations.Migration):

dependencies = [
("courses", "0002_auto_20190426_2158"),
]
Expand Down
1 change: 0 additions & 1 deletion backend/courses/migrations/0004_auto_20190428_1710.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@


class Migration(migrations.Migration):

dependencies = [
("courses", "0003_auto_20190428_1707"),
]
Expand Down
1 change: 0 additions & 1 deletion backend/courses/migrations/0005_auto_20190428_1845.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@


class Migration(migrations.Migration):

dependencies = [
("courses", "0004_auto_20190428_1710"),
]
Expand Down
1 change: 0 additions & 1 deletion backend/courses/migrations/0006_auto_20190508_0200.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@


class Migration(migrations.Migration):

dependencies = [
("courses", "0005_auto_20190428_1845"),
]
Expand Down
1 change: 0 additions & 1 deletion backend/courses/migrations/0007_auto_20190508_0202.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@


class Migration(migrations.Migration):

dependencies = [
("courses", "0006_auto_20190508_0200"),
]
Expand Down
1 change: 0 additions & 1 deletion backend/courses/migrations/0008_auto_20190510_0114.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@


class Migration(migrations.Migration):

dependencies = [
("courses", "0007_auto_20190508_0202"),
]
Expand Down
1 change: 0 additions & 1 deletion backend/courses/migrations/0009_requirement.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@


class Migration(migrations.Migration):

dependencies = [
("courses", "0008_auto_20190510_0114"),
]
Expand Down
1 change: 0 additions & 1 deletion backend/courses/migrations/0010_auto_20190510_0454.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@


class Migration(migrations.Migration):

dependencies = [
("courses", "0009_requirement"),
]
Expand Down
1 change: 0 additions & 1 deletion backend/courses/migrations/0011_auto_20190510_0504.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@


class Migration(migrations.Migration):

dependencies = [
("courses", "0010_auto_20190510_0454"),
]
Expand Down
1 change: 0 additions & 1 deletion backend/courses/migrations/0012_auto_20190510_0559.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@


class Migration(migrations.Migration):

dependencies = [
("courses", "0011_auto_20190510_0504"),
]
Expand Down
1 change: 0 additions & 1 deletion backend/courses/migrations/0013_auto_20190517_0313.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@


class Migration(migrations.Migration):

dependencies = [
("courses", "0012_auto_20190510_0559"),
]
Expand Down
1 change: 0 additions & 1 deletion backend/courses/migrations/0013_course_full_code.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@


class Migration(migrations.Migration):

dependencies = [
("courses", "0012_auto_20190510_0559"),
]
Expand Down
1 change: 0 additions & 1 deletion backend/courses/migrations/0014_auto_20190518_1641.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@


class Migration(migrations.Migration):

dependencies = [
("courses", "0013_auto_20190517_0313"),
]
Expand Down
1 change: 0 additions & 1 deletion backend/courses/migrations/0015_merge_20190518_2155.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@


class Migration(migrations.Migration):

dependencies = [
("courses", "0013_course_full_code"),
("courses", "0014_auto_20190518_1641"),
Expand Down
1 change: 0 additions & 1 deletion backend/courses/migrations/0016_auto_20190523_1554.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@


class Migration(migrations.Migration):

dependencies = [
("courses", "0015_merge_20190518_2155"),
]
Expand Down
Loading
Loading