Skip to content

Commit 489a94d

Browse files
committed
Added balance display to subscription purchase view. Probably closes dry-python#33
1 parent c63d45d commit 489a94d

File tree

7 files changed

+15
-8
lines changed

7 files changed

+15
-8
lines changed

django/example/services/show_category_prices.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ class ShopCategoryPrices:
77
"""Show purchase variants for category."""
88

99
@story
10-
@arguments("category_id", "error_in")
10+
@arguments("user", "category_id", "error_in")
1111
def show(I):
1212

1313
I.find_category
@@ -38,6 +38,7 @@ def show_purchase_form(self, ctx):
3838
"category": ctx.category,
3939
"prices": ctx.prices,
4040
"forms": ctx.forms,
41+
"account_balance": ctx.user.profile.balance,
4142
})
4243

4344
# Dependencies.

django/example/templates/category_detail.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
<a href="{% url 'category-shop' %}">{% trans 'Shop' %}</a>
1313
</li>
1414
<li>
15-
<a href="{% url 'profile' %}">{% trans 'Profile' %}</a>
15+
<a href="{% url 'profile' %}">{% trans 'Profile' %} ({{ user.username }})</a>
1616
</li>
1717
<li>
1818
<a href="{% url 'notification-list' %}">{% trans 'Notifications' %}</a>

django/example/templates/category_list.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
<a href="{% url 'category-shop' %}">{% trans 'Shop' %}</a>
1010
</li>
1111
<li>
12-
<a href="{% url 'profile' %}">{% trans 'Profile' %}</a>
12+
<a href="{% url 'profile' %}">{% trans 'Profile' %} ({{ user.username }})</a>
1313
</li>
1414
<li>
1515
<a href="{% url 'notification-list' %}">{% trans 'Notifications' %}</a>

django/example/templates/category_shop.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
<a href="{% url 'category-list' %}">{% trans 'Categories' %}</a>
1111
</li>
1212
<li>
13-
<a href="{% url 'profile' %}">{% trans 'Profile' %}</a>
13+
<a href="{% url 'profile' %}">{% trans 'Profile' %} ({{ user.username }})</a>
1414
</li>
1515
<li>
1616
<a href="{% url 'notification-list' %}">{% trans 'Notifications' %}</a>

django/example/templates/notification_list.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
<a href="{% url 'category-shop' %}">{% trans 'Shop' %}</a>
1313
</li>
1414
<li>
15-
<a href="{% url 'profile' %}">{% trans 'Profile' %}</a>
15+
<a href="{% url 'profile' %}">{% trans 'Profile' %} ({{ user.username }})</a>
1616
</li>
1717
<li>
1818
<a href="{% url 'logout' %}">{% trans 'Logout' %}</a>

django/example/templates/subscribe.html

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
<a href="{% url 'category-shop' %}">{% trans 'Shop' %}</a>
1414
</li>
1515
<li>
16-
<a href="{% url 'profile' %}">{% trans 'Profile' %}</a>
16+
<a href="{% url 'profile' %}">{% trans 'Profile' %} ({{ user.username }})</a>
1717
</li>
1818
<li>
1919
<a href="{% url 'notification-list' %}">{% trans 'Notifications' %}</a>
@@ -43,6 +43,12 @@ <h1>{{ category.name }}</h1>
4343
{% endblocktrans %}
4444
{% endwith %}
4545
</p>
46+
<p>
47+
<b>{% trans 'Balance' %}</b>
48+
{% with account_balance=account_balance %}
49+
You have $ {{ account_balance }} available.
50+
{% endwith %}
51+
</p>
4652
<form method="POST" action="">
4753
{% csrf_token %}
4854
{{ form.as_p }}

django/example/views/buy_subscription.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@ class BuySubscriptionView(Injector):
2323
render = functions.Render.do
2424

2525
@operation
26-
def get(show_prices, category_id, render):
26+
def get(show_prices, user, category_id, render):
2727

28-
return render(show_prices(category_id, None))
28+
return render(show_prices(user, category_id, None))
2929

3030
@operation
3131
def post(

0 commit comments

Comments
 (0)