Skip to content

Commit

Permalink
Django 1.11 compatibility.
Browse files Browse the repository at this point in the history
- Drop support for Django 1.7 and lower.
- Drop support for Oscar 1.0 and lower.
  • Loading branch information
solarissmoke committed Oct 8, 2017
1 parent 76542ce commit 1c17dc8
Show file tree
Hide file tree
Showing 50 changed files with 312 additions and 290 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ docs/_build
htmlcov
.tox
.coverage
.coveralls.yml

# Database
sandbox/db.sqlite
Expand Down
53 changes: 32 additions & 21 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,29 +1,40 @@
# Use Travis new infrastructure
sudo: false

language: python
sudo: false

env:
# Generated with https://www.dominicrodger.com/tox-and-travis.html
- TOX_ENV=py27-django17-oscar10
- TOX_ENV=py27-django17-oscar11
- TOX_ENV=py27-django18-oscar10
- TOX_ENV=py27-django18-oscar11
- TOX_ENV=py33-django17-oscar10
- TOX_ENV=py33-django17-oscar11
- TOX_ENV=py33-django18-oscar10
- TOX_ENV=py33-django18-oscar11
- TOX_ENV=py34-django17-oscar10
- TOX_ENV=py34-django17-oscar11
- TOX_ENV=py34-django18-oscar10
- TOX_ENV=py34-django18-oscar11
matrix:
include:
- python: 2.7
env: TOXENV=py27-django18
- python: 2.7
env: TOXENV=py27-django110
- python: 2.7
env: TOXENV=py27-django111
- python: 3.3
env: TOXENV=py33-django18
- python: 3.4
env: TOXENV=py34-django18
- python: 3.4
env: TOXENV=py34-django110
- python: 3.4
env: TOXENV=py34-django111
- python: 3.5
env: TOXENV=py35-django18
- python: 3.5
env: TOXENV=py35-django110
- python: 3.5
env: TOXENV=py35-django111
- python: 3.6
env: TOXENV=py36-django111

- python: 3.5
env: TOXENV=lint

install:
- pip install tox
- pip install tox codecov

script:
- tox -e $TOX_ENV
- tox

notifications:
email: false
after_success:
- tox -e coverage-report
- codecov
File renamed without changes.
10 changes: 5 additions & 5 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ PayPal package for django-oscar
===============================

This package provides integration between django-oscar_ and both `PayPal
Express`_ and `PayPal Payflow Pro`_.
Express`_ and `PayPal Payflow Pro`_.

.. _django-oscar: https://github.com/django-oscar/django-oscar
.. _`PayPal Express`: https://www.paypal.com/uk/cgi-bin/webscr?cmd=_additional-payment-ref-impl1
Expand Down Expand Up @@ -51,9 +51,9 @@ Tests
:alt: Continuous integration status
:target: http://travis-ci.org/#!/django-oscar/django-oscar-paypal

.. image:: https://coveralls.io/repos/django-oscar/django-oscar-paypal/badge.png?branch=master
.. image:: http://codecov.io/github/django-oscar/django-oscar-paypal/coverage.svg?branch=master
:alt: Coverage
:target: https://coveralls.io/r/django-oscar/django-oscar-paypal
:target: http://codecov.io/github/django-oscar/django-oscar-paypal?branch=master

Changelog
---------
Expand Down Expand Up @@ -97,7 +97,7 @@ Changelog
~~~~~

* Use the correct key to look up a previous transaction ID (for
refund/capture/void operations). `#81`_
refund/capture/void operations). `#81`_

.. _`#81`: https://github.com/django-oscar/django-oscar-paypal/pull/81

Expand Down Expand Up @@ -140,7 +140,7 @@ Changelog
0.6.1
~~~~~
* Persist shipping method name when using PayPal Express as a payment method
only.
only.

0.6
~~~
Expand Down
12 changes: 6 additions & 6 deletions docs/express.rst
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,13 @@ follows::

from paypal.express.dashboard.app import application

