updating to support python3
git-svn-id: https://vault.zeeksgeeks.com/svn/django_aws_ses/trunk@7 ed966f06-d3d6-432b-bc91-693151a5c6b4
This commit is contained in:
parent
823d6c1b2d
commit
b3a7db0013
|
@ -14,7 +14,6 @@ from . import settings
|
||||||
from . import signals
|
from . import signals
|
||||||
from . import utils
|
from . import utils
|
||||||
from .models import BounceRecord
|
from .models import BounceRecord
|
||||||
from saleor.core.utils import email_exclusion_filter
|
|
||||||
|
|
||||||
logger = settings.logger
|
logger = settings.logger
|
||||||
|
|
||||||
|
@ -158,9 +157,6 @@ class SESBackend(BaseEmailBackend):
|
||||||
logger.info("message.recipients() = %s" % message.recipients())
|
logger.info("message.recipients() = %s" % message.recipients())
|
||||||
|
|
||||||
marketing = message.extra_headers.get("marketing","False")
|
marketing = message.extra_headers.get("marketing","False")
|
||||||
message.to = email_exclusion_filter(message.to,marketing)
|
|
||||||
message.cc = email_exclusion_filter(message.cc,marketing)
|
|
||||||
message.bcc = email_exclusion_filter(message.bcc,marketing)
|
|
||||||
|
|
||||||
message.to = utils.filter_recipiants(message.to)
|
message.to = utils.filter_recipiants(message.to)
|
||||||
message.cc = utils.filter_recipiants(message.cc)
|
message.cc = utils.filter_recipiants(message.cc)
|
||||||
|
|
|
@ -9,7 +9,7 @@ from django.dispatch import receiver
|
||||||
from django.contrib.sites.models import Site
|
from django.contrib.sites.models import Site
|
||||||
from django.contrib.auth import get_user_model # If used custom user model
|
from django.contrib.auth import get_user_model # If used custom user model
|
||||||
from django.urls import reverse
|
from django.urls import reverse
|
||||||
from django.utils.encoding import force_bytes, force_text
|
from django.utils.encoding import force_bytes, force_str
|
||||||
from django.utils.http import urlsafe_base64_encode, urlsafe_base64_decode
|
from django.utils.http import urlsafe_base64_encode, urlsafe_base64_decode
|
||||||
|
|
||||||
User = get_user_model()
|
User = get_user_model()
|
||||||
|
|
|
@ -53,7 +53,7 @@ HOME_URL = getattr(settings, 'HOME_URL', '')
|
||||||
if not BASE_DIR:
|
if not BASE_DIR:
|
||||||
raise RuntimeError('No BASE_DIR defined in project settings, django_aws_ses requires BASE_DIR to be defined and pointed at your root directory. i.e. BASE_DIR = os.path.dirname(os.path.abspath(__file__))')
|
raise RuntimeError('No BASE_DIR defined in project settings, django_aws_ses requires BASE_DIR to be defined and pointed at your root directory. i.e. BASE_DIR = os.path.dirname(os.path.abspath(__file__))')
|
||||||
|
|
||||||
UNSUBSCRIBE_TEMPLET = getattr(settings, 'UNSUBSCRIBE_TEMPLET', 'django_aws_ses/unsebscribe.html')
|
UNSUBSCRIBE_TEMPLET = getattr(settings, 'UNSUBSCRIBE_TEMPLET', 'django_aws_ses/unsubscribe.html')
|
||||||
BASE_TEMPLET = getattr(settings, 'UNSUBSCRIBE_TEMPLET', 'django_aws_ses/base.html')
|
BASE_TEMPLET = getattr(settings, 'UNSUBSCRIBE_TEMPLET', 'django_aws_ses/base.html')
|
||||||
|
|
||||||
AWS_SES_REGION_ENDPOINT_URL = getattr(settings, 'AWS_SES_REGION_ENDPOINT_URL','https://' + AWS_SES_REGION_ENDPOINT)
|
AWS_SES_REGION_ENDPOINT_URL = getattr(settings, 'AWS_SES_REGION_ENDPOINT_URL','https://' + AWS_SES_REGION_ENDPOINT)
|
||||||
|
|
|
@ -0,0 +1,11 @@
|
||||||
|
{% extends base_template_name %}
|
||||||
|
|
||||||
|
{% block title1 %}
|
||||||
|
Unsubscribe
|
||||||
|
{% endblock title1 %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
<div>
|
||||||
|
<h3>{{ unsubscribe_message }}</h3>
|
||||||
|
</div>
|
||||||
|
{% endblock content %}
|
|
@ -1,4 +1,4 @@
|
||||||
from django.conf.urls import include, url
|
from django.urls import include, path
|
||||||
from django.views.decorators.csrf import csrf_exempt
|
from django.views.decorators.csrf import csrf_exempt
|
||||||
|
|
||||||
from .views import (
|
from .views import (
|
||||||
|
@ -10,7 +10,7 @@ from .views import (
|
||||||
app_name = "django_aws_ses"
|
app_name = "django_aws_ses"
|
||||||
|
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
url(r'^status/$', dashboard, name='aws_ses_status'),
|
path('status/', dashboard, name='aws_ses_status'),
|
||||||
url(r'^bounce/$', csrf_exempt(handle_bounce),name='aws_ses_bounce'),
|
path('bounce/', csrf_exempt(handle_bounce),name='aws_ses_bounce'),
|
||||||
url(r'^unsubscribe/(?P<uuid>[0-9a-zA-Z]+)/(?P<hash>[0-9a-zA-Z]+)/$', HandleUnsubscribe.as_view(), name='aws_ses_unsubscribe')
|
path('unsubscribe/<uuid:uuid>/<str:hash>/', HandleUnsubscribe.as_view(), name='aws_ses_unsubscribe')
|
||||||
]
|
]
|
||||||
|
|
|
@ -111,7 +111,7 @@ class BounceMessageVerifier(object):
|
||||||
)
|
)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import M2Crypto
|
from M2Crypto import X509
|
||||||
except ImportError:
|
except ImportError:
|
||||||
raise ImproperlyConfigured(
|
raise ImproperlyConfigured(
|
||||||
"`M2Crypto` is required for bounce message verification. "
|
"`M2Crypto` is required for bounce message verification. "
|
||||||
|
@ -132,8 +132,8 @@ class BounceMessageVerifier(object):
|
||||||
# If the certificate is invalid then return
|
# If the certificate is invalid then return
|
||||||
# false as we couldn't verify the message.
|
# false as we couldn't verify the message.
|
||||||
try:
|
try:
|
||||||
self._certificate = M2Crypto.X509.load_cert_string(response.content)
|
self._certificate = X509.load_cert_string(response.content)
|
||||||
except M2Crypto.X509.X509Error as e:
|
except X509.X509Error as e:
|
||||||
logger.warning(u'Could not load certificate from %s: "%s"', cert_url, e)
|
logger.warning(u'Could not load certificate from %s: "%s"', cert_url, e)
|
||||||
self._certificate = None
|
self._certificate = None
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,7 @@ from django.core.exceptions import PermissionDenied
|
||||||
from django.shortcuts import render, redirect
|
from django.shortcuts import render, redirect
|
||||||
from django.contrib.auth import get_user_model
|
from django.contrib.auth import get_user_model
|
||||||
from django.views.generic.base import TemplateView
|
from django.views.generic.base import TemplateView
|
||||||
from django.utils.encoding import force_bytes, force_text
|
from django.utils.encoding import force_bytes, force_str
|
||||||
|
|
||||||
from . import settings
|
from . import settings
|
||||||
from . import signals
|
from . import signals
|
||||||
|
@ -432,7 +432,7 @@ class HandleUnsubscribe(TemplateView):
|
||||||
logger.info("in get ----- self.base_template_name: %s" % self.base_template_name)
|
logger.info("in get ----- self.base_template_name: %s" % self.base_template_name)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
uuid = force_text(urlsafe_base64_decode(uuid).decode())
|
uuid = force_str(urlsafe_base64_decode(uuid).decode())
|
||||||
logger.info('uuid: %s' % uuid)
|
logger.info('uuid: %s' % uuid)
|
||||||
user = User.objects.get(pk=uuid)
|
user = User.objects.get(pk=uuid)
|
||||||
logger.info('user.pk: %s' % user.pk)
|
logger.info('user.pk: %s' % user.pk)
|
||||||
|
|
Loading…
Reference in New Issue