Skip to content

Commit

Permalink
activity stream DRY & cleanup (#5041)
Browse files Browse the repository at this point in the history
* massive activity stream cleanup

* make fix

* make fix

* lint fixes
  • Loading branch information
owocki authored and thelostone-mc committed Aug 22, 2019
1 parent 5329f8f commit 1cb0949
Show file tree
Hide file tree
Showing 12 changed files with 70 additions and 377 deletions.
28 changes: 22 additions & 6 deletions app/assets/v2/css/activity_stream.css
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

#activity_stream .avatar {
.activity_stream .avatar {
width: 50px;
height: 50px;
margin: 0px auto;
Expand All @@ -17,14 +17,17 @@
height: 80px;
}

.funder-avatar,
.activity-avatar {
text-align: center;
.activity .secondary_avatar {
width: 3.125rem;
height: 3.125rem;
top: 1rem;
right: 0rem;
position: absolute;
}

.funder-avatar,
.activity div {
margin: auto;
.activity-avatar {
text-align: center;
}

.last-icon {
Expand All @@ -43,3 +46,16 @@
.activity.new_kudos .activity-tags .tag {
display: none;
}

@media (max-width: 767.98px) {

.activity-info {
text-align: center;
}

.activity_stream .activity .avatar.secondary_avatar {
position: unset;
margin-left: -20px;
margin-top: 20px;
}
}
21 changes: 19 additions & 2 deletions app/dashboard/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -1727,8 +1727,8 @@ class Activity(SuperModel):
('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_abandonment_escalation_to_mods', 'Escalated checkin from @gitcoinbot about bounty status'),
('bounty_abandonment_warning', 'Checkin from @gitcoinbot about bounty status'),
('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'),
Expand Down Expand Up @@ -1848,6 +1848,7 @@ def view_props(self):
if getattr(self, fk):
activity[fk] = getattr(self, fk).to_standard_dict(properties=properties)
print(activity['kudos'])
activity['secondary_avatar_url'] = self.secondary_avatar_url
# KO notes 2019/01/30
# this is a bunch of bespoke information that is computed for the views
# in a later release, it couild be refactored such that its just contained in the above code block ^^.
Expand Down Expand Up @@ -1878,6 +1879,22 @@ def view_props(self):

return activity

@property
def secondary_avatar_url(self):
if self.metadata.get('to_username'):
return f"/dynamic/avatar/{self.metadata['to_username']}"
if self.metadata.get('worker_handle'):
return f"/dynamic/avatar/{self.metadata['worker_handle']}"
if self.metadata.get('url'):
return self.metadata['url']
if self.bounty:
return self.bounty.avatar_url
if self.metadata.get('grant_logo'):
return self.metadata['grant_logo']
if self.grant:
return self.grant.logo.url
return None

@property
def token_name(self):
if self.bounty:
Expand Down
3 changes: 2 additions & 1 deletion app/dashboard/templates/profiles/profile.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
<link rel="stylesheet" href={% static "v2/css/tabs.css" %} />
<link rel="stylesheet" href={% static "v2/css/rating.css" %} />
<link rel="stylesheet" href={% static "v2/css/scroll-carousel.css" %} />
<link rel="stylesheet" href="{% static "v2/css/activity_stream.css" %}">
</head>
<body class="interior {{ active }} g-font-muli">
{% include 'shared/tag_manager_2.html' %}
Expand Down Expand Up @@ -263,7 +264,7 @@ <h1 class="profile-header__handle">
<div id="section-{{ tab.id }}" class="tab-section">
<div class="container">
<div class="row mb-3 p-2">
<div id="{{ tab.id }}" class="col-12 activities" count="{{ tab.count }}">
<div id="{{ tab.id }}" class="col-12 activities activity_stream" count="{{ tab.count }}">
{% if show_activity %}
{% if tab.type == 'activity' %}
{% include 'profiles/profile_activities.html' with activities=tab.objects %}
Expand Down
12 changes: 1 addition & 11 deletions app/dashboard/templates/profiles/profile_activities.html
Original file line number Diff line number Diff line change
@@ -1,13 +1,3 @@
{% for activity in activities %}
{% if activity.tip %}
{% include "shared/profile_activities_tip.html" with tip=activity.tip %}
{% elif activity.bounty %}
{% include "shared/profile_activities_bounty.html" %}
{% elif activity.grant %}
{% include "shared/profile_activities_grant.html" %}
{% elif activity.subscription %}
{% include "shared/profile_activities_subscription.html" %}
{% else %}
{% include "shared/profile_activities_misc.html" %}
{% endif %}
{% include 'shared/activity.html' with row=activity %}
{% endfor %}
110 changes: 0 additions & 110 deletions app/dashboard/templates/shared/profile_activities_bounty.html

This file was deleted.

63 changes: 0 additions & 63 deletions app/dashboard/templates/shared/profile_activities_grant.html

This file was deleted.

27 changes: 0 additions & 27 deletions app/dashboard/templates/shared/profile_activities_misc.html

This file was deleted.

This file was deleted.

Loading

0 comments on commit 1cb0949

Please sign in to comment.