urlpatterns = patterns('',
(r'^admin/', include(admin.site.urls)),
(r'^checkout/paypal/', include('paypal.express.urls')),
urlpatterns = [
url(r'^admin/', include(admin.site.urls)),
url(r'^checkout/paypal/', include('paypal.express.urls')),
# Optional
(r'^dashboard/paypal/express/', include(application.urls)),
(r'', include(shop.urls)),
url(r'^dashboard/paypal/express/', include(application.urls)),
url(r'', include(shop.urls)),
]

If you are using the dashboard views, extend the dashboard navigation to include
the appropriate links::
Expand All @@ -69,7 +70,6 @@ links to PayPal. This can be done by creating a new template

{% extends 'oscar/basket/partials/basket_content.html' %}
{% load i18n %}
{% load url from future %}

{% block formactions %}
<div class="form-actions">
Expand Down
2 changes: 1 addition & 1 deletion paypal/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
VERSION = '0.9.7'
VERSION = '0.10'
4 changes: 2 additions & 2 deletions paypal/admin.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
from paypal.express.admin import *
from paypal.payflow.admin import *
from paypal.express.admin import * # noqa F403
from paypal.payflow.admin import * # noqa F403
4 changes: 2 additions & 2 deletions paypal/base.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
from __future__ import unicode_literals

from django.db import models
from django.utils import six
from django.utils.six.moves.urllib.parse import parse_qsl
from django.utils.translation import ugettext_lazy as _

from django.db import models


class ResponseModel(models.Model):

Expand Down
4 changes: 0 additions & 4 deletions paypal/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,3 @@ class PaymentError(Exception):

class PayPalError(PaymentError):
pass


class PayPalError(PaymentError):
pass
1 change: 1 addition & 0 deletions paypal/express/admin.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from django.contrib import admin

from paypal import models


Expand Down
7 changes: 3 additions & 4 deletions paypal/express/dashboard/app.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from django.conf.urls import patterns, url
from django.conf.urls import url
from django.contrib.admin.views.decorators import staff_member_required

from oscar.core.application import Application

from paypal.express.dashboard import views
Expand All @@ -12,12 +11,12 @@ class ExpressDashboardApplication(Application):
detail_view = views.TransactionDetailView

def get_urls(self):
urlpatterns = patterns('',
urlpatterns = [
url(r'^transactions/$', self.list_view.as_view(),
name='paypal-express-list'),
url(r'^transactions/(?P<pk>\d+)/$', self.detail_view.as_view(),
name='paypal-express-detail'),
)
]
return self.post_process_urls(urlpatterns)

def get_url_decorator(self, url_name):
Expand Down
2 changes: 1 addition & 1 deletion paypal/express/dashboard/views.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from django.views import generic
from django.conf import settings
from django.views import generic

from paypal.express import models

Expand Down
12 changes: 6 additions & 6 deletions paypal/express/facade.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@
Responsible for briding between Oscar and the PayPal gateway
"""
from __future__ import unicode_literals
from django.core.urlresolvers import reverse
from django.contrib.sites.models import Site

from django.conf import settings
from django.contrib.sites.models import Site
from django.core.exceptions import ImproperlyConfigured
from django.core.urlresolvers import reverse

from paypal.express.gateway import (AUTHORIZATION, DO_EXPRESS_CHECKOUT, ORDER,
SALE, do_capture, do_txn, do_void, get_txn,
refund_txn, set_txn)
from paypal.express.models import ExpressTransaction as Transaction
from paypal.express.gateway import (
set_txn, get_txn, do_txn, SALE, AUTHORIZATION, ORDER,
do_capture, DO_EXPRESS_CHECKOUT, do_void, refund_txn
)


def _get_payment_action():
Expand Down
13 changes: 8 additions & 5 deletions paypal/express/gateway.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
from __future__ import unicode_literals

import logging
from decimal import Decimal as D

from django.conf import settings
from django.core.exceptions import ImproperlyConfigured
from django.utils.http import urlencode
from django.template.defaultfilters import striptags, truncatewords
from django.utils import six
from django.utils.http import urlencode
from django.utils.translation import ugettext as _
from django.template.defaultfilters import truncatewords, striptags
from localflavor.us import us_states

from . import models, exceptions as express_exceptions
from paypal import gateway
from paypal import exceptions
from paypal import exceptions, gateway

from . import exceptions as express_exceptions
from . import models

# PayPal methods
SET_EXPRESS_CHECKOUT = 'SetExpressCheckout'
Expand Down Expand Up @@ -400,6 +401,8 @@ def do_void(txn_id, note=None):

FULL_REFUND = 'Full'
PARTIAL_REFUND = 'Partial'


def refund_txn(txn_id, is_partial=False, amount=None, currency=None):
params = {
'TRANSACTIONID': txn_id,
Expand Down
2 changes: 1 addition & 1 deletion paypal/express/models.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from __future__ import unicode_literals

import re

from django.db import models
Expand Down Expand Up @@ -44,4 +45,3 @@ def is_successful(self):
def __str__(self):
return 'method: %s: token: %s' % (
self.method, self.token)

7 changes: 3 additions & 4 deletions paypal/express/urls.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
from django.conf.urls import *
from django.conf.urls import url
from django.views.decorators.csrf import csrf_exempt

from paypal.express import views


urlpatterns = patterns('',
urlpatterns = [
# Views for normal flow that starts on the basket page
url(r'^redirect/', views.RedirectView.as_view(), name='paypal-redirect'),
url(r'^preview/(?P<basket_id>\d+)/$',
Expand All @@ -21,4 +20,4 @@
# View for using PayPal as a payment method
url(r'^payment/', views.RedirectView.as_view(as_payment_method=True),
name='paypal-direct-payment'),
)
]
28 changes: 13 additions & 15 deletions paypal/express/views.py
Original file line number Diff line number Diff line change
@@ -1,31 +1,29 @@
from __future__ import unicode_literals
from decimal import Decimal as D

import logging
from decimal import Decimal as D

from django.views.generic import RedirectView, View
from django.conf import settings
from django.http import HttpResponse
from django.shortcuts import get_object_or_404
from django.contrib import messages
from django.contrib.auth.models import AnonymousUser
from django.core.urlresolvers import reverse
from django.http import HttpResponseRedirect
from django.utils.http import urlencode
from django.http import HttpResponse, HttpResponseRedirect
from django.shortcuts import get_object_or_404
from django.utils import six
from django.utils.http import urlencode
from django.utils.translation import ugettext_lazy as _

import oscar
from django.views.generic import RedirectView, View
from oscar.apps.payment.exceptions import UnableToTakePayment
from oscar.apps.shipping.methods import FixedPrice, NoShippingRequired
from oscar.core.exceptions import ModuleNotFoundError
from oscar.core.loading import get_class, get_model
from oscar.apps.shipping.methods import FixedPrice, NoShippingRequired

from paypal.express.facade import (
get_paypal_url, fetch_transaction_details, confirm_transaction)
from paypal.express.exceptions import (
EmptyBasketException, MissingShippingAddressException,
MissingShippingMethodException, InvalidBasket)
from paypal.exceptions import PayPalError
from paypal.express.exceptions import (EmptyBasketException, InvalidBasket,
MissingShippingAddressException,
MissingShippingMethodException)
from paypal.express.facade import (confirm_transaction,
fetch_transaction_details, get_paypal_url)

# Load views dynamically
PaymentDetailsView = get_class('checkout.views', 'PaymentDetailsView')
Expand Down Expand Up @@ -232,7 +230,7 @@ def load_frozen_basket(self, basket_id):
basket.strategy = Selector().strategy(self.request)

# Re-apply any offers
Applicator().apply(request=self.request, basket=basket)
Applicator().apply(basket, self.request.user, request=self.request)

return basket

Expand Down
5 changes: 3 additions & 2 deletions paypal/gateway.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
from __future__ import unicode_literals
import requests

import time

from django.utils.http import urlencode
import requests
from django.utils import six
from django.utils.http import urlencode
from django.utils.six.moves.urllib.parse import parse_qsl

from paypal import exceptions
Expand Down
4 changes: 2 additions & 2 deletions paypal/models.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
from paypal.express.models import *
from paypal.payflow.models import *
from paypal.express.models import * # noqa F403
from paypal.payflow.models import * # noqa F403
7 changes: 3 additions & 4 deletions paypal/payflow/dashboard/app.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from django.conf.urls import patterns, url
from django.conf.urls import url
from django.contrib.admin.views.decorators import staff_member_required

from oscar.core.application import Application

from . import views
Expand All @@ -12,12 +11,12 @@ class PayFlowDashboardApplication(Application):
detail_view = views.TransactionDetailView

def get_urls(self):
urlpatterns = patterns('',
urlpatterns = [
url(r'^transactions/$', self.list_view.as_view(),
name='paypal-payflow-list'),
url(r'^transactions/(?P<pk>\d+)/$', self.detail_view.as_view(),
name='paypal-payflow-detail'),
)
]
return self.post_process_urls(urlpatterns)

def get_url_decorator(self, url_name):
Expand Down
Loading

0 comments on commit 1c17dc8

Please sign in to comment.