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

a few grant admin fixes #8263

Merged
merged 1 commit into from
Jan 19, 2021
Merged
Changes from all commits
Commits
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
21 changes: 20 additions & 1 deletion app/grants/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,18 +96,23 @@ class GrantAdmin(GeneralAdmin):
'link', 'clr_prediction_curve', 'hidden', 'next_clr_calc_date', 'last_clr_calc_date',
'metadata', 'twitter_handle_1', 'twitter_handle_2', 'view_count', 'is_clr_eligible', 'in_active_clrs',
'last_update', 'funding_info', 'twitter_verified', 'twitter_verified_by', 'twitter_verified_at', 'stats_history',
'zcash_payout_address', 'celo_payout_address','zil_payout_address'
'zcash_payout_address', 'celo_payout_address','zil_payout_address', 'emails'
]
readonly_fields = [
'logo_svg_asset', 'logo_asset',
'team_member_list', 'clr_prediction_curve',
'subscriptions_links', 'contributions_links', 'link',
'migrated_to', 'view_count', 'in_active_clrs', 'stats_history',
'emails'
]
list_display =['pk', 'sybil_score', 'weighted_risk_score', 'match_amount', 'positive_round_contributor_count', 'is_clr_eligible', 'title', 'active', 'link', 'hidden', 'migrated_to']
raw_id_fields = ['admin_profile', 'twitter_verified_by']
search_fields = ['description', 'admin_profile__handle']

def get_queryset(self, request):
qs = super(GrantAdmin, self).get_queryset(request)
self.request = request
return qs

# Custom Avatars
def logo_svg_asset(self, instance):
Expand All @@ -116,6 +121,13 @@ def logo_svg_asset(self, instance):
return mark_safe(f'<img src="{instance.svg.url}" width="300" height="300" />')
return mark_safe('N/A')

def emails(self, instance):
emails = []
emails.append(instance.admin_profile.email)
for profile in instance.team_members.all():
emails.append(profile.email)
return ",".join(emails)

def view_count(self, instance):
return instance.get_view_count

Expand Down Expand Up @@ -148,6 +160,9 @@ def logo_asset(self, instance):
return mark_safe('N/A')

def subscriptions_links(self, instance):
if not self.request.GET.get('show_data'):
return mark_safe(f"<a href={instance.admin_url}?show_data=1>Show data</a>")

"""Define the logo image tag to be displayed in the admin."""
eles = []
# todo: figure out how to set request
Expand All @@ -168,6 +183,8 @@ def response_change(self, request, obj):
return redirect(obj.admin_url)

def contributions_links(self, instance):
if not self.request.GET.get('show_data'):
return mark_safe(f"<a href={instance.admin_url}?show_data=1>Show data</a>")
"""Define the logo image tag to be displayed in the admin."""
eles = []

Expand All @@ -190,6 +207,8 @@ def migrated_to(self, instance):
return mark_safe(html)

def stats_history(self, instance):
if not self.request.GET.get('show_data'):
return mark_safe(f"<a href={instance.admin_url}?show_data=1>Show data</a>")
html = "<table>"
html += "<tr><td>Date</td><td>Impressions</td><td>Cart Additions</td><td>Contributions</td></tr>"
for ele in instance.stats.filter(snapshot_type='increment').order_by('-created_on'):
Expand Down