Skip to content

Commit

Permalink
fix: add some changes related to sanity check
Browse files Browse the repository at this point in the history
  • Loading branch information
AfaqShuaib09 committed May 2, 2024
1 parent 95769da commit 2372c09
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions course_discovery/apps/course_metadata/managers.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ class DraftManager(models.Manager):
""" Model manager that hides draft rows unless you ask for them. """

def get_queryset(self, allow_restricted=False):
if allow_restricted:
if allow_restricted or self.model.__name__ != 'CourseRun':
return super().get_queryset().filter(draft=models.Value(0))
return super().get_queryset().filter(draft=models.Value(0), restricted_run__isnull=True)

def _with_drafts(self, allow_restricted=False):
if allow_restricted:
if allow_restricted or self.model.__name__ != 'CourseRun':
return super().get_queryset()
return super().get_queryset().filter(restricted_run__isnull=True)

Expand All @@ -23,8 +23,8 @@ def filter_drafts(self, allow_restricted=False, **kwargs):
Acts like filter(), but prefers draft versions.
If a draft is not available, we give back the non-draft version.
"""
if allow_restricted:
return self._with_drafts(allow_restricted=allow_restricted).filter(Q(draft=models.Value(1)) | Q(draft_version=None)).filter(**kwargs)
if allow_restricted and self.model.__name__ =='CourseRun':
return self._with_drafts(allow_restricted=allow_restricted).filter(Q(draft=models.Value(1)) | Q(draft_version=None)).filter(**kwargs)
return self._with_drafts().filter(Q(draft=models.Value(1)) | Q(draft_version=None)).filter(**kwargs)

def get_draft(self, **kwargs):
Expand Down

0 comments on commit 2372c09

Please sign in to comment.