Skip to content

Commit

Permalink
Backend version updates (#605)
Browse files Browse the repository at this point in the history
* first pass

* configure ruff

* pin black version

* update Python version in backend check, revert pin black version

* fix..?

* switch to Python 3.11, fix tests

* fix dependency

* lint

* fix channels

* use ruff w/shared actions, remove black, flake8, isort

* oops lol

* this is embarrassing

* use 3.11 base image

* temporarily add integration tests

* attempt to fix

* fixed django base

* fix integration tests

* fix csrf?

* plz

* remove integration tests
  • Loading branch information
rm03 authored Feb 20, 2024
1 parent 6c9ebd7 commit 260a2b9
Show file tree
Hide file tree
Showing 122 changed files with 1,505 additions and 1,610 deletions.
8 changes: 5 additions & 3 deletions .github/workflows/build-and-deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,14 @@ on: push
jobs:
backend-check:
name: "Backend Check"
uses: pennlabs/shared-actions/.github/workflows/django.yaml@8785a7d7b9158d8d5705a0202f5695db2c0beb97
uses: pennlabs/shared-actions/.github/workflows/django.yaml@e6edf59024578b2ddbe6d5b79fa49a7137a63d36
with:
projectName: pennclubs
path: backend
flake: true
black: true
pythonVersion: 3.11-bookworm
flake: false
black: false
ruff: true

frontend-check:
name: "Frontend Check"
Expand Down
20 changes: 6 additions & 14 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,21 @@
repos:
- repo: local
hooks:
- id: black
name: black
entry: bash -c "export PIPENV_IGNORE_VIRTUALENVS=1 && cd backend && pipenv run black ."
- id: ruff-format
name: Ruff Formatter
entry: bash -c "export PIPENV_IGNORE_VIRTUALENVS=1 && cd backend && pipenv run ruff format ."
language: python
types: [python]
require_serial: true
files: ^backend/
pass_filenames: false
- id: isort
name: isort
entry: isort
- id: ruff-lint-fix
name: Ruff Lint (Apply Fixes)
entry: ruff check . --fix
language: python
types: [python]
require_serial: true
files: ^backend/
- id: flake8
name: flake8
entry: flake8
language: python
types: [python]
require_serial: true
files: ^backend/
args: [--config, backend/setup.cfg]
- id: frontend
name: Yarn Linter
entry: bash -c "cd frontend && yarn lint"
Expand Down
2 changes: 1 addition & 1 deletion backend/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM pennlabs/django-base:9c4f31bf1af44219d0f9019271a0033a222291c2-3.8.5
FROM pennlabs/django-base:b269ea1613686b1ac6370154debbb741b012de1a-3.11

LABEL maintainer="Penn Labs"

Expand Down
14 changes: 5 additions & 9 deletions backend/Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,16 @@ url = "https://pypi.org/simple"
verify_ssl = true

[dev-packages]
black = "==19.10b0"
unittest-xml-reporting = ">=3.0.2"
flake8 = "==5.0.3"
flake8-isort = "*"
isort = "*"
flake8-quotes = "*"
django-debug-toolbar = "*"
django-extensions = "*"
ruff = "*"

[packages]
dj-database-url = "*"
djangorestframework = "*"
sentry-sdk = "*"
django = "<4"
django = ">=5"
django-labs-accounts = "*"
drf-nested-routers = "*"
"bs4" = "*"
Expand All @@ -34,7 +30,7 @@ qrcode = "*"
python-dateutil = "*"
psycopg2 = "*"
django-simple-history = "*"
channels = "<3"
channels = {extras = ["daphne"], version = "*"}
django-runtime-options = "*"
social-auth-app-django = "*"
django-redis = "*"
Expand All @@ -44,7 +40,7 @@ uvloop = {version = "*", sys_platform = "== 'linux'"}
uvicorn = {extras = ["standard"], version = "*"}
gunicorn = "*"
httptools = "*"
ics = "==0.7"
ics = "*"
urlextract = "*"
jsonref = "*"
unittest-xml-reporting = "*"
Expand All @@ -59,4 +55,4 @@ numpy = "*"
coverage = "*"

[requires]
python_version = "3"
python_version = "3.11"
2,698 changes: 1,278 additions & 1,420 deletions backend/Pipfile.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion backend/clubs/management/commands/import_paideia_events.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def handle(self, *args, **kwargs):
"https://snfpaideia.upenn.edu/wp-json/wp/v2/event?"
"order=asc&per_page=100&page=1&onlyInclude=upcoming_events"
)
with (urllib.request.urlopen(url)) as data:
with urllib.request.urlopen(url) as data:
parsed_json = json.loads(data.read().decode())
for event in parsed_json:
try:
Expand Down
3 changes: 2 additions & 1 deletion backend/clubs/management/commands/merge_duplicates.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,8 @@ def merge_clubs(one, two):
Membership.objects.filter(club=primary).values_list("person__id", flat=True)
)
Membership.objects.filter(
club=secondary, person__in=duplicate_memberships,
club=secondary,
person__in=duplicate_memberships,
).delete()
Membership.objects.filter(club=secondary).update(club=primary)

