Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Grant contributions in profile (#3316) #3859

Merged
merged 26 commits into from
Apr 24, 2019
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
1096cce
Grant contribution activity (#3316)
Feb 27, 2019
c54d417
Grant activity on profile (#3316)
Mar 7, 2019
b4d590a
Update app/grants/views.py
Mar 7, 2019
ddb5338
owocki's requested changes (#3316)
Mar 8, 2019
c25f034
Merge branch 'master' of github.com:e18r/web
Mar 8, 2019
a271bd0
owocki's requested changes 2 (#3316)
Mar 10, 2019
c3e27e8
Show grant-related activity in the /activity page (#3316)
Mar 13, 2019
32a59d0
Fixed icon bug (#3316)
Mar 13, 2019
6d90018
Record grant lifecycle activities (#3316)
Mar 13, 2019
caeee0f
Show grant lifecycle activities in profile (#3316)
Mar 13, 2019
bbe8096
Show new activities in /activity page (#3316)
Mar 13, 2019
c527307
Merge branch 'master' of https://github.com/gitcoinco/web
Mar 15, 2019
d92d575
Merge latest Gitcoinco changes into my local repo
Mar 19, 2019
3428359
Changes requested by @thelostone-mc (#3316)
Mar 19, 2019
ee5fe57
Undo change from `far` to `fa` (requested by @thelostone-mc) (#3316)
Mar 24, 2019
be021fe
Merge branch 'master' of https://github.com/gitcoinco/web
Mar 25, 2019
a83ef10
Merge branch 'master' of https://github.com/gitcoinco/web
Mar 26, 2019
6b94906
Solved migration conflict (requested by @danlipert) (#3316)
Mar 27, 2019
384a2c9
Merge branch 'master' into master
thelostone-mc Apr 6, 2019
2e13a32
Merge branch 'master' of https://github.com/gitcoinco/web
Apr 16, 2019
c1c0b58
Merge branch 'master' of https://github.com/gitcoinco/web
Apr 16, 2019
107aa54
Merge branch 'master' of https://github.com/gitcoinco/web
Apr 18, 2019
36aca5b
[#3316] Solved conflicting migrations
Apr 18, 2019
d303030
Merge branch 'master' of github.com:e18r/web
Apr 18, 2019
7e38f62
Merge branch 'master' into master
danlipert Apr 24, 2019
9b388f7
Merge branch 'master' into master
danlipert Apr 24, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions app/dashboard/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -1554,6 +1554,7 @@ class Activity(SuperModel):
('update_grant', 'Updated Grant'),
('killed_grant', 'Cancelled Grant'),
('new_grant_contribution', 'Contributed to Grant'),
('new_grant_subscription', 'Subscribed to Grant'),
e18r marked this conversation as resolved.
Show resolved Hide resolved
('killed_grant_contribution', 'Cancelled Grant Contribution'),
('new_milestone', 'New Milestone'),
('update_milestone', 'Updated Milestone'),
Expand Down Expand Up @@ -1585,6 +1586,12 @@ class Activity(SuperModel):
on_delete=models.CASCADE,
blank=True, null=True
)
subscription = models.ForeignKey(
e18r marked this conversation as resolved.
Show resolved Hide resolved
'grants.Subscription',
related_name='activities',
on_delete=models.CASCADE,
blank=True, null=True
)
created = models.DateTimeField(auto_now_add=True, blank=True, null=True, db_index=True)
activity_type = models.CharField(max_length=50, choices=ACTIVITY_TYPES, blank=True, db_index=True)
metadata = JSONField(default=dict)
Expand Down Expand Up @@ -2435,8 +2442,9 @@ def get_bounty_and_tip_activities(self, network='mainnet'):

all_activities = all_activities.filter(
Q(bounty__network=network) |
Q(tip__network=network),
).select_related('bounty', 'tip').all().order_by('-created')
Q(tip__network=network) |
Q(subscription__network=network)
).select_related('bounty', 'tip', 'subscription').all().order_by('-created')

return all_activities

Expand Down
2 changes: 2 additions & 0 deletions app/dashboard/templates/profiles/profile_activities.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,7 @@
{% include "shared/profile_activities_tip.html" with tip=activity.tip %}
{% elif activity.bounty %}
{% include "shared/profile_activities_bounty.html" %}
{% elif activity.subscription %}
{% include "shared/profile_activities_grant.html" %}
{% endif %}
{% endfor %}
77 changes: 77 additions & 0 deletions app/dashboard/templates/shared/profile_activities_grant.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
{% load i18n humanize %}
<a class="row result bounty_row {{ activity.subscription.network }}" target="_blank"
{% if activity.subscription.grant.url %} href="{{ activity.subscription.grant.url }}"
{% elif activity.subscription.grant.reference_url %} href="{{ activity.subscription.grant.reference_url }}"
{% endif %}>
<div class="avatar-container col-1 justify-content-center special_tag hide_min_viewport">
{% if activity.subscription.grant.logo %}
<img class="avatar" src="{{ activity.subscription.grant.logo.url }}">
{% else %}
<img class="avatar" src="{% url 'org_avatar' activity.subscription.grant.admin_profile.handle %}">
{% endif %}
</div>
<div class="col-12 col-md-7 d-flex flex-column">
<div class="bounty-detail">
<div class="title font-subheader">
{{ activity.subscription.grant.title }}
</div>

<div class="bounty-summary col-12">
<div class="info font-caption">
{{ activity.subscription.grant.amount_received | floatformat:2 }} /
{{ activity.subscription.grant.amount_goal | floatformat:2 }}
{{ activity.subscription.grant.token_symbol }}
&bull; {{ activity.created | naturaltime }}
</div>
</div>
</div>
</div>
<div class="col-12 col-md-4 tags fixed font-caption align-items-center">
{% if activity.activity_type == 'new_grant_contribution' %}
<div class="tag success">
<p>
<span>{% trans "Contributed " %}</span>
</p>
</div>
{% elif activity.activity_type == 'new_grant_subscription' %}
<div class="tag success">
<p>
<span>{% trans "Subscribed " %}</span>
</p>
</div>
{% elif activity.activity_type == 'killed_grant_contribution' %}
<div class="tag warning">
<p>
<span>{% trans "Canceled subscription " %}</span>
</p>
</div>
{% else %}
<div class="tag in-progress">
<p>
<span>{{ activity.i18n_name }}</span>
</p>
</div>
{% endif %}
{% if activity.subscription.network != 'mainnet' %}
<div class="tag network_warning">
<p>
<span>{{ activity.subscription.network }}</span>
</p>
</div>
e18r marked this conversation as resolved.
Show resolved Hide resolved
{% endif %}
<div class="tag token">
<p>
{{ activity.subscription.amount_per_period | floatformat:2 }}
<span>{{ activity.subscription.token_symbol }}</span>
</p>
</div>
{% if activity.subscription.value_in_usdt_now %}
<div class="tag usd">
<p>
{{ activity.subscription.value_in_usdt_now }}
<span>USD</span>
</p>
</div>
{% endif %}
</div>
</a>
3 changes: 3 additions & 0 deletions app/dashboard/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -1267,6 +1267,9 @@ def profile(request, handle):
('work_done', _('Bounties Completed')),
('new_tip', _('Tips Sent')),
('receive_tip', _('Tips Received')),
('new_grant_contribution', _('Grants contributed to')),
('new_grant_subscription', _('Grants subscribed to')),
('killed_grant_contribution', _('Grants unsubscribed from')),
]
page = request.GET.get('p', None)

Expand Down
15 changes: 14 additions & 1 deletion app/grants/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@

from app.utils import get_profile
from cacheops import cached_view
from dashboard.models import Profile
from dashboard.models import Profile, Activity
e18r marked this conversation as resolved.
Show resolved Hide resolved
from gas.utils import conf_time_spread, eth_usd_conv_rate, gas_advisories, recommend_min_gas_price_to_confirm_in_time
from grants.forms import MilestoneForm
from grants.models import Contribution, Grant, MatchPledge, Milestone, Subscription, Update
Expand Down Expand Up @@ -387,13 +387,20 @@ def grant_fund(request, grant_id, grant_slug):
subscription.contributor_profile = profile
subscription.grant = grant
subscription.save()
activity_kwargs = {
e18r marked this conversation as resolved.
Show resolved Hide resolved
'profile': profile,
'subscription': subscription,
'activity_type': 'new_grant_subscription',
}

# one time payments
if subscription.num_tx_approved == '1':
subscription.successful_contribution(subscription.new_approve_tx_id);
subscription.error = True #cancel subs so it doesnt try to bill again
subscription.subminer_comments = "skipping subminer bc this is a 1 and done subscription, and tokens were alredy sent"
subscription.save()
activity_kwargs['activity_type'] = 'new_grant_contribution'
Activity.objects.create(**activity_kwargs)

messages.info(
request,
Expand Down Expand Up @@ -472,6 +479,12 @@ def subscription_cancel(request, grant_id, grant_slug, subscription_id):
subscription.cancel_tx_id = request.POST.get('sub_cancel_tx_id', '')
subscription.active = False
subscription.save()
activity_kwargs = {
e18r marked this conversation as resolved.
Show resolved Hide resolved
'profile': profile,
'subscription': subscription,
'activity_type': 'killed_grant_contribution',
}
Activity.objects.create(**activity_kwargs)

value_usdt = subscription.get_converted_amount
if value_usdt:
Expand Down