Skip to content

Commit

Permalink
Merge branch 'master' into south
Browse files Browse the repository at this point in the history
  • Loading branch information
Natim authored Apr 10, 2020
2 parents f35328e + c14d510 commit 9b07b53
Show file tree
Hide file tree
Showing 8 changed files with 89 additions and 29 deletions.
21 changes: 21 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,32 @@ matrix:

- python: 3.5
env: TOX_ENV=py35-django20
- python: 3.5
env: TOX_ENV=py35-django21
- python: 3.5
env: TOX_ENV=py35-django22

- python: 3.6
env: TOX_ENV=flake8
- python: 3.6
env: TOX_ENV=py36-django20
- python: 3.6
env: TOX_ENV=py36-django21
- python: 3.6
env: TOX_ENV=py36-django22

- python: 3.7
dist: xenial
env: TOX_ENV=flake8
- python: 3.7
dist: xenial
env: TOX_ENV=py37-django20
- python: 3.7
dist: xenial
env: TOX_ENV=py37-django21
- python: 3.7
dist: xenial
env: TOX_ENV=py37-django22
addons:
apt:
packages:
Expand Down
10 changes: 8 additions & 2 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,16 @@ Changelog
This document describes changes between each past release.


2.8.0 (unreleased)
2.9.0 (unreleased)
==================

- Nothing changed yet.
- Upgrade test matrix to Python 3.7 and Django 2.1, 2.2


2.8.0 (2019-01-15)
==================

- Use the attrs set on instantiation as well as the attrs passed to render (#237)


2.7.0 (2017-12-19)
Expand Down
5 changes: 3 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def read_file(filename):

setup(
name="django-tinymce",
version='2.8.0.dev0',
version='2.9.0.dev0',
packages=find_packages(),
include_package_data=True,
author="Aljosa Mohorovic",
Expand All @@ -40,8 +40,9 @@ def read_file(filename):
'Programming Language :: Python :: 2',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
'Topic :: Software Development :: Libraries :: Application Frameworks',
'Topic :: Software Development :: Libraries :: Python Modules',
],
Expand Down
1 change: 1 addition & 0 deletions testtinymce/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
'OPTIONS': {
'context_processors': [
"django.contrib.auth.context_processors.auth",
"django.contrib.messages.context_processors.messages",
]
},
},
Expand Down
8 changes: 6 additions & 2 deletions tinymce/settings.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import os
from django.conf import settings
from django.contrib.staticfiles import finders
from django.core.exceptions import AppRegistryNotReady

DEFAULT_CONFIG = getattr(settings, 'TINYMCE_DEFAULT_CONFIG',
{'theme': "simple", 'relative_urls': False})
Expand All @@ -18,7 +18,11 @@

if 'staticfiles' in settings.INSTALLED_APPS or 'django.contrib.staticfiles' in settings.INSTALLED_APPS:
JS_URL = getattr(settings, 'TINYMCE_JS_URL', os.path.join(settings.STATIC_URL, 'tiny_mce/tiny_mce.js'))
JS_ROOT = getattr(settings, 'TINYMCE_JS_ROOT', finders.find('tiny_mce', all=False))
try:
from django.contrib.staticfiles import finders
JS_ROOT = getattr(settings, 'TINYMCE_JS_ROOT', finders.find('tiny_mce', all=False))
except AppRegistryNotReady:
JS_ROOT = getattr(settings, 'TINYMCE_JS_ROOT', os.path.join(settings.STATIC_ROOT, 'tiny_mce'))
else:
JS_URL = getattr(settings, 'TINYMCE_JS_URL', '{!s}js/tiny_mce/tiny_mce.js'.format(settings.MEDIA_URL))
JS_ROOT = getattr(settings, 'TINYMCE_JS_ROOT', os.path.join(settings.MEDIA_ROOT, 'js/tiny_mce'))
Expand Down
54 changes: 36 additions & 18 deletions tinymce/templates/tinymce/filebrowser.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,39 @@
function djangoFileBrowser(field_name, url, type, win) {
var url = "{{ fb_url }}?pop=2&type=" + type;
if (tinyMCE.majorVersion >= 4) {
var url = "{{ fb_url }}?pop=4&type=" + type;

tinyMCE.activeEditor.windowManager.open(
{
'file': url,
'width': 820,
'height': 500,
'resizable': "yes",
'scrollbars': "yes",
'inline': "no",
'close_previous': "no"
},
{
'window': win,
'input': field_name,
'editor_id': tinyMCE.selectedInstance.editorId
}
);
return false;
tinyMCE.activeEditor.windowManager.open(
{
'file': url,
'width': 820,
'height': 500,
},
{
'window': win,
'input': field_name,
}
);
return false;
}
else {
var url = "{{ fb_url }}?pop=2&type=" + type;

tinyMCE.activeEditor.windowManager.open(
{
'file': url,
'width': 820,
'height': 500,
'resizable': "yes",
'scrollbars': "yes",
'inline': "no",
'close_previous': "no"
},
{
'window': win,
'input': field_name,
'editor_id': tinyMCE.selectedInstance.editorId
}
);
return false;
}
}
11 changes: 9 additions & 2 deletions tinymce/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@
devnull = open(os.devnull, 'w')


def compress_whitespace(s):
# replace whitespace runs with a single space
return ' '.join(s.split())


class TestViews(TestCase):

@patch('tinymce.views.enchant')
Expand Down Expand Up @@ -115,6 +120,8 @@ def test_render_to_image_list(self):
@patch('tinymce.views.reverse', return_value='/filebrowser')
def test_filebrowser(self, reverse_mock):
response = self.client.get('/tinymce/filebrowser/')
response_ok = b'function djangoFileBrowser(field_name, url, type, win) {\n var url = "http://testserver/filebrowser?pop=2&type=" + type;\n\n tinyMCE.activeEditor.windowManager.open(\n {\n \'file\': url,\n \'width\': 820,\n \'height\': 500,\n \'resizable\': "yes",\n \'scrollbars\': "yes",\n \'inline\': "no",\n \'close_previous\': "no"\n },\n {\n \'window\': win,\n \'input\': field_name,\n \'editor_id\': tinyMCE.selectedInstance.editorId\n }\n );\n return false;\n}\n'
with open('tinymce/templates/tinymce/filebrowser.js') as f:
response_ok = f.read()
response_ok = response_ok.replace('{{ fb_url }}', 'http://testserver/filebrowser')
self.assertEqual(200, response.status_code)
self.assertEqual(response_ok, response.content)
self.assertEqual(compress_whitespace(response_ok), compress_whitespace(response.content.decode()))
8 changes: 5 additions & 3 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
[tox]
envlist =
py27-django{111},
py34-django{111},
py35-django{2},
py36-django{2},
py35-django{20,21,22},
py36-django{20,21,22},
py37-django{20,21,22},
flake8

[testenv]
deps =
django111: Django>=1.11,<2.0
django20: Django>=2.0,<2.1
django21: Django>=2.1,<2.2
django22: Django>=2.2,<3.0
coverage
mock
pyenchant
Expand Down

0 comments on commit 9b07b53

Please sign in to comment.