Skip to content

Commit

Permalink
Merge pull request #5054 from gitcoinco/kevin/phantom_funding
Browse files Browse the repository at this point in the history
adds the ability for phantom funding of a grant
  • Loading branch information
octavioamu authored Sep 11, 2019
2 parents 787ebbd + 0833579 commit 3e3871e
Show file tree
Hide file tree
Showing 17 changed files with 526 additions and 228 deletions.
6 changes: 6 additions & 0 deletions app/app/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
from dashboard.models import Activity, Tip, UserAction
from dashboard.utils import _get_utm_from_cookie
from kudos.models import KudosTransfer
from marketing.utils import handle_marketing_callback
from retail.helpers import get_ip

RECORD_VISIT_EVERY_N_SECONDS = 60 * 60
Expand Down Expand Up @@ -75,6 +76,11 @@ def preprocess(request):
if record_join:
Activity.objects.create(profile=profile, activity_type='joined')

# handles marketing callbacks
if request.GET.get('cb'):
callback = request.GET.get('cb')
handle_marketing_callback(callback, request)

context = {
'STATIC_URL': settings.STATIC_URL,
'MEDIA_URL': settings.MEDIA_URL,
Expand Down
19 changes: 19 additions & 0 deletions app/assets/v2/css/grants/fund.css
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
#grant-link {
color: #0D0764;
}
.tab_target{
width: 100%;
}

.banner-img {
max-height: 22rem;
Expand Down Expand Up @@ -143,6 +146,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
Binary file added app/assets/v2/images/grants/signal.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
16 changes: 14 additions & 2 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 Expand Up @@ -295,7 +307,7 @@ const subscribeToGrant = (transactionHash) => {
$('#transaction_url').attr('href', linkURL);
enableWaitState('#grants_form');
// TODO: fix the tweet modal
// $('#tweetModal').modal('show');
$('#tweetModal').css('display', 'block');

deployedSubscription.methods.extraNonce(accounts[0]).call(function(err, nonce) {

Expand Down Expand Up @@ -400,7 +412,7 @@ const splitPayment = (account, toFirst, toSecond, valueFirst, valueSecond) => {
$('#transaction_url').attr('href', linkURL);
enableWaitState('#grants_form');
// TODO: Fix tweet modal
// $('#tweetModal').modal('show');
$('#tweetModal').css('display', 'block');
}).on('confirmation', function(confirmationNumber, receipt) {
data = {
'subscription_hash': 'onetime',
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,
},
),
]
24 changes: 24 additions & 0 deletions app/grants/migrations/0029_auto_20190830_1613.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Generated by Django 2.2.3 on 2019-08-30 16:13

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


class Migration(migrations.Migration):

dependencies = [
('grants', '0028_phantomfunding'),
]

operations = [
migrations.AlterField(
model_name='phantomfunding',
name='grant',
field=models.ForeignKey(help_text='The associated grant being Phantom Funding.', on_delete=django.db.models.deletion.CASCADE, related_name='phantom_funding', to='grants.Grant'),
),
migrations.AlterField(
model_name='phantomfunding',
name='profile',
field=models.ForeignKey(help_text='The associated profile doing the Phantom Funding.', on_delete=django.db.models.deletion.CASCADE, related_name='grant_phantom_funding', to='dashboard.Profile'),
),
]
26 changes: 26 additions & 0 deletions app/grants/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -901,3 +901,29 @@ 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 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}"
Loading

0 comments on commit 3e3871e

Please sign in to comment.