From 55b823aff7f3a9aa5de024781f07f17d51aacd79 Mon Sep 17 00:00:00 2001 From: gotlium Date: Thu, 20 Apr 2017 16:51:00 +0500 Subject: [PATCH 1/8] update compatibly --- README.rst | 2 +- docs/installation.rst | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) 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/docs/installation.rst b/docs/installation.rst index 74385c0..2837a86 100644 --- a/docs/installation.rst +++ b/docs/installation.rst @@ -3,8 +3,8 @@ 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 From c5b1c1ff7a60aa7d449a0fa6fd740f39b456643e Mon Sep 17 00:00:00 2001 From: gotlium Date: Thu, 20 Apr 2017 17:43:16 +0500 Subject: [PATCH 2/8] demo: django 1.11 --- demo/demo/settings.py | 45 +++++++++++++++++++++++-------------------- demo/demo/urls.py | 9 +++++---- demo/requirements.txt | 35 ++++++++++++++++----------------- 3 files changed, 46 insertions(+), 43 deletions(-) diff --git a/demo/demo/settings.py b/demo/demo/settings.py index 6303763..c7cc18d 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', ] @@ -147,7 +150,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 68a7688..c9330b2 100644 --- a/demo/demo/urls.py +++ b/demo/demo/urls.py @@ -5,16 +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 071249e..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.7.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 From db73cdc6ef8c43dc5c0879add98fb45e57141202 Mon Sep 17 00:00:00 2001 From: gotlium Date: Thu, 20 Apr 2017 18:41:44 +0500 Subject: [PATCH 3/8] fix sendmail args --- .../management/commands/dbmail_test_send.py | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) 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): From 6166dc1a7c32112a9991a042bf41dd5c72c6b4c6 Mon Sep 17 00:00:00 2001 From: gotlium Date: Thu, 20 Apr 2017 18:44:14 +0500 Subject: [PATCH 4/8] #76 fix browse vars --- dbmail/static/dbmail/admin/js/dbmail.js | 17 ++++++++++------- demo/demo/settings.py | 4 +++- 2 files changed, 13 insertions(+), 8 deletions(-) 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 c7cc18d..d7c312f 100644 --- a/demo/demo/settings.py +++ b/demo/demo/settings.py @@ -113,7 +113,6 @@ if 'test' not in sys.argv: INSTALLED_APPS += [ 'django_extensions', - 'admin_jqueryui', 'reversion', 'reversion_compare', 'djcelery', @@ -122,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: From 8ecc62bb93851f5888a7864ff45912e52ab2fd06 Mon Sep 17 00:00:00 2001 From: gotlium Date: Fri, 21 Jul 2017 23:14:38 +0500 Subject: [PATCH 5/8] apns fix --- dbmail/providers/apple/apns.py | 1 + 1 file changed, 1 insertion(+) 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) From 5c3f9be9857e4fbfe6ac408201aefeba0b9b31c8 Mon Sep 17 00:00:00 2001 From: gotlium Date: Sun, 23 Jul 2017 00:36:40 +0500 Subject: [PATCH 6/8] gcm fix --- dbmail/providers/google/android.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/dbmail/providers/google/android.py b/dbmail/providers/google/android.py index 48b1d54..ae507b5 100644 --- a/dbmail/providers/google/android.py +++ b/dbmail/providers/google/android.py @@ -1,8 +1,16 @@ # -*- 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 urlparse import urlparse + +try: + from urlparse import urlparse +except ImportError: + from urllib.parse import urlparse from django.conf import settings From ce894a4e114408367e6baa5e3745e042ca076d11 Mon Sep 17 00:00:00 2001 From: gotlium Date: Sun, 23 Jul 2017 11:33:51 +0500 Subject: [PATCH 7/8] #90 docs update --- docs/installation.rst | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/docs/installation.rst b/docs/installation.rst index 2837a86..c051801 100644 --- a/docs/installation.rst +++ b/docs/installation.rst @@ -3,12 +3,14 @@ Installation 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, 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 From fcdf8703dc4cc668b17b8bb5c6d7e48c28bf1391 Mon Sep 17 00:00:00 2001 From: gotlium Date: Sun, 23 Jul 2017 12:18:06 +0500 Subject: [PATCH 8/8] providers fixes --- dbmail/providers/boxcar/push.py | 9 +++++++-- dbmail/providers/centrifugo/push.py | 10 ++++++++-- dbmail/providers/google/android.py | 8 ++------ dbmail/providers/http/push.py | 9 +++++++-- dbmail/providers/iqsms/sms.py | 9 +++++++-- dbmail/providers/parse_com/push.py | 6 +++++- dbmail/providers/pushover/push.py | 9 +++++++-- dbmail/providers/slack/push.py | 11 ++++++++--- dbmail/providers/twilio/sms.py | 9 +++++++-- 9 files changed, 58 insertions(+), 22 deletions(-) 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 ae507b5..801d893 100644 --- a/dbmail/providers/google/android.py +++ b/dbmail/providers/google/android.py @@ -2,16 +2,12 @@ try: from httplib import HTTPSConnection -except ImportError: - from http.client import HTTPSConnection - -from json import dumps, loads - -try: 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