Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated urls.py and utils.py to get rid of deprecation warnings #62

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions .coveragerc
Original file line number Diff line number Diff line change
@@ -1,5 +1,2 @@
[report]
source=django_markdown

[run]
source=django_markdown
13 changes: 4 additions & 9 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,13 @@ language: python

python:
- "2.7"
- "3.4"

env:
- TOXENV=py27-d16
- TOXENV=py27-d17
- TOXENV=py34-d17
- TOXENV=d16
- TOXENV=d17
- TOXENV=cov

branches:
only:
- master
- develop

install: pip install --quiet --use-mirrors tox

script: tox
Expand All @@ -22,4 +17,4 @@ after_script:
- if [ $TOXENV == "cov" ]; then
pip install --quiet --use-mirrors coveralls;
coveralls;
fi
fi
7 changes: 4 additions & 3 deletions django_markdown/urls.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
""" Define preview URL. """

from django.conf.urls import patterns, url
from django.conf.urls import url

from .views import preview

urlpatterns = patterns(
'', url('preview/$', preview, name='django_markdown_preview'))
urlpatterns = [
url(r'^preview/$', preview, name='django_markdown_preview')
]
7 changes: 3 additions & 4 deletions django_markdown/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import markdown as markdown_module
from django.utils.encoding import force_text
from django.utils.safestring import mark_safe
from django.template import loader, Context
from django.template import loader

try:
import json as simplejson
Expand Down Expand Up @@ -41,7 +41,6 @@ def editor_js_initialization(selector, **extra_settings):
previewParserPath=reverse('django_markdown_preview'),
**settings.MARKDOWN_EDITOR_SETTINGS)
options.update(extra_settings)
ctx = Context(dict(
selector=selector, extra_settings=simplejson.dumps(options)),
autoescape=False)
ctx = dict(selector=selector,
extra_settings=mark_safe(simplejson.dumps(options)))
return INIT_TEMPLATE.render(ctx)
8 changes: 7 additions & 1 deletion django_markdown/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,14 @@ def preview(request):
from django.contrib.auth.views import redirect_to_login
return redirect_to_login(request.get_full_path())

# https://github.com/klen/django_markdown/pull/60
if request.POST:
content = request.POST.get('data', 'No content posted.')
else:
content = request.REQUEST.get('data', 'No content posted.')

return render(
request, settings.MARKDOWN_PREVIEW_TEMPLATE, dict(
content=request.REQUEST.get('data', 'No content posted'),
content=content,
css=settings.MARKDOWN_STYLE
))
14 changes: 4 additions & 10 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[tox]
envlist=py27-d16,py27-d17,py34-d17,cov
envlist=d16,d17,cov

[pylama]
skip=example/*
Expand All @@ -26,24 +26,18 @@ commands=py.test
deps =
pytest

[testenv:py27-d16]
[testenv:d16]
basepython = python2.7
deps =
django==1.6.7
{[testenv]deps}

[testenv:py27-d17]
[testenv:d17]
basepython = python2.7
deps =
django==1.7
{[testenv]deps}

[testenv:py34-d17]
basepython = python3.4
deps =
django==1.7
{[testenv]deps}

[testenv:cov]
deps =
coverage
Expand All @@ -52,4 +46,4 @@ deps =

commands =
coverage run -m py.test
coverage report
coverage report