Skip to content

Commit

Permalink
Show new activities in /activity page (gitcoinco#3316)
Browse files Browse the repository at this point in the history
* Added icons for each activity type in the Activity model
* Modified the metadata of grant activities so that it can be
  displayed correctly
* Adapted the activity template so it shows the grant information
  correctly
* Corrected spelling of "cancelled"
  • Loading branch information
Emilio Silva Schlenker committed Mar 15, 2019
1 parent ab06669 commit e8060af
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 4 deletions.
3 changes: 3 additions & 0 deletions app/dashboard/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -1634,6 +1634,9 @@ def view_props(self):
'new_bounty': 'fa-money-bill-alt',
'work_done': 'fa-check-circle',
'new_kudos': 'fa-thumbs-up',
'new_grant': 'fa-envelope',
'update_grant': 'fa-edit',
'killed_grant': 'fa-trash',
'new_grant_contribution': 'fa-coins',
'new_grant_subscription': 'fa-calendar-check',
'killed_grant_contribution': 'fa-calendar-times',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
{% elif activity.activity_type == 'killed_grant_contribution' %}
<div class="tag warning">
<p>
<span>{% trans "Canceled subscription " %}</span>
<span>{% trans "Cancelled subscription " %}</span>
</p>
</div>
{% else %}
Expand Down
15 changes: 12 additions & 3 deletions app/grants/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -657,13 +657,17 @@ def record_subscription_activity_helper(activity_type, subscription, profile):
profile (dashboard.models.Profile): The current user's profile.
"""
try:
grant_logo = subscription.grant.logo.url
except:
grant_logo = None
metadata = {
'id': subscription.id,
'value_in_token': str(subscription.amount_per_period),
'value_in_usdt_now': str(subscription.amount_per_period_usdt),
'token_name': subscription.token_symbol,
'title': subscription.grant.title,
'grant_logo': subscription.grant.logo.url,
'grant_logo': grant_logo,
'grant_url': subscription.grant.url,
'category': 'grant',
}
Expand All @@ -684,12 +688,17 @@ def record_grant_activity_helper(activity_type, grant, profile):
profile (dashboard.models.Profile): The current user's profile.
"""
try:
grant_logo = grant.logo.url
except:
grant_logo = None
metadata = {
'id': grant.id,
'value_in_token': str(grant.amount_received),
'value_in_token': '{0:.2f}'.format(grant.amount_received),
'amount_goal': '{0:.2f}'.format(grant.amount_goal),
'token_name': grant.token_symbol,
'title': grant.title,
'grant_logo': grant.logo.url,
'grant_logo': grant_logo,
'grant_url': grant.url,
'category': 'grant',
}
Expand Down
20 changes: 20 additions & 0 deletions app/retail/templates/shared/activity.html
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,21 @@
<a href="/profile/{{ row.metadata.to_username|cut:'@' }}">
{{ row.metadata.to_username }}
</a>
{% elif row.activity_type == 'new_grant' %}
{% trans "created" %}
<a href="{{ row.metadata.grant_url }}" target="_blank">
{{ row.metadata.title }}
</a>
{% elif row.activity_type == 'update_grant' %}
{% trans "updated" %}
<a href="{{ row.metadata.grant_url }}" target="_blank">
{{ row.metadata.title }}
</a>
{% elif row.activity_type == 'killed_grant' %}
{% trans "cancelled" %}
<a href="{{ row.metadata.grant_url }}" target="_blank">
{{ row.metadata.title }}
</a>
{% elif row.activity_type == 'new_grant_contribution' %}
{% trans "contributed to" %}
<a href="{{ row.metadata.grant_url }}" target="_blank">
Expand Down Expand Up @@ -88,16 +103,21 @@
<span>{{ row.value_in_token_disp }} {{row.token_name}}</span>
{% elif row.metadata.value_in_eth %}
<span>{{ row.metadata.value_in_eth }} {{row.token_name}}</span>
{% elif row.grant %}
{{ row.metadata.value_in_token | floatformat:2 }} / {{ row.metadata.amount_goal | floatformat:2 }}
{{ row.metadata.token_name }}
{% else %}
<span>{{row.metadata.value_in_token_old}} - {{row.metadata.value_in_token}} {{row.metadata.token_name}}</span>
{% endif %}
</p>
</div>
{% if row.value_in_usdt_now %}
<div class="tag usd">
<p>
<span>{{ row.value_in_usdt_now }} USD</span>
</p>
</div>
{% endif %}
<span class="mx-2">
{{ row.created_human_time }}
</span>
Expand Down

0 comments on commit e8060af

Please sign in to comment.