From 1ebd037a776b8a1991b9377714b5422c41db758d Mon Sep 17 00:00:00 2001 From: frankchen07 Date: Wed, 3 Jun 2020 13:39:40 -0700 Subject: [PATCH 001/186] updating r6 calculations, ripping out stuff, adding in last round combination calculations --- app/grants/clr.py | 368 ++++++++++++++++++++++++---------------------- 1 file changed, 196 insertions(+), 172 deletions(-) diff --git a/app/grants/clr.py b/app/grants/clr.py index deceafe7453..b838cfe9d7e 100644 --- a/app/grants/clr.py +++ b/app/grants/clr.py @@ -44,44 +44,67 @@ TOTAL_POT_MEDIA = 50120.0 #50k + 120 from negative voting per https://twitter.com/owocki/status/1249420758167588864 TOTAL_POT_HEALTH = 50000.0 -''' - Helper function that translates existing grant data structure - to a list of lists. - Args: - { - 'id': (string) , - 'contibutions' : [ - { - contributor_profile (str) : contribution_amount (int) - } - ] - } - Returns: - [[grant_id (str), user_id (str), contribution_amount (float)]] ''' -def translate_data(grants): + translates django grant data structure to a list of lists + + args: + django grant data structure + { + 'id': (string) , + 'contibutions' : [ + { + contributor_profile (str) : contribution_amount (int) + } + ] + } + + returns: + list of lists of grant data + [[grant_id (str), user_id (str), contribution_amount (float)]] +''' +def translate_data(grants_data): grants_list = [] - for grant in grants: - grant_id = grant.get('id') - for contribution in grant.get('contributions'): - val = [grant_id] + [list(contribution.keys())[0], list(contribution.values())[0]] + for g in grants_data: + grant_id = g.get('id') + for c in g.get('contributions'): + val = [grant_id] + [list(c.keys())[0], list(c.values())[0]] grants_list.append(val) + return grants_list ''' - Helper function that aggregates contributions by contributor, and then uses the aggregated contributors by contributor and calculates total contributions by unique pairs. + combine previous round 1/3 contributions with current round contributions - Args: - from translate_data: + args: previous round contributions list of lists + + returns: list of lists of combined contributions [[grant_id (str), user_id (str), contribution_amount (float)]] - Returns: - {grant_id (str): {user_id (str): aggregated_amount (float)}} - {user_id (str): {user_id (str): pair_total (float)}} +''' +def combine_previous_round(previous, current): + for x in previous: + x[2] = x[2]/3.0 + combined = current + previous + + return combined + + + +''' + aggregates contributions by contributor, and calculates total contributions by unique pairs + + args: + list of lists of grant data + [[grant_id (str), user_id (str), contribution_amount (float)]] + + returns: + aggregated contributions by pair & total contributions by pair + {grant_id (str): {user_id (str): aggregated_amount (float)}} + {user_id (str): {user_id (str): pair_total (float)}} ''' def aggregate_contributions(grant_contributions): contrib_dict = {} @@ -99,157 +122,166 @@ def aggregate_contributions(grant_contributions): if k2 not in tot_overlap[k1]: tot_overlap[k1][k2] = 0 tot_overlap[k1][k2] += (v1 * v2) ** 0.5 - return contrib_dict, tot_overlap - - - -''' - Helper function that runs the pairwise clr formula for positive or negative instances, depending on the switch. - Args: - aggregated_contributions: {grant_id (str): {user_id (str): aggregated_amount (float)}} - pair_totals: {user_id (str): {user_id (str): pair_total (float)}} - threshold: pairwise coefficient - total_pot: total pot set for the round category - positive: positive or negative contributions - - Returns: - totals: total clr, positive or negative sum and award by grant -''' -def calculate_new_clr(aggregated_contributions, pair_totals, threshold=0.0, total_pot=0.0, positive=True): - totals = [] - if positive: # positive - for proj, contribz in aggregated_contributions.items(): - tot = 0 - for k1, v1 in contribz.items(): - for k2, v2 in contribz.items(): - if k2 > k1: # removes single donations, vitalik's formula - tot += ((v1 * v2) ** 0.5) / (pair_totals[k1][k2] / threshold + 1) - totals.append({'id': proj, 'clr_amount': tot}) - - if not positive: # negative - for proj, contribz in aggregated_contributions.items(): - tot = 0 - for k1, v1 in contribz.items(): - for k2, v2 in contribz.items(): - if k2 > k1: # removes single donations but adds it in below, vitalik's formula - tot += ((v1 * v2) ** 0.5) / (pair_totals[k1][k2] / threshold + 1) - if k2 == k1: # negative vote will count less if single, but will count - tot += ((v1 * v2) ** 0.5) - totals.append({'id': proj, 'clr_amount': tot}) - - return totals + return contrib_dict, tot_overlap ''' - Helper function that calculates the final difference between positive and negative totals and finds the final clr reward amount. The amount is also normalized as well. - - ### UNCOMMENTING CHANGES HERE MAY BE NECESSARY HERE FOR NORMALIZATION ### - - Args: - totals_pos: [{'id': proj, 'clr_amount': tot}] - totals_neg: [{'id': proj, 'clr_amount': tot}] - total_pot: total pot for the category round - - Returns: - totals: total clr award by grant pos less neg, normalized by the normalization factor + calculates the clr amount at the given threshold and total pot + + args: + aggregated_contributions + {grant_id (str): {user_id (str): aggregated_amount (float)}} + pair_totals + {user_id (str): {user_id (str): pair_total (float)}} + threshold + float + total_pot + float + + returns: + total clr award by grant, normalized by the normalization factor + [{'id': proj, 'clr_amount': tot}] + saturation point + boolean ''' -def calculate_new_clr_final(totals_pos, totals_neg, total_pot=0.0): - # calculate final totals - # print(f'+ve {len(totals_pos)} {totals_pos}') - # print(f'-ve {len(totals_neg)} {totals_neg}') - neg_ids = [y['id'] for y in totals_neg] - [totals_neg.append({'id': x['id'], 'clr_amount': 0}) for x in totals_pos if x['id'] not in neg_ids] - - pos_ids = [x['id'] for x in totals_pos] - [totals_pos.append({'id': y['id'], 'clr_amount': 0}) for y in totals_neg if y['id'] not in pos_ids] - +def calculate_clr(aggregated_contributions, pair_totals, threshold=25.0, total_pot=0.0): + bigtot = 0 totals = [] - for x in totals_pos: - for y in totals_neg: - if x['id'] == y['id'] and (x['clr_amount'] == 0 or x['clr_amount'] < y['clr_amount']): - totals.append({'id': x['id'], 'clr_amount': 0}) - elif x['id'] == y['id']: - totals.append({'id': x['id'], 'clr_amount': (math.sqrt(x['clr_amount']) - math.sqrt(y['clr_amount']))**2}) + for proj, contribz in aggregated_contributions.items(): + tot = 0 + for k1, v1 in contribz.items(): + for k2, v2 in contribz.items(): + if k2 > k1: # removes single donations, vitalik's formula + tot += ((v1 * v2) ** 0.5) / (pair_totals[k1][k2] / threshold + 1) + bigtot += tot + totals.append({'id': proj, 'clr_amount': tot}) - bigtot = 0 # find normalization factor - for x in totals: - bigtot += x['clr_amount'] normalization_factor = bigtot / total_pot - # modify totals - if normalization_factor != 0: - for x in totals: - x['clr_amount'] = x['clr_amount'] / normalization_factor - return bigtot, totals - -''' - Clubbed function that intakes grant data, calculates necessary intermediate calculations, and spits out clr calculations. This function is re-used for positive and negative contributions - - Args: - grant_contributions: { - 'id': (string) , - 'contributions' : [ - { - contributor_profile (str) : contribution_amount (int) - } - ] - } - threshold: pairwise coefficient - total_pot: total pot set for the round category - positive: positive or negative contributions + # modify totals + for result in totals: + result['clr_amount'] = result['clr_amount'] / normalization_factor - Returns: - totals: clr totals -''' -def grants_clr_calculate(grant_contributions, total_pot=0.0, threshold=0.0, positive=True): - grants_list = translate_data(grant_contributions) - aggregated_contributions, pair_totals = aggregate_contributions(grants_list) - totals = calculate_new_clr(aggregated_contributions, pair_totals, threshold=threshold, total_pot=total_pot, positive=positive) return totals +# ''' +# Clubbed function that intakes grant data, calculates necessary intermediate calculations, and spits out clr calculations. This function is re-used for positive and negative contributions + +# Args: +# grant_contributions: { +# 'id': (string) , +# 'contributions' : [ +# { +# contributor_profile (str) : contribution_amount (int) +# } +# ] +# } +# threshold: pairwise coefficient +# total_pot: total pot set for the round category +# positive: positive or negative contributions + +# Returns: +# totals: clr totals +# ''' +# def grants_clr_calculate(grant_contributions, total_pot=0.0, threshold=0.0, positive=True): +# grants_list = translate_data(grant_contributions) +# aggregated_contributions, pair_totals = aggregate_contributions(grants_list) +# totals = calculate_new_clr(aggregated_contributions, pair_totals, threshold=threshold, total_pot=total_pot, positive=positive) +# return totals + + + +# ''' +# Clubbed function that intakes the result of grants_clr_calculate and calculates the final difference calculation between positive and negative grant contributions. + +# Args: +# totals_pos: [{'id': proj, 'clr_amount': tot}] +# totals_neg: [{'id': proj, 'clr_amount': tot}] +# total_pot: total pot set for the round category + +# Returns: +# final_bigtot: should equal total pot +# final_totals: final clr totals + +# Final flow: +# grants_clr_calculate includes: +# translate_data +# aggregate_contributions +# calculate_new_clr +# and outputs: positive & negatives clr amounts +# grants_clr_calculate_pos_neg uses output from grants_clr_calculates to output final totals +# ''' +# def grants_clr_calculate_pos_neg(pos_totals, neg_totals, total_pot=0.0): +# final_bigtot, final_totals = calculate_new_clr_final(pos_totals, neg_totals, total_pot=total_pot) +# return final_bigtot, final_totals + + + +''' + clubbed function that runs all calculation functions + + args: + grant_contribs_curr + { + 'id': (string) , + 'contibutions' : [ + { + contributor_profile (str) : contribution_amount (int) + } + ] + } + grant_contribs_prev + { + 'id': (string) , + 'contibutions' : [ + { + contributor_profile (str) : contribution_amount (int) + } + ] + } + threshold + float + total_pot + float + + returns: + grants clr award amounts ''' - Clubbed function that intakes the result of grants_clr_calculate and calculates the final difference calculation between positive and negative grant contributions. +def run_clr_calcs(grant_contribs_curr, grant_contribs_prev, threshold=20.0, total_pot=100000.0): + + # get data + curr_round = translate_data(grant_contribs_curr) + prev_round = translate_data(grant_contribs_prev) + + # combined round + comb_round = combine_previous_round(prev_round, curr_round) + + # clr calcluations + agg_contribs, pair_tots = aggregate_contributions(comb_round) + totals = calculate_clr(agg_contribs, pair_tots, threshold=threshold, total_pot=total_pot) + + return totals - Args: - totals_pos: [{'id': proj, 'clr_amount': tot}] - totals_neg: [{'id': proj, 'clr_amount': tot}] - total_pot: total pot set for the round category - Returns: - final_bigtot: should equal total pot - final_totals: final clr totals - - Final flow: - grants_clr_calculate includes: - translate_data - aggregate_contributions - calculate_new_clr - and outputs: positive & negatives clr amounts - grants_clr_calculate_pos_neg uses output from grants_clr_calculates to output final totals -''' -def grants_clr_calculate_pos_neg(pos_totals, neg_totals, total_pot=0.0): - final_bigtot, final_totals = calculate_new_clr_final(pos_totals, neg_totals, total_pot=total_pot) - return final_bigtot, final_totals +def calculate_clr_for_donation(grant, amount, grant_contributions_curr, grant_contributions_prev, total_pot, threshold): -def calculate_clr_for_donation(grant, amount, positive_grant_contributions, negative_grant_contributions, total_pot, threshold): + _grant_contributions_curr = copy.deepcopy(grant_contributions_curr) + _grant_contributions_prev = copy.deepcopy(grant_contributions_prev) - _positive_grant_contributions = copy.deepcopy(positive_grant_contributions) # find grant in contributions list and add donation if amount != 0: - for grant_contribution in _positive_grant_contributions: + for grant_contribution in _grant_contributions_curr: if grant_contribution['id'] == grant.id: # add this donation with a new profile (id 99999999999) to get impact grant_contribution['contributions'].append({'999999999999': amount}) - pos_totals = grants_clr_calculate(_positive_grant_contributions, total_pot=total_pot, threshold=threshold, positive=True) - neg_totals = grants_clr_calculate(negative_grant_contributions, total_pot=total_pot, threshold=threshold, positive=False) - _, grants_clr = grants_clr_calculate_pos_neg(pos_totals, neg_totals, total_pot=total_pot) + grants_clr = run_clr_calcs(_grant_contributions_curr, _grant_contributions_prev, threshold=threshold, total_pot=total_pot) # find grant we added the contribution to and get the new clr amount for grant_clr in grants_clr: @@ -260,6 +292,7 @@ def calculate_clr_for_donation(grant, amount, positive_grant_contributions, nega return (None, None) + ''' Populate Data needed to calculate CLR @@ -380,7 +413,7 @@ def predict_clr(save_to_db=False, from_date=None, clr_type=None, network='mainne # setup clr_calc_start_time = timezone.now() debug_output = [] - grants, positive_contrib_data, negative_contrib_data, total_pot, threshold = populate_data_for_clr(clr_type, network, mechanism=mechanism) + grants, grant_contributions_curr, grant_contributions_prev, total_pot, threshold = populate_data_for_clr(clr_type, network, mechanism=mechanism) # print(f'GRANT {len(grants)}') # print(f'CONTRIB {len(positive_contrib_data)}') @@ -396,8 +429,8 @@ def predict_clr(save_to_db=False, from_date=None, clr_type=None, network='mainne predicted_clr, grants_clr = calculate_clr_for_donation( grant, amount, - positive_contrib_data, - negative_contrib_data, + grant_contributions_curr, + grant_contributions_prev, total_pot, threshold ) @@ -490,32 +523,23 @@ def predict_clr(save_to_db=False, from_date=None, clr_type=None, network='mainne Returns: clr_amount ''' -def calculate_clr_for_donation_live(grant, contributor, amount, is_postive_vote, positive_grant_contributions, negative_grant_contributions, total_pot, threshold): +def calculate_clr_for_donation_live(grant, contributor, amount, grant_contributions_curr, grant_contributions_prev, total_pot, threshold): if amount == 0: return 0 - _positive_grant_contributions = copy.deepcopy(positive_grant_contributions) - _negative_grant_contributions = copy.deepcopy(negative_grant_contributions) + _grant_contributions_curr = copy.deepcopy(grant_contributions_curr) + _grant_contributions_prev = copy.deepcopy(grant_contributions_prev) profile_id = str(contributor.pk) - if is_postive_vote: - for grant_contribution in _positive_grant_contributions: - if grant_contribution['id'] == grant.id: - grant_contribution['contributions'].append({ - profile_id: amount - }) - else: - for grant_contribution in _negative_grant_contributions: - if grant_contribution['id'] == grant.id: - grant_contribution['contributions'].append({ - profile_id: amount - }) + for grant_contribution in _grant_contributions_curr: + if grant_contribution['id'] == grant.id: + grant_contribution['contributions'].append({ + profile_id: amount + }) - pos_totals = grants_clr_calculate(_positive_grant_contributions, total_pot=total_pot, threshold=threshold, positive=True) - neg_totals = grants_clr_calculate(_negative_grant_contributions, total_pot=total_pot, threshold=threshold, positive=False) - _, grants_clr = grants_clr_calculate_pos_neg(pos_totals, neg_totals, total_pot=total_pot) + grants_clr = run_clr_calcs(_grant_contributions_curr, _grant_contributions_prev, threshold=threshold, total_pot=total_pot) # find grant we added the contribution to and get the new clr amount for grant_clr in grants_clr: @@ -539,7 +563,7 @@ def calculate_clr_for_donation_live(grant, contributor, amount, is_postive_vote, Returns: predicted_clr_match ''' -def predict_clr_live(grant, contributor, amount, is_postive_vote=True): +def predict_clr_live(grant, contributor, amount): if not grant or not contributor: print('error: predict_clr_live - missing parameters') @@ -550,10 +574,10 @@ def predict_clr_live(grant, contributor, amount, is_postive_vote=True): clr_type = grant.grant_type network = grant.network - _, positive_contrib_data, negative_contrib_data , total_pot, threshold = populate_data_for_clr(clr_type, network) + _, grant_contributions_curr, grant_contributions_prev, total_pot, threshold = populate_data_for_clr(clr_type, network) predicted_clr_match = calculate_clr_for_donation_live( - grant, contributor, amount, is_postive_vote, positive_contrib_data, negative_contrib_data, total_pot, threshold + grant, contributor, amount, grant_contributions_curr, grant_contributions_prev, total_pot, threshold ) return predicted_clr_match From d9d20c7776bcfc3c02e60cd2cb5709642ad2b251 Mon Sep 17 00:00:00 2001 From: frankchen07 Date: Wed, 3 Jun 2020 13:42:35 -0700 Subject: [PATCH 002/186] removed unused code --- app/grants/clr.py | 53 ----------------------------------------------- 1 file changed, 53 deletions(-) diff --git a/app/grants/clr.py b/app/grants/clr.py index b838cfe9d7e..28fa0d6e7c3 100644 --- a/app/grants/clr.py +++ b/app/grants/clr.py @@ -169,59 +169,6 @@ def calculate_clr(aggregated_contributions, pair_totals, threshold=25.0, total_p -# ''' -# Clubbed function that intakes grant data, calculates necessary intermediate calculations, and spits out clr calculations. This function is re-used for positive and negative contributions - -# Args: -# grant_contributions: { -# 'id': (string) , -# 'contributions' : [ -# { -# contributor_profile (str) : contribution_amount (int) -# } -# ] -# } -# threshold: pairwise coefficient -# total_pot: total pot set for the round category -# positive: positive or negative contributions - -# Returns: -# totals: clr totals -# ''' -# def grants_clr_calculate(grant_contributions, total_pot=0.0, threshold=0.0, positive=True): -# grants_list = translate_data(grant_contributions) -# aggregated_contributions, pair_totals = aggregate_contributions(grants_list) -# totals = calculate_new_clr(aggregated_contributions, pair_totals, threshold=threshold, total_pot=total_pot, positive=positive) -# return totals - - - -# ''' -# Clubbed function that intakes the result of grants_clr_calculate and calculates the final difference calculation between positive and negative grant contributions. - -# Args: -# totals_pos: [{'id': proj, 'clr_amount': tot}] -# totals_neg: [{'id': proj, 'clr_amount': tot}] -# total_pot: total pot set for the round category - -# Returns: -# final_bigtot: should equal total pot -# final_totals: final clr totals - -# Final flow: -# grants_clr_calculate includes: -# translate_data -# aggregate_contributions -# calculate_new_clr -# and outputs: positive & negatives clr amounts -# grants_clr_calculate_pos_neg uses output from grants_clr_calculates to output final totals -# ''' -# def grants_clr_calculate_pos_neg(pos_totals, neg_totals, total_pot=0.0): -# final_bigtot, final_totals = calculate_new_clr_final(pos_totals, neg_totals, total_pot=total_pot) -# return final_bigtot, final_totals - - - ''' clubbed function that runs all calculation functions From ea13ec8d872583b3d1eaa5fd6b1e5a5bb217f6fe Mon Sep 17 00:00:00 2001 From: frankchen07 Date: Thu, 4 Jun 2020 17:03:24 -0700 Subject: [PATCH 003/186] add pulling the correct current and previous CLR data --- app/grants/clr.py | 122 +++++++++++++++++++++------------------------- 1 file changed, 56 insertions(+), 66 deletions(-) diff --git a/app/grants/clr.py b/app/grants/clr.py index 28fa0d6e7c3..4aa5072878a 100644 --- a/app/grants/clr.py +++ b/app/grants/clr.py @@ -31,10 +31,10 @@ from marketing.models import Stat from perftools.models import JSONStore +PREV_CLR_START_DATE = +PREV_CLR_END_DATE = CLR_START_DATE = dt.datetime(2020, 5, 6, 0, 0) -ROUND_5_5_GRANTS = [656, 493, 494, 502, 504, 662] - # TODO: MOVE TO DB THRESHOLD_TECH = 20.0 THRESHOLD_MEDIA = 20.0 @@ -258,14 +258,14 @@ def populate_data_for_clr(clr_type=None, network='mainnet', mechanism='profile') import pytz from_date = timezone.now() + # get all the eligible contributions and calculate total contributions = Contribution.objects.prefetch_related('subscription').filter(match=True, created_on__gte=CLR_START_DATE, created_on__lte=from_date, success=True) - if ROUND_5_5_GRANTS: - grants = Grant.objects.filter(id__in=ROUND_5_5_GRANTS) - threshold = THRESHOLD_HEALTH - total_pot = TOTAL_POT_HEALTH - elif clr_type == 'tech': + # gt all the previous eligible contributions and calculate total + contributions_prev = Contribution.objects.prefetch_related('subscription').filter(match=True, created_on__gte=PREV_CLR_START_DATE, created_on__lte=PREV_CLR_END_DATE, success=True) + + if clr_type == 'tech': grants = Grant.objects.filter(network=network, hidden=False, active=True, grant_type='tech', link_to_new_grant=None) threshold = THRESHOLD_TECH total_pot = TOTAL_POT_TECH @@ -282,78 +282,68 @@ def populate_data_for_clr(clr_type=None, network='mainnet', mechanism='profile') return None, None, None, None # set up data to load contributions for each grant - positive_contrib_data = [] - negative_contrib_data = [] + contrib_data_list = [] + contrib_data_list_prev = [] for grant in grants: grant_id = grant.defer_clr_to.pk if grant.defer_clr_to else grant.id - # Get the +ve and -ve contributions - positive_contributions = copy.deepcopy(contributions).filter(subscription__grant_id=grant.id, subscription__is_postive_vote=True) - negative_contributions = copy.deepcopy(contributions).filter(subscription__grant_id=grant.id, subscription__is_postive_vote=False) + # this round and last round contributions + contribs = copy.deepcopy(contributions).filter(subscription__grant_id=grant.id, subscription__is_postive_vote=True) + contribs_prev = copy.deepcopy(contributions_prev).filter(subscription__grant_id=grant.id, subscription__is_postive_vote=True) - # Generate list of profiles who've made +ve and -ve contributions to the grant + # this round and last round phantom funding profiles phantom_funding_profiles = PhantomFunding.objects.filter(grant_id=grant.id, created_on__gte=CLR_START_DATE, created_on__lte=from_date) - - # filter out new github profiles - positive_contribution_ids = [ele.pk for ele in positive_contributions if ele.subscription.contributor_profile.github_created_on.replace(tzinfo=pytz.UTC) < CLR_START_DATE.replace(tzinfo=pytz.UTC)] # only allow github profiles created after CLR Round - positive_contributions = positive_contributions.filter(pk__in=positive_contribution_ids) - negative_contribution_ids = [ele.pk for ele in negative_contributions if ele.subscription.contributor_profile.github_created_on.replace(tzinfo=pytz.UTC) < CLR_START_DATE.replace(tzinfo=pytz.UTC)] # only allow github profiles created after CLR Round - negative_contributions = negative_contributions.filter(pk__in=negative_contribution_ids) - phantom_funding_profiles = [ele for ele in phantom_funding_profiles if ele.profile.github_created_on.replace(tzinfo=pytz.UTC) < CLR_START_DATE.replace(tzinfo=pytz.UTC)] # only allow github profiles created after CLR Round - - positive_contributing_profile_ids = list(set([c.identity_identifier(mechanism) for c in positive_contributions] + [p.profile_id for p in phantom_funding_profiles])) - negative_contributing_profile_ids = list(set([c.identity_identifier(mechanism) for c in negative_contributions])) - - # print(f'positive contrib profiles : {positive_contributing_profile_ids}') - # print(f'negative contrib profiles : {negative_contributing_profile_ids}') - # print(f'positive contributions : {positive_contributions}') - # print(f'negative contributions : {negative_contributions}') - - positive_summed_contributions = [] - negative_summed_contributions = [] - - # POSITIVE CONTRIBUTIONS - if len(positive_contributing_profile_ids) > 0: - for profile_id in positive_contributing_profile_ids: - # get sum of contributions per grant for each profile - if mechanism == 'originated_address': - profile_positive_contributions = positive_contributions.filter(originated_address=profile_id) - else: - profile_positive_contributions = positive_contributions.filter(subscription__contributor_profile_id=profile_id) - sum_of_each_profiles_contributions = float(sum([c.subscription.amount_per_period_usdt for c in profile_positive_contributions if c.subscription.amount_per_period_usdt])) - - if mechanism != 'originated_address': - phantom_funding = PhantomFunding.objects.filter(created_on__gte=CLR_START_DATE, grant_id=grant.id, profile_id=profile_id, created_on__lte=from_date) - if phantom_funding.exists(): - sum_of_each_profiles_contributions = sum_of_each_profiles_contributions + phantom_funding.first().value - - positive_summed_contributions.append({str(profile_id): sum_of_each_profiles_contributions}) - + phantom_funding_profiles_prev = PhantomFunding.objects.filter(grant_id=grant.id, created_on__gte=PREV_CLR_START_DATE, created_on__lte=PREV_CLR_END_DATE) + + # only allow github profiles created after clr round + contribs_ids = [ele.pk for ele in contribs if ele.subscription.contributor_profile.github_created_on.replace(tzinfo=pytz.UTC) < CLR_START_DATE.replace(tzinfo=pytz.UTC)] + contribs = contribs.filter(pk__in=contribs_ids) + + # only allow github profiles created after previous clr round + contribs_ids_prev = [ele.pk for ele in contribs_prev if ele.subscription.contributor_profile.github_created_on.replace(tzinfo=pytz.UTC) < PREV_CLR_START_DATE.replace(tzinfo=pytz.UTC)] + contribs_prev = contribs_prev.filter(pk__in=negative_contribution_ids) + + # phantom - only allow github profiles created after clr round + phantom_funding_profiles = [ele for ele in phantom_funding_profiles if ele.profile.github_created_on.replace(tzinfo=pytz.UTC) < CLR_START_DATE.replace(tzinfo=pytz.UTC)] + phantom_funding_profiles_prev = [ele for ele in phantom_funding_profiles if ele.profile.github_created_on.replace(tzinfo=pytz.UTC) < PREV_CLR_START_DATE.replace(tzinfo=pytz.UTC)] + + contributing_profile_ids = list(set([c.identity_identifier(mechanism) for c in contribs] + [p.profile_id for p in phantom_funding_profiles])) + contributing_profile_ids_prev = list(set([c.identity_identifier(mechanism) for c in contribs_prev])) + + summed_contributions = [] + summed_contributions_prev = [] + + # CONTRIBUTIONS + if len(contributing_profile_ids) > 0: + for profile_id in contributing_profile_ids: + profile_contributions = contribs.filter(subscription__contributor_profile_id=profile_id) + sum_of_each_profiles_contributions = float(sum([c.subscription.amount_per_period_usdt for c in profile_contributions if c.subscription.amount_per_period_usdt])) + if phantom_funding.exists(): + sum_of_each_profiles_contributions = sum_of_each_profiles_contributions + phantom_funding.first().value + summed_contributions.append({str(profile_id): sum_of_each_profiles_contributions}) # for each grant, list the contributions in key value pairs like {'profile id': sum of contributions} - positive_contrib_data.append({ + contrib_data_list.append({ 'id': grant_id, - 'contributions': positive_summed_contributions + 'contributions': summed_contributions }) - # NEGATIVE CONTRIBUTIONS - if len(negative_contributing_profile_ids) > 0: - for profile_id in negative_contributing_profile_ids: - if mechanism == 'originated_address': - profile_negative_contributions = negative_contributions.filter(originated_address=profile_id) - else: - profile_negative_contributions = negative_contributions.filter(subscription__contributor_profile_id=profile_id) - sum_of_each_negative_contributions = float(sum([c.subscription.amount_per_period_usdt for c in profile_negative_contributions if c.subscription.amount_per_period_usdt])) - negative_summed_contributions.append({str(profile_id): sum_of_each_negative_contributions}) - - negative_contrib_data.append({ + # PREVIOUS CONTRIBUTIONS + if len(contributing_profile_ids_prev) > 0: + for profile_id in contributing_profile_ids_prev: + profile_contributions_prev = contribs_prev.filter(subscription__contributor_profile_id=profile_id) + sum_of_each_profiles_contributions_prev = float(sum([c.subscription.amount_per_period_usdt for c in profile_contributions_prev if c.subscription.amount_per_period_usdt])) + if phantom_funding.exists(): + sum_of_each_profiles_contributions_prev = sum_of_each_profiles_contributions_prev + phantom_funding.first().value + summed_contributions_prev.append({str(profile_id): sum_of_each_profiles_contributions_prev}) + # for each grant, list the contributions in key value pairs like {'profile id': sum of contributions} + contrib_data_list_prev.append({ 'id': grant_id, - 'contributions': negative_summed_contributions + 'contributions': summed_contributions_prev }) - # print(f'\n positive contributions data: {positive_contrib_data} \n') - # print(f'\n negative contributions data: {negative_contrib_data} \n') - return (grants, positive_contrib_data, negative_contrib_data, total_pot, threshold) + return (grants, contrib_data_list, contrib_data_list_prev, total_pot, threshold) + def predict_clr(save_to_db=False, from_date=None, clr_type=None, network='mainnet', mechanism='profile'): From f2b0fb8508bf866f32165293804b408b220a5dec Mon Sep 17 00:00:00 2001 From: frankchen07 Date: Sun, 7 Jun 2020 12:33:48 -0700 Subject: [PATCH 004/186] clr.py --- app/grants/clr.py | 208 +++++++++++++++++++++++++++++----------------- 1 file changed, 131 insertions(+), 77 deletions(-) diff --git a/app/grants/clr.py b/app/grants/clr.py index 4aa5072878a..86cf684629a 100644 --- a/app/grants/clr.py +++ b/app/grants/clr.py @@ -76,63 +76,93 @@ def translate_data(grants_data): -''' - combine previous round 1/3 contributions with current round contributions - - args: previous round contributions list of lists - - returns: list of lists of combined contributions - [[grant_id (str), user_id (str), contribution_amount (float)]] - -''' -def combine_previous_round(previous, current): - for x in previous: - x[2] = x[2]/3.0 - combined = current + previous - - return combined - - - ''' aggregates contributions by contributor, and calculates total contributions by unique pairs args: list of lists of grant data [[grant_id (str), user_id (str), contribution_amount (float)]] + round + str ('current' or 'previous') only returns: - aggregated contributions by pair & total contributions by pair - {grant_id (str): {user_id (str): aggregated_amount (float)}} - {user_id (str): {user_id (str): pair_total (float)}} + aggregated contributions by pair in nested list + { + round: { + grant_id (str): { + user_id (str): aggregated_amount (float) + } + } + } ''' -def aggregate_contributions(grant_contributions): +def aggregate_contributions(grant_contributions, round='current'): + round_dict = {} contrib_dict = {} for proj, user, amount in grant_contributions: if proj not in contrib_dict: contrib_dict[proj] = {} contrib_dict[proj][user] = contrib_dict[proj].get(user, 0) + amount + round_dict[round] = contrib_dict + return round_dict + + + +''' + gets pair totals between current round, current and previous round + + args: + aggregated contributions by pair in nested dict + { + round: { + grant_id (str): { + user_id (str): aggregated_amount (float) + } + } + } + + returns: + pair totals between current round, current and previous round + {user_id (str): {user_id (str): pair_total (float)}} + +''' +def get_totals_by_pair(contrib_dict): tot_overlap = {} - for proj, contribz in contrib_dict.items(): + + # start pairwise match + for proj, contribz in contrib_dict['current'].items(): for k1, v1 in contribz.items(): if k1 not in tot_overlap: tot_overlap[k1] = {} + + # pairwise matches to current round for k2, v2 in contribz.items(): if k2 not in tot_overlap[k1]: tot_overlap[k1][k2] = 0 tot_overlap[k1][k2] += (v1 * v2) ** 0.5 + + # pairwise matches to last round + if contrib_dict['previous'].get(proj): + for x1, y1 in contrib_dict['previous'][proj].items(): + if x1 not in tot_overlap[k1]: + tot_overlap[k1][x1] = 0 + tot_overlap[k1][x1] += (v1 * y1) ** 0.5 - return contrib_dict, tot_overlap + return tot_overlap ''' calculates the clr amount at the given threshold and total pot - args: - aggregated_contributions - {grant_id (str): {user_id (str): aggregated_amount (float)}} + aggregated_contributions by pair in nested dict + { + round: { + grant_id (str): { + user_id (str): aggregated_amount (float) + } + } + } pair_totals {user_id (str): {user_id (str): pair_total (float)}} threshold @@ -146,18 +176,33 @@ def aggregate_contributions(grant_contributions): saturation point boolean ''' -def calculate_clr(aggregated_contributions, pair_totals, threshold=25.0, total_pot=0.0): +def calculate_clr(aggregated_contributions, pair_totals, threshold=25.0, total_pot=100000.0): + saturation_point = False bigtot = 0 totals = [] - for proj, contribz in aggregated_contributions.items(): + for proj, contribz in aggregated_contributions['current'].items(): tot = 0 + + # start pairwise matches for k1, v1 in contribz.items(): + + # pairwise matches to current round for k2, v2 in contribz.items(): - if k2 > k1: # removes single donations, vitalik's formula + if k2 > k1: tot += ((v1 * v2) ** 0.5) / (pair_totals[k1][k2] / threshold + 1) + + # pairwise matches to last round + if aggregated_contributions['previous'].get(proj): + for x1, y1 in aggregated_contributions['previous'][proj].items(): + if x1 > k1: + tot += ((v1 * y1) ** 0.5) / (pair_totals[k1][x1] / threshold + 1) + bigtot += tot totals.append({'id': proj, 'clr_amount': tot}) + if bigtot >= total_pot: + saturation_point = True + # find normalization factor normalization_factor = bigtot / total_pot @@ -165,7 +210,7 @@ def calculate_clr(aggregated_contributions, pair_totals, threshold=25.0, total_p for result in totals: result['clr_amount'] = result['clr_amount'] / normalization_factor - return totals + return totals, saturation_point @@ -204,13 +249,17 @@ def run_clr_calcs(grant_contribs_curr, grant_contribs_prev, threshold=20.0, tota # get data curr_round = translate_data(grant_contribs_curr) prev_round = translate_data(grant_contribs_prev) + + # aggregate data + curr_agg = aggregate_contributions(curr_round, 'current') + prev_agg = aggregate_contributions(prev_round, 'previous') + combinedagg = {**prev_agg, **curr_agg} - # combined round - comb_round = combine_previous_round(prev_round, curr_round) + # get pair totals + ptots = get_totals_by_pair(combinedagg) - # clr calcluations - agg_contribs, pair_tots = aggregate_contributions(comb_round) - totals = calculate_clr(agg_contribs, pair_tots, threshold=threshold, total_pot=total_pot) + # clr calcluation + totals, _ = calculate_clr(combinedagg, ptots, threshold=threshold, total_pot=total_pot) return totals @@ -254,16 +303,13 @@ def calculate_clr_for_donation(grant, amount, grant_contributions_curr, grant_co total_pot: float threshold : int ''' -def populate_data_for_clr(clr_type=None, network='mainnet', mechanism='profile'): +def db_data_call(clr_type=None, network='mainnet', start_date=dt.datetime(2020, 1, 1, 0, 0), from_date=timezone.now()): import pytz - from_date = timezone.now() + # from_date = timezone.now() # get all the eligible contributions and calculate total - contributions = Contribution.objects.prefetch_related('subscription').filter(match=True, created_on__gte=CLR_START_DATE, created_on__lte=from_date, success=True) - - # gt all the previous eligible contributions and calculate total - contributions_prev = Contribution.objects.prefetch_related('subscription').filter(match=True, created_on__gte=PREV_CLR_START_DATE, created_on__lte=PREV_CLR_END_DATE, success=True) + contributions = Contribution.objects.prefetch_related('subscription').filter(match=True, created_on__gte=start_date, created_on__lte=from_date, success=True) if clr_type == 'tech': grants = Grant.objects.filter(network=network, hidden=False, active=True, grant_type='tech', link_to_new_grant=None) @@ -281,40 +327,55 @@ def populate_data_for_clr(clr_type=None, network='mainnet', mechanism='profile') # print('error: populate_data_for_clr missing clr_type') return None, None, None, None + phantom_funding_profiles = PhantomFunding.objects.filter(created_on__gte=start_date, created_on__lte=from_date) + + return contributions, grants, phantom_funding_profiles + + + +''' + Populate Data needed to calculate CLR + + Args: + clr_type : media | tech | None + network : mainnet | rinkeby + + Returns: + grants: list of grants based on clr_type + positive_contrib_data: [{'id': , 'contributions': }] + negative_contrib_data: [{'id': , 'contributions': }] + total_pot: float + threshold : int +''' +def populate_data_for_clr(contributions, grants, phantom_funding_profiles, mechanism='profile', clr_start_date=dt.datetime(2020, 1, 1, 0, 0), clr_end_date=timezone.now()): + # set up data to load contributions for each grant contrib_data_list = [] - contrib_data_list_prev = [] for grant in grants: grant_id = grant.defer_clr_to.pk if grant.defer_clr_to else grant.id - # this round and last round contributions + # contributions contribs = copy.deepcopy(contributions).filter(subscription__grant_id=grant.id, subscription__is_postive_vote=True) - contribs_prev = copy.deepcopy(contributions_prev).filter(subscription__grant_id=grant.id, subscription__is_postive_vote=True) - # this round and last round phantom funding profiles - phantom_funding_profiles = PhantomFunding.objects.filter(grant_id=grant.id, created_on__gte=CLR_START_DATE, created_on__lte=from_date) - phantom_funding_profiles_prev = PhantomFunding.objects.filter(grant_id=grant.id, created_on__gte=PREV_CLR_START_DATE, created_on__lte=PREV_CLR_END_DATE) + # phantom funding + phantom_funding_profiles = phantom_funding_profiles.filter(grant_id=grant.id, created_on__gte=clr_start_date, created_on__lte=clr_end_date) # only allow github profiles created after clr round - contribs_ids = [ele.pk for ele in contribs if ele.subscription.contributor_profile.github_created_on.replace(tzinfo=pytz.UTC) < CLR_START_DATE.replace(tzinfo=pytz.UTC)] - contribs = contribs.filter(pk__in=contribs_ids) - - # only allow github profiles created after previous clr round - contribs_ids_prev = [ele.pk for ele in contribs_prev if ele.subscription.contributor_profile.github_created_on.replace(tzinfo=pytz.UTC) < PREV_CLR_START_DATE.replace(tzinfo=pytz.UTC)] - contribs_prev = contribs_prev.filter(pk__in=negative_contribution_ids) + contribs_ids = [ele.pk for ele in contribs if ele.subscription.contributor_profile.github_created_on.replace(tzinfo=pytz.UTC) < clr_start_date.replace(tzinfo=pytz.UTC)] + contribs = contribs.filter(pk__in=contribs_ids) + ### FILTER BY CLR DATES? - # phantom - only allow github profiles created after clr round - phantom_funding_profiles = [ele for ele in phantom_funding_profiles if ele.profile.github_created_on.replace(tzinfo=pytz.UTC) < CLR_START_DATE.replace(tzinfo=pytz.UTC)] - phantom_funding_profiles_prev = [ele for ele in phantom_funding_profiles if ele.profile.github_created_on.replace(tzinfo=pytz.UTC) < PREV_CLR_START_DATE.replace(tzinfo=pytz.UTC)] + # only allow phantom github profiles created after clr round + phantom_funding_profiles = [ele for ele in phantom_funding_profiles if ele.profile.github_created_on.replace(tzinfo=pytz.UTC) < clr_start_date.replace(tzinfo=pytz.UTC)] + ### ADD PHANTOM FILTERING BY CLR DATES? + # combine contributing_profile_ids = list(set([c.identity_identifier(mechanism) for c in contribs] + [p.profile_id for p in phantom_funding_profiles])) - contributing_profile_ids_prev = list(set([c.identity_identifier(mechanism) for c in contribs_prev])) summed_contributions = [] - summed_contributions_prev = [] - # CONTRIBUTIONS + # contributions if len(contributing_profile_ids) > 0: for profile_id in contributing_profile_ids: profile_contributions = contribs.filter(subscription__contributor_profile_id=profile_id) @@ -327,22 +388,9 @@ def populate_data_for_clr(clr_type=None, network='mainnet', mechanism='profile') 'id': grant_id, 'contributions': summed_contributions }) + ### DO WE NEED TO FILTER THE GRANTS OBJECT TOO? - # PREVIOUS CONTRIBUTIONS - if len(contributing_profile_ids_prev) > 0: - for profile_id in contributing_profile_ids_prev: - profile_contributions_prev = contribs_prev.filter(subscription__contributor_profile_id=profile_id) - sum_of_each_profiles_contributions_prev = float(sum([c.subscription.amount_per_period_usdt for c in profile_contributions_prev if c.subscription.amount_per_period_usdt])) - if phantom_funding.exists(): - sum_of_each_profiles_contributions_prev = sum_of_each_profiles_contributions_prev + phantom_funding.first().value - summed_contributions_prev.append({str(profile_id): sum_of_each_profiles_contributions_prev}) - # for each grant, list the contributions in key value pairs like {'profile id': sum of contributions} - contrib_data_list_prev.append({ - 'id': grant_id, - 'contributions': summed_contributions_prev - }) - - return (grants, contrib_data_list, contrib_data_list_prev, total_pot, threshold) + return (grants, contrib_data_list, total_pot, threshold) @@ -350,12 +398,18 @@ def predict_clr(save_to_db=False, from_date=None, clr_type=None, network='mainne # setup clr_calc_start_time = timezone.now() debug_output = [] - grants, grant_contributions_curr, grant_contributions_prev, total_pot, threshold = populate_data_for_clr(clr_type, network, mechanism=mechanism) + + grants, contributions, phantom_funding_profiles = db_data_call(clr_type, network) + + # one for previous, one for current + grants, grant_contributions, total_pot, threshold = populate_data_for_clr(mechanism=mechanism) + grants, grant_contributions, total_pot, threshold = populate_data_for_clr(mechanism=mechanism) # print(f'GRANT {len(grants)}') # print(f'CONTRIB {len(positive_contrib_data)}') - # calculate clr given additional donations + # calculate clr given additional donations + ### HOW DOES THIS CHANGE WITH INPUTS ABOVE? for grant in grants: # five potential additional donations plus the base case of 0 potential_donations = [0, 1, 10, 100, 1000, 10000] From 0b47e189343ef46eb2c23f3bf6ddeb0fb873b5ce Mon Sep 17 00:00:00 2001 From: Ben DiFrancesco Date: Wed, 13 May 2020 17:11:28 -0400 Subject: [PATCH 005/186] Wire up an Add To Cart button on the grant page --- app/assets/v2/js/grants/info.js | 7 +++++++ app/grants/templates/grants/detail/index.html | 1 + app/grants/templates/grants/detail/info.html | 8 +++----- 3 files changed, 11 insertions(+), 5 deletions(-) create mode 100644 app/assets/v2/js/grants/info.js diff --git a/app/assets/v2/js/grants/info.js b/app/assets/v2/js/grants/info.js new file mode 100644 index 00000000000..3d09eaf6a90 --- /dev/null +++ b/app/assets/v2/js/grants/info.js @@ -0,0 +1,7 @@ +$(document).ready(function() { + + $('#js-addToCart-button').click(function(e) { + e.preventDefault(); + console.log("Hello world"); + }); +}); \ No newline at end of file diff --git a/app/grants/templates/grants/detail/index.html b/app/grants/templates/grants/detail/index.html index bd997d757bf..8ec3153e189 100644 --- a/app/grants/templates/grants/detail/index.html +++ b/app/grants/templates/grants/detail/index.html @@ -73,6 +73,7 @@ + diff --git a/app/grants/templates/grants/detail/info.html b/app/grants/templates/grants/detail/info.html index c3bc7fd2c7c..eac51e45fe7 100644 --- a/app/grants/templates/grants/detail/info.html +++ b/app/grants/templates/grants/detail/info.html @@ -156,11 +156,9 @@

{% else %} - - - + {% endif %} {% endif %} From 8f14c72276e258fb48a65dbbd7d4343f0d2f2d5f Mon Sep 17 00:00:00 2001 From: Ben DiFrancesco Date: Thu, 14 May 2020 16:46:20 -0400 Subject: [PATCH 006/186] Pass various grant details to frontend via hidden form inputs --- app/assets/v2/js/grants/fund.js | 2 ++ app/assets/v2/js/grants/info.js | 26 +++++++++++++++++--- app/grants/templates/grants/detail/info.html | 17 ++++++++++--- 3 files changed, 38 insertions(+), 7 deletions(-) diff --git a/app/assets/v2/js/grants/fund.js b/app/assets/v2/js/grants/fund.js index 256c9ee3ff9..0e6ef447b13 100644 --- a/app/assets/v2/js/grants/fund.js +++ b/app/assets/v2/js/grants/fund.js @@ -192,12 +192,14 @@ $(document).ready(function() { }); $('.contribution_type select').trigger('change'); + // TODO: convert add to cart to form and grab data from hidden inputs like this $('#js-fundGrant').submit(function(e) { e.preventDefault(); var data = {}; var form = $(this).serializeArray(); $.each(form, function() { + console.log(this.name, this.value); data[this.name] = this.value; }); diff --git a/app/assets/v2/js/grants/info.js b/app/assets/v2/js/grants/info.js index 3d09eaf6a90..e1805325093 100644 --- a/app/assets/v2/js/grants/info.js +++ b/app/assets/v2/js/grants/info.js @@ -1,7 +1,25 @@ + +// DOCUMENT + $(document).ready(function() { - $('#js-addToCart-button').click(function(e) { - e.preventDefault(); - console.log("Hello world"); + $('#js-addToCart-form').submit(function(event) { + event.preventDefault(); + + const formData = objectifySerialized($(this).serializeArray()); + console.log("Form data", formData); }); -}); \ No newline at end of file +}); + +// HELPERS + +function objectifySerialized(data) { + let objectData = {}; + + for (let i = 0; i < data.length; i++) { + const item = data[i]; + objectData[item.name] = item.value; + } + + return objectData; +} \ No newline at end of file diff --git a/app/grants/templates/grants/detail/info.html b/app/grants/templates/grants/detail/info.html index eac51e45fe7..69a063ac6d2 100644 --- a/app/grants/templates/grants/detail/info.html +++ b/app/grants/templates/grants/detail/info.html @@ -156,9 +156,20 @@

