Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-platform
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
edx-platform
Commits
406066ca
Commit
406066ca
authored
Feb 12, 2016
by
Eric Fischer
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #11525 from edx/efischer/fix_global_message
Fix config_model admin view
parents
04ca0af5
63942380
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
3 deletions
+13
-3
common/djangoapps/config_models/admin.py
+13
-3
No files found.
common/djangoapps/config_models/admin.py
View file @
406066ca
...
...
@@ -31,7 +31,17 @@ class ConfigurationModelAdmin(admin.ModelAdmin):
}
def
get_list_display
(
self
,
request
):
return
self
.
model
.
_meta
.
get_all_field_names
()
return
self
.
get_displayable_field_names
()
def
get_displayable_field_names
(
self
):
"""
Return all field names, excluding reverse foreign key relationships.
"""
return
[
f
.
name
for
f
in
self
.
model
.
_meta
.
get_fields
()
if
not
f
.
one_to_many
]
# Don't allow deletion of configuration
def
has_delete_permission
(
self
,
request
,
obj
=
None
):
...
...
@@ -40,7 +50,7 @@ class ConfigurationModelAdmin(admin.ModelAdmin):
# Make all fields read-only when editing an object
def
get_readonly_fields
(
self
,
request
,
obj
=
None
):
if
obj
:
# editing an existing object
return
self
.
model
.
_meta
.
get_all
_field_names
()
return
self
.
get_displayable
_field_names
()
return
self
.
readonly_fields
def
add_view
(
self
,
request
,
form_url
=
''
,
extra_context
=
None
):
...
...
@@ -160,7 +170,7 @@ class KeyedConfigurationModelAdmin(ConfigurationModelAdmin):
def
get_list_display
(
self
,
request
):
""" Add a link to each row for creating a new row using the chosen row as a template """
return
self
.
model
.
_meta
.
get_all
_field_names
()
+
[
'edit_link'
]
return
self
.
get_displayable
_field_names
()
+
[
'edit_link'
]
def
add_view
(
self
,
request
,
form_url
=
''
,
extra_context
=
None
):
# Prepopulate new configuration entries with the value of the current config, if given:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment