diff --git a/app/grants/admin.py b/app/grants/admin.py index e864b76bd73..f830f578fa1 100644 --- a/app/grants/admin.py +++ b/app/grants/admin.py @@ -27,8 +27,8 @@ import twitter from grants.models import ( - CartActivity, CLRMatch, Contribution, Flag, Grant, GrantBrandingRoutingPolicy, GrantCLR, GrantCLRCalculation, - GrantCollection, GrantStat, GrantTag, GrantType, MatchPledge, PhantomFunding, Subscription, + CartActivity, CLRMatch, Contribution, Flag, Grant, GrantBrandingRoutingPolicy, GrantTag, GrantCLR, + GrantCLRCalculation, GrantCollection, GrantStat, GrantType, MatchPledge, Subscription, ) from grants.views import record_grant_activity_helper from marketing.mails import grant_more_info_required, new_grant_approved @@ -410,24 +410,6 @@ def response_change(self, request, obj): return redirect(obj.admin_url) -class PhantomFundingAdmin(admin.ModelAdmin): - """Define the GeneralAdmin administration layout.""" - - ordering = ['-id'] - list_display = ['id', 'github_created_on', 'from_ip_address', '__str__'] - raw_id_fields = ['profile', 'grant'] - - def github_created_on(self, instance): - return naturaltime(instance.profile.github_created_on) - - def from_ip_address(self, instance): - end = instance.created_on + timezone.timedelta(hours=1) - start = instance.created_on - timezone.timedelta(hours=1) - visits = set(instance.profile.actions.filter(created_on__gt=start, created_on__lte=end).values_list('ip_address', flat=True)) - visits = [visit for visit in visits if visit] - return " , ".join(visits) - - class CartActivityAdmin(admin.ModelAdmin): list_display = ['id', 'grant', 'profile', 'action', 'bulk', 'latest', 'created_on'] raw_id_fields = ['grant', 'profile'] @@ -537,7 +519,6 @@ class GrantBrandingRoutingPolicyAdmin(admin.ModelAdmin): list_display = ['pk', 'policy_name', 'url_pattern', 'priority' ] -admin.site.register(PhantomFunding, PhantomFundingAdmin) admin.site.register(MatchPledge, MatchPledgeAdmin) admin.site.register(Grant, GrantAdmin) admin.site.register(Flag, FlagAdmin) diff --git a/app/grants/migrations/0124_delete_phantomfunding.py b/app/grants/migrations/0124_delete_phantomfunding.py new file mode 100644 index 00000000000..193d11144b4 --- /dev/null +++ b/app/grants/migrations/0124_delete_phantomfunding.py @@ -0,0 +1,16 @@ +# Generated by Django 2.2.24 on 2021-09-23 22:30 + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('grants', '0123_auto_20210726_0703'), + ] + + operations = [ + migrations.DeleteModel( + name='PhantomFunding', + ), + ] diff --git a/app/grants/models/__init__.py b/app/grants/models/__init__.py index 2797f6605cc..9b3e183af82 100644 --- a/app/grants/models/__init__.py +++ b/app/grants/models/__init__.py @@ -33,5 +33,4 @@ from .grant_tag import GrantTag from .grant_type import GrantType from .match_pledge import MatchPledge -from .phantom_funding import PhantomFunding from .subscription import Subscription diff --git a/app/grants/models/clr_match.py b/app/grants/models/clr_match.py index 32835ac2449..5cd26afb999 100644 --- a/app/grants/models/clr_match.py +++ b/app/grants/models/clr_match.py @@ -53,4 +53,4 @@ class CLRMatch(SuperModel): def __str__(self): """Return the string representation of a Grant.""" - return f"id: {self.pk}, grant: {self.grant.pk}, round: {self.round_number}, amount: {self.amount}" \ No newline at end of file + return f"id: {self.pk}, grant: {self.grant.pk}, round: {self.round_number}, amount: {self.amount}" diff --git a/app/grants/models/grant.py b/app/grants/models/grant.py index e7f44e801f6..ec8ab8fe42a 100644 --- a/app/grants/models/grant.py +++ b/app/grants/models/grant.py @@ -488,7 +488,7 @@ class Meta: ) in_active_clrs = models.ManyToManyField( - GrantCLR, + "GrantCLR", help_text="Active Grants CLR Round" ) is_clr_active = models.BooleanField(default=False, help_text=_('CLR Round active or not? (auto computed)')) @@ -885,7 +885,6 @@ def save(self, update=True, *args, **kwargs): self.clr_prediction_curve = self.calc_clr_prediction_curve self.clr_round_num = self.calc_clr_round_label - self.search_vector = ( SearchVector('title', weight='A') + SearchVector('description', weight='B') ) diff --git a/app/grants/models/match_pledge.py b/app/grants/models/match_pledge.py index 4afa84c9a8b..fcd26445d2d 100644 --- a/app/grants/models/match_pledge.py +++ b/app/grants/models/match_pledge.py @@ -57,4 +57,4 @@ def data_json(self): def __str__(self): """Return the string representation of this object.""" - return f"{self.profile} <> {self.amount} DAI" \ No newline at end of file + return f"{self.profile} <> {self.amount} DAI" diff --git a/app/grants/models/phantom_funding.py b/app/grants/models/phantom_funding.py deleted file mode 100644 index 096ecfae691..00000000000 --- a/app/grants/models/phantom_funding.py +++ /dev/null @@ -1,49 +0,0 @@ -from django.db import models -from django.utils.translation import gettext_lazy as _ - -from economy.models import SuperModel - - -class PhantomFunding(SuperModel): - """Define the structure of a PhantomFunding object. - - For Grants, we have a fund we’re contributing on their behalf. just having a quick button they can push saves all the hassle of (1) asking them their wallet, (2) sending them the DAI (3) contributing it. - - """ - - round_number = models.PositiveIntegerField(blank=True, null=True) - grant = models.ForeignKey( - 'grants.Grant', - related_name='phantom_funding', - on_delete=models.CASCADE, - help_text=_('The associated grant being Phantom Funding.'), - ) - - profile = models.ForeignKey( - 'dashboard.Profile', - related_name='grant_phantom_funding', - on_delete=models.CASCADE, - help_text=_('The associated profile doing the Phantom Funding.'), - ) - - def __str__(self): - """Return the string representation of this object.""" - return f"{self.round_number}; {self.profile} <> {self.grant}" - - def competing_phantum_funds(self): - return PhantomFunding.objects.filter(profile=self.profile, round_number=self.round_number) - - @property - def value(self): - return 5/(self.competing_phantum_funds().count()) - - def to_mock_contribution(self): - context = self.to_standard_dict() - context['subscription'] = { - 'contributor_profile': self.profile, - 'amount_per_period': self.value, - 'token_symbol': 'DAI', - } - context['tx_cleared'] = True - context['success'] = True - return context diff --git a/app/grants/models/subscription.py b/app/grants/models/subscription.py index a4d8a9ad8d6..dbbe91a6192 100644 --- a/app/grants/models/subscription.py +++ b/app/grants/models/subscription.py @@ -554,4 +554,4 @@ def create_contribution(self, tx_id, is_successful_contribution=True): successful_contribution(self.grant, self, contribution) update_grant_metadata.delay(self.pk) - return contribution \ No newline at end of file + return contribution diff --git a/app/marketing/management/commands/post_data.py b/app/marketing/management/commands/post_data.py index b1bef4ee292..a6c734d99ad 100644 --- a/app/marketing/management/commands/post_data.py +++ b/app/marketing/management/commands/post_data.py @@ -28,7 +28,7 @@ from dashboard.models import Activity, Earning, Profile from economy.utils import convert_token_to_usdt from grants.models import * -from grants.models import CartActivity, Contribution, PhantomFunding +from grants.models import CartActivity, Contribution from grants.utils import get_clr_rounds_metadata from townsquare.models import Comment @@ -308,8 +308,7 @@ def grants(): contributions = Contribution.objects.filter(created_on__gt=start, created_on__lt=end, subscription_network='mainnet')#, subscription__grant__in=grants_pks) if must_be_successful: contributions = contributions.filter(success=True) - pfs = PhantomFunding.objects.filter(created_on__gt=start, created_on__lt=end) - total = contributions.count() + pfs.count() + total = contributions.count() current_carts = CartActivity.objects.filter(created_on__gt=start, latest=True)#, grant__in=grants_pks) num_carts = 0 diff --git a/scripts/debug/add_squelched_profiles.py b/scripts/debug/add_squelched_profiles.py index ac5164c0735..9d1a2e652c5 100644 --- a/scripts/debug/add_squelched_profiles.py +++ b/scripts/debug/add_squelched_profiles.py @@ -3,7 +3,7 @@ from django.utils import timezone from grants.models import * -from grants.models import Contribution, PhantomFunding +from grants.models import Contribution from grants.utils import get_clr_rounds_metadata # total stats @@ -12,11 +12,10 @@ _, round_start_date, round_end_date, _ = get_clr_rounds_metadata() contributions = Contribution.objects.filter(created_on__gt=round_start_date, created_on__lt=round_end_date, success=True) -pfs = PhantomFunding.objects.filter(created_on__gt=round_start_date, created_on__lt=round_end_date) -total = contributions.count() + pfs.count() +total = contributions.count() -contributors = len(set(list(contributions.values_list('subscription__contributor_profile', flat=True)) + list(pfs.values_list('profile', flat=True)))) -amount = sum([float(contrib.subscription.amount_per_period_usdt) for contrib in contributions] + [float(pf.value) for pf in pfs]) +contributors = len(set(list(contributions.values_list('subscription__contributor_profile', flat=True)))) +amount = sum([float(contrib.subscription.amount_per_period_usdt) for contrib in contributions]) print("contributions", total) print("contributors", contributors) diff --git a/scripts/debug/address_usage_finder.py b/scripts/debug/address_usage_finder.py index f337f2faf05..2303f601d16 100644 --- a/scripts/debug/address_usage_finder.py +++ b/scripts/debug/address_usage_finder.py @@ -3,7 +3,7 @@ from django.utils import timezone from grants.models import * -from grants.models import Contribution, PhantomFunding, Subscription +from grants.models import Contribution, Subscription from grants.utils import get_clr_rounds_metadata # total stats @@ -11,11 +11,10 @@ _, round_start_date, round_end_date, _ = get_clr_rounds_metadata() contributions = Contribution.objects.filter(created_on__gt=round_start_date, created_on__lt=round_end_date, success=True) -pfs = PhantomFunding.objects.filter(created_on__gt=round_start_date, created_on__lt=round_end_date) -total = contributions.count() + pfs.count() +total = contributions.count() -contributors = len(set(list(contributions.values_list('subscription__contributor_profile', flat=True)) + list(pfs.values_list('profile', flat=True)))) -amount = sum([float(contrib.subscription.amount_per_period_usdt) for contrib in contributions] + [float(pf.value) for pf in pfs]) +contributors = len(set(list(contributions.values_list('subscription__contributor_profile', flat=True)))) +amount = sum([float(contrib.subscription.amount_per_period_usdt) for contrib in contributions]) print("contributions", total) print("contributors", contributors)