mirror of
https://github.com/pacnpal/django-anymail.git
synced 2025-12-20 11:51:05 -05:00
Cleaned up .gitignor, PEP-8 issues and documentation
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -1,4 +1,3 @@
|
||||
.idea/
|
||||
.DS_Store
|
||||
._*
|
||||
*.pyc
|
||||
|
||||
@@ -6,5 +6,6 @@ if sys.version < '3':
|
||||
return x
|
||||
else:
|
||||
import codecs
|
||||
|
||||
def b(x):
|
||||
return codecs.latin_1_encode(x)[0]
|
||||
@@ -16,6 +16,7 @@ import requests
|
||||
from djrill import MANDRILL_API_URL, signals
|
||||
from .compat import b
|
||||
|
||||
|
||||
class DjrillAdminMedia(object):
|
||||
def _media(self):
|
||||
js = ["js/core.js", "js/jquery.min.js", "js/jquery.init.js"]
|
||||
@@ -102,6 +103,7 @@ class DjrillWebhookSecretMixin(object):
|
||||
return super(DjrillWebhookSecretMixin, self).dispatch(
|
||||
request, *args, **kwargs)
|
||||
|
||||
|
||||
class DjrillWebhookSignatureMixin(object):
|
||||
|
||||
@method_decorator(csrf_exempt)
|
||||
@@ -127,7 +129,7 @@ class DjrillWebhookSignatureMixin(object):
|
||||
post_lists = sorted(request.POST.lists())
|
||||
for value_list in post_lists:
|
||||
for item in value_list[1]:
|
||||
post_string += "%s%s" % (value_list[0],item)
|
||||
post_string += "%s%s" % (value_list[0], item)
|
||||
|
||||
hash_string = b64encode(hmac.new(key=b(signature_key), msg=b(post_string), digestmod=hashlib.sha1).digest())
|
||||
if signature != hash_string:
|
||||
@@ -136,6 +138,7 @@ class DjrillWebhookSignatureMixin(object):
|
||||
return super(DjrillWebhookSignatureMixin, self).dispatch(
|
||||
request, *args, **kwargs)
|
||||
|
||||
|
||||
class DjrillIndexView(DjrillApiMixin, TemplateView):
|
||||
template_name = "djrill/status.html"
|
||||
|
||||
@@ -196,7 +199,7 @@ class DjrillUrlListView(DjrillAdminMedia, DjrillApiMixin,
|
||||
return self.render_to_response(context)
|
||||
|
||||
|
||||
class DjrillWebhookView(DjrillWebhookSecretMixin,DjrillWebhookSignatureMixin, View):
|
||||
class DjrillWebhookView(DjrillWebhookSecretMixin, DjrillWebhookSignatureMixin, View):
|
||||
def head(self, request, *args, **kwargs):
|
||||
return HttpResponse()
|
||||
|
||||
|
||||
@@ -30,12 +30,12 @@ Your code can connect to this signal for further processing.
|
||||
reject calls without the correct key.
|
||||
|
||||
* You can, optionally include the two settings :setting:`DJRILL_WEBHOOK_SIGNATURE_KEY`
|
||||
and :setting:`DJRILL_WEBHOOK_URL` to enforce webhook signature checking
|
||||
and :setting:`DJRILL_WEBHOOK_URL` to enforce `webhook signature`_ checking
|
||||
|
||||
|
||||
.. _Mandrill webhooks: http://help.mandrill.com/entries/21738186-Introduction-to-Webhooks
|
||||
.. _securing webhooks: http://apidocs.mailchimp.com/webhooks/#securing-webhooks
|
||||
.. _webhook signatures: http://help.mandrill.com/entries/23704122-Authenticating-webhook-requests
|
||||
.. _webhook signature: http://help.mandrill.com/entries/23704122-Authenticating-webhook-requests
|
||||
|
||||
.. _webhooks-config:
|
||||
|
||||
|
||||
Reference in New Issue
Block a user