Skip to content

Commit

Permalink
update version
Browse files Browse the repository at this point in the history
  • Loading branch information
pylixm committed Dec 19, 2019
1 parent 8e8316d commit baf9f86
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 21 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
# django-mdeditor


[![ENV](https://img.shields.io/badge/release-v0.1.16-blue.svg)](https://github.com/pylixm/django-mdeditor)
[![ENV](https://img.shields.io/badge/中文-v0.1.16-blue.svg)](./README_CN.md)
[![ENV](https://img.shields.io/badge/Gitter-v0.1.16-blue.svg)](https://gitter.im/django-mdeditor/Lobby)
[![ENV](https://img.shields.io/badge/release-v0.1.17-blue.svg)](https://github.com/pylixm/django-mdeditor)
[![ENV](https://img.shields.io/badge/中文-v0.1.17-blue.svg)](./README_CN.md)
[![ENV](https://img.shields.io/badge/Gitter-v0.1.17-blue.svg)](https://gitter.im/django-mdeditor/Lobby)
[![ENV](https://img.shields.io/badge/python-2.x/3.x-green.svg)](https://github.com/pylixm/django-mdeditor)
[![ENV](https://img.shields.io/badge/django-1.7+-green.svg)](https://github.com/pylixm/django-mdeditor)
[![LICENSE](https://img.shields.io/badge/license-GPL3.0-green.svg)](https://github.com/pylixm/django-mdeditor/master/LICENSE.txt)
Expand Down
6 changes: 3 additions & 3 deletions README_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
# django-mdeditor


[![ENV](https://img.shields.io/badge/release-v0.1.16-blue.svg)](https://github.com/pylixm/django-mdeditor)
[![ENV](https://img.shields.io/badge/中文文档-v0.1.16-blue.svg)](./README_CN.md)
[![ENV](https://img.shields.io/badge/gitter-v0.1.16-blue.svg)](https://gitter.im/django-mdeditor/Lobby)
[![ENV](https://img.shields.io/badge/release-v0.1.17-blue.svg)](https://github.com/pylixm/django-mdeditor)
[![ENV](https://img.shields.io/badge/中文文档-v0.1.17-blue.svg)](./README_CN.md)
[![ENV](https://img.shields.io/badge/gitter-v0.1.17-blue.svg)](https://gitter.im/django-mdeditor/Lobby)
[![ENV](https://img.shields.io/badge/python-2.x/3.x-green.svg)](https://github.com/pylixm/django-mdeditor)
[![ENV](https://img.shields.io/badge/django-1.7+-green.svg)](https://github.com/pylixm/django-mdeditor)
[![LICENSE](https://img.shields.io/badge/license-GPL3.0-green.svg)](https://github.com/pylixm/django-mdeditor/master/LICENSE.txt)
Expand Down
Binary file modified db.sqlite3
Binary file not shown.
25 changes: 12 additions & 13 deletions mdeditor/views.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
# -*- coding:utf-8 -*-
import os
import datetime
import json

from django.views import generic
from django.conf import settings
from django.http import HttpResponse
from django.http import JsonResponse
from django.views.decorators.csrf import csrf_exempt
from django.utils.decorators import method_decorator
from .configs import MDConfig
Expand All @@ -27,35 +26,35 @@ def post(self, request, *args, **kwargs):

# image none check
if not upload_image:
return HttpResponse(json.dumps({
return JsonResponse({
'success': 0,
'message': "未获取到要上传的图片",
'url': ""
}))
})

# image format check
file_name_list = upload_image.name.split('.')
file_extension = file_name_list.pop(-1)
file_name = '.'.join(file_name_list)
if file_extension not in MDEDITOR_CONFIGS['upload_image_formats']:
return HttpResponse(json.dumps({
return JsonResponse({
'success': 0,
'message': "上传图片格式错误,允许上传图片格式为:%s" % ','.join(
MDEDITOR_CONFIGS['upload_image_formats']),
'url': ""
}))
})

# image floder check
file_path = os.path.join(media_root, MDEDITOR_CONFIGS['image_folder'])
if not os.path.exists(file_path):
try:
os.makedirs(file_path)
except Exception as err:
return HttpResponse(json.dumps({
return JsonResponse({
'success': 0,
'message': "上传失败:%s" % str(err),
'url': ""
}))
})

# save image
file_full_name = '%s_%s.%s' % (file_name,
Expand All @@ -65,8 +64,8 @@ def post(self, request, *args, **kwargs):
for chunk in upload_image.chunks():
file.write(chunk)

return HttpResponse(json.dumps({'success': 1,
'message': "上传成功!",
'url': '{0}{1}/{2}'.format(settings.MEDIA_URL,
MDEDITOR_CONFIGS['image_folder'],
file_full_name)}))
return JsonResponse({'success': 1,
'message': "上传成功!",
'url': os.path.join(settings.MEDIA_URL,
MDEDITOR_CONFIGS['image_folder'],
file_full_name)})
2 changes: 1 addition & 1 deletion mdeditor_demo_app/templates/forms.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{% load staticfiles %}
{% load static %}
<!DOCTYPE html>
<html lang="zh">
<head>
Expand Down
4 changes: 3 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

setup(
name='django-mdeditor',
version='0.1.16',
version='0.1.17',
packages=find_packages(exclude=['mdeditor_demo', 'mdeditor_demo_app.*', 'mdeditor_demo_app']),
include_package_data=True,
license='GPL-3.0 License',
Expand All @@ -30,6 +30,7 @@
'Framework :: Django :: 2.0',
'Framework :: Django :: 2.1',
'Framework :: Django :: 2.2',
'Framework :: Django :: 3.0',
'Intended Audience :: Developers',
'License :: OSI Approved :: GNU General Public License v3 (GPLv3)',
'Operating System :: OS Independent',
Expand All @@ -40,6 +41,7 @@
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
'Topic :: Internet :: WWW/HTTP',
'Topic :: Internet :: WWW/HTTP :: Dynamic Content'
]
Expand Down

0 comments on commit baf9f86

Please sign in to comment.