Skip to content

Commit

Permalink
add kudos data to activity feed
Browse files Browse the repository at this point in the history
  • Loading branch information
octavioamu committed Nov 2, 2018
1 parent 4cc1c89 commit 4ddaf7b
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 3 deletions.
25 changes: 25 additions & 0 deletions app/dashboard/migrations/0111_auto_20181101_1922.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Generated by Django 2.1.2 on 2018-11-01 19:22

from django.db import migrations, models
import django.db.models.deletion


class Migration(migrations.Migration):

dependencies = [
('kudos', '0005_auto_20181101_1356'),
('dashboard', '0110_auto_20181027_1727'),
]

operations = [
migrations.AddField(
model_name='activity',
name='kudos',
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='activities', to='kudos.KudosTransfer'),
),
migrations.AlterField(
model_name='activity',
name='activity_type',
field=models.CharField(blank=True, choices=[('new_bounty', 'New Bounty'), ('start_work', 'Work Started'), ('stop_work', 'Work Stopped'), ('work_submitted', 'Work Submitted'), ('work_done', 'Work Done'), ('worker_approved', 'Worker Approved'), ('worker_rejected', 'Worker Rejected'), ('worker_applied', 'Worker Applied'), ('increased_bounty', 'Increased Funding'), ('killed_bounty', 'Canceled Bounty'), ('new_tip', 'New Tip'), ('receive_tip', 'Tip Received'), ('bounty_abandonment_escalation_to_mods', 'Escalated for Abandonment of Bounty'), ('bounty_abandonment_warning', 'Warning for Abandonment of Bounty'), ('bounty_removed_slashed_by_staff', 'Dinged and Removed from Bounty by Staff'), ('bounty_removed_by_staff', 'Removed from Bounty by Staff'), ('bounty_removed_by_funder', 'Removed from Bounty by Funder'), ('new_crowdfund', 'New Crowdfund Contribution'), ('new_kudos', 'New Kudos')], max_length=50),
),
]
3 changes: 3 additions & 0 deletions app/dashboard/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -1455,6 +1455,7 @@ def i18n_name(self):
@property
def view_props(self):
from dashboard.tokens import token_by_name
from kudos.models import Token
icons = {
'new_tip': 'fa-thumbs-up',
'start_work': 'fa-lightbulb',
Expand All @@ -1465,6 +1466,8 @@ def view_props(self):

activity = self
activity.icon = icons.get(activity.activity_type, 'fa-check-circle')
if activity.kudos:
activity.kudos_data = Token.objects.get(pk=activity.kudos.kudos_token_cloned_from_id)
obj = activity.metadata
if 'new_bounty' in activity.metadata:
obj = activity.metadata['new_bounty']
Expand Down
2 changes: 1 addition & 1 deletion app/kudos/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -470,7 +470,7 @@ def record_kudos_activity(kudos_transfer, github_handle, event_name):
kwargs['bounty'] = kudos_transfer.bounty
except:
pass
try:
try:
Activity.objects.create(**kwargs)
except Exception as e:
logging.error(f"error in record_kudos_activity: {e} - {event_name} - {kudos_transfer} - {github_handle}")
Expand Down
21 changes: 19 additions & 2 deletions app/retail/templates/shared/activity.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@
<div class="col-12 col-md-1">
<div class="activity-avatar">
<img class="avatar" src="/dynamic/avatar/{{ row.profile.handle }}"/>
{% if row.metadata.to_username %}
<img class="avatar" src="/dynamic/avatar/{{ row.metadata.to_username|cut:'@' }}" style="
width: 30px; height: 30px; bottom: 0; right: 0; position: absolute;"/>
{% endif %}
</div>
</div>
<div class="col-12 col-md-10 activity-info">
Expand All @@ -32,6 +36,13 @@
<a href="https://gitcoin.co/profile/{{ row.metadata.to_username }}" target="_blank">
@{{ row.metadata.to_username }}
</a>
{% elif row.activity_type == 'new_kudos' %}
{% trans "send a" %}
{{ row.i18n_name|lower }}
{% trans "to" %}
<a href="/profile/{{ row.metadata.to_username|cut:'@' }}">
{{ row.metadata.to_username }}
</a>
{% elif row.activity_type == 'new_bounty' %}
<span>{% trans "funded a new issue: " %}</span>{{ row.urled_title | safe }}
{% elif row.activity_type == 'start_work' %}
Expand Down Expand Up @@ -73,7 +84,13 @@
</div>
</div>
</div>
<div class="col-12 col-md-1">
<i class="far {{ row.icon }} last-icon"></i>
<div class="col-12 col-md-1 text-center">
{% if row.kudos %}
<a href="/kudos/{{row.kudos.kudos_token_cloned_from_id}}/{{row.kudos.kudos_token_cloned_from.name}}">
<img src="{% static row.kudos_data.image %}" alt="" class="w-100">
</a>
{% else %}
<i class="far {{ row.icon }} last-icon"></i>
{% endif %}
</div>
</div>

0 comments on commit 4ddaf7b

Please sign in to comment.