{% else %} - +
+ + + + + + + + + + +
{% endif %} {% endif %} From 423d2857b893ae6594c7ec74a67c6b340bd20216 Mon Sep 17 00:00:00 2001 From: Ben DiFrancesco Date: Thu, 14 May 2020 17:25:33 -0400 Subject: [PATCH 007/186] Add grant data to local storage button is pressed --- app/assets/v2/js/grants/fund.js | 2 -- app/assets/v2/js/grants/info.js | 38 +++++++++++++++++++++++++++++++-- 2 files changed, 36 insertions(+), 4 deletions(-) diff --git a/app/assets/v2/js/grants/fund.js b/app/assets/v2/js/grants/fund.js index 0e6ef447b13..256c9ee3ff9 100644 --- a/app/assets/v2/js/grants/fund.js +++ b/app/assets/v2/js/grants/fund.js @@ -192,14 +192,12 @@ $(document).ready(function() { }); $('.contribution_type select').trigger('change'); - // TODO: convert add to cart to form and grab data from hidden inputs like this $('#js-fundGrant').submit(function(e) { e.preventDefault(); var data = {}; var form = $(this).serializeArray(); $.each(form, function() { - console.log(this.name, this.value); data[this.name] = this.value; }); diff --git a/app/assets/v2/js/grants/info.js b/app/assets/v2/js/grants/info.js index e1805325093..63c68edbffe 100644 --- a/app/assets/v2/js/grants/info.js +++ b/app/assets/v2/js/grants/info.js @@ -7,7 +7,8 @@ $(document).ready(function() { event.preventDefault(); const formData = objectifySerialized($(this).serializeArray()); - console.log("Form data", formData); + addToCart(formData); + // console.log("CART", loadCart()); }); }); @@ -22,4 +23,37 @@ function objectifySerialized(data) { } return objectData; -} \ No newline at end of file +} + +function cartContainsGrantWithSlug(grantSlug) { + const cart = loadCart(); + const slugList = cart.map(grant => { + return grant.grant_slug; + }); + + return slugList.includes(grantSlug); +} + +function addToCart(grantData) { + if (cartContainsGrantWithSlug(grantData.grant_slug)) { + return; + } + + let cartList = loadCart() + cartList.push(grantData); + setCart(cartList); +} + +function loadCart() { + let cartList = localStorage.getItem('grants_cart'); + + if (!cartList) { + return []; + } + + return JSON.parse(cartList); +} + +function setCart(list) { + localStorage.setItem('grants_cart', JSON.stringify(list)); +} From 29847de986483f544abf267f1dbf1e374181f5bd Mon Sep 17 00:00:00 2001 From: mds <17163988+mds1@users.noreply.github.com> Date: Thu, 14 May 2020 08:59:27 -0700 Subject: [PATCH 008/186] Add /grants/cart route --- app/grants/templates/grants/cart.html | 72 +++++++++++++++++++++++++++ app/grants/urls.py | 6 +-- app/grants/views.py | 6 +++ 3 files changed, 81 insertions(+), 3 deletions(-) create mode 100644 app/grants/templates/grants/cart.html diff --git a/app/grants/templates/grants/cart.html b/app/grants/templates/grants/cart.html new file mode 100644 index 00000000000..5481c0e4c24 --- /dev/null +++ b/app/grants/templates/grants/cart.html @@ -0,0 +1,72 @@ +{% comment %} + Copyright (C) 2020 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 . +{% endcomment %} +{% load static i18n %} + + + + {% include 'shared/head.html' with slim=1 %} + {% include 'shared/cards.html' %} + + + + + + + + {% include 'shared/tag_manager_2.html' %} +
+ {% include 'shared/top_nav.html' with class='d-md-flex' %} + {% include 'grants/nav.html' %} +
+
+ {% include 'shared/no_metamask_error.html' %} + {% include 'shared/zero_balance_error.html' %} + {% include 'shared/unlock_metamask.html' %} + {% include 'shared/connect_metamask.html' %} +
+
+
+ + +
+ THIS IS THE CART +
+ + + {% include 'shared/current_profile.html' %} + {% include 'shared/bottom_notification.html' %} + {% include 'shared/analytics.html' %} + {% include 'shared/footer_scripts.html' with ignore_inject_web3=1 %} + {% include 'shared/footer.html' %} + {% include 'grants/shared/shared_scripts.html' %} + + + + + + + + + + + + + + + + + diff --git a/app/grants/urls.py b/app/grants/urls.py index 4a795f67b87..455c38035a7 100644 --- a/app/grants/urls.py +++ b/app/grants/urls.py @@ -22,9 +22,8 @@ from grants.views import ( flag, grant_categories, grant_details, grant_fund, grant_new, grant_new_whitelabel, grants, grants_addr_as_json, grants_stats_view, invoice, leaderboard, new_matching_partner, predict_clr_v1, profile, quickstart, - subscription_cancel, + subscription_cancel, grants_cart_view, ) - app_name = 'grants' urlpatterns = [ path('', grants, name='grants'), @@ -51,5 +50,6 @@ invoice, name='contribution_invoice' ), - path('api/v1//predict-clr', predict_clr_v1, name='predict_clr_v1') + path('api/v1//predict-clr', predict_clr_v1, name='predict_clr_v1'), + path('cart', grants_cart_view, name='cart') ] diff --git a/app/grants/views.py b/app/grants/views.py index 340efc530d6..7f98865620c 100644 --- a/app/grants/views.py +++ b/app/grants/views.py @@ -1031,6 +1031,12 @@ def subscription_cancel(request, grant_id, grant_slug, subscription_id): return TemplateResponse(request, 'grants/cancel.html', params) +# @login_required +def grants_cart_view(request): + response = TemplateResponse(request, 'grants/cart.html') + response['X-Frame-Options'] = 'SAMEORIGIN' + return response + @login_required def profile(request): From 08918ee3cb3588f9b693c8c86449fd706e5e4557 Mon Sep 17 00:00:00 2001 From: mds <17163988+mds1@users.noreply.github.com> Date: Thu, 14 May 2020 09:51:14 -0700 Subject: [PATCH 009/186] Working vue component that shows value of a variable --- app/assets/v2/js/cart.js | 55 +++++++++++++++++++ .../grants/{cart.html => cart-vue.html} | 22 ++++++-- app/grants/views.py | 2 +- 3 files changed, 74 insertions(+), 5 deletions(-) create mode 100644 app/assets/v2/js/cart.js rename app/grants/templates/grants/{cart.html => cart-vue.html} (83%) diff --git a/app/assets/v2/js/cart.js b/app/assets/v2/js/cart.js new file mode 100644 index 00000000000..8624d79caa6 --- /dev/null +++ b/app/assets/v2/js/cart.js @@ -0,0 +1,55 @@ +let testString = 'qwertyyyyyy'; + +Vue.component('grants-cart', { + delimiters: [ '[[', ']]' ], + // props: [ 'tribe', 'is_my_org' ], + data: function() { + return { + testString + }; + }, + + mounted() { + // + }, + created() { + // + }, + beforeMount() { + window.addEventListener('scroll', () => { + this.bottom = this.bottomVisible(); + }, false); + }, + beforeDestroy() { + window.removeEventListener('scroll', () => { + this.bottom = this.bottomVisible(); + }); + } +}); + +if (document.getElementById('gc-grants-cart')) { + + var app = new Vue({ + delimiters: [ '[[', ']]' ], + el: '#gc-grants-cart', + data: { + testString + }, + mounted() { + // + }, + created() { + // + }, + beforeMount() { + window.addEventListener('scroll', () => { + this.bottom = this.bottomVisible(); + }, false); + }, + beforeDestroy() { + window.removeEventListener('scroll', () => { + this.bottom = this.bottomVisible(); + }); + } + }); +} \ No newline at end of file diff --git a/app/grants/templates/grants/cart.html b/app/grants/templates/grants/cart-vue.html similarity index 83% rename from app/grants/templates/grants/cart.html rename to app/grants/templates/grants/cart-vue.html index 5481c0e4c24..6dda06e9420 100644 --- a/app/grants/templates/grants/cart.html +++ b/app/grants/templates/grants/cart-vue.html @@ -27,7 +27,7 @@ - {% include 'shared/tag_manager_2.html' %} + {% include 'shared/tag_manager_2.html' %}
{% include 'shared/top_nav.html' with class='d-md-flex' %} {% include 'grants/nav.html' %} @@ -42,9 +42,16 @@
-
- THIS IS THE CART -
+
+ THIS IS THE CART +
+ +
+ This string is from the Vue component: [[ testString ]] +
+
+
+
{% include 'shared/current_profile.html' %} @@ -53,8 +60,15 @@ {% include 'shared/footer_scripts.html' with ignore_inject_web3=1 %} {% include 'shared/footer.html' %} {% include 'grants/shared/shared_scripts.html' %} + + + + {% comment %} + TODO this template was initialized by copying the temlate of another file, so + we don't need all of these scripts and need to determine which to remove + {% endcomment %} diff --git a/app/grants/views.py b/app/grants/views.py index 7f98865620c..91071c91c79 100644 --- a/app/grants/views.py +++ b/app/grants/views.py @@ -1033,7 +1033,7 @@ def subscription_cancel(request, grant_id, grant_slug, subscription_id): # @login_required def grants_cart_view(request): - response = TemplateResponse(request, 'grants/cart.html') + response = TemplateResponse(request, 'grants/cart-vue.html') response['X-Frame-Options'] = 'SAMEORIGIN' return response From da46c3bf68716b75d9d0957840caed45ac48d640 Mon Sep 17 00:00:00 2001 From: mds <17163988+mds1@users.noreply.github.com> Date: Thu, 14 May 2020 12:15:44 -0700 Subject: [PATCH 010/186] Setup heading section --- app/assets/v2/css/grants/cart.css | 15 ++++++ app/assets/v2/js/cart.js | 23 ++++----- app/grants/templates/grants/cart-vue.html | 58 +++++++++++++++-------- 3 files changed, 62 insertions(+), 34 deletions(-) create mode 100644 app/assets/v2/css/grants/cart.css diff --git a/app/assets/v2/css/grants/cart.css b/app/assets/v2/css/grants/cart.css new file mode 100644 index 00000000000..d5ab670d3b6 --- /dev/null +++ b/app/assets/v2/css/grants/cart.css @@ -0,0 +1,15 @@ +.container { + display: flex; + align-items: center; + flex-direction: column; + justify-content: center; + max-width: 750px; +} + +.separator { + border-top-width: 1px; + border-top-style: solid; + border-top-color: var(--text-light); + display: block; + margin: 1rem 0 2rem; +} diff --git a/app/assets/v2/js/cart.js b/app/assets/v2/js/cart.js index 8624d79caa6..98b7bad50df 100644 --- a/app/assets/v2/js/cart.js +++ b/app/assets/v2/js/cart.js @@ -1,11 +1,13 @@ let testString = 'qwertyyyyyy'; +let numberOfGrants = 'TBD'; Vue.component('grants-cart', { delimiters: [ '[[', ']]' ], // props: [ 'tribe', 'is_my_org' ], data: function() { return { - testString + testString, + numberOfGrants }; }, @@ -16,14 +18,10 @@ Vue.component('grants-cart', { // }, beforeMount() { - window.addEventListener('scroll', () => { - this.bottom = this.bottomVisible(); - }, false); + // }, beforeDestroy() { - window.removeEventListener('scroll', () => { - this.bottom = this.bottomVisible(); - }); + // } }); @@ -33,7 +31,8 @@ if (document.getElementById('gc-grants-cart')) { delimiters: [ '[[', ']]' ], el: '#gc-grants-cart', data: { - testString + testString, + numberOfGrants }, mounted() { // @@ -42,14 +41,10 @@ if (document.getElementById('gc-grants-cart')) { // }, beforeMount() { - window.addEventListener('scroll', () => { - this.bottom = this.bottomVisible(); - }, false); + // }, beforeDestroy() { - window.removeEventListener('scroll', () => { - this.bottom = this.bottomVisible(); - }); + // } }); } \ No newline at end of file diff --git a/app/grants/templates/grants/cart-vue.html b/app/grants/templates/grants/cart-vue.html index 6dda06e9420..614e3fb7769 100644 --- a/app/grants/templates/grants/cart-vue.html +++ b/app/grants/templates/grants/cart-vue.html @@ -1,22 +1,21 @@ {% comment %} - Copyright (C) 2020 Gitcoin Core +Copyright (C) 2020 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 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. +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 . {% endcomment %} {% load static i18n %} + - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see . -{% endcomment %} -{% load static i18n %} - - {% include 'shared/head.html' with slim=1 %} {% include 'shared/cards.html' %} @@ -25,7 +24,9 @@ + + {% include 'shared/tag_manager_2.html' %}
@@ -43,11 +44,27 @@
- THIS IS THE CART
- This string is from the Vue component: [[ testString ]] + {% comment %} Heading section {% endcomment %} +
+

