diff --git a/README.rst b/README.rst index b34289a..73e0bf3 100644 --- a/README.rst +++ b/README.rst @@ -592,4 +592,4 @@ Screenshots Compatibility ------------- * Python: 2.7, pypy, 3.4, 3.5, 3.6, pypy3 -* Django: 1.4, 1.5, 1.6, 1.7, 1.8, 1.9, 1.10 +* Django: 1.4, 1.5, 1.6, 1.7, 1.8, 1.9, 1.10, 1.11 diff --git a/dbmail/__init__.py b/dbmail/__init__.py index c95d3be..da91b0a 100644 --- a/dbmail/__init__.py +++ b/dbmail/__init__.py @@ -4,7 +4,7 @@ import sys -VERSION = (2, 3, 18) +VERSION = (2, 3, 18, 2) default_app_config = 'dbmail.apps.DBMailConfig' diff --git a/dbmail/management/commands/dbmail_test_send.py b/dbmail/management/commands/dbmail_test_send.py index aed8a24..463aea3 100644 --- a/dbmail/management/commands/dbmail_test_send.py +++ b/dbmail/management/commands/dbmail_test_send.py @@ -19,16 +19,15 @@ def send_test_msg(pk, email, user=None, **kwargs): class Command(BaseCommand): - option_list = BaseCommand.option_list + ( - optparse.make_option('--email', dest='email', help='Recipients'), - optparse.make_option('--pk', dest='pk', help='DBMail template id'), - optparse.make_option('--without-celery', action='store_true', - default=False, dest='celery', - help='Send direct message'), - optparse.make_option('--provider', dest='provider', help='Provider'), - optparse.make_option( - '--backend', dest='backend', help='Backend', default='mail'), - ) + def add_arguments(self, parser): + parser.add_argument('--email', default='localhost', help='Recipients') + parser.add_argument('--pk', default=1, help='DBMail template id') + parser.add_argument('--without-celery', + action='store_true', + default=False, dest='celery', + help='Send direct message') + parser.add_argument('--provider', help='Provider') + parser.add_argument('--backend', help='Backend') @staticmethod def get_kwargs(options): diff --git a/dbmail/providers/apple/apns.py b/dbmail/providers/apple/apns.py index a0545b8..80e13e7 100644 --- a/dbmail/providers/apple/apns.py +++ b/dbmail/providers/apple/apns.py @@ -55,6 +55,7 @@ def send(token_hex, message, **kwargs): token_length_bin = pack('>H', len(token)) payload_length_bin = pack('>H', len(payload)) zero_byte = bytes('\0', 'utf-8') if PY3 is True else '\0' + payload = bytes(payload, 'utf-8') if PY3 is True else payload notification = ( zero_byte + token_length_bin + token + payload_length_bin + payload) diff --git a/dbmail/providers/boxcar/push.py b/dbmail/providers/boxcar/push.py index c69c84d..fd1c740 100644 --- a/dbmail/providers/boxcar/push.py +++ b/dbmail/providers/boxcar/push.py @@ -1,7 +1,12 @@ # -*- encoding: utf-8 -*- -from httplib import HTTPSConnection -from urllib import urlencode + +try: + from httplib import HTTPSConnection + from urllib import urlencode +except ImportError: + from http.client import HTTPSConnection + from urllib.parse import urlencode from dbmail.providers.prowl.push import from_unicode from dbmail import get_version diff --git a/dbmail/providers/centrifugo/push.py b/dbmail/providers/centrifugo/push.py index 13c56a7..8fd2e64 100644 --- a/dbmail/providers/centrifugo/push.py +++ b/dbmail/providers/centrifugo/push.py @@ -1,10 +1,16 @@ # -*- encoding: utf-8 -*- +try: + from urllib2 import urlopen, Request + from urllib import urlencode +except ImportError: + from urllib.request import urlopen, Request + from urllib.parse import urlencode + import hmac from hashlib import sha256 from json import dumps -from urllib import urlencode -from urllib2 import urlopen, Request + from django.conf import settings diff --git a/dbmail/providers/google/android.py b/dbmail/providers/google/android.py index 48b1d54..801d893 100644 --- a/dbmail/providers/google/android.py +++ b/dbmail/providers/google/android.py @@ -1,9 +1,13 @@ # -*- encoding: utf-8 -*- -from httplib import HTTPSConnection -from json import dumps, loads -from urlparse import urlparse +try: + from httplib import HTTPSConnection + from urlparse import urlparse +except ImportError: + from http.client import HTTPSConnection + from urllib.parse import urlparse +from json import dumps, loads from django.conf import settings diff --git a/dbmail/providers/http/push.py b/dbmail/providers/http/push.py index f13750e..436d548 100644 --- a/dbmail/providers/http/push.py +++ b/dbmail/providers/http/push.py @@ -1,7 +1,12 @@ # -*- encoding: utf-8 -*- -from httplib import HTTPConnection, HTTPSConnection -from urlparse import urlparse +try: + from httplib import HTTPConnection, HTTPSConnection + from urlparse import urlparse +except ImportError: + from http.client import HTTPSConnection, HTTPConnection + from urllib.parse import urlparse + from json import dumps from django.conf import settings diff --git a/dbmail/providers/iqsms/sms.py b/dbmail/providers/iqsms/sms.py index 953f419..b4248df 100644 --- a/dbmail/providers/iqsms/sms.py +++ b/dbmail/providers/iqsms/sms.py @@ -1,7 +1,12 @@ # -*- encoding: utf-8 -*- -from httplib import HTTPConnection -from urllib import urlencode +try: + from httplib import HTTPConnection + from urllib import urlencode +except ImportError: + from http.client import HTTPConnection + from urllib.parse import urlencode + from base64 import b64encode from django.conf import settings diff --git a/dbmail/providers/parse_com/push.py b/dbmail/providers/parse_com/push.py index 6e92e60..0db4b9d 100644 --- a/dbmail/providers/parse_com/push.py +++ b/dbmail/providers/parse_com/push.py @@ -1,6 +1,10 @@ # -*- encoding: utf-8 -*- -from httplib import HTTPSConnection +try: + from httplib import HTTPSConnection +except ImportError: + from http.client import HTTPSConnection + from json import dumps, loads from django.conf import settings diff --git a/dbmail/providers/pushover/push.py b/dbmail/providers/pushover/push.py index db8defe..397473a 100644 --- a/dbmail/providers/pushover/push.py +++ b/dbmail/providers/pushover/push.py @@ -1,7 +1,12 @@ # -*- encoding: utf-8 -*- -from httplib import HTTPSConnection -from urllib import urlencode +try: + from httplib import HTTPSConnection + from urllib import urlencode +except ImportError: + from http.client import HTTPSConnection + from urllib.parse import urlencode + from json import loads from django.conf import settings diff --git a/dbmail/providers/slack/push.py b/dbmail/providers/slack/push.py index b1e0cfa..ed3fd43 100644 --- a/dbmail/providers/slack/push.py +++ b/dbmail/providers/slack/push.py @@ -1,8 +1,13 @@ # -*- encoding: utf-8 -*- -from httplib import HTTPSConnection -from urllib import urlencode -from urlparse import urlparse +try: + from httplib import HTTPSConnection + from urlparse import urlparse + from urllib import urlencode +except ImportError: + from http.client import HTTPSConnection + from urllib.parse import urlparse, urlencode + from json import dumps from django.conf import settings diff --git a/dbmail/providers/twilio/sms.py b/dbmail/providers/twilio/sms.py index d542f59..936e410 100644 --- a/dbmail/providers/twilio/sms.py +++ b/dbmail/providers/twilio/sms.py @@ -1,7 +1,12 @@ # -*- coding: utf-8 -*- -from httplib import HTTPSConnection -from urllib import urlencode +try: + from httplib import HTTPSConnection + from urllib import urlencode +except ImportError: + from http.client import HTTPSConnection + from urllib.parse import urlencode + from base64 import b64encode from json import loads diff --git a/dbmail/static/dbmail/admin/js/dbmail.js b/dbmail/static/dbmail/admin/js/dbmail.js index fef1d18..465bdb4 100644 --- a/dbmail/static/dbmail/admin/js/dbmail.js +++ b/dbmail/static/dbmail/admin/js/dbmail.js @@ -2,8 +2,8 @@ $(document).ready(function () { if (document.location.href.indexOf('/add/') == -1) { if ($('#searchbar').length == 0 && $('#grp-changelist-search').length == 0) { - var test_button = '
  • Test template
  • '; - var browse_button = '
  • Browse vars
  • '; + var test_button = '
  • Test template
  • '; + var browse_button = '
  • Browse vars
  • '; if ($('.object-tools').length == 1) { $('.object-tools').append(test_button); $('.object-tools').append(browse_button); @@ -12,14 +12,17 @@ $('.grp-object-tools').append(test_button); $('.grp-object-tools').append(browse_button); } - ; } - ; } - ; + + test_app_template = function () { + location.href = document.location.href.replace('change/', '') + 'sendmail/'; + }; + show_apps_dialog = function () { + var appUrl = document.location.href.replace('change/', '') + 'sendmail/apps/'; $( - '
    ' + '
    ' ).dialog({ modal: true, draggable: true, @@ -32,7 +35,7 @@ at: "center", of: window } - ) + ).show() ; } ; diff --git a/demo/demo/settings.py b/demo/demo/settings.py index 6303763..d7c312f 100644 --- a/demo/demo/settings.py +++ b/demo/demo/settings.py @@ -8,7 +8,6 @@ PROJECT_ROOT = os.path.normpath(os.path.dirname(__file__)) DEBUG = True -TEMPLATE_DEBUG = DEBUG ADMINS = ( ('root', 'root@local.host'), @@ -55,36 +54,40 @@ SECRET_KEY = 'f969z_xc+^g*^gmt9oe7@og%kxd)54b!c!do)d7f2w2**f6%c0' -TEMPLATE_LOADERS = ( - 'django.template.loaders.filesystem.Loader', - 'django.template.loaders.app_directories.Loader', - 'django.template.loaders.eggs.Loader', -) - -TEMPLATE_CONTEXT_PROCESSORS = ( - 'django.contrib.auth.context_processors.auth', - 'django.core.context_processors.request', - 'django.core.context_processors.static', - "django.contrib.messages.context_processors.messages", - "django.core.context_processors.i18n", -) +TEMPLATES = [{ + 'BACKEND': 'django.template.backends.django.DjangoTemplates', + 'DIRS': [], + 'APP_DIRS': False, + 'OPTIONS': { + 'context_processors': [ + 'django.template.context_processors.debug', + 'django.template.context_processors.request', + 'django.contrib.auth.context_processors.auth', + 'django.contrib.messages.context_processors.messages', + + ], + 'loaders': [ + 'django.template.loaders.filesystem.Loader', + 'django.template.loaders.app_directories.Loader', + 'django.template.loaders.eggs.Loader', + ], + }, +}] MIDDLEWARE_CLASSES = ( - 'django.middleware.common.CommonMiddleware', + 'django.middleware.security.SecurityMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', + 'django.middleware.common.CommonMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', + 'django.middleware.clickjacking.XFrameOptionsMiddleware', ) ROOT_URLCONF = 'demo.urls' WSGI_APPLICATION = 'demo.wsgi.application' -TEMPLATE_DIRS = ( - os.path.join(PROJECT_ROOT, 'templates'), -) - INSTALLED_APPS = [] if 'test' not in sys.argv: @@ -96,13 +99,13 @@ ] INSTALLED_APPS += [ + 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.sites', 'django.contrib.messages', 'django.contrib.staticfiles', - 'django.contrib.admin', 'dbmail', ] @@ -110,7 +113,6 @@ if 'test' not in sys.argv: INSTALLED_APPS += [ 'django_extensions', - 'admin_jqueryui', 'reversion', 'reversion_compare', 'djcelery', @@ -119,6 +121,9 @@ 'south', ] + if 'grappelli' not in INSTALLED_APPS: + INSTALLED_APPS += ['admin_jqueryui'] + if django.VERSION >= (1, 7): DJ17_NOT_SUPPORTED_APPS = ['south', 'tinymce'] for app in DJ17_NOT_SUPPORTED_APPS: @@ -147,7 +152,7 @@ 'console': { 'level': 'DEBUG', 'class': 'logging.StreamHandler', - #'formatter': 'verbose' + # 'formatter': 'verbose' } }, 'loggers': { diff --git a/demo/demo/urls.py b/demo/demo/urls.py index 145b109..c9330b2 100644 --- a/demo/demo/urls.py +++ b/demo/demo/urls.py @@ -5,17 +5,17 @@ from django.contrib import admin from django.conf import settings -admin.autodiscover() +import demo.views urlpatterns = [ - url(r'^admin/', include(admin.site.urls)), + url(r'^admin/', admin.site.urls), # url(r'^rosetta/', include('rosetta.urls')), url(r'^grappelli/', include('grappelli.urls')), url(r'^dbmail/', include('dbmail.urls')), - url('^browser_notification/$', "demo.views.browser_notification"), - url('^web-push/$', "demo.views.web_push_notification"), + url('^browser_notification/$', demo.views.browser_notification), + url('^web-push/$', demo.views.web_push_notification), url(r'^ckeditor/', include('ckeditor_uploader.urls')), ] + staticfiles_urlpatterns() diff --git a/demo/requirements.txt b/demo/requirements.txt index ebd3a3d..f6ae8e3 100644 --- a/demo/requirements.txt +++ b/demo/requirements.txt @@ -1,33 +1,32 @@ -Django>=1.8,<1.9 +Django>=1.11,<1.12 django-bootstrap-static==2.3.2 -django-debug-toolbar==1.6 -django-extensions==1.7.6 -django-rosetta==0.7.12 +django-debug-toolbar==1.7 +django-extensions==1.7.8 +django-rosetta==0.7.13 django-redis==4.7.0 django-redis-cache==1.7.1 -django-celery==3.1.17 +django-celery==3.2.1 celery>=3.1,<4 # MySQL-python>=1.2.5 -Werkzeug>=0.11.15 -ipython>=5.1.0 -tornado>=4.4.2 +Werkzeug>=0.12.1 +ipython>=5.3.0 +tornado>=4.5 coverage>=4.3.4 pyzmq>=16.0.2 -Jinja2>=2.9.4 -flake8>=3.2.1 -Sphinx>=1.5.2 +Jinja2>=2.9.6 +flake8>=3.3.0 +Sphinx>=1.5.5 redis>=2.10.5 -wheel>=0.24.0 +wheel>=0.29.0 -django-grappelli==2.8.3 -django-suit==0.2.23 -django-ckeditor==5.2.1 +django-grappelli==2.9.1 +django-suit==0.2.25 +django-ckeditor==5.2.2 django-reversion==2.0.8 -django-reversion-compare==0.7.2 +django-reversion-compare==0.7.4 diff-match-patch==20121119 -# premailer==3.0.1 -pytz>=2016.10 +pytz>=2017.2 django-sslserver==0.19 -e git+https://github.com/hint/django-admin-jqueryui.git#egg=django-admin-jqueryui diff --git a/docs/installation.rst b/docs/installation.rst index 74385c0..c051801 100644 --- a/docs/installation.rst +++ b/docs/installation.rst @@ -3,12 +3,14 @@ Installation Compatibility ------------- -* Python: 2.7, pypy, 3.4, 3.5, pypy3 -* Django: 1.4, 1.5, 1.6, 1.7, 1.8, 1.9, 1.10 + +* Python: 2.7, pypy, 3.4, 3.5, 3.6, pypy3 +* Django: 1.4, 1.5, 1.6, 1.7, 1.8, 1.9, 1.10, 1.11 Installation ------------ + Recommended way to install is via pip: .. code-block:: bash @@ -24,15 +26,17 @@ Recommended way to install is via pip: Settings configuration ---------------------- -Add ``dbmail`` to ``INSTALLED_APPS`` in the settings.py: +Add ``dbmail`` and ``django.contrib.sites`` to ``INSTALLED_APPS`` in the settings.py: .. code-block:: python INSTALLED_APPS = ( ... + 'django.contrib.sites', 'dbmail', ... ) + SITE_ID = 1 DB initialization