Skip to content

Commit

Permalink
grants admin message && visible toggle (#8496)
Browse files Browse the repository at this point in the history
* grants admin message

* Update views.py

* Recreates migration

* Updates admin_message alert styles to match twitter verification alert

Co-authored-by: Aditya Anand M C <[email protected]>
Co-authored-by: Graham Dixon <[email protected]>
  • Loading branch information
3 people authored Mar 17, 2021
1 parent 1b5bd00 commit 5a25838
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 5 deletions.
9 changes: 6 additions & 3 deletions app/grants/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,18 +100,20 @@ class GrantAdmin(GeneralAdmin):

ordering = ['-id']
fields = [
'title',
'active', 'visible', 'is_clr_eligible',
'migrated_to', 'region',
'title', 'grant_type', 'categories', 'description', 'description_rich', 'github_project_url', 'reference_url', 'admin_address', 'active',
'grant_type', 'categories', 'description', 'description_rich', 'github_project_url', 'reference_url', 'admin_address',
'amount_received', 'amount_received_in_round', 'monthly_amount_subscribed',
'deploy_tx_id', 'cancel_tx_id', 'admin_profile', 'token_symbol',
'token_address', 'contract_address', 'contract_version', 'network', 'required_gas_price', 'logo_svg_asset',
'logo_asset', 'created_on', 'modified_on', 'team_member_list',
'subscriptions_links', 'contributions_links', 'logo', 'logo_svg', 'image_css',
'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',
'metadata', 'twitter_handle_1', 'twitter_handle_2', 'view_count', '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', 'harmony_payout_address', 'binance_payout_address',
'polkadot_payout_address', 'kusama_payout_address', 'rsk_payout_address', 'emails'
'polkadot_payout_address', 'kusama_payout_address', 'rsk_payout_address', 'emails', 'admin_message'
]
readonly_fields = [
'logo_svg_asset', 'logo_asset',
Expand Down Expand Up @@ -194,6 +196,7 @@ def response_change(self, request, obj):
if "_mark_fraud" in request.POST:
obj.active = False
obj.is_clr_eligible = False
obj.visible = False
obj.save()
self.message_user(request, "Marked Grant as Fraudulent. Consider blocking the grant admin next?")
if "_calc_clr" in request.POST:
Expand Down
23 changes: 23 additions & 0 deletions app/grants/migrations/0116_auto_20210316_2021.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Generated by Django 2.2.4 on 2021-03-16 20:21

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('grants', '0115_auto_20210310_0532'),
]

operations = [
migrations.AddField(
model_name='grant',
name='admin_message',
field=models.TextField(blank=True, default='', help_text='An admin message that will be shown to visitors of this grant.'),
),
migrations.AddField(
model_name='grant',
name='visible',
field=models.BooleanField(default=True, help_text='Is grant visible on the site'),
),
]
3 changes: 3 additions & 0 deletions app/grants/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,8 @@ class Meta:
reference_url = models.URLField(blank=True, help_text=_('The associated reference URL of the Grant.'))
github_project_url = models.URLField(blank=True, null=True, help_text=_('Grant Github Project URL'))
is_clr_eligible = models.BooleanField(default=True, help_text="Is grant eligible for CLR")
admin_message = models.TextField(default='', blank=True, help_text=_('An admin message that will be shown to visitors of this grant.'))
visible = models.BooleanField(default=True, help_text="Is grant visible on the site")
region = models.CharField(
max_length=30,
null=True,
Expand Down Expand Up @@ -945,6 +947,7 @@ def repr(self, user, build_absolute_uri):
'reference_url': self.reference_url,
'github_project_url': self.github_project_url or '',
'funding_info': self.funding_info,
'admin_message': self.admin_message,
'link_to_new_grant': self.link_to_new_grant.url if self.link_to_new_grant else self.link_to_new_grant,
'region': {'name':self.region, 'label':self.get_region_display()} if self.region and self.region != 'null' else None
}
Expand Down
14 changes: 12 additions & 2 deletions app/grants/templates/grants/detail/template-grant-details.html
Original file line number Diff line number Diff line change
Expand Up @@ -220,12 +220,22 @@ <h3>About</h3>

<!-- Grant Management -->
<div class="grant-managment">
<div class="my-0 mx-0" v-if="grant.admin_message">
<div class="bs-alert alert alert-warning p-2 d-flex">
<div class="text-center w-100">
<i class="fas fa-exclamation-triangle verification__warning__icon mr-1 my-2 d-inline-block" style="font-size:1rem"></i>
<div class="d-inline-block uppercase font-weight-semibold w-100">
[[grant.admin_message]]
</div>
</div>
</div>
</div>
<div class="my-0 mx-0" v-if="grant.active && !grant.verified">
<div class="bs-alert alert alert-warning pt-2 pb-2 pr-2 pl-2 d-flex">
<div class="bs-alert alert alert-warning p-2 d-flex">
<div class="text-center">
<i class="fas fa-exclamation-triangle verification__warning__icon mr-1 my-2 d-inline-block" style="font-size:1rem"></i>
<div class="d-inline-block uppercase">
Warning: This grant has not verified their ownership of the twitter account listed.
<span class="font-weight-semibold">Warning:</span> This grant has not verified their ownership of the twitter account listed.
</div>
<template v-if="grant.is_on_team && user_code">
<div class="my-2 d-inline-block text-center w-100">
Expand Down
2 changes: 2 additions & 0 deletions app/grants/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -1312,6 +1312,8 @@ def grant_details(request, grant_id, grant_slug):
pk=grant_id
)

if not grant.visible:
raise Http404
increment_view_count.delay([grant.pk], grant.content_type, request.user.id, 'individual')
subscriptions = grant.subscriptions.none()
cancelled_subscriptions = grant.subscriptions.none()
Expand Down

0 comments on commit 5a25838

Please sign in to comment.