Skip to content

Commit

Permalink
Feature/delete portfolio projects (#7520)
Browse files Browse the repository at this point in the history
* feat(profile): delete portfolio item

* fix(tests): resolve import error

* fix(docs): little updates
  • Loading branch information
chibie authored Sep 24, 2020
1 parent 182bbb3 commit b248b35
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 8 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
6 changes: 4 additions & 2 deletions app/marketing/management/commands/new_bounties_email.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@

THROTTLE_S = 0.005


class Command(BaseCommand):

help = 'sends new_bounty_daily _emails'
Expand Down Expand Up @@ -63,15 +64,16 @@ def handle(self, *args, **options):
# stats
speed = counter_total / (time.time() - start_time)
ETA = round((total_count - counter_total) / speed / 3600, 1)
print(f"{counter_sent} sent/{counter_total} enabled/ {total_count} total, {round(speed, 2)}/s, ETA:{ETA}h, working on {to_email} ")
print(
f"{counter_sent} sent/{counter_total} enabled/ {total_count} total, {round(speed, 2)}/s, ETA:{ETA}h, working on {to_email} ")

# send
did_send = new_bounty_daily(es.pk)
if did_send:
counter_sent += 1

time.sleep(THROTTLE_S)

except Exception as e:
logging.exception(e)
print(e)
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
@pytest.mark.django_db
class TestNewBountiesEmail(TestCase):
"""Define tests for testing new bounties email."""

def setUp(self):
"""Perform setup for the testcase."""

Profile.objects.create(
data={},
handle='fred',
Expand Down Expand Up @@ -69,8 +69,7 @@ def setUp(self):
network='mainnet',
)


def test_get_bounties_for_keywords(self):
"""Test get_bounties_for_keywords function to confirm a bounty reserved for a specific user is excluded."""
new_bounties, _all_bounties = get_bounties_for_keywords('Python',24)
new_bounties, _all_bounties = get_bounties_for_keywords('Python', 24)
assert new_bounties.count() == 1
2 changes: 1 addition & 1 deletion docs/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ life easier for you if you are the kind who enjoys multiple things parallely.
These should also be created directly off of the `master` branch.

```shell
git checkout -b my-branch -t upstream/master
git checkout -b my-branch
```

### Step 3: Code
Expand Down
2 changes: 1 addition & 1 deletion docs/GRANTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ can use this account to send transfers without prompting you for each transfer!
only held by this account temporarily to improve UX. Because it does not permanently hold funds
there is no additional security risk.

### Checkout Fow
### Checkout Flow

Based on the items in your cart, we check your zkSync balances to see if you already have enough
funds on zkSync to complete checkout.
Expand Down

0 comments on commit b248b35

Please sign in to comment.