Skip to content

Commit

Permalink
Fix #1311 flake8/black tidy
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisjsimpson committed Mar 7, 2024
1 parent 697b51b commit 8e0164a
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 19 deletions.
2 changes: 1 addition & 1 deletion subscribie/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ def create_plan():
plan = Plan()
database.session.add(plan)
for field in planData:
if type(field[1]) == list:
if isinstance(field[1], list):
for sellingPoint in field[1]:
plan.selling_points.append(
PlanSellingPoints(point=sellingPoint.point)
Expand Down
2 changes: 1 addition & 1 deletion subscribie/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -579,7 +579,7 @@ def wrapped_view(**kwargs):
stripe_connect_url = url_for("admin.stripe_connect")
flash(
Markup(
f"You must <a href='{ stripe_connect_url }'>connect Stripe first.</a>" # noqa: E501
f"You must <a href='{stripe_connect_url}'>connect Stripe first.</a>" # noqa: E501
)
)
log.debug(f'Redirecting user to {url_for("admin.dashboard")}')
Expand Down
16 changes: 12 additions & 4 deletions subscribie/blueprints/admin/subscriber.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from subscribie.auth import login_required
from subscribie.models import Person
from flask import render_template
from subscribie.utils import get_stripe_secret_key, get_stripe_connect_account, get_stripe_connect_account_id
from subscribie.utils import get_stripe_secret_key, get_stripe_connect_account_id
import stripe
import logging

Expand All @@ -22,10 +22,18 @@ def show_subscriber(subscriber_id):
# Add hosted_invoice_url attribute to all open invoices
try:
for index, open_invoice in enumerate(open_invoices):
stripe_invoice = stripe.Invoice.retrieve(id=open_invoice.id, stripe_account=stripe_connect_account_id)
setattr(open_invoices[index], 'hosted_invoice_url', stripe_invoice.hosted_invoice_url)
stripe_invoice = stripe.Invoice.retrieve(
id=open_invoice.id, stripe_account=stripe_connect_account_id
)
setattr(
open_invoices[index],
"hosted_invoice_url",
stripe_invoice.hosted_invoice_url,
)
except Exception as e:
log.error(f"Unable to get/set hosted_invoice_url for invoice: {open_invoice.id}. {e}")
log.error(
f"Unable to get/set hosted_invoice_url for invoice: {open_invoice.id}. {e}"
)

# Try to be helpful to the shop owner by highlighting recent payment
# payment stripe_decline_code errors (if any).
Expand Down
13 changes: 7 additions & 6 deletions subscribie/blueprints/iframe/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,14 @@
def get_iframe_embed():
"""Set optimised title tags for your pages."""
log.info("Generating iframe")
iframe = """<iframe src={} width="100%" frameborder="0" height="800px" scrolling="auto"
allowfullscreen="true"
title="Subscription shop">
</iframe>
""".format(
request.host_url + '?iframe_embeded="1"'
iframe = (
f'<iframe src={request.host_url}?iframe_embeded="1" '
'width="100%" frameborder="0" height="800px" scrolling="auto" '
'allowfullscreen="true" '
'title="Subscription shop">\n'
"</iframe>"
)

try:
return render_template("show-iframe-embed.html", iframe=iframe)
except TemplateNotFound:
Expand Down
7 changes: 0 additions & 7 deletions subscribie/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -249,15 +249,8 @@ def modify_stripe_account_capability(account_id):


def create_stripe_tax_rate():
from .models import PaymentProvider
from subscribie.models import TaxRate

payment_provider = PaymentProvider.query.first()
if payment_provider.stripe_livemode:
livemode = True
else:
livemode = False

# If there's no tax rate for current live mode create and save one:
# if TaxRate.query.filter_by(stripe_livemode=livemode).first() is None:
stripe.api_key = get_stripe_secret_key()
Expand Down

0 comments on commit 8e0164a

Please sign in to comment.