Skip to content

Commit 6c6a8d7

Browse files
authored
feat: adds tags_requested and command to place main-rnd tag on all approved grants (#10750)
1 parent 15b9079 commit 6c6a8d7

File tree

6 files changed

+59
-9
lines changed

6 files changed

+59
-9
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
from django.core.management.base import BaseCommand
2+
3+
from grants.models import Grant, GrantTag
4+
5+
class Command(BaseCommand):
6+
7+
help = 'updates all approved grants to include the main-round tag'
8+
9+
def handle(self, *args, **options):
10+
# main-round tag
11+
tag = GrantTag.objects.get(pk=62)
12+
grants = Grant.objects.filter(active=True, hidden=False, is_clr_eligible=True)
13+
14+
print(f"adding main-round tag to {grants.count()} Grants:")
15+
16+
# for every eligible grant
17+
for grant in grants:
18+
try:
19+
# update the tag record to include the main round tag
20+
grant.tags.add(tag)
21+
grant.save()
22+
except Exception as e:
23+
pass
24+
25+
print("\n - done\n")

app/grants/admin.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ class FlagAdmin(admin.ModelAdmin):
5151
ordering = ['-id']
5252
raw_id_fields = ['profile', 'grant']
5353
readonly_fields = ['grant_link']
54-
54+
5555
def grant_link(self, obj):
5656
return format_html("<a href='/grants/{id}/{slug}' target=\"_blank\">Grant Details</a>", id=obj.grant.id, slug=obj.grant.slug)
5757

@@ -105,9 +105,10 @@ class GrantAdmin(GeneralAdmin):
105105
'title', 'is_grant_idle',
106106
'active', 'visible', 'is_clr_eligible',
107107
'migrated_to', 'region',
108-
'grant_type', 'tags', 'tag_eligibility_reason','description', 'description_rich', 'github_project_url', 'reference_url', 'admin_address',
109-
'amount_received', 'amount_received_in_round', 'monthly_amount_subscribed', 'defer_clr_to',
110-
'deploy_tx_id', 'cancel_tx_id', 'admin_profile', 'token_symbol',
108+
'grant_type', 'tags_requested', 'tags', 'tag_eligibility_reason',
109+
'description', 'description_rich', 'github_project_url', 'reference_url',
110+
'admin_address', 'amount_received', 'amount_received_in_round', 'monthly_amount_subscribed',
111+
'defer_clr_to', 'deploy_tx_id', 'cancel_tx_id', 'admin_profile', 'token_symbol',
111112
'token_address', 'contract_address', 'contract_version', 'network', 'required_gas_price', 'logo_svg_asset',
112113
'logo_asset', 'created_on', 'modified_on', 'team_member_list',
113114
'subscriptions_links', 'contributions_links', 'logo', 'logo_svg', 'image_css',
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Generated by Django 2.2.24 on 2022-08-09 11:34
2+
3+
from django.db import migrations, models
4+
5+
6+
class Migration(migrations.Migration):
7+
8+
dependencies = [
9+
('grants', '0145_grant_tag_eligibility_reason'),
10+
]
11+
12+
operations = [
13+
migrations.AddField(
14+
model_name='grant',
15+
name='tags_requested',
16+
field=models.ManyToManyField(blank=True, related_name='tags_requested', to='grants.GrantTag'),
17+
),
18+
migrations.AlterField(
19+
model_name='grant',
20+
name='tags',
21+
field=models.ManyToManyField(blank=True, related_name='tags', to='grants.GrantTag'),
22+
),
23+
]

app/grants/models/grant.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -584,7 +584,8 @@ class Meta:
584584
db_index=True,
585585
)
586586
categories = models.ManyToManyField('GrantCategory', blank=True) # TODO: REMOVE
587-
tags = models.ManyToManyField('GrantTag', blank=True)
587+
tags = models.ManyToManyField('GrantTag', blank=True, related_name='tags')
588+
tags_requested = models.ManyToManyField('GrantTag', blank=True, related_name='tags_requested')
588589
tag_eligibility_reason = models.TextField(default='', blank=True, help_text=_('Eligibility Tag Reasoning'))
589590
twitter_handle_1 = models.CharField(default='', max_length=255, help_text=_('Grants twitter handle'), blank=True)
590591
twitter_handle_2 = models.CharField(default='', max_length=255, help_text=_('Grants twitter handle'), blank=True)

app/grants/utils.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,7 @@ def save_grant_to_notion(grant):
321321
# fully qualified url
322322
fullUrl = BASE_URL.rstrip('/') + grant.url
323323
grant_tags = []
324-
for tag in grant.tags.all():
324+
for tag in grant.tags_requested.all():
325325
grant_tags.append(str(tag))
326326

327327
# write to NOTION_SYBIL_DB following the defined schema (returns dict of new object)
@@ -494,10 +494,10 @@ def bsci_script(csv: str) -> tuple:
494494
# Assign final `is_sybil` markings according to a priorization criteria
495495
df.loc[labels_by_evaluation, 'is_sybil'] = df[labels_by_evaluation].evaluation_score > EVAL_THRESHOLD
496496
df.loc[labels_by_evaluation, 'label'] = "Human Evaluation"
497-
497+
498498
df.loc[labels_by_heuristic, 'is_sybil'] = df[labels_by_heuristic].heuristic_score > HEURISTIC_THRESHOLD
499499
df.loc[labels_by_heuristic, 'label'] = "Heuristics"
500-
500+
501501
df.loc[labels_by_prediction, 'is_sybil'] = df[labels_by_prediction].prediction_score > ML_THRESHOLD
502502
df.loc[labels_by_prediction, 'label'] = "ML Prediction"
503503

app/grants/views.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3347,7 +3347,7 @@ def post(self, request):
33473347
for tag_id in tag_ids:
33483348
try:
33493349
tag = GrantTag.objects.get(pk=tag_id)
3350-
grant.tags.add(tag)
3350+
grant.tags_requested.add(tag)
33513351
except Exception as e:
33523352
pass
33533353

0 commit comments

Comments
 (0)