Skip to content

Commit

Permalink
Fixed formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
samhotep committed May 23, 2024
1 parent 7a005a0 commit b1ee0dc
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 19 deletions.
64 changes: 49 additions & 15 deletions webapp/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,8 +209,12 @@
app.add_url_rule("/navigation", view_func=navigation_nojs)
app.add_url_rule("/pro/dashboard", view_func=advantage_view)
app.add_url_rule("/pro/user-subscriptions", view_func=get_user_subscriptions)
app.add_url_rule("/pro/subscriptions.json", view_func=get_annotated_subscriptions)
app.add_url_rule("/pro/contracts/<contract_id>/token", view_func=get_contract_token)
app.add_url_rule(
"/pro/subscriptions.json", view_func=get_annotated_subscriptions
)
app.add_url_rule(
"/pro/contracts/<contract_id>/token", view_func=get_contract_token
)
app.add_url_rule("/pro/users", view_func=advantage_account_users_view)
app.add_url_rule("/pro/account-users", view_func=get_account_users)
app.add_url_rule(
Expand Down Expand Up @@ -241,7 +245,9 @@
view_func=post_auto_renewal_settings,
methods=["POST"],
)
app.add_url_rule("/pro/renewals/<renewal_id>", view_func=get_renewal, methods=["GET"])
app.add_url_rule(
"/pro/renewals/<renewal_id>", view_func=get_renewal, methods=["GET"]
)
app.add_url_rule(
"/pro/trial/<account_id>",
view_func=cancel_trial,
Expand Down Expand Up @@ -272,7 +278,9 @@
methods=["GET"],
)

app.add_url_rule("/pro/attach", view_func=activate_magic_attach, methods=["POST"])
app.add_url_rule(
"/pro/attach", view_func=activate_magic_attach, methods=["POST"]
)
app.add_url_rule("/pro/attach", view_func=magic_attach_view, methods=["GET"])
# shop
app.add_url_rule(
Expand Down Expand Up @@ -377,7 +385,11 @@
# end of shop

app.add_url_rule(
("/download" "/<regex('server|desktop|cloud|raspberry-pi'):category>" "/thank-you"),
(
"/download"
"/<regex('server|desktop|cloud|raspberry-pi'):category>"
"/thank-you"
),
view_func=download_thank_you,
)

Expand Down Expand Up @@ -511,7 +523,9 @@
view_func=build_engage_pages_sitemap(engage_pages),
)

app.add_url_rule("/openstack/resources", view_func=openstack_engage(engage_pages))
app.add_url_rule(
"/openstack/resources", view_func=openstack_engage(engage_pages)
)
# Custom engage page in German
app.add_url_rule(
"/engage/de/warum-openstack",
Expand Down Expand Up @@ -567,9 +581,15 @@ def takeovers_json():

def takeovers_index():
all_takeovers = discourse_takeovers.get_index()
all_takeovers.sort(key=lambda takeover: takeover["active"] == "true", reverse=True)
all_takeovers.sort(
key=lambda takeover: takeover["active"] == "true", reverse=True
)
active_count = len(
[takeover for takeover in all_takeovers if takeover["active"] == "true"]
[
takeover
for takeover in all_takeovers
if takeover["active"] == "true"
]
)

return flask.render_template(
Expand Down Expand Up @@ -698,11 +718,15 @@ def takeovers_index():
)
tutorials_docs.init_app(app)

app.add_url_rule("/tutorials.json", view_func=build_tutorials_query(tutorials_docs))
app.add_url_rule(
"/tutorials.json", view_func=build_tutorials_query(tutorials_docs)
)

# Ceph docs
ceph_docs = Docs(
parser=DocParser(api=discourse_api, index_topic_id=17250, url_prefix="/ceph/docs"),
parser=DocParser(
api=discourse_api, index_topic_id=17250, url_prefix="/ceph/docs"
),
document_template="/ceph/docs/document.html",
url_prefix="/ceph/docs",
blueprint_name="ceph",
Expand All @@ -724,7 +748,9 @@ def takeovers_index():

# Core docs
core_docs = Docs(
parser=DocParser(api=discourse_api, index_topic_id=19764, url_prefix="/core/docs"),
parser=DocParser(
api=discourse_api, index_topic_id=19764, url_prefix="/core/docs"
),
document_template="/core/docs/document.html",
url_prefix="/core/docs",
blueprint_name="core",
Expand Down Expand Up @@ -861,7 +887,9 @@ def takeovers_index():
app.add_url_rule("/credentials/shop/", view_func=cred_shop)
app.add_url_rule("/credentials/shop/<p>", view_func=cred_shop)
app.add_url_rule("/credentials/shop/keys", view_func=cred_shop_keys)
app.add_url_rule("/credentials/shop/order-thank-you", view_func=cred_shop_thank_you)
app.add_url_rule(
"/credentials/shop/order-thank-you", view_func=cred_shop_thank_you
)
app.add_url_rule(
"/credentials/shop/webhook_responses",
view_func=cred_shop_webhook_responses,
Expand Down Expand Up @@ -1077,13 +1105,17 @@ def takeovers_index():
# HPE blog section
def render_blogs():
blogs = BlogViews(
api=BlogAPI(session=session, thumbnail_width=555, thumbnail_height=311),
api=BlogAPI(
session=session, thumbnail_width=555, thumbnail_height=311
),
tag_ids=[4307],
per_page=3,
blog_title="HPE blogs",
)
hpe_articles = blogs.get_tag("hpe")
return flask.render_template("/hpe/index.html", blogs=hpe_articles["articles"])
return flask.render_template(
"/hpe/index.html", blogs=hpe_articles["articles"]
)


app.add_url_rule("/hpe", view_func=render_blogs)
Expand All @@ -1092,7 +1124,9 @@ def render_blogs():
# Supermicro blog section
def render_supermicro_blogs():
blogs = BlogViews(
api=BlogAPI(session=session, thumbnail_width=555, thumbnail_height=311),
api=BlogAPI(
session=session, thumbnail_width=555, thumbnail_height=311
),
tag_ids=[2247],
per_page=3,
blog_title="Supermicro blogs",
Expand Down
10 changes: 6 additions & 4 deletions webapp/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,9 @@ def get_navigation(path):
child_to_set_active = None

for child in nav_section["children"]:
if (child["path"] == path and path.startswith(nav_section["path"])) or (
path.startswith(child["path"])
):
if (
child["path"] == path and path.startswith(nav_section["path"])
) or (path.startswith(child["path"])):
# look for the closest patch match
if len(child["path"]) > longest_match_path:
longest_match_path = len(child["path"])
Expand Down Expand Up @@ -165,7 +165,9 @@ def get_json_feed(url, offset=0, limit=None):
json.JSONDecodeError,
requests.exceptions.RequestException,
) as fetch_error:
logger.warning("Error getting feed from {}: {}".format(url, str(fetch_error)))
logger.warning(
"Error getting feed from {}: {}".format(url, str(fetch_error))
)
return False

return content[offset:end]
Expand Down

0 comments on commit b1ee0dc

Please sign in to comment.