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

adds the ability for phantom funding of a grant #5054

Merged
merged 14 commits into from
Sep 11, 2019
16 changes: 16 additions & 0 deletions app/assets/v2/css/grants/fund.css
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,22 @@
bottom: -1.2rem;
}

.nav{
text-align: center;
}
.nav-link{
border-right: 1px solid black;
border-top: 1px solid black;
border-left: 1px solid black;
margin-right: 10px;
}
.nav-link:visited{
color: black;
}
.nav-item.active{
text-decoration: underline;
}

@media (min-width:1140px) and (max-width: 1600px) {

#gitcoin-grant-section .fee-slider,
Expand Down
12 changes: 12 additions & 0 deletions app/assets/v2/js/grants/fund.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,18 @@ $(document).ready(function() {

updateSummary();

$('.nav-item').click(function(e) {
$('.nav-item a').removeClass('active');
$(this).find('a').addClass('active');
var targetid = $(this).find('a').data('target');
var target = $('#' + targetid);

$('.tab_target').addClass('hidden');
target.removeClass('hidden');

e.preventDefault();
});

$('#frequency_unit, #js-token').on('select2:select', event => {
updateSummary();
});
Expand Down
5 changes: 3 additions & 2 deletions app/grants/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
from django.contrib import admin
from django.utils.safestring import mark_safe

from grants.models import CLRMatch, Contribution, Grant, MatchPledge, Subscription
from grants.models import CLRMatch, Contribution, Grant, MatchPledge, PhantomFunding, Subscription


class GeneralAdmin(admin.ModelAdmin):
Expand Down Expand Up @@ -179,7 +179,8 @@ class ContributionAdmin(GeneralAdmin):
"""Define the Contribution administration layout."""
raw_id_fields = ['subscription']



admin.site.register(PhantomFunding, GeneralAdmin)
admin.site.register(MatchPledge, MatchPledgeAdmin)
admin.site.register(Grant, GrantAdmin)
admin.site.register(CLRMatch, GeneralAdmin)
Expand Down
30 changes: 30 additions & 0 deletions app/grants/migrations/0028_phantomfunding.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Generated by Django 2.2.3 on 2019-08-21 17:25

from django.db import migrations, models
import django.db.models.deletion
import economy.models


class Migration(migrations.Migration):

dependencies = [
('dashboard', '0048_merge_20190808_1934'),
('grants', '0027_remove_grant_request_ownership_change'),
]

operations = [
migrations.CreateModel(
name='PhantomFunding',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('created_on', models.DateTimeField(db_index=True, default=economy.models.get_time)),
('modified_on', models.DateTimeField(default=economy.models.get_time)),
('round_number', models.PositiveIntegerField(blank=True, null=True)),
('grant', models.ForeignKey(help_text='The associated Phantom Funding.', on_delete=django.db.models.deletion.CASCADE, related_name='phantom_funding', to='grants.Grant')),
('profile', models.ForeignKey(help_text='The associated Phantom Funding.', on_delete=django.db.models.deletion.CASCADE, related_name='grant_phantom_funding', to='dashboard.Profile')),
],
options={
'abstract': False,
},
),
]
22 changes: 22 additions & 0 deletions app/grants/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -900,3 +900,25 @@ class MatchPledge(SuperModel):
def __str__(self):
"""Return the string representation of this object."""
return f"{self.profile} <> {self.amount} DAI"

class PhantomFunding(SuperModel):
"""Define the structure of a subscription agreement."""
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we add something that describes what this is for or why we created it? Looks like this is from a cut-and-paste job ;)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated


round_number = models.PositiveIntegerField(blank=True, null=True)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@frankchen07 this is the new model that will contain info about when people phantom fund.

two ways we can manage this:

  1. you just build phantom funding into your existing reports
  2. myself or engineering builds a finalize_phantom_funding job that runs once per round, at end of round, that
    a. closes out phantom funding for that round
    b. makes the phantom contribs into actual contributions (both on chain and in the DB)
    c. anything else??

cc @danlipert 4 other ideas

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. I'm assuming the data model reflects this in a way where it's easy to build it into the reports. I think as long as it tell me the contributor, which grant(s) they've committed to and how much, it can be easily integrated into the report at the end of the CLR round.

  2. from a product perspective, point number 2 is the trickier one, especially with As a funder I want to see previous contributions to projects and what my expected CLR match is #3663 - since this is part of the product update that vitalik requested (a nifty little feature that tells us in "real" time, how much potential a contribution has in the LR context, and this needs all the contributions, real and phantom in order to be the most accurate). I might be overthinking it in the sense that if the data exists it can be used in the feature, and the phantom_funding job is a completely separate "payout" related action at the end.

In a related conversation, Dan suggested that we do some kind of simplified calculation and cache the results so we can give them a range, since doing a live calculation with real data every time someone changes a number in an input box can be performance hell.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. yea it does that (tho 'how much' is inferred by 5/(num_votes_cast_by_contrib)
  2. hmm.. yeah As a funder I want to see previous contributions to projects and what my expected CLR match is #3663 does make it more complicated. ill add a note there about phantom funding.

agree with @danlipert s thoughts.

grant = models.ForeignKey(
'grants.Grant',
related_name='phantom_funding',
on_delete=models.CASCADE,
help_text=_('The associated Phantom Funding.'),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change help text to something like The grant being Phantom funded

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated

)

profile = models.ForeignKey(
'dashboard.Profile',
related_name='grant_phantom_funding',
on_delete=models.CASCADE,
help_text=_('The associated Phantom Funding.'),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change help text to The user profile creating the Phantom Funding

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated

)

def __str__(self):
"""Return the string representation of this object."""
return f"{self.round_number}; {self.profile} <> {self.grant}"
Loading