Expand Down
5 changes: 4 additions & 1 deletion backend/clubs/management/commands/populate.py
Original file line number Diff line number Diff line change
Expand Up @@ -672,7 +672,10 @@ def get_image(url):
status_counter % len(ApplicationSubmission.STATUS_TYPES)
][0]
ApplicationSubmission.objects.create(
status=status, user=user, application=application, committee=None,
status=status,
user=user,
application=application,
committee=None,
)
status_counter += 1
for committee in application.committees.all():
Expand Down
9 changes: 6 additions & 3 deletions backend/clubs/management/commands/send_emails.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,14 +202,17 @@ def handle(self, *args, **kwargs):

if action == "update_status_reminder":
wc_badge = Badge.objects.filter(
label="Wharton Council", purpose="org",
label="Wharton Council",
purpose="org",
).first()
clubs = Club.objects.filter(badges__in=[wc_badge])
payloads = []
for club in clubs:
emails = (
Membership.objects.filter(
role__lte=Membership.ROLE_OFFICER, club__active=True, club=club,
role__lte=Membership.ROLE_OFFICER,
club__active=True,
club=club,
)
.values_list("person__email", flat=True)
.distinct()
Expand All @@ -220,7 +223,7 @@ def handle(self, *args, **kwargs):
payloads.append((applications_url, emails))
if test_email is not None:
payloads = [(payloads[0][0], [test_email])]
for (applications_url, emails) in payloads:
for applications_url, emails in payloads:
for email in emails:
if not dry_run:
template = "update_status_reminder"
Expand Down
1 change: 0 additions & 1 deletion backend/clubs/migrations/0001_initial.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@


class Migration(migrations.Migration):

initial = True

dependencies = [migrations.swappable_dependency(settings.AUTH_USER_MODEL)]
Expand Down
1 change: 0 additions & 1 deletion backend/clubs/migrations/0002_auto_20190926_1641.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@


class Migration(migrations.Migration):

dependencies = [("clubs", "0001_initial")]

operations = [
Expand Down
1 change: 0 additions & 1 deletion backend/clubs/migrations/0003_auto_20191025_2102.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@


class Migration(migrations.Migration):

dependencies = [("clubs", "0002_auto_20190926_1641")]

operations = [
Expand Down
1 change: 0 additions & 1 deletion backend/clubs/migrations/0003_auto_20191025_2120.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@


class Migration(migrations.Migration):

dependencies = [("clubs", "0002_auto_20190926_1641")]

operations = [
Expand Down
1 change: 0 additions & 1 deletion backend/clubs/migrations/0004_merge_20191025_2143.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@


class Migration(migrations.Migration):

dependencies = [
("clubs", "0003_auto_20191025_2102"),
("clubs", "0003_auto_20191025_2120"),
Expand Down
1 change: 0 additions & 1 deletion backend/clubs/migrations/0005_auto_20191025_2218.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@


class Migration(migrations.Migration):

dependencies = [("clubs", "0004_merge_20191025_2143")]

operations = [
Expand Down
1 change: 0 additions & 1 deletion backend/clubs/migrations/0006_profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@


class Migration(migrations.Migration):

dependencies = [
("auth", "0011_update_proxy_permissions"),
("clubs", "0005_auto_20191025_2218"),
Expand Down
1 change: 0 additions & 1 deletion backend/clubs/migrations/0007_auto_20191103_1843.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ def reverse_func(apps, schema_editor):


class Migration(migrations.Migration):

dependencies = [("clubs", "0006_profile")]

operations = [migrations.RunPython(forwards_func, reverse_func)]
1 change: 0 additions & 1 deletion backend/clubs/migrations/0008_auto_20191111_1835.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@


class Migration(migrations.Migration):

dependencies = [("clubs", "0007_auto_20191103_1843")]

operations = [
Expand Down
1 change: 0 additions & 1 deletion backend/clubs/migrations/0008_subscribe.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),
("clubs", "0007_auto_20191103_1843"),
Expand Down
1 change: 0 additions & 1 deletion backend/clubs/migrations/0009_merge_20191206_2311.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@


class Migration(migrations.Migration):

dependencies = [("clubs", "0008_subscribe"), ("clubs", "0008_auto_20191111_1835")]

operations = []
1 change: 0 additions & 1 deletion backend/clubs/migrations/0010_note_notetag.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),
("clubs", "0009_merge_20191206_2311"),
Expand Down
1 change: 0 additions & 1 deletion backend/clubs/migrations/0011_auto_20200103_1615.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@


class Migration(migrations.Migration):

dependencies = [("clubs", "0010_note_notetag")]

operations = [
Expand Down
1 change: 0 additions & 1 deletion backend/clubs/migrations/0012_testimonial.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@


class Migration(migrations.Migration):

dependencies = [("clubs", "0011_auto_20200103_1615")]

operations = [
Expand Down
1 change: 0 additions & 1 deletion backend/clubs/migrations/0013_auto_20200112_2104.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@


class Migration(migrations.Migration):

dependencies = [("clubs", "0012_testimonial")]

operations = [
Expand Down
1 change: 0 additions & 1 deletion backend/clubs/migrations/0014_club_youtube.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@


class Migration(migrations.Migration):

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


class Migration(migrations.Migration):

dependencies = [
("clubs", "0014_club_youtube"),
]
Expand Down
5 changes: 3 additions & 2 deletions backend/clubs/migrations/0016_auto_20200128_2024.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@


class Migration(migrations.Migration):

dependencies = [
("clubs", "0015_auto_20200119_1422"),
]

operations = [
migrations.AlterField(
model_name="event", name="description", field=models.TextField(blank=True),
model_name="event",
name="description",
field=models.TextField(blank=True),
),
]
1 change: 0 additions & 1 deletion backend/clubs/migrations/0017_joinrequest.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),
("clubs", "0016_auto_20200128_2024"),
Expand Down
1 change: 0 additions & 1 deletion backend/clubs/migrations/0017_report.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),
("clubs", "0016_auto_20200128_2024"),
Expand Down
6 changes: 4 additions & 2 deletions backend/clubs/migrations/0018_auto_20200207_1737.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,14 @@


class Migration(migrations.Migration):

dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
("clubs", "0017_joinrequest"),
]

operations = [
migrations.RenameModel(old_name="JoinRequest", new_name="MembershipRequest",),
migrations.RenameModel(
old_name="JoinRequest",
new_name="MembershipRequest",
),
]
1 change: 0 additions & 1 deletion backend/clubs/migrations/0019_merge_20200228_1615.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@


class Migration(migrations.Migration):

dependencies = [
("clubs", "0018_auto_20200207_1737"),
("clubs", "0017_report"),
Expand Down
1 change: 0 additions & 1 deletion backend/clubs/migrations/0020_auto_20200228_1651.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),
("clubs", "0019_merge_20200228_1615"),
Expand Down
5 changes: 3 additions & 2 deletions backend/clubs/migrations/0021_auto_20200307_1913.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@


class Migration(migrations.Migration):

dependencies = [
("clubs", "0020_auto_20200228_1651"),
]

operations = [
migrations.AlterField(
model_name="event", name="code", field=models.SlugField(max_length=255),
model_name="event",
name="code",
field=models.SlugField(max_length=255),
),
]
1 change: 0 additions & 1 deletion backend/clubs/migrations/0022_auto_20200308_1116.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),
("clubs", "0021_auto_20200307_1913"),
Expand Down
Loading

0 comments on commit 260a2b9

Please sign in to comment.