+ Grant Cart ([[ numberOfGrants ]] items) +

+ Robot with torch +
+ Clear my cart +
+
+ {% comment %} Divider {% endcomment %} +
+
+
+ {% comment %} Cart section {% endcomment %} +
+ This string is from the Vue component: [[ testString ]] +
@@ -66,8 +83,8 @@ {% comment %} - TODO this template was initialized by copying the temlate of another file, so - we don't need all of these scripts and need to determine which to remove + TODO this template was initialized by copying the temlate of another file, so + we don't need all of these scripts and need to determine which to remove {% endcomment %} @@ -83,4 +100,5 @@ - + + From 5c8e3c4ad0c2eec892f1265f5018f30d4d113275 Mon Sep 17 00:00:00 2001 From: mds <17163988+mds1@users.noreply.github.com> Date: Thu, 14 May 2020 13:31:42 -0700 Subject: [PATCH 011/186] Initial setup of grants cart layout --- app/assets/v2/css/grants/cart.css | 32 ++++++++++++++++++-- app/assets/v2/js/cart.js | 36 +++++++++++++++++++++-- app/grants/templates/grants/cart-vue.html | 31 ++++++++++++++++++- 3 files changed, 94 insertions(+), 5 deletions(-) diff --git a/app/assets/v2/css/grants/cart.css b/app/assets/v2/css/grants/cart.css index d5ab670d3b6..3e6caea2a7e 100644 --- a/app/assets/v2/css/grants/cart.css +++ b/app/assets/v2/css/grants/cart.css @@ -7,9 +7,37 @@ } .separator { - border-top-width: 1px; - border-top-style: solid; border-top-color: var(--text-light); + border-top-style: solid; + border-top-width: 1px; display: block; margin: 1rem 0 2rem; } + +.flex-container { + width: 100%; + display: -webkit-flex; + display: flex; + justify-content: space-between; + -webkit-justify-content: space-between; + align-items: center +} + +.grant-row { + width: 100%; +} + +.grant-row-style { + background-color: var(--gc-grey); + border-color: var(--text-light); + border-radius: 5px; + border-style: solid; + border-width: 1px; + margin-bottom: 1rem; + padding: 1rem; +} + +.grant-name { + font-weight: bold; + margin-left: 0.5rem; +} diff --git a/app/assets/v2/js/cart.js b/app/assets/v2/js/cart.js index 98b7bad50df..780d553d92b 100644 --- a/app/assets/v2/js/cart.js +++ b/app/assets/v2/js/cart.js @@ -1,5 +1,33 @@ let testString = 'qwertyyyyyy'; let numberOfGrants = 'TBD'; +let grantHeaders = [ 'Grant', 'Amount', 'Type', 'Total CLR Match Amount' ]; +// Using dummy data for now +let grantData = [ + { + grantImgPath: '../static/v2/images/gitcoinco.png', + grantName: 'Burner Wallet', + donationAmount: 1, + donationCurrency: 'DAI', + donationType: 'Recurring', + numberOfRounds: 3 + }, + { + grantImgPath: '../static/v2/images/gitcoinco.png', + grantName: 'Covid Mask', + donationAmount: 1, + donationCurrency: 'DAI', + donationType: 'Recurring', + numberOfRounds: 2 + }, + { + grantImgPath: '../static/v2/images/gitcoinco.png', + grantName: 'Save Whales', + donationAmount: 1, + donationCurrency: 'ETH', + donationType: 'One Time', + numberOfRounds: undefined + } +]; Vue.component('grants-cart', { delimiters: [ '[[', ']]' ], @@ -7,7 +35,9 @@ Vue.component('grants-cart', { data: function() { return { testString, - numberOfGrants + numberOfGrants, + grantHeaders, + grantData }; }, @@ -32,7 +62,9 @@ if (document.getElementById('gc-grants-cart')) { el: '#gc-grants-cart', data: { testString, - numberOfGrants + numberOfGrants, + grantHeaders, + grantData }, mounted() { // diff --git a/app/grants/templates/grants/cart-vue.html b/app/grants/templates/grants/cart-vue.html index 614e3fb7769..496c98a24bb 100644 --- a/app/grants/templates/grants/cart-vue.html +++ b/app/grants/templates/grants/cart-vue.html @@ -63,7 +63,36 @@

