Skip to content

Commit

Permalink
Merge branch 'pincoin-dj200'
Browse files Browse the repository at this point in the history
  • Loading branch information
Park Hyunwoo committed Dec 11, 2017
2 parents 4108b4b + d135a01 commit 7c3e3b6
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 14 deletions.
9 changes: 8 additions & 1 deletion django_summernote/test_settings.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,25 @@
import django

DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': 'django_summernote.db',
}
}

MIDDLEWARE_CLASSES = (
__MIDDLEWARE__ = (
'django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.middleware.locale.LocaleMiddleware',
)

if django.VERSION <= (1, 9):
MIDDLEWARE_CLASSES = __MIDDLEWARE__
else:
MIDDLEWARE = __MIDDLEWARE__

STATIC_URL = '/'
MEDIA_ROOT = 'test_media'

Expand Down
2 changes: 1 addition & 1 deletion django_summernote/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ class SimpleParentModel(models.Model):

class SimpleModel2(models.Model):
foobar = models.TextField()
parent = models.ForeignKey(SimpleParentModel)
parent = models.ForeignKey(SimpleParentModel, on_delete=models.CASCADE)

class SimpleModelInline(SummernoteInlineModelAdmin):
model = SimpleModel2
Expand Down
21 changes: 13 additions & 8 deletions django_summernote/views.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import django
from django.contrib.staticfiles.templatetags.staticfiles import static
from django.http import HttpResponse, JsonResponse
from django.shortcuts import render
Expand All @@ -12,14 +13,14 @@ def editor(request, id):
static_default_js = tuple(static(x) for x in summernote_config['default_js'])

css = summernote_config['base_css'] \
+ (summernote_config['codemirror_css'] if 'codemirror' in summernote_config else ()) \
+ static_default_css \
+ summernote_config['css']
+ (summernote_config['codemirror_css'] if 'codemirror' in summernote_config else ()) \
+ static_default_css \
+ summernote_config['css']

js = summernote_config['base_js'] \
+ (summernote_config['codemirror_js'] if 'codemirror' in summernote_config else ()) \
+ static_default_js \
+ summernote_config['js']
+ (summernote_config['codemirror_js'] if 'codemirror' in summernote_config else ()) \
+ static_default_js \
+ summernote_config['js']

return render(
request,
Expand All @@ -42,8 +43,12 @@ def upload_attachment(request):
'message': _('Only POST method is allowed'),
}, status=400)

if summernote_config['attachment_require_authentication']:
if not request.user.is_authenticated():
authenticated = \
request.user.is_authenticated if django.VERSION >= (1, 10) \
else request.user.is_authenticated()

if summernote_config['attachment_require_authentication'] and \
not authenticated:
return JsonResponse({
'status': 'false',
'message': _('Only authenticated users are allowed'),
Expand Down
8 changes: 4 additions & 4 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
[tox]
envlist =
{py27,py34,py35}-{dj108,dj109,dj110,dj111},
{py36}-{dj111}
{py27}-{dj108,dj111},
{py34,py35}-{dj108,dj111,dj200},
{py36}-{dj111,dj200}

[tox:travis]
2.7 = py27
Expand All @@ -19,9 +20,8 @@ basepython =
deps =
coverage
dj108: Django<1.9
dj109: Django<1.10
dj110: Django<1.11
dj111: Django<1.12
dj200: Django<2.1
djmaster: https://github.com/django/django/archive/master.tar.gz

commands = coverage run -a setup.py test

0 comments on commit 7c3e3b6

Please sign in to comment.