Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
D
django-wiki
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
OpenEdx
django-wiki
Commits
62ececa8
Commit
62ececa8
authored
Jul 27, 2017
by
cahrens
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Django 1.11 updates.
https://github.com/django-wiki/django-wiki/pull/634
parent
88a63108
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
24 additions
and
7 deletions
+24
-7
testproject/testproject/urls.py
+0
-1
wiki/core/compat.py
+14
-0
wiki/editors/markitup.py
+7
-4
wiki/forms.py
+3
-2
No files found.
testproject/testproject/urls.py
View file @
62ececa8
...
@@ -8,7 +8,6 @@ admin.autodiscover()
...
@@ -8,7 +8,6 @@ admin.autodiscover()
urlpatterns
=
[
urlpatterns
=
[
url
(
r'^admin/'
,
include
(
admin
.
site
.
urls
)),
url
(
r'^admin/'
,
include
(
admin
.
site
.
urls
)),
url
(
r'^notify/'
,
include
(
'django_notify.urls'
,
namespace
=
'notify'
)),
]
]
if
settings
.
DEBUG
:
if
settings
.
DEBUG
:
...
...
wiki/core/compat.py
0 → 100644
View file @
62ececa8
# Django 1.11 Widget.build_attrs has a different signature, designed for the new
# template based rendering. The previous version was more useful for our needs,
# so we restore that version.
# When support for Django < 1.11 is dropped, we should look at using the
# new template based rendering, at which point this probably won't be needed at all.
class
BuildAttrsCompat
(
object
):
def
build_attrs_compat
(
self
,
extra_attrs
=
None
,
**
kwargs
):
"Helper function for building an attribute dictionary."
attrs
=
self
.
attrs
.
copy
()
if
extra_attrs
is
not
None
:
attrs
.
update
(
extra_attrs
)
if
kwargs
is
not
None
:
attrs
.
update
(
kwargs
)
return
attrs
wiki/editors/markitup.py
View file @
62ececa8
...
@@ -4,9 +4,11 @@ from django.utils.encoding import force_unicode
...
@@ -4,9 +4,11 @@ from django.utils.encoding import force_unicode
from
django.utils.html
import
conditional_escape
from
django.utils.html
import
conditional_escape
from
django.utils.safestring
import
mark_safe
from
django.utils.safestring
import
mark_safe
from
wiki.core.compat
import
BuildAttrsCompat
from
wiki.editors.base
import
BaseEditor
from
wiki.editors.base
import
BaseEditor
class
MarkItUpAdminWidget
(
forms
.
Widget
):
class
MarkItUpAdminWidget
(
BuildAttrsCompat
,
forms
.
Widget
):
"""A simplified more fail-safe widget for the backend"""
"""A simplified more fail-safe widget for the backend"""
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.
...
@@ -18,11 +20,12 @@ class MarkItUpAdminWidget(forms.Widget):
...
@@ -18,11 +20,12 @@ class MarkItUpAdminWidget(forms.Widget):
def
render
(
self
,
name
,
value
,
attrs
=
None
):
def
render
(
self
,
name
,
value
,
attrs
=
None
):
if
value
is
None
:
value
=
''
if
value
is
None
:
value
=
''
final_attrs
=
self
.
build_attrs
(
attrs
,
name
=
name
)
final_attrs
=
self
.
build_attrs
_compat
(
attrs
,
name
=
name
)
return
mark_safe
(
u'<textarea
%
s>
%
s</textarea>'
%
(
flatatt
(
final_attrs
),
return
mark_safe
(
u'<textarea
%
s>
%
s</textarea>'
%
(
flatatt
(
final_attrs
),
conditional_escape
(
force_unicode
(
value
))))
conditional_escape
(
force_unicode
(
value
))))
class
MarkItUpWidget
(
forms
.
Widget
):
class
MarkItUpWidget
(
BuildAttrsCompat
,
forms
.
Widget
):
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
=
{
'class'
:
'markItUp'
,
default_attrs
=
{
'class'
:
'markItUp'
,
...
@@ -33,7 +36,7 @@ class MarkItUpWidget(forms.Widget):
...
@@ -33,7 +36,7 @@ class MarkItUpWidget(forms.Widget):
def
render
(
self
,
name
,
value
,
attrs
=
None
):
def
render
(
self
,
name
,
value
,
attrs
=
None
):
if
value
is
None
:
value
=
''
if
value
is
None
:
value
=
''
final_attrs
=
self
.
build_attrs
(
attrs
,
name
=
name
)
final_attrs
=
self
.
build_attrs
_compat
(
attrs
,
name
=
name
)
return
mark_safe
(
u'<div><textarea
%
s>
%
s</textarea></div>'
%
(
flatatt
(
final_attrs
),
return
mark_safe
(
u'<div><textarea
%
s>
%
s</textarea></div>'
%
(
flatatt
(
final_attrs
),
conditional_escape
(
force_unicode
(
value
))))
conditional_escape
(
force_unicode
(
value
))))
...
...
wiki/forms.py
View file @
62ececa8
...
@@ -16,6 +16,7 @@ from django.forms.widgets import HiddenInput
...
@@ -16,6 +16,7 @@ from django.forms.widgets import HiddenInput
from
wiki.core.plugins.base
import
PluginSettingsFormMixin
from
wiki.core.plugins.base
import
PluginSettingsFormMixin
from
django.contrib.auth.models
import
User
from
django.contrib.auth.models
import
User
from
wiki.core
import
permissions
from
wiki.core
import
permissions
from
wiki.core.compat
import
BuildAttrsCompat
class
SpamProtectionMixin
():
class
SpamProtectionMixin
():
...
@@ -100,7 +101,7 @@ class EditForm(forms.Form):
...
@@ -100,7 +101,7 @@ class EditForm(forms.Form):
return
cd
return
cd
class
SelectWidgetBootstrap
(
forms
.
Select
):
class
SelectWidgetBootstrap
(
BuildAttrsCompat
,
forms
.
Select
):
"""
"""
http://twitter.github.com/bootstrap/components.html#buttonDropdowns
http://twitter.github.com/bootstrap/components.html#buttonDropdowns
Needs bootstrap and jquery
Needs bootstrap and jquery
...
@@ -143,7 +144,7 @@ class SelectWidgetBootstrap(forms.Select):
...
@@ -143,7 +144,7 @@ class SelectWidgetBootstrap(forms.Select):
def
render
(
self
,
name
,
value
,
attrs
=
None
,
choices
=
()):
def
render
(
self
,
name
,
value
,
attrs
=
None
,
choices
=
()):
if
value
is
None
:
value
=
''
if
value
is
None
:
value
=
''
final_attrs
=
self
.
build_attrs
(
attrs
,
name
=
name
)
final_attrs
=
self
.
build_attrs
_compat
(
attrs
,
name
=
name
)
output
=
[
"""<div
%(attrs)
s>"""
output
=
[
"""<div
%(attrs)
s>"""
""" <button class="btn btn-group-label" type="button">
%(label)
s</button>"""
""" <button class="btn btn-group-label" type="button">
%(label)
s</button>"""
""" <button class="btn dropdown-toggle" type="button" data-toggle="dropdown">"""
""" <button class="btn dropdown-toggle" type="button" data-toggle="dropdown">"""
...
...
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