{% comment %} Cart section {% endcomment %}
- This string is from the Vue component: [[ testString ]] +
+
+
+
+
+ Grant logo +
[[grant.grantName]]
+
+
+
+
+ [[grant.donationAmount]] + [[grant.donationCurrency]] +
+
+ + Add comment to owner +
+
+
+ [[grant.donationType]] + + for [[grant.numberOfRounds]] rounds + +
+
+ +
+
+
+
From 5457fd44becfd230745b7f1bceed0c2452283fe9 Mon Sep 17 00:00:00 2001 From: mds <17163988+mds1@users.noreply.github.com> Date: Fri, 15 May 2020 07:29:25 -0700 Subject: [PATCH 012/186] Various tweaks and additions to the cart page - Add header row above cart content - Add CLR match amount - Number of grants no longer hardcoded - Remove stray comment from views.py --- app/assets/v2/css/grants/cart.css | 16 +++++++-- app/assets/v2/js/cart.js | 12 +++---- app/grants/templates/grants/cart-vue.html | 43 +++++++++++++++++++---- app/grants/views.py | 1 - 4 files changed, 57 insertions(+), 15 deletions(-) diff --git a/app/assets/v2/css/grants/cart.css b/app/assets/v2/css/grants/cart.css index 3e6caea2a7e..a047cc597c7 100644 --- a/app/assets/v2/css/grants/cart.css +++ b/app/assets/v2/css/grants/cart.css @@ -3,7 +3,7 @@ align-items: center; flex-direction: column; justify-content: center; - max-width: 750px; + max-width: 1000px; } .separator { @@ -20,7 +20,12 @@ display: flex; justify-content: space-between; -webkit-justify-content: space-between; - align-items: center + align-items: center; +} + +.grant-header-row { + padding: 1rem; + width: 100%; } .grant-row { @@ -41,3 +46,10 @@ font-weight: bold; margin-left: 0.5rem; } + +.clr-match-box { + background-color: rgba(15, 206, 124, 0.1); + border: 1px rgba(15, 206, 124, 0.1) solid; + border-radius: 5px; + padding: 0.5rem 1rem; +} diff --git a/app/assets/v2/js/cart.js b/app/assets/v2/js/cart.js index 780d553d92b..8d3bbaf6da1 100644 --- a/app/assets/v2/js/cart.js +++ b/app/assets/v2/js/cart.js @@ -1,5 +1,4 @@ let testString = 'qwertyyyyyy'; -let numberOfGrants = 'TBD'; let grantHeaders = [ 'Grant', 'Amount', 'Type', 'Total CLR Match Amount' ]; // Using dummy data for now let grantData = [ @@ -9,7 +8,8 @@ let grantData = [ donationAmount: 1, donationCurrency: 'DAI', donationType: 'Recurring', - numberOfRounds: 3 + numberOfRounds: 3, + clrMatchAmount: 250 }, { grantImgPath: '../static/v2/images/gitcoinco.png', @@ -17,7 +17,8 @@ let grantData = [ donationAmount: 1, donationCurrency: 'DAI', donationType: 'Recurring', - numberOfRounds: 2 + numberOfRounds: 2, + clrMatchAmount: 250 }, { grantImgPath: '../static/v2/images/gitcoinco.png', @@ -25,7 +26,8 @@ let grantData = [ donationAmount: 1, donationCurrency: 'ETH', donationType: 'One Time', - numberOfRounds: undefined + numberOfRounds: undefined, + clrMatchAmount: 250 } ]; @@ -35,7 +37,6 @@ Vue.component('grants-cart', { data: function() { return { testString, - numberOfGrants, grantHeaders, grantData }; @@ -62,7 +63,6 @@ if (document.getElementById('gc-grants-cart')) { el: '#gc-grants-cart', data: { testString, - numberOfGrants, grantHeaders, grantData }, diff --git a/app/grants/templates/grants/cart-vue.html b/app/grants/templates/grants/cart-vue.html index 496c98a24bb..feb220b251e 100644 --- a/app/grants/templates/grants/cart-vue.html +++ b/app/grants/templates/grants/cart-vue.html @@ -50,7 +50,7 @@ {% comment %} Heading section {% endcomment %}

