Skip to content

Commit

Permalink
dev2m
Browse files Browse the repository at this point in the history
  • Loading branch information
gotlium committed Aug 1, 2017
2 parents 28deb3d + fcdf870 commit cf57815
Show file tree
Hide file tree
Showing 18 changed files with 140 additions and 85 deletions.
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion dbmail/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import sys


VERSION = (2, 3, 18)
VERSION = (2, 3, 18, 2)

default_app_config = 'dbmail.apps.DBMailConfig'

Expand Down
19 changes: 9 additions & 10 deletions dbmail/management/commands/dbmail_test_send.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
1 change: 1 addition & 0 deletions dbmail/providers/apple/apns.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
9 changes: 7 additions & 2 deletions dbmail/providers/boxcar/push.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
10 changes: 8 additions & 2 deletions dbmail/providers/centrifugo/push.py
Original file line number Diff line number Diff line change
@@ -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

Expand Down
10 changes: 7 additions & 3 deletions dbmail/providers/google/android.py
Original file line number Diff line number Diff line change
@@ -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


Expand Down
9 changes: 7 additions & 2 deletions dbmail/providers/http/push.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
9 changes: 7 additions & 2 deletions dbmail/providers/iqsms/sms.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
6 changes: 5 additions & 1 deletion dbmail/providers/parse_com/push.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
9 changes: 7 additions & 2 deletions dbmail/providers/pushover/push.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
11 changes: 8 additions & 3 deletions dbmail/providers/slack/push.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
9 changes: 7 additions & 2 deletions dbmail/providers/twilio/sms.py
Original file line number Diff line number Diff line change
@@ -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

Expand Down
17 changes: 10 additions & 7 deletions dbmail/static/dbmail/admin/js/dbmail.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = '<li><a href="./sendmail/" class="historylink">Test template</a></li>';
var browse_button = '<li><a href="javascript:void(0);" onclick="show_apps_dialog()" class="historylink" target="_blank">Browse vars</a></li>';
var test_button = '<li><a href="javascript:void(0);" onclick="test_app_template();" class="historylink">Test template</a></li>';
var browse_button = '<li><a href="javascript:void(0);" onclick="show_apps_dialog();" class="historylink" target="_blank">Browse vars</a></li>';
if ($('.object-tools').length == 1) {
$('.object-tools').append(test_button);
$('.object-tools').append(browse_button);
Expand All @@ -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/';
$(
'<div><iframe src="./sendmail/apps/" width="100%" height="100%"></iframe></div>'
'<div><iframe src="'+appUrl+'" width="100%" height="100%"></iframe></div>'
).dialog({
modal: true,
draggable: true,
Expand All @@ -32,7 +35,7 @@
at: "center",
of: window
}
)
).show()
;
}
;
Expand Down
49 changes: 27 additions & 22 deletions demo/demo/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
PROJECT_ROOT = os.path.normpath(os.path.dirname(__file__))

DEBUG = True
TEMPLATE_DEBUG = DEBUG

ADMINS = (
('root', '[email protected]'),
Expand Down Expand Up @@ -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:
Expand All @@ -96,21 +99,20 @@
]

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',
]

if 'test' not in sys.argv:
INSTALLED_APPS += [
'django_extensions',
'admin_jqueryui',
'reversion',
'reversion_compare',
'djcelery',
Expand All @@ -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:
Expand Down Expand Up @@ -147,7 +152,7 @@
'console': {
'level': 'DEBUG',
'class': 'logging.StreamHandler',
#'formatter': 'verbose'
# 'formatter': 'verbose'
}
},
'loggers': {
Expand Down
8 changes: 4 additions & 4 deletions demo/demo/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down
Loading

0 comments on commit cf57815

Please sign in to comment.