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
e5b8f287
Commit
e5b8f287
authored
5 years ago
by
Matt Tuchfarber
Browse files
Options
Downloads
Patches
Plain Diff
Update with some preferences
parent
47255197
Loading
Loading
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
openedx/core/djangoapps/plugins/constants.py
+1
-1
1 addition, 1 deletion
openedx/core/djangoapps/plugins/constants.py
openedx/core/djangoapps/plugins/plugin_contexts.py
+26
-3
26 additions, 3 deletions
openedx/core/djangoapps/plugins/plugin_contexts.py
with
27 additions
and
4 deletions
openedx/core/djangoapps/plugins/constants.py
+
1
−
1
View file @
e5b8f287
...
...
@@ -79,7 +79,7 @@ class PluginSignals(object):
class
PluginContextsViews
(
object
):
STUDENT
_DASHBOARD
=
u
'
student
_dashboard
'
COURSE
_DASHBOARD
=
u
'
course
_dashboard
'
class
PluginContexts
(
object
):
...
...
This diff is collapsed.
Click to expand it.
openedx/core/djangoapps/plugins/plugin_contexts.py
+
26
−
3
View file @
e5b8f287
from
importlib
import
import_module
from
logging
import
getLogger
from
.
import
constants
,
registry
log
=
getLogger
(
__name__
)
log
=
getLogger
(
__name__
)
def
get_plugins_view_context
(
project_type
,
view_name
,
existing_context
=
{}):
"""
...
...
@@ -18,11 +19,33 @@ def get_plugins_view_context(project_type, view_name, existing_context={}):
context_function_path
=
_get_context_function
(
app_config
,
project_type
,
view_name
)
if
context_function_path
:
module_path
,
_
,
name
=
context_function_path
.
rpartition
(
'
.
'
)
context_function
=
getattr
(
import_module
(
module_path
),
name
)
plugin_context
=
context_function
(
existing_context
)
try
:
module
=
import_module
(
module_path
)
except
ImportError
,
ModuleNotFoundError
:
log
.
exception
(
"
Failed to import %s plugin when creating %s context
"
,
module_path
,
view_name
)
continue
context_function
=
getattr
(
module
,
name
,
None
)
if
context_function
:
plugin_context
=
context_function
(
existing_context
)
else
:
log
.
exception
(
"
Failed to call %s function from %s plugin when creating %s context
"
,
name
,
module_path
,
view_name
)
continue
# NOTE: If two plugins have try to set the same context keys, the last one
# called will overwrite the others.
for
key
in
plugin_context
:
if
key
in
aggregate_context
:
log
.
warning
(
"
Plugin %s is overwriting the value of %s for view %s
"
,
app_config
.
__module__
,
key
,
view_name
)
aggregate_context
.
update
(
plugin_context
)
return
aggregate_context
...
...
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