Skip to content

Commit

Permalink
Add Sales/Purchases history pages
Browse files Browse the repository at this point in the history
  • Loading branch information
pH-7 committed Oct 26, 2017
1 parent a8bd7d0 commit a458fce
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 0 deletions.
3 changes: 3 additions & 0 deletions marketplaceapp/templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@
<a href="{% url 'my_gigs' %}">My Gigs</a>
</li>
<li role="separator" class="divider"></li>
<li><a href="{% url 'my_sales' %}">My Sales</a></li>
<li><a href="{% url 'my_purchases' %}">My Purchases</a></li>
<li role="separator" class="divider"></li>
<li><a href="{% url 'profile' user.username %}">My Profile</a></li>
<li role="separator" class="divider"></li>
<li>
Expand Down
2 changes: 2 additions & 0 deletions marketplaceapp/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,6 @@
url(r'^edit-gig/(?P<id>[0-9]+)/$', views.edit_gig, name='edit_gig'),
url(r'^profile/(?P<username>\w+)/$', views.profile, name='profile'),
url(r'^checkout/$', views.create_purchase, name='checkout'),
url(r'^my-sales/$', views.my_sales, name='my_sales'),
url(r'^my-purchases/$', views.my_purchases, name='my_purchases'),
]
20 changes: 20 additions & 0 deletions marketplaceapp/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,26 @@ def create_purchase(request):

return redirect(home)

@login_required(login_url=home)
def my_sales(request):
purchases = Purchase.objects.filter(gig__user=request.user)

return render(
request,
'my_sales.html',
{'purchases': purchases}
)

@login_required(login_url=home)
def my_purchases(request):
purchases = Purchase.objects.filter(buyer=request.user)

return render(
request,
'my_purchases.html',
{'purchases': purchases}
)

def __update_profile(request, profile):
profile.bio = request.POST.get('bio')
profile.slogan = request.POST.get('slogan')
Expand Down

0 comments on commit a458fce

Please sign in to comment.