Skip to content

Commit

Permalink
feat(profile): delete portfolio item
Browse files Browse the repository at this point in the history
  • Loading branch information
chibie committed Sep 24, 2020
1 parent 182bbb3 commit 6e115c1
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
5 changes: 5 additions & 0 deletions app/dashboard/templates/profiles/tab_portfolio.html
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,11 @@ <h5 class="font-weight-semibold">{{pi.title}}</h5>&nbsp;
{% if pi.link %}
<a class="btn btn-gc-blue btn-sm m-2" href="{{pi.link}}">View Work &gt;</a>
{% endif %}
<form method="POST">
{% csrf_token %}
<input type="hidden" value="{{ pi.pk }}" name="project_pk">
<input class="btn btn-gc-pink btn-sm m-2" type="submit" name="submit" id="submit" value="Delete">
</form>
</div>
</div>
{% endfor %}
Expand Down
9 changes: 9 additions & 0 deletions app/dashboard/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -2821,6 +2821,7 @@ def get_profile_tab(request, profile, tab, prev_context):
pass
elif tab == 'portfolio':
title = request.POST.get('project_title')
pk = request.POST.get('project_pk')
if title:
if request.POST.get('URL')[0:4] != "http":
messages.error(request, 'Invalid link.')
Expand All @@ -2836,6 +2837,14 @@ def get_profile_tab(request, profile, tab, prev_context):
tags=request.POST.get('tags').split(','),
)
messages.info(request, 'Portfolio Item added.')
if pk:
# delete portfolio item
if not request.user.is_authenticated or request.user.profile.pk != profile.pk:
messages.error(request, 'Not Authorized')
pi = PortfolioItem.objects.filter(pk=pk).first()
if pi:
pi.delete()
messages.info(request, 'Portfolio Item has been deleted.')
elif tab == 'earnings':
context['earnings'] = Earning.objects.filter(to_profile=profile, network='mainnet', value_usd__isnull=False).order_by('-created_on')
elif tab == 'spent':
Expand Down

0 comments on commit 6e115c1

Please sign in to comment.