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

Clr backend #5192

Merged
merged 42 commits into from
Sep 20, 2019
Merged
Show file tree
Hide file tree
Changes from 40 commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
9014b88
feat: add clr label to grant
thelostone-mc Aug 19, 2019
6e18566
add clr logoc
thelostone-mc Sep 12, 2019
7bdb4e6
initial setup and starting per-grant calculation
danlipert Sep 13, 2019
e1032d7
one function left
danlipert Sep 13, 2019
cb07934
add url and view
danlipert Sep 13, 2019
d479d09
getting closer to per-donation clr prediction and adding comments
danlipert Sep 17, 2019
1f97743
add base level clr and store raw data
danlipert Sep 17, 2019
6662b7b
WIP
danlipert Sep 17, 2019
580cd60
edge case fix
thelostone-mc Sep 17, 2019
583d949
fix various bugs
danlipert Sep 18, 2019
4a80f36
working w/ test data, add mgmt command and migration
danlipert Sep 18, 2019
a463e01
add easy testing, fix contrib data setup
danlipert Sep 18, 2019
dfc1be0
isort fix
thelostone-mc Sep 18, 2019
4b9a444
add iterations check
danlipert Sep 18, 2019
7179265
Merge remote-tracking branch 'upstream/master' into clr-backend
thelostone-mc Sep 18, 2019
245223c
clr estimates frontend
owocki Sep 16, 2019
25a9a12
merged clr frontend code
thelostone-mc Sep 18, 2019
36ec03a
cleanup and small tweaks
danlipert Sep 18, 2019
c745820
wiring UI to BE
thelostone-mc Sep 18, 2019
e0e6243
add admin, fix url conf, etc.
danlipert Sep 18, 2019
a9443f8
Merge branch 'clr-backend' of github.com:gitcoinco/web into clr-backend
danlipert Sep 18, 2019
3a5d806
remove backend lerp
danlipert Sep 18, 2019
d4402b9
added lerp
thelostone-mc Sep 18, 2019
a4d27e3
Merge branch 'clr-backend' of github.com:gitcoinco/web into clr-backend
thelostone-mc Sep 18, 2019
4c0c598
fix bugs and edge case
danlipert Sep 19, 2019
0708ab3
fix crontab name
danlipert Sep 19, 2019
3e6c16f
fix migration?
danlipert Sep 19, 2019
274a2cf
fix eslint
danlipert Sep 19, 2019
2ef6530
cleanup unused imports
danlipert Sep 19, 2019
053c7ae
remove bad migration
danlipert Sep 19, 2019
90cd3ee
remove another bad migration
danlipert Sep 19, 2019
81b8f24
final fixes
thelostone-mc Sep 19, 2019
bda1fa4
Merge branch 'clr-backend' of github.com:gitcoinco/web into clr-backend
thelostone-mc Sep 19, 2019
ce54f3f
fixed navbar color
thelostone-mc Sep 19, 2019
7073a2a
fix date
danlipert Sep 19, 2019
b6628e8
Merge branch 'clr-backend' of github.com:gitcoinco/web into clr-backend
danlipert Sep 19, 2019
0155cce
fix bug in fund.js, fix templates
danlipert Sep 19, 2019
1720998
add phantom funding
danlipert Sep 19, 2019
68952a7
add phantom funding clr estimates
danlipert Sep 20, 2019
a9761b6
fix eslint and isort
danlipert Sep 20, 2019
dcdfe9b
isort fix
thelostone-mc Sep 20, 2019
1991165
Merge branch 'master' into clr-backend
thelostone-mc Sep 20, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/app/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'app.middleware.drop_accept_langauge',
'app.middleware.bleach_requests',
# 'app.middleware.bleach_requests',
'django.middleware.locale.LocaleMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
Expand Down
14 changes: 14 additions & 0 deletions app/assets/v2/css/grants/card.css
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,20 @@
display: flex;
}

.clr {
right: 1.25rem;
}

.clr h2 {
background: #10cd7a;
color: #fff;
border-radius: 3px;
}

