From aa27d1afadbce48069f6512f7ff8f954a757a962 Mon Sep 17 00:00:00 2001 From: Russell Ballestrini Date: Thu, 7 Jul 2022 12:56:44 -0400 Subject: [PATCH] Fix syntax error manifesting as ValueError modified: make_post_sell/tests/test_sanitize_html.py modified: make_post_sell/views/__init__.py modified: make_post_sell/views/coupon.py --- make_post_sell/tests/test_sanitize_html.py | 2 +- make_post_sell/views/__init__.py | 23 +++------------------- make_post_sell/views/coupon.py | 2 +- 3 files changed, 5 insertions(+), 22 deletions(-) diff --git a/make_post_sell/tests/test_sanitize_html.py b/make_post_sell/tests/test_sanitize_html.py index 0a214ff..7d59561 100644 --- a/make_post_sell/tests/test_sanitize_html.py +++ b/make_post_sell/tests/test_sanitize_html.py @@ -24,7 +24,7 @@ class SanitizeHtml(unittest.TestCase, object): def test_default_tag_acl(self): tag_acl = default_tag_acl() self.assertFalse(tag_acl) - self.assertEquals(len(tag_acl.keys()), 0) + self.assertEqual(len(tag_acl.keys()), 0) def test_complex_cleaner_tag_acl(self): tag_acl = { diff --git a/make_post_sell/views/__init__.py b/make_post_sell/views/__init__.py index 7addaff..6cd24a5 100644 --- a/make_post_sell/views/__init__.py +++ b/make_post_sell/views/__init__.py @@ -2,24 +2,8 @@ from pyramid.httpexceptions import HTTPFound def get_referer_or_home(request): - """return referer or safe_redirect or '/'""" - return ( - request.referer - if request.referer is not None - # else request.app.get("safe_redirect", "/") - else "/" - ) - - -def get_join_or_log_in_route_uri(request, return_to=""): - query = None - if return_to: - query = {"return-to":return_to} - return request.route_url( - "join-or-log-in", - _query=query, - ) - + """return referer or or '/'""" + return request.referer if request.referer is not None else "/" # view decorator. def user_required( @@ -38,10 +22,9 @@ def user_required( return_to = "" if return_to_route_name: return_to = request.route_url(return_to_route_name) - return HTTPFound(get_join_or_log_in_route_uri(request, return_to)) + return HTTPFound(get_referer_or_home(request)) return inner - return wrapped diff --git a/make_post_sell/views/coupon.py b/make_post_sell/views/coupon.py index 2bc3250..80d5ec0 100644 --- a/make_post_sell/views/coupon.py +++ b/make_post_sell/views/coupon.py @@ -25,7 +25,7 @@ def get_coupon_from_matchdict(request): @view_config(route_name="coupons", renderer="coupons.j2") -@shop_owner_required +@shop_owner_required() def coupons(request): return { "coupons": request.shop.coupons.all()