Skip to content

Commit

Permalink
added buy button conditional
Browse files Browse the repository at this point in the history
  • Loading branch information
abhigyanghosh30 committed Jun 26, 2023
1 parent a54c9d9 commit e847a86
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
4 changes: 4 additions & 0 deletions templates/credentials/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@
<h1>Canonical Credentials</h1>
<p class="p-heading--4">Learn, excel, certify!</p>
<p>Find the shortest path to your passion. Develop and certify your skills on the world's most popular Linux OS.</p>
{% if can_purchase %}
<p><a href="/credentials/shop"><button class="p-button--positive">Get your exam now!</button></a></p>
{% endif %}
</div>
</div>
</section>
Expand Down Expand Up @@ -78,9 +80,11 @@ <h3 class="p-heading--5 u-no-margin--bottom">CUE.01: Linux QuickCert</h3>
<div class="col-2">
<a href="/credentials/syllabus?exam=CUE.01%3A%20Linux">Syllabus&nbsp;›</a>
</div>
{% if can_purchase %}
<div class="col-2">
<a href="/credentials/shop">Take now&nbsp;›</a>
</div>
{% endif %}
</div>
</div>
<div class="u-sv4">
Expand Down
13 changes: 11 additions & 2 deletions webapp/shop/cred/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,17 @@


@shop_decorator(area="cred", permission="user_or_guest", response="html")
def cred_home(**_):
return flask.render_template("credentials/index.html")
def cred_home(ua_contracts_api, **_):
available_products = ua_contracts_api.get_product_listings(
"canonical-cube"
).get("productListings")
print(available_products)
for product in available_products:
if product.get("name") == "CUE Linux Essentials":
return flask.render_template(
"credentials/index.html", can_purchase=True
)
return flask.render_template("credentials/index.html", can_purchase=False)


@shop_decorator(area="cred", permission="user_or_guest", response="html")
Expand Down

0 comments on commit e847a86

Please sign in to comment.