.clr p {
font-size: 10px;
}

.grant-item__img {
height: 11rem;
overflow: hidden;
Expand Down
100 changes: 96 additions & 4 deletions app/assets/v2/css/grants/fund.css
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#grant-link {
color: #0D0764;
}

.tab_target{
width: 100%;
}
Expand All @@ -23,6 +24,12 @@
object-fit: cover;
}

#grants_form .nav-link {
border-top-left-radius: 4px;
border-top-right-radius: 4px;
color: #000;
}

#grants_form .form__input.valid,
#grants_form .form__input.error {
background-position: top 0.5rem right 0.5rem;
Expand Down Expand Up @@ -146,22 +153,101 @@
bottom: -1.2rem;
}

.nav{
.nav {
Copy link
Contributor

Choose a reason for hiding this comment

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

user text-center calls instead of overwriting the framework

text-align: center;
}
.nav-link{

.nav-link {
Copy link
Contributor

Choose a reason for hiding this comment

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

extend core class don't overwrite

border-right: 1px solid black;
border-top: 1px solid black;
border-left: 1px solid black;
margin-right: 10px;
}
.nav-link:visited{

.nav-link:visited {
Copy link
Contributor

Choose a reason for hiding this comment

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

extend core class don't overwrite

color: black;
}
.nav-item.active{

.nav-item.active {
Copy link
Contributor

Choose a reason for hiding this comment

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

extend core class don't overwrite

text-decoration: underline;
}

.clr_estimate {
background-color: white;
border-radius: 5px;
border: 2px solid #10cd7a;
text-align: left;
width: 250px;
padding: 1rem 15px;
position: absolute;
top: 0px;
left: 0px;
}

.clr_estimate.extraleft {
left: -270px;
}

.clr_estimate:after {
content: '';
position: absolute;
right: 0;
top: 30%;
width: 0;
height: 0;
border: 20px solid transparent;
border-left-color: #10cd7a;
border-right: 0;
border-bottom: 0;
margin-top: -10px;
margin-right: -20px;
}

.clr_estimate img {
float: right;
width: 50px;
}

.clr_estimate h3 {
text-align: left;
color: white;
font-size: 12px;
text-transform: uppercase;
width: 150px;
}

.clr_estimate h3 span {
background-color: #10cd7a;
border-radius: 3px;
padding: 4px 6px;

}

.clr_estimate h4 {
padding-top: 0px;
text-align: left;
color: #10cd7a;
font-size: 10px;
font-weight: bold;
}

.clr_estimate h4 span {
font-size: 16px;
}

.clr_estimate p {
text-align: left;
color: #10cd7a;
font-size: 12px;
color: #959595;
}

#phantom_fund .description i {
thelostone-mc marked this conversation as resolved.
Show resolved Hide resolved
font-size: 10px;
position: relative;
top: -1px;
}

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

#gitcoin-grant-section .fee-slider,
Expand All @@ -188,3 +274,9 @@
max-width: 100%;
}
}

@media (max-width: 1199.98px) {
.clr_estimate {
display: none;
}
}
Binary file added app/assets/v2/images/diamonds_high_fiving.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
96 changes: 94 additions & 2 deletions app/assets/v2/js/grants/fund.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,14 @@ let gitcoinDonationAddress;


$(document).ready(function() {

predictPhantomCLRMatch();
predictCLRMatch();

$('#amount').on('input', () => {
predictCLRMatch();
});

gitcoinDonationAddress = $('#gitcoin_donation_address').val();
splitterAddress = $('#splitter_contract_address').val();

Expand All @@ -23,7 +31,7 @@ $(document).ready(function() {

updateSummary();

$('.nav-item').click(function(e) {
$('#grants_form .nav-item').click(function(e) {
Copy link
Contributor

Choose a reason for hiding this comment

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

this kind of rules will be a problem when we start creating a bundle js since we are not going to control this being loaded in other areas, use custom classes or data attr

Copy link
Member

Choose a reason for hiding this comment

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

agreed this would need to be fixed in a follow up PR to use what the tabs we already have
It's creating random weird bugs in css cause of that

cc @owocki

$('.nav-item a').removeClass('active');
$(this).find('a').addClass('active');
var targetid = $(this).find('a').data('target');
Expand Down Expand Up @@ -489,6 +497,90 @@ const splitGrantAmount = () => {
}

$('.gitcoin-grant-percent').html(percent);
$('.summary-gitcoin-amount').html(gitcoin_grant_amount);
$('.summary-gitcoin-amount').html(gitcoin_grant_amount.toFixed(2));
$('#summary-amount').html(grant_amount);
};

const lerp = (x_lower, x_upper, y_lower, y_upper, x) => {
return y_lower + (((y_upper - y_lower) * (x - x_lower)) / (x_upper - x_lower));
};

const predictPhantomCLRMatch = () => {

let amount = phantom_value;

if (0 < amount && amount < 1) {
x_lower = 0;
x_upper = 1;
y_lower = clr_prediction_curve[0];
y_upper = clr_prediction_curve[1];
} else if (1 < amount && amount < 10) {
x_lower = 1;
x_upper = 10;
y_lower = clr_prediction_curve[1];
y_upper = clr_prediction_curve[2];
}

let predicted_clr = lerp(x_lower, x_upper, y_lower, y_upper, amount);

$('.phantom_clr_increase').html((predicted_clr - clr_prediction_curve[0]).toFixed(2));
};

const predictCLRMatch = () => {

let amount = Number.parseFloat($('#amount').val());

if (amount > 10000) {
amount = 10000;
}

let predicted_clr = 0;

const contributions_axis = [ 0, 1, 10, 100, 1000, 10000 ];

let index = 0;

if (isNaN(amount)) {
predicted_clr = clr_prediction_curve[index];
} else if (contributions_axis.indexOf(amount) >= 0) {
index = contributions_axis.indexOf(amount);
predicted_clr = clr_prediction_curve[index];
} else {
let x_lower = 0;
let x_upper = 0;
let y_lower = 0;
let y_upper = 0;

if (0 < amount && amount < 1) {
x_lower = 0;
x_upper = 1;
y_lower = clr_prediction_curve[0];
y_upper = clr_prediction_curve[1];
} else if (1 < amount && amount < 10) {
x_lower = 1;
x_upper = 10;
y_lower = clr_prediction_curve[1];
y_upper = clr_prediction_curve[2];
} else if (10 < amount && amount < 100) {
x_lower = 10;
x_upper = 100;
y_lower = clr_prediction_curve[2];
y_upper = clr_prediction_curve[3];
} else if (100 < amount && amount < 1000) {
x_lower = 100;
x_upper = 1000;
y_lower = clr_prediction_curve[3];
y_upper = clr_prediction_curve[4];
} else {
x_lower = 1000;
x_upper = 10000;
y_lower = clr_prediction_curve[4];
y_upper = clr_prediction_curve[5];
}

predicted_clr = lerp(x_lower, x_upper, y_lower, y_upper, amount);
}

$('.clr_match_prediction').html(predicted_clr.toFixed(2));
$('.clr_increase').html((predicted_clr - clr_prediction_curve[0]).toFixed(2));
};
6 changes: 3 additions & 3 deletions app/grants/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,12 @@ class GrantAdmin(GeneralAdmin):
'token_address', 'contract_address', 'contract_version', 'network', 'required_gas_price', 'logo_svg_asset',
'logo_asset', 'created_on', 'modified_on', 'team_member_list',
'subscriptions_links', 'contributions_links', 'logo', 'logo_svg', 'image_css',
'link', 'clr_matching', 'hidden'
'link', 'clr_matching', 'clr_prediction_curve', 'hidden'
]
readonly_fields = [
'logo_svg_asset', 'logo_asset',
'team_member_list',
'subscriptions_links', 'contributions_links', 'link',
'subscriptions_links', 'contributions_links', 'link',
]
raw_id_fields = ['admin_profile']

Expand Down Expand Up @@ -179,7 +179,7 @@ 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)
Expand Down
Loading