- Grant Cart ([[ numberOfGrants ]] items) + Grant Cart ([[ grantData.length ]] items)

Robot with torch
@@ -61,8 +61,30 @@

- {% comment %} Cart section {% endcomment %} -
+ {% comment %} Cart header {% endcomment %} +
+
+
+
+ Grant +
+
+
+ Amount +
+
+ Type +
+
+
+ Total CLR Match Amount +
+
+
+   +
+
+ {% comment %} Cart content {% endcomment %}
@@ -72,7 +94,7 @@

[[grant.grantName]]

-
+
[[grant.donationAmount]] [[grant.donationCurrency]] @@ -81,13 +103,22 @@

+ Add comment to owner

-
+
[[grant.donationType]] for [[grant.numberOfRounds]] rounds
-
+
+
+
+ [[grant.clrMatchAmount]] DAI +
+ Diamonds high-fiving +
+
+
diff --git a/app/grants/views.py b/app/grants/views.py index 91071c91c79..5dfc69b73e9 100644 --- a/app/grants/views.py +++ b/app/grants/views.py @@ -1031,7 +1031,6 @@ def subscription_cancel(request, grant_id, grant_slug, subscription_id): return TemplateResponse(request, 'grants/cancel.html', params) -# @login_required def grants_cart_view(request): response = TemplateResponse(request, 'grants/cart-vue.html') response['X-Frame-Options'] = 'SAMEORIGIN' From f2fef8d4e6676cd55a09f2bcce4923b5601edcf6 Mon Sep 17 00:00:00 2001 From: mds <17163988+mds1@users.noreply.github.com> Date: Fri, 15 May 2020 07:34:57 -0700 Subject: [PATCH 013/186] Update cart header/footer content Previously this scripts and styles loaded were pulled from an arbitrary page, so these have been replaced to match the scripts and styles from the grant detail page --- app/grants/templates/grants/cart-vue.html | 65 ++++++++++++++--------- 1 file changed, 39 insertions(+), 26 deletions(-) diff --git a/app/grants/templates/grants/cart-vue.html b/app/grants/templates/grants/cart-vue.html index feb220b251e..790327ba432 100644 --- a/app/grants/templates/grants/cart-vue.html +++ b/app/grants/templates/grants/cart-vue.html @@ -18,30 +18,29 @@ {% include 'shared/head.html' with slim=1 %} - {% include 'shared/cards.html' %} - + {% include 'shared/cards_pic.html' %} + + + + + + - + - + {% include 'shared/tag_manager_2.html' %} -
+
{% include 'shared/top_nav.html' with class='d-md-flex' %} {% include 'grants/nav.html' %} -
-
- {% include 'shared/no_metamask_error.html' %} - {% include 'shared/zero_balance_error.html' %} - {% include 'shared/unlock_metamask.html' %} - {% include 'shared/connect_metamask.html' %} -
-
+ {% include 'grants/shared/waiting_state.html' %} +
@@ -142,23 +141,37 @@

- {% comment %} - TODO this template was initialized by copying the temlate of another file, so - we don't need all of these scripts and need to determine which to remove - {% endcomment %} - - - - - - - + {% include 'shared/activity_scripts.html' %} + + + + + - + + + + + - + + + From 8565fb94d0b13b839b20d28dd5efccea1bf603a5 Mon Sep 17 00:00:00 2001 From: mds <17163988+mds1@users.noreply.github.com> Date: Tue, 19 May 2020 16:53:07 -0700 Subject: [PATCH 014/186] Cart now reads data from local storage --- app/assets/v2/js/cart.js | 39 +++-------------------- app/assets/v2/js/grants/info.js | 8 +++++ app/grants/templates/grants/cart-vue.html | 18 ++++++----- 3 files changed, 22 insertions(+), 43 deletions(-) diff --git a/app/assets/v2/js/cart.js b/app/assets/v2/js/cart.js index 8d3bbaf6da1..9acc2218a66 100644 --- a/app/assets/v2/js/cart.js +++ b/app/assets/v2/js/cart.js @@ -1,49 +1,19 @@ -let testString = 'qwertyyyyyy'; let grantHeaders = [ 'Grant', 'Amount', 'Type', 'Total CLR Match Amount' ]; -// Using dummy data for now -let grantData = [ - { - grantImgPath: '../static/v2/images/gitcoinco.png', - grantName: 'Burner Wallet', - donationAmount: 1, - donationCurrency: 'DAI', - donationType: 'Recurring', - numberOfRounds: 3, - clrMatchAmount: 250 - }, - { - grantImgPath: '../static/v2/images/gitcoinco.png', - grantName: 'Covid Mask', - donationAmount: 1, - donationCurrency: 'DAI', - donationType: 'Recurring', - numberOfRounds: 2, - clrMatchAmount: 250 - }, - { - grantImgPath: '../static/v2/images/gitcoinco.png', - grantName: 'Save Whales', - donationAmount: 1, - donationCurrency: 'ETH', - donationType: 'One Time', - numberOfRounds: undefined, - clrMatchAmount: 250 - } -]; +let grantData = []; Vue.component('grants-cart', { delimiters: [ '[[', ']]' ], - // props: [ 'tribe', 'is_my_org' ], + data: function() { return { - testString, grantHeaders, grantData }; }, mounted() { - // + // Read array of grants in cart from localStorage + this.grantData = JSON.parse(window.localStorage.getItem('grants_cart')); }, created() { // @@ -62,7 +32,6 @@ if (document.getElementById('gc-grants-cart')) { delimiters: [ '[[', ']]' ], el: '#gc-grants-cart', data: { - testString, grantHeaders, grantData }, diff --git a/app/assets/v2/js/grants/info.js b/app/assets/v2/js/grants/info.js index 63c68edbffe..3e8ac99e3af 100644 --- a/app/assets/v2/js/grants/info.js +++ b/app/assets/v2/js/grants/info.js @@ -39,6 +39,14 @@ function addToCart(grantData) { return; } + // Add donation defaults + // TODO Update to use real data + grantData.grant_donation_amount = 5; + grantData.grant_donation_currency = 'DAI'; + grantData.grant_donation_type = 'one-time'; // options are 'one-time' and 'recurring' + grantData.grant_donation_num_rounds = 0; // N/A if type is one-time + grantData.grant_donation_clr_match = 250; + let cartList = loadCart() cartList.push(grantData); setCart(cartList); diff --git a/app/grants/templates/grants/cart-vue.html b/app/grants/templates/grants/cart-vue.html index 790327ba432..d37f87eae50 100644 --- a/app/grants/templates/grants/cart-vue.html +++ b/app/grants/templates/grants/cart-vue.html @@ -89,29 +89,31 @@

- Grant logo -
[[grant.grantName]]
+ Grant logo +
[[grant.grant_title]]
- [[grant.donationAmount]] - [[grant.donationCurrency]] + [[grant.grant_donation_amount]] + [[grant.grant_donation_currency]]
+ Add comment to owner
- [[grant.donationType]] - - for [[grant.numberOfRounds]] rounds + One Time + Recurring + Error: Invalid donation type + + for [[grant.grant_donation_num_rounds]] rounds
- [[grant.clrMatchAmount]] DAI + [[grant.grant_donation_clr_match]] DAI
Diamonds high-fiving From 3ff95757ddf43169b01a74c677478efecfff35c2 Mon Sep 17 00:00:00 2001 From: mds <17163988+mds1@users.noreply.github.com> Date: Tue, 19 May 2020 17:34:37 -0700 Subject: [PATCH 015/186] Add input fields that user can adjust --- app/assets/v2/js/cart.js | 3 ++- app/grants/templates/grants/cart-vue.html | 28 +++++++++++++++++++---- 2 files changed, 25 insertions(+), 6 deletions(-) diff --git a/app/assets/v2/js/cart.js b/app/assets/v2/js/cart.js index 9acc2218a66..f456829b494 100644 --- a/app/assets/v2/js/cart.js +++ b/app/assets/v2/js/cart.js @@ -7,7 +7,8 @@ Vue.component('grants-cart', { data: function() { return { grantHeaders, - grantData + grantData, + currencies: [ 'ETH', 'DAI', 'USDC' ] // TODO update with Gitcoin's list of tokens }; }, diff --git a/app/grants/templates/grants/cart-vue.html b/app/grants/templates/grants/cart-vue.html index d37f87eae50..921f1414b95 100644 --- a/app/grants/templates/grants/cart-vue.html +++ b/app/grants/templates/grants/cart-vue.html @@ -87,21 +87,31 @@

+ {% comment %} Title and logo {% endcomment %}
Grant logo
[[grant.grant_title]]
-
-
- [[grant.grant_donation_amount]] - [[grant.grant_donation_currency]] + {% comment %} Grant amount and currency {% endcomment %} +
+
+
+ +
+
+ + +
+ Add comment to owner
+ {% comment %} Grant type {% endcomment %}
One Time Recurring @@ -110,15 +120,17 @@

for [[grant.grant_donation_num_rounds]] rounds

+ {% comment %} CLR match amount {% endcomment %}
- [[grant.grant_donation_clr_match]] DAI + [[grant.grant_donation_clr_match]] [[grant.grant_donation_currency]]
Diamonds high-fiving
+ {% comment %} Delete icon {% endcomment %}
@@ -132,6 +144,12 @@

+ + {% include 'shared/current_profile.html' %} {% include 'shared/bottom_notification.html' %} {% include 'shared/analytics.html' %} From 6f71f6e910245ed4072d3b6ca05ff5b02c70ea1e Mon Sep 17 00:00:00 2001 From: mds <17163988+mds1@users.noreply.github.com> Date: Wed, 20 May 2020 11:13:06 -0700 Subject: [PATCH 016/186] Add total and summary sections --- app/assets/v2/css/grants/cart.css | 16 +++++ app/assets/v2/js/cart.js | 72 +++++++++++++++++++ app/grants/templates/grants/cart-vue.html | 86 ++++++++++++++++++++++- 3 files changed, 171 insertions(+), 3 deletions(-) diff --git a/app/assets/v2/css/grants/cart.css b/app/assets/v2/css/grants/cart.css index a047cc597c7..29cc80eb701 100644 --- a/app/assets/v2/css/grants/cart.css +++ b/app/assets/v2/css/grants/cart.css @@ -42,6 +42,10 @@ padding: 1rem; } +.cart-section { + padding: 0rem 1rem; +} + .grant-name { font-weight: bold; margin-left: 0.5rem; @@ -53,3 +57,15 @@ border-radius: 5px; padding: 0.5rem 1rem; } + +.black { + color: black; +} + +.medium-dark-gray { + color: var(--gc-medium-dark-gray); +} + +.darker-grey { + color: var(--gc-darker-grey); +} diff --git a/app/assets/v2/js/cart.js b/app/assets/v2/js/cart.js index f456829b494..e433115133e 100644 --- a/app/assets/v2/js/cart.js +++ b/app/assets/v2/js/cart.js @@ -12,6 +12,78 @@ Vue.component('grants-cart', { }; }, + computed: { + donationTotals() { + const totals = {}; + + this.grantData.forEach(grant => { + const token = grant.grant_donation_currency; + + if (!totals[token]) { + // First time seeing this token, set the field and initial value + totals[token] = grant.grant_donation_amount; + } else { + // We've seen this token, so just update the total + totals[token] += grant.grant_donation_amount; + } + }); + return totals; + }, + + donationTotalsString() { + const totals = this.donationTotals; + let string = ''; + + if (!totals) { + return undefined; + } + + Object.keys(totals).forEach(key => { + if (string === '') { + string += `${totals[key]} ${key}`; + } else { + string += `+ ${totals[key]} ${key}`; + } + }); + return string; + }, + + donationsToGitcoin() { + const totals = {}; + + this.grantData.forEach(grant => { + const token = grant.grant_donation_currency; + + if (!totals[token]) { + // First time seeing this token, set the field and initial value + totals[token] = grant.grant_donation_amount * 0.05; + } else { + // We've seen this token, so just update the total + totals[token] += (grant.grant_donation_amount * 0.05); + } + }); + return totals; + }, + + donationsToGitcoinString() { + const totals = this.donationsToGitcoin; + let string = ''; + + if (!totals) { + return undefined; + } + + Object.keys(totals).forEach(key => { + if (string === '') { + string += `${totals[key]} ${key}`; + } else { + string += `+ ${totals[key]} ${key}`; + } + }); + return string; + } + }, + mounted() { // Read array of grants in cart from localStorage this.grantData = JSON.parse(window.localStorage.getItem('grants_cart')); diff --git a/app/grants/templates/grants/cart-vue.html b/app/grants/templates/grants/cart-vue.html index 921f1414b95..348c25ad478 100644 --- a/app/grants/templates/grants/cart-vue.html +++ b/app/grants/templates/grants/cart-vue.html @@ -46,6 +46,7 @@
+ {% comment %} Heading section {% endcomment %}

@@ -56,12 +57,15 @@

Clear my cart

+ {% comment %} Divider {% endcomment %}
- {% comment %} Cart header {% endcomment %} + + {% comment %} Main container {% endcomment %}
+ {% comment %} Cart header {% endcomment %}
@@ -83,7 +87,7 @@

 

- {% comment %} Cart content {% endcomment %} + {% comment %} Cart contents {% endcomment %}
@@ -91,7 +95,7 @@

Grant logo -
[[grant.grant_title]]
+
[[grant.grant_title]]
{% comment %} Grant amount and currency {% endcomment %} @@ -137,6 +141,82 @@

+ + {% comment %} Cart total {% endcomment %} +
+
+
+ TOTAL +
+
+
+
+ [[donationTotalsString]] +
+
+
+ + {% comment %} Hide wallet option {% endcomment %} +
+
+
+
+ + {% trans "Hide my wallet address" %} + + {% trans "If this option is chosen, your wallet address will be hidden" %} +
+
+
+
+ + {% comment %} Contribution to Gitcoin notice {% endcomment %} +
+
+
+
+ {% trans "By using this service, you’ll also be contributing" %} + 5{% trans "% of your contribution to the" %} + Gitcoin Grants + Round 6+ Development Fund . +
+
+
+
+ + {% comment %} Summary {% endcomment %} +
+
+
+ SUMMARY +
+
+
+
+
+
+
    +
  • + You are contributing [[donationTotalsString]] +
  • +
  • + You are additionally contributing + [[donationsToGitcoinString]] + to the Gitcoin Mainainter Grant +
  • +
  • + Note: You will have to approve 2 transactions via your Web3 wallet on submit. Read how this + works. +
  • +
+
+
+
+
From 30af51d64078fae1806d2cd987395502aae80156 Mon Sep 17 00:00:00 2001 From: mds <17163988+mds1@users.noreply.github.com> Date: Wed, 20 May 2020 11:18:59 -0700 Subject: [PATCH 017/186] Add button to fund grants in cart --- app/grants/templates/grants/cart-vue.html | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/app/grants/templates/grants/cart-vue.html b/app/grants/templates/grants/cart-vue.html index 348c25ad478..fbfce615bb7 100644 --- a/app/grants/templates/grants/cart-vue.html +++ b/app/grants/templates/grants/cart-vue.html @@ -196,6 +196,7 @@

+
@@ -217,6 +218,16 @@

+
+
+
+ +
+
+
+
From 71eae514e0e62d0c07afbc56d9c8e13f3e1ccb3e Mon Sep 17 00:00:00 2001 From: mds <17163988+mds1@users.noreply.github.com> Date: Wed, 20 May 2020 12:15:06 -0700 Subject: [PATCH 018/186] Change default amount to 1 DAI --- app/assets/v2/js/grants/info.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/assets/v2/js/grants/info.js b/app/assets/v2/js/grants/info.js index 3e8ac99e3af..fb0f5a98990 100644 --- a/app/assets/v2/js/grants/info.js +++ b/app/assets/v2/js/grants/info.js @@ -41,7 +41,7 @@ function addToCart(grantData) { // Add donation defaults // TODO Update to use real data - grantData.grant_donation_amount = 5; + grantData.grant_donation_amount = 1; grantData.grant_donation_currency = 'DAI'; grantData.grant_donation_type = 'one-time'; // options are 'one-time' and 'recurring' grantData.grant_donation_num_rounds = 0; // N/A if type is one-time From 0439044bc4f6352fdbc5c5317ef0bc6a6de10462 Mon Sep 17 00:00:00 2001 From: mds <17163988+mds1@users.noreply.github.com> Date: Wed, 20 May 2020 14:19:08 -0700 Subject: [PATCH 019/186] Change how recurring donations are handled/displayed, fix UI bug Bug fix is that the amount being contributed to the Gitcoin grant is now rounded to 2 digits to account for floating point errors --- app/assets/v2/js/cart.js | 11 +++++++++-- app/assets/v2/js/grants/info.js | 4 +--- app/grants/templates/grants/cart-vue.html | 16 ++++++++-------- 3 files changed, 18 insertions(+), 13 deletions(-) diff --git a/app/assets/v2/js/cart.js b/app/assets/v2/js/cart.js index e433115133e..1719068f4f2 100644 --- a/app/assets/v2/js/cart.js +++ b/app/assets/v2/js/cart.js @@ -74,10 +74,17 @@ Vue.component('grants-cart', { } Object.keys(totals).forEach(key => { + // Round to 2 digits + const amount = totals[key]; + const formattedAmount = amount.toLocaleString(undefined, { + minimumFractionDigits: 2, + maximumFractionDigits: 2 + }); + if (string === '') { - string += `${totals[key]} ${key}`; + string += `${formattedAmount} ${key}`; } else { - string += `+ ${totals[key]} ${key}`; + string += `+ ${formattedAmount} ${key}`; } }); return string; diff --git a/app/assets/v2/js/grants/info.js b/app/assets/v2/js/grants/info.js index fb0f5a98990..b3aad07c51b 100644 --- a/app/assets/v2/js/grants/info.js +++ b/app/assets/v2/js/grants/info.js @@ -40,11 +40,9 @@ function addToCart(grantData) { } // Add donation defaults - // TODO Update to use real data grantData.grant_donation_amount = 1; grantData.grant_donation_currency = 'DAI'; - grantData.grant_donation_type = 'one-time'; // options are 'one-time' and 'recurring' - grantData.grant_donation_num_rounds = 0; // N/A if type is one-time + grantData.grant_donation_num_rounds = 1; grantData.grant_donation_clr_match = 250; let cartList = loadCart() diff --git a/app/grants/templates/grants/cart-vue.html b/app/grants/templates/grants/cart-vue.html index fbfce615bb7..fa3e9b0d844 100644 --- a/app/grants/templates/grants/cart-vue.html +++ b/app/grants/templates/grants/cart-vue.html @@ -78,7 +78,7 @@

Type
-
+
Total CLR Match Amount
@@ -117,15 +117,15 @@

{% comment %} Grant type {% endcomment %}
- One Time - Recurring - Error: Invalid donation type - - for [[grant.grant_donation_num_rounds]] rounds - +
+ split accross + + CLR rounds +
{% comment %} CLR match amount {% endcomment %} -
+
[[grant.grant_donation_clr_match]] [[grant.grant_donation_currency]] From 8d6580a46167d9f70e866fc8410e59b3652536c7 Mon Sep 17 00:00:00 2001 From: mds <17163988+mds1@users.noreply.github.com> Date: Wed, 20 May 2020 14:56:44 -0700 Subject: [PATCH 020/186] Add ability to clear cart or remove one item --- app/assets/v2/css/grants/cart.css | 5 +++++ app/assets/v2/js/cart.js | 12 ++++++++++++ app/grants/templates/grants/cart-vue.html | 10 +++++++--- 3 files changed, 24 insertions(+), 3 deletions(-) diff --git a/app/assets/v2/css/grants/cart.css b/app/assets/v2/css/grants/cart.css index 29cc80eb701..7ba04ee6afc 100644 --- a/app/assets/v2/css/grants/cart.css +++ b/app/assets/v2/css/grants/cart.css @@ -69,3 +69,8 @@ .darker-grey { color: var(--gc-darker-grey); } + +.hyperlink { + color: var(--link-color); + cursor: pointer; +} diff --git a/app/assets/v2/js/cart.js b/app/assets/v2/js/cart.js index 1719068f4f2..0759ef82127 100644 --- a/app/assets/v2/js/cart.js +++ b/app/assets/v2/js/cart.js @@ -91,6 +91,18 @@ Vue.component('grants-cart', { } }, + methods: { + clearCart() { + window.localStorage.setItem('grants_cart', JSON.stringify([])); + this.grantData = []; + }, + + removeGrantFromCart(id) { + this.grantData = this.grantData.filter(grant => grant.grant_id !== id); + window.localStorage.setItem('grants_cart', JSON.stringify(this.grantData)); + } + }, + mounted() { // Read array of grants in cart from localStorage this.grantData = JSON.parse(window.localStorage.getItem('grants_cart')); diff --git a/app/grants/templates/grants/cart-vue.html b/app/grants/templates/grants/cart-vue.html index fa3e9b0d844..27d7d07e38b 100644 --- a/app/grants/templates/grants/cart-vue.html +++ b/app/grants/templates/grants/cart-vue.html @@ -53,7 +53,7 @@

Grant Cart ([[ grantData.length ]] items)

Robot with torch -
+
@@ -64,7 +64,11 @@

{% comment %} Main container {% endcomment %} -
+
+ Your cart is empty. +
+
{% comment %} Cart header {% endcomment %}
@@ -136,7 +140,7 @@

{% comment %} Delete icon {% endcomment %}
- +
From cc43f588586d08430248dce2cbcc97de9f8fdc44 Mon Sep 17 00:00:00 2001 From: mds <17163988+mds1@users.noreply.github.com> Date: Wed, 20 May 2020 14:59:06 -0700 Subject: [PATCH 021/186] Add watcher to sync Vue state with localStorage, small fixes/cleanup - Add cursor icon when hovering over delete icon - Remove unused lifecycle hooks from Vue component --- app/assets/v2/js/cart.js | 31 ++++++++--------------- app/grants/templates/grants/cart-vue.html | 3 ++- 2 files changed, 12 insertions(+), 22 deletions(-) diff --git a/app/assets/v2/js/cart.js b/app/assets/v2/js/cart.js index 0759ef82127..c86f9eb7b0f 100644 --- a/app/assets/v2/js/cart.js +++ b/app/assets/v2/js/cart.js @@ -103,18 +103,19 @@ Vue.component('grants-cart', { } }, + watch: { + // Use watcher to keep local storage in sync with Vue state + grantData: { + handler() { + window.localStorage.setItem('grants_cart', JSON.stringify(this.grantData)); + }, + deep: true + } + }, + mounted() { // Read array of grants in cart from localStorage this.grantData = JSON.parse(window.localStorage.getItem('grants_cart')); - }, - created() { - // - }, - beforeMount() { - // - }, - beforeDestroy() { - // } }); @@ -126,18 +127,6 @@ if (document.getElementById('gc-grants-cart')) { data: { grantHeaders, grantData - }, - mounted() { - // - }, - created() { - // - }, - beforeMount() { - // - }, - beforeDestroy() { - // } }); } \ No newline at end of file diff --git a/app/grants/templates/grants/cart-vue.html b/app/grants/templates/grants/cart-vue.html index 27d7d07e38b..f80847e155b 100644 --- a/app/grants/templates/grants/cart-vue.html +++ b/app/grants/templates/grants/cart-vue.html @@ -140,7 +140,8 @@

{% comment %} Delete icon {% endcomment %}
- +
From 610d8f10726974bb9a9dadaddfabfbecb3ea051a Mon Sep 17 00:00:00 2001 From: Ben DiFrancesco Date: Tue, 19 May 2020 07:55:12 -0400 Subject: [PATCH 022/186] Initial Changes to Grant Details UI * Move tabs below the grant info * Move funding info into card on right --- .../v2/js/grants/{info.js => funding.js} | 2 +- .../templates/grants/detail/funding.html | 109 ++++++++++++++++++ app/grants/templates/grants/detail/index.html | 17 +-- app/grants/templates/grants/detail/info.html | 94 +-------------- app/grants/templates/grants/detail/tabs.html | 2 +- 5 files changed, 122 insertions(+), 102 deletions(-) rename app/assets/v2/js/grants/{info.js => funding.js} (96%) create mode 100644 app/grants/templates/grants/detail/funding.html diff --git a/app/assets/v2/js/grants/info.js b/app/assets/v2/js/grants/funding.js similarity index 96% rename from app/assets/v2/js/grants/info.js rename to app/assets/v2/js/grants/funding.js index b3aad07c51b..c51b500c2c2 100644 --- a/app/assets/v2/js/grants/info.js +++ b/app/assets/v2/js/grants/funding.js @@ -8,7 +8,7 @@ $(document).ready(function() { const formData = objectifySerialized($(this).serializeArray()); addToCart(formData); - // console.log("CART", loadCart()); + console.log("CART", loadCart()); }); }); diff --git a/app/grants/templates/grants/detail/funding.html b/app/grants/templates/grants/detail/funding.html new file mode 100644 index 00000000000..9850fb94406 --- /dev/null +++ b/app/grants/templates/grants/detail/funding.html @@ -0,0 +1,109 @@ +{% comment %} + Copyright (C) 2020 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 . +{% endcomment %} + +{% load static humanize i18n grants_extra %} + +
+
+
+
+
+ {% if clr_active or show_clr_card %} + {% include 'grants/card/clr_match.html' %} + {% else %} +

MONTHLY RECURRING

+

+ {{ grant.monthly_amount_subscribed|floatformat:0|intcomma }} DAI +

+ {% endif %} +
+ +
+

+ {% if is_round_5_5 %} + ROUND 5.5 + {% else %} + ROUND 5 + {% endif %}

+

+ + {{grant.amount_received_in_round|floatformat:0|intcomma}} DAI + +
+ {{grant.positive_round_contributor_count}} contributors + {% if grant.negative_round_contributor_count %} +
+ {{grant.negative_round_contributor_count}} + negative contributors + {% endif %} +

+ +
+ +
+ + {% if clr_active or show_clr_card %} + {% include 'grants/card/clr_estimate.html' %} + {% endif %} + + {% if grant_is_inactive %} + + + {% elif not is_team_member %} + + {% if user_non_errored_subscription %} + + + + {% elif grant.link_to_new_grant %} + + + + {% else %} +
+ + + + + + + + + + +
+ {% endif %} + + {% endif %} + + {% if not is_team_member %} +
+ {% if grant.negative_voting_enabled %} + Negative Fund + {% endif %} + Flag +
+ {% endif %} +
+
+
\ No newline at end of file diff --git a/app/grants/templates/grants/detail/index.html b/app/grants/templates/grants/detail/index.html index 8ec3153e189..f1245f58d6e 100644 --- a/app/grants/templates/grants/detail/index.html +++ b/app/grants/templates/grants/detail/index.html @@ -48,16 +48,19 @@ {% endif %}
-
-
- {% include 'grants/detail/info.html' %} +
+
+ {% include 'grants/detail/info.html' %} +
+
+ {% include 'grants/detail/tabs.html' %} +
-
- {% include 'grants/detail/tabs.html' %} +
+ {% include 'grants/detail/funding.html' %}
-
{% include 'shared/current_profile.html' %} @@ -73,7 +76,7 @@ - + diff --git a/app/grants/templates/grants/detail/info.html b/app/grants/templates/grants/detail/info.html index 69a063ac6d2..8f8bfe0b192 100644 --- a/app/grants/templates/grants/detail/info.html +++ b/app/grants/templates/grants/detail/info.html @@ -15,7 +15,7 @@ along with this program. If not, see . {% endcomment %} {% load static humanize i18n grants_extra %} -
+ - {% if grant_is_inactive %} - - - {% elif not is_team_member %} - - {% if user_non_errored_subscription %} - - - - {% elif grant.link_to_new_grant %} - - - - {% else %} -
- - - - - - - - - - -
- {% endif %} - - {% endif %} - - {% if not is_team_member %} -
- {% if grant.negative_voting_enabled %} - Negative Fund - {% endif %} - Flag -
- {% endif %} -
- - -
- - -
-
- {% if clr_active or show_clr_card %} - {% include 'grants/card/clr_match.html' %} - {% else %} -

MONTHLY RECURRING

-

- {{ grant.monthly_amount_subscribed|floatformat:0|intcomma }} DAI -

- {% endif %} -
- -
-

- {% if is_round_5_5 %} - ROUND 5.5 - {% else %} - ROUND 5 - {% endif %}

-

- - {{grant.amount_received_in_round|floatformat:0|intcomma}} DAI - -
- {{grant.positive_round_contributor_count}} contributors - {% if grant.negative_round_contributor_count %} -
- {{grant.negative_round_contributor_count}} - negative contributors - {% endif %} -

- -
- -
- - {% if clr_active or show_clr_card %} - {% include 'grants/card/clr_estimate.html' %} - {% endif %} -
- - {% if not is_team_member or grant_is_inactive %} {% if grant.categories and grant.categories.all %}
diff --git a/app/grants/templates/grants/detail/tabs.html b/app/grants/templates/grants/detail/tabs.html index 81926a74ecf..8c1711f400e 100644 --- a/app/grants/templates/grants/detail/tabs.html +++ b/app/grants/templates/grants/detail/tabs.html @@ -15,7 +15,7 @@ along with this program. If not, see . {% endcomment %} {% load static humanize i18n grants_extra %} -
+
- -
- - {% trans "Drag & Drop or Browse" %} - +
-
- - {% else %} - - - {% endif %} -
- -
-

- {% if is_team_member %} - {% else %} - {{ grant.title }} - {% endif %} -

- -
+ - {% if grant.hidden and not grant.link_to_new_grant %} -
- -

- This grant is hidden from the main grant explorer.
-

-
{% endif %} +
- -
+
+

{% if is_team_member %} - + {% else %} - - - {{ grant.reference_url }} - + {{ grant.title }} {% endif %} -

- - - - {% if is_unsubscribed_from_updates_from_this_grant %} -
- - You are unsubscribed from updates for this grant. -

-
- {% endif %} - - {% if grant.link_to_new_grant %} -
- -

- Not accepting contributions as a new grant was created to replace this one by the owner
 -

-
- {% elif grant.token_symbol %} +

+ + +
+ + {% if grant.hidden and not grant.link_to_new_grant %} +
+ +

+ This grant is hidden from the main grant explorer.
+

+
+ {% endif %} + +
- -

- Grant accepts {{ grant.token_symbol }} -

+ {% if is_team_member %} + + {% else %} + + + {{ grant.reference_url }} + + {% endif %}
- {% endif %} - - {% if user_non_errored_subscription %} -
- -

- You are contributing - {{ user_non_errored_subscription.amount_per_period|floatformat:2|intcomma }} - {{ user_non_errored_subscription.token_symbol }} every {{ user_non_errored_subscription.frequency }} {{ user_non_errored_subscription.frequency_unit }} -

+ + - {% endif %} - + + {% if is_unsubscribed_from_updates_from_this_grant %} +
+ + You are unsubscribed from updates for this grant. +

+
+ {% endif %} + + {% if grant.link_to_new_grant %} +
+ +

+ Not accepting contributions as a new grant was created to replace this one by the owner
 +

+
+ {% elif grant.token_symbol %} +
+ +

+ Grant accepts {{ grant.token_symbol }} +

+
+ {% endif %} + + {% if user_non_errored_subscription %} +
+ +

+ You are contributing + {{ user_non_errored_subscription.amount_per_period|floatformat:2|intcomma }} + {{ user_non_errored_subscription.token_symbol }} every {{ user_non_errored_subscription.frequency }} {{ user_non_errored_subscription.frequency_unit }} +

+
+ {% endif %} + +
+
+
{% if not is_team_member or grant_is_inactive %} {% if grant.categories and grant.categories.all %}
diff --git a/app/grants/templates/grants/detail/tabs.html b/app/grants/templates/grants/detail/tabs.html index 8c1711f400e..f22e8cdaecb 100644 --- a/app/grants/templates/grants/detail/tabs.html +++ b/app/grants/templates/grants/detail/tabs.html @@ -15,7 +15,7 @@ along with this program. If not, see . {% endcomment %} {% load static humanize i18n grants_extra %} -
+

From 6cd1f59cb81ba515093a78430f08579e7bd0d322 Mon Sep 17 00:00:00 2001 From: Sebastian T F Date: Mon, 25 May 2020 13:08:48 +0530 Subject: [PATCH 034/186] modify search field --- app/grants/templates/grants/shared/sidebar_search.html | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/app/grants/templates/grants/shared/sidebar_search.html b/app/grants/templates/grants/shared/sidebar_search.html index 0d2e2e9196d..37f784bc690 100644 --- a/app/grants/templates/grants/shared/sidebar_search.html +++ b/app/grants/templates/grants/shared/sidebar_search.html @@ -18,11 +18,10 @@