Skip to content

Commit

Permalink
Fix NGSS restrictions, filter out permission-required courses from PC…
Browse files Browse the repository at this point in the history
…A stats
  • Loading branch information
mureytasroc committed Sep 23, 2023
1 parent 54b2244 commit 256cf7d
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 13 deletions.
20 changes: 9 additions & 11 deletions backend/courses/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -494,17 +494,6 @@ class NGSSRestriction(models.Model):
)
)

courses = models.ManyToManyField(
Course,
related_name="ngss_restrictions",
blank=True,
help_text=dedent(
"""
Individual Course objects which have this restriction.
"""
),
)

def __str__(self):
return f"{self.code} - {self.restriction_type} - {self.description}"

Expand Down Expand Up @@ -683,6 +672,15 @@ class Meta:
"""
),
)
ngss_restrictions = models.ManyToManyField(
NGSSRestriction,
related_name="sections",
blank=True,
help_text=(
"All NGSS registration Restriction objects to which this section is subject. "
"This field will be empty for sections in 2022B or later."
),
)
pre_ngss_restrictions = models.ManyToManyField(
PreNGSSRestriction,
related_name="sections",
Expand Down
18 changes: 16 additions & 2 deletions backend/review/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,14 @@
from rest_framework.permissions import IsAuthenticated
from rest_framework.response import Response

from courses.models import Course, Department, Instructor, PreNGSSRestriction, Section
from courses.models import (
Course,
Department,
Instructor,
NGSSRestriction,
PreNGSSRestriction,
Section,
)
from courses.util import get_current_semester, get_or_create_add_drop_period
from PennCourses.docs_settings import PcxAutoSchema
from PennCourses.settings.base import (
Expand Down Expand Up @@ -63,13 +70,20 @@
& Q(capacity__gt=0)
& ~Q(course__semester__icontains="b") # Filter out summer classes
& Q(has_status_updates=True)
& ~Q(
id__in=Subquery(
NGSSRestriction.objects.filter(restriction_type="Special Approval").values(
"sections__id"
)
)
) # Filter out sections that require permit for registration
& ~Q(
id__in=Subquery(
PreNGSSRestriction.objects.filter(
code__in=PRE_NGSS_PERMIT_REQ_RESTRICTION_CODES
).values("sections__id")
)
) # Filter out sections that require permit for registration
) # Filter out sections that require permit for registration (pre-NGSS)
# TODO: get permit information from new OpenData API
)

Expand Down

0 comments on commit 256cf7d

Please sign in to comment.