-
-
Notifications
You must be signed in to change notification settings - Fork 777
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Extract grants models into individual files (#9341)
* create new directory for models, copy over Contribution model * extract grants models to individual files * rename relocated_models directory, remove original models directory, add imports, resolve circular dependencies * extract CLRMatch into separate file * extract Flag into separate file * extract MatchPledge to separate file * extract Donation and PhantomFunding * extract GrantStat into separate file * refactor * extract GrantBrandingRoutingPolicy to separate file * update migration * add missing import to MatchPledge, remove imports from __init__.py * add missing import * decouple GrantCLRCalculation and move to own file * extract GrantType to own file * extract GrantCLR to own file * add missing import * refactor, add missing imports * remove whitespace * resolve circular dependency * run 'make fix' * import changes from #9314 * add try/except to migration file instead of editing migration directly * refactor
- Loading branch information
Jeremy Schuurmans
committed
Sep 22, 2021
1 parent
6f736d0
commit 337a72e
Showing
26 changed files
with
2,487 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# -*- coding: utf-8 -*- | ||
"""Define the Grant models. | ||
Copyright (C) 2021 Gitcoin Core | ||
This program is free software: you can redistribute it and/or modify | ||
it under the terms of the GNU Affero General Public License as published | ||
by the Free Software Foundation, either version 3 of the License, or | ||
(at your option) any later version. | ||
This program is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
GNU Affero General Public License for more details. | ||
You should have received a copy of the GNU Affero General Public License | ||
along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
""" | ||
|
||
from .cart_activity import CartActivity | ||
from .clr_match import CLRMatch | ||
from .contribution import Contribution | ||
from .donation import Donation | ||
from .flag import Flag | ||
from .grant import Grant, GrantCLR | ||
from .grant_api_key import GrantAPIKey | ||
from .grant_branding_routing_policy import GrantBrandingRoutingPolicy | ||
from .grant_category import GrantCategory | ||
from .grant_clr_calculation import GrantCLRCalculation | ||
from .grant_collection import GrantCollection | ||
from .grant_stat import GrantStat | ||
from .grant_tag import GrantTag | ||
from .grant_type import GrantType | ||
from .match_pledge import MatchPledge | ||
from .phantom_funding import PhantomFunding | ||
from .subscription import Subscription |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
from django.contrib.postgres.fields import JSONField | ||
from django.db import models | ||
from django.utils.translation import gettext_lazy as _ | ||
|
||
from economy.models import SuperModel | ||
|
||
|
||
class CartActivity(SuperModel): | ||
ACTIONS = ( | ||
('ADD_ITEM', 'Add item to cart'), | ||
('REMOVE_ITEM', 'Remove item to cart'), | ||
('CLEAR_CART', 'Clear cart') | ||
) | ||
grant = models.ForeignKey('Grant', null=True, on_delete=models.CASCADE, related_name='cart_actions', | ||
help_text=_('Related Grant Activity ')) | ||
profile = models.ForeignKey('dashboard.Profile', on_delete=models.CASCADE, related_name='cart_activity', | ||
help_text=_('User Cart Activity')) | ||
action = models.CharField(max_length=20, choices=ACTIONS, help_text=_('Type of activity')) | ||
metadata = JSONField(default=dict, blank=True, help_text=_('Related data to the action')) | ||
bulk = models.BooleanField(default=False) | ||
latest = models.BooleanField(default=False) | ||
|
||
def __str__(self): | ||
return f'{self.action} {self.grant.id if self.grant else "bulk"} from the cart {self.profile.handle}' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
from django.db import models | ||
from django.utils.translation import gettext_lazy as _ | ||
|
||
from economy.models import SuperModel | ||
|
||
|
||
class CLRMatch(SuperModel): | ||
"""Define the structure of a CLR Match amount.""" | ||
|
||
round_number = models.PositiveIntegerField(blank=True, null=True) | ||
amount = models.FloatField() | ||
grant = models.ForeignKey( | ||
'grants.Grant', | ||
related_name='clr_matches', | ||
on_delete=models.CASCADE, | ||
null=False, | ||
help_text=_('The associated Grant.'), | ||
) | ||
has_passed_kyc = models.BooleanField(default=False, help_text=_('Has this grant gone through KYC?')) | ||
ready_for_test_payout = models.BooleanField(default=False, help_text=_('Ready for test payout or not')) | ||
test_payout_tx = models.CharField( | ||
max_length=255, | ||
blank=True, | ||
help_text=_('The test payout txid'), | ||
) | ||
test_payout_tx_date = models.DateTimeField(null=True, blank=True) | ||
test_payout_contribution = models.ForeignKey( | ||
'grants.Contribution', | ||
related_name='test_clr_match_payouts', | ||
null=True, | ||
blank=True, | ||
on_delete=models.SET_NULL, | ||
help_text=_('Contribution for the test payout') | ||
) | ||
|
||
ready_for_payout = models.BooleanField(default=False, help_text=_('Ready for regular payout or not')) | ||
payout_tx = models.CharField( | ||
max_length=255, | ||
blank=True, | ||
help_text=_('The test payout txid'), | ||
) | ||
payout_tx_date = models.DateTimeField(null=True, blank=True) | ||
payout_contribution = models.ForeignKey( | ||
'grants.Contribution', | ||
related_name='clr_match_payouts', | ||
null=True, | ||
blank=True, | ||
on_delete=models.SET_NULL, | ||
help_text=_('Contribution for the payout') | ||
) | ||
comments = models.TextField(default='', blank=True, help_text=_('The comments.')) | ||
|
||
|
||
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}" |
Oops, something went wrong.