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
54d14098
Commit
54d14098
authored
Dec 05, 2017
by
Jeremy Bowman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
PLAT-1427 Adapt to build_attrs change in Django 1.11
parent
62f91dd7
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
29 additions
and
2 deletions
+29
-2
lms/djangoapps/course_wiki/editors.py
+19
-1
openedx/core/djangoapps/api_admin/widgets.py
+10
-1
No files found.
lms/djangoapps/course_wiki/editors.py
View file @
54d14098
"""
Support for using the CodeMirror code editor as a wiki content editor.
"""
import
django
from
django
import
forms
from
django
import
forms
from
django.forms.utils
import
flatatt
from
django.forms.utils
import
flatatt
from
django.template.loader
import
render_to_string
from
django.template.loader
import
render_to_string
...
@@ -9,6 +14,9 @@ from wiki.editors.markitup import MarkItUpAdminWidget
...
@@ -9,6 +14,9 @@ from wiki.editors.markitup import MarkItUpAdminWidget
class
CodeMirrorWidget
(
forms
.
Widget
):
class
CodeMirrorWidget
(
forms
.
Widget
):
"""
Use CodeMirror as a Django form widget (like a textarea).
"""
def
__init__
(
self
,
attrs
=
None
):
def
__init__
(
self
,
attrs
=
None
):
# The 'rows' and 'cols' attributes are required for HTML correctness.
# The 'rows' and 'cols' attributes are required for HTML correctness.
default_attrs
=
{
default_attrs
=
{
...
@@ -25,7 +33,14 @@ class CodeMirrorWidget(forms.Widget):
...
@@ -25,7 +33,14 @@ class CodeMirrorWidget(forms.Widget):
if
value
is
None
:
if
value
is
None
:
value
=
''
value
=
''
final_attrs
=
self
.
build_attrs
(
attrs
,
name
=
name
)
# TODO: Remove Django 1.11 upgrade shim
# SHIM: Compensate for build_attrs() implementation change in 1.11
if
django
.
VERSION
<
(
1
,
11
):
final_attrs
=
self
.
build_attrs
(
attrs
,
name
=
name
)
else
:
extra_attrs
=
attrs
.
copy
()
extra_attrs
[
'name'
]
=
name
final_attrs
=
self
.
build_attrs
(
self
.
attrs
,
extra_attrs
=
extra_attrs
)
# pylint: disable=redundant-keyword-arg
# TODO use the help_text field of edit form instead of rendering a template
# TODO use the help_text field of edit form instead of rendering a template
...
@@ -36,6 +51,9 @@ class CodeMirrorWidget(forms.Widget):
...
@@ -36,6 +51,9 @@ class CodeMirrorWidget(forms.Widget):
class
CodeMirror
(
BaseEditor
):
class
CodeMirror
(
BaseEditor
):
"""
Wiki content editor using CodeMirror.
"""
editor_id
=
'codemirror'
editor_id
=
'codemirror'
def
get_admin_widget
(
self
,
instance
=
None
):
def
get_admin_widget
(
self
,
instance
=
None
):
...
...
openedx/core/djangoapps/api_admin/widgets.py
View file @
54d14098
""" Form widget classes """
""" Form widget classes """
import
django
from
django.conf
import
settings
from
django.conf
import
settings
from
django.core.urlresolvers
import
reverse
from
django.core.urlresolvers
import
reverse
from
django.forms.utils
import
flatatt
from
django.forms.utils
import
flatatt
...
@@ -15,7 +16,15 @@ class TermsOfServiceCheckboxInput(CheckboxInput):
...
@@ -15,7 +16,15 @@ class TermsOfServiceCheckboxInput(CheckboxInput):
""" Renders a checkbox with a label linking to the terms of service. """
""" Renders a checkbox with a label linking to the terms of service. """
def
render
(
self
,
name
,
value
,
attrs
=
None
):
def
render
(
self
,
name
,
value
,
attrs
=
None
):
final_attrs
=
self
.
build_attrs
(
attrs
,
type
=
'checkbox'
,
name
=
name
)
# TODO: Remove Django 1.11 upgrade shim
# SHIM: Compensate for behavior change of default authentication backend in 1.10
if
django
.
VERSION
<
(
1
,
11
):
final_attrs
=
self
.
build_attrs
(
attrs
,
type
=
'checkbox'
,
name
=
name
)
else
:
extra_attrs
=
attrs
.
copy
()
extra_attrs
.
update
({
'type'
:
'checkbox'
,
'name'
:
name
})
final_attrs
=
self
.
build_attrs
(
self
.
attrs
,
extra_attrs
=
extra_attrs
)
# pylint: disable=redundant-keyword-arg
if
self
.
check_test
(
value
):
if
self
.
check_test
(
value
):
final_attrs
[
'checked'
]
=
'checked'
final_attrs
[
'checked'
]
=
'checked'
if
not
(
value
is
True
or
value
is
False
or
value
is
None
or
value
==
''
):
if
not
(
value
is
True
or
value
is
False
or
value
is
None
or
value
==
''
):
...
...
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