~netlandish/django-wiki

9c38174846c293c47bc669c20aa8e2e958deacfd — Benjamin Bach 6 years ago 31a6c87 + 5909b5b
Merge pull request #779 from atombrella/utils_json

Simplified wiki.core.utils.object_to_json_response.
4 files changed, 8 insertions(+), 39 deletions(-)

M .travis.yml
M setup.py
M src/wiki/core/utils.py
M tox.ini
M .travis.yml => .travis.yml +0 -10
@@ 5,16 5,12 @@ language: python
cache: pip

python:
  - "2.7"
  - "3.4"
  - "3.5"
  - "3.6"

env:
  - LINT="yes"
  - DJANGO="1.8"
  - DJANGO="1.9"
  - DJANGO="1.10"
  - DJANGO="1.11"

matrix:


@@ 25,12 21,6 @@ matrix:
    env: LINT="yes"
  - python: "3.6"
    env: LINT="yes"
  - python: "3.6"
    env: DJANGO="1.8"
  - python: "3.6"
    env: DJANGO="1.9"
  - python: "3.6"
    env: DJANGO="1.10"

addons:
  apt:

M setup.py => setup.py +2 -13
@@ 1,6 1,5 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import print_function

import os
import sys


@@ 24,17 23,8 @@ def get_path(fname):
    return os.path.join(os.path.dirname(__file__), fname)


def read_file(fname):
    """
    Read file and decode in py2k
    """
    if sys.version_info < (3,):
        return open(fname).read().decode("utf-8")
    return open(fname).read()


requirements = [
    "Django>=1.8,<2.0",
    "Django>=1.11,<2.0",
    "bleach>=1.5,<2",
    "Pillow",
    "django-nyt>=1.0,<1.1",


@@ 57,7 47,7 @@ setup(
    packages=find_packages('src'),
    package_dir={'': 'src'},
    py_modules=[os.path.splitext(os.path.basename(path))[0] for path in glob('src/*.py')],
    long_description=read_file('README.rst'),
    long_description=open('README.rst').read(),
    zip_safe=False,
    install_requires=requirements,
    classifiers=[


@@ 68,7 58,6 @@ setup(
        'Intended Audience :: Developers',
        'Operating System :: OS Independent',
        'Programming Language :: Python',
        'Programming Language :: Python :: 2.7',
        'Programming Language :: Python :: 3.4',
        'Programming Language :: Python :: 3.5',
        'Programming Language :: Python :: 3.6',

M src/wiki/core/utils.py => src/wiki/core/utils.py +4 -6
@@ 1,10 1,9 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals

import json
from importlib import import_module

from django.http.response import HttpResponse
from django.http.response import JsonResponse


def get_class_from_str(class_path):


@@ 20,7 19,6 @@ def object_to_json_response(obj, status=200):
    Given an object, returns an HttpResponse object with a JSON serialized
    version of that object
    """
    data = json.dumps(obj, ensure_ascii=False)
    response = HttpResponse(content_type='application/json', status=status)
    response.write(data)
    return response
    return JsonResponse(
        data=obj, status=status, safe=False, json_dumps_params={'ensure_ascii': False},
    )

M tox.ini => tox.ini +2 -10
@@ 1,20 1,16 @@
[tox]
# Ensure you add to .travis.yml if you add here, using `tox -l`
envlist = {py27,py34,py35,py36}-django{18,19,110,111},lint
envlist = {py34,py35,py36}-django{111},lint


[travis]
python =
  2.7: py27,lint
  3.4: py34
  3.5: py35
  3.6: py36

[travis:env]
DJANGO =
  1.8: django18
  1.9: django19
  1.10: django110
  1.11: django111
LINT =
  yes: lint


@@ 48,9 44,6 @@ deps =
  Markdown==2.6.7
  django_nyt==1.0
  bleach==1.5.0
  django18: Django==1.8.2
  django19: Django==1.9
  django110: Django==1.10.2
  django111: Django==1.11
  django-mptt==0.8.6
  django-sekizai==0.10.0


@@ 60,14 53,13 @@ deps =
  WebTest==2.0.28

basepython =
  py27: python2.7
  py34: python3.4
  py35: python3.5
  py36: python3.6


[testenv:lint]
basepython = python2.7
basepython = python3.4
deps = flake8
commands =
  flake8 src/wiki