Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
edx-platform-release
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Hsin-Yu Chien
edx-platform-release
Commits
0a57ff98
Unverified
Commit
0a57ff98
authored
5 years ago
by
Nimisha Asthagiri
Committed by
GitHub
5 years ago
Browse files
Options
Downloads
Plain Diff
Merge pull request #23547 from edx/arch/django-22-content-type-gating
Django2 StackedConfigurationModel: Fix query filter
parents
358b181b
5447e863
Loading
Loading
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
openedx/core/djangoapps/config_model_utils/models.py
+14
-13
14 additions, 13 deletions
openedx/core/djangoapps/config_model_utils/models.py
with
14 additions
and
13 deletions
openedx/core/djangoapps/config_model_utils/models.py
+
14
−
13
View file @
0a57ff98
...
...
@@ -183,19 +183,20 @@ class StackedConfigurationModel(ConfigurationModel):
values
=
field_defaults
.
copy
()
global_override_q
=
Q
(
site
=
None
,
org
=
None
,
org_course
=
None
,
course_id
=
None
)
site_override_q
=
Q
(
site
=
site
,
org
=
None
,
org_course
=
None
,
course_id
=
None
)
org_override_q
=
Q
(
site
=
None
,
org
=
org
,
org_course
=
None
,
course_id
=
None
)
org_course_override_q
=
Q
(
site
=
None
,
org
=
None
,
org_course
=
org_course
,
course_id
=
None
)
course_override_q
=
Q
(
site
=
None
,
org
=
None
,
org_course
=
None
,
course_id
=
course_key
)
overrides
=
cls
.
objects
.
current_set
().
filter
(
global_override_q
|
site_override_q
|
org_override_q
|
org_course_override_q
|
course_override_q
)
# Build a multi_filter_query that defaults to querying for the global-level setting and adds queries
# for the stacked-level settings when applicable.
# Note: Django2+ requires checking for 'isnull' rather than passing 'None' in the queries.
multi_filter_query
=
Q
(
site__isnull
=
True
,
org__isnull
=
True
,
org_course__isnull
=
True
,
course_id__isnull
=
True
)
if
site
:
multi_filter_query
|=
Q
(
site
=
site
,
org__isnull
=
True
,
org_course__isnull
=
True
,
course_id__isnull
=
True
)
if
org
:
multi_filter_query
|=
Q
(
site__isnull
=
True
,
org
=
org
,
org_course__isnull
=
True
,
course_id__isnull
=
True
)
if
org_course
:
multi_filter_query
|=
Q
(
site__isnull
=
True
,
org__isnull
=
True
,
org_course
=
org_course
,
course_id__isnull
=
True
)
if
course_key
:
multi_filter_query
|=
Q
(
site__isnull
=
True
,
org__isnull
=
True
,
org_course__isnull
=
True
,
course_id
=
course_key
)
overrides
=
cls
.
objects
.
current_set
().
filter
(
multi_filter_query
)
provenances
=
defaultdict
(
lambda
:
Provenance
.
default
)
# We are sorting in python to avoid doing a filesort in the database for
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment