Commit 98b133a2 authored by fred's avatar fred

use django.utils.six for cookielib/urllib/urllib2 modules

parent f45bf81f
...@@ -4,9 +4,6 @@ import email ...@@ -4,9 +4,6 @@ import email
import hashlib import hashlib
import random import random
import socket import socket
import urllib
import urllib2
import cookielib
import datetime import datetime
from django.conf import settings from django.conf import settings
...@@ -15,7 +12,10 @@ from django.core.urlresolvers import reverse_lazy ...@@ -15,7 +12,10 @@ from django.core.urlresolvers import reverse_lazy
from django.db import models, IntegrityError from django.db import models, IntegrityError
from django.http import JsonResponse from django.http import JsonResponse
from django.shortcuts import get_object_or_404 from django.shortcuts import get_object_or_404
from django.utils.http import urlencode
from django.utils.translation import ugettext as _ from django.utils.translation import ugettext as _
import django.utils.six.moves.urllib as urllib2
import django.utils.six.moves.http_cookiejar as cookielib
from django.views.generic.base import TemplateView, RedirectView from django.views.generic.base import TemplateView, RedirectView
from django.views.generic.detail import DetailView from django.views.generic.detail import DetailView
...@@ -69,12 +69,12 @@ def unsubscription(request) : ...@@ -69,12 +69,12 @@ def unsubscription(request) :
cookie_jar = cookielib.CookieJar() cookie_jar = cookielib.CookieJar()
url_opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cookie_jar)) url_opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cookie_jar))
login_params = urllib.urlencode({'email' : subscriber.email, 'password' : subscriber.password}) login_params = urlencode({'email' : subscriber.email, 'password' : subscriber.password})
login_request = urllib2.Request(settings.NEWSLETTER_UNSUBSCRIPTION_URL, login_params) login_request = urllib2.Request(settings.NEWSLETTER_UNSUBSCRIPTION_URL, login_params)
url = url_opener.open(login_request) url = url_opener.open(login_request)
unsubscribe_action_url = ("%s/%s" % (settings.NEWSLETTER_UNSUBSCRIPTION_URL, subscriber.email)) unsubscribe_action_url = ("%s/%s" % (settings.NEWSLETTER_UNSUBSCRIPTION_URL, subscriber.email))
unsubscribe_params = urllib.urlencode({'unsub' : 'Résilier', 'unsubconfirm' : '1'}) unsubscribe_params = urlencode({'unsub' : 'Résilier', 'unsubconfirm' : '1'})
unsubscribe_request = urllib2.Request(unsubscribe_action_url, unsubscribe_params) unsubscribe_request = urllib2.Request(unsubscribe_action_url, unsubscribe_params)
url = url_opener.open(unsubscribe_request) url = url_opener.open(unsubscribe_request)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment