Skip to content

Commit

Permalink
stable -> master (#7586)
Browse files Browse the repository at this point in the history
* Fix bugs in #7458 that happen when items are removed from cart (#7573)

* hide events when no calendar id is associated (#7575)

* round end

* calendar

* fixes timer on /grants

* send ga on edit profile

* onboard darkmode

* missing dark mode

* track related grants, useful for sybil resistence

Co-authored-by: Matt <matt@mattsolomon.dev>
Co-authored-by: Miguel Angel Gordián <miguel@gordian.dev>
Co-authored-by: owocki <ksowocki@gmail.com>
Co-authored-by: octavioamu <octavioamuchastegui@gmail.com>
  • Loading branch information
5 people authored Oct 2, 2020
1 parent 2335908 commit 03d1032
Show file tree
Hide file tree
Showing 15 changed files with 140 additions and 49 deletions.
40 changes: 40 additions & 0 deletions app/assets/v2/css/town_square.css
Original file line number Diff line number Diff line change
Expand Up @@ -1343,6 +1343,46 @@ body.green.offer_view .announce {
color: white;
}

.dark-mode .modal-content{
background: var(--bg-shade-0);
}

.dark-mode .vs__dropdown-menu {
background: var(--bg-shade-1);
color: var(--default-text-color);
}

.dark-mode .modal-content .btn-radio,
.dark-mode .modal-content .close,
.dark-mode .vs__search,
.dark-mode .vs__selected,
.dark-mode .vs__dropdown-option,
.dark-mode .vs__search:focus {
color: var(--default-text-color);
}
.dark-mode .vs__dropdown-toggle {
border-color: var(--default-text-color);
}

.dark-mode .vs__clear,
.dark-mode .vs__open-indicator {
fill: var(--default-text-color);
}

.dark-mode .modal-content .btn-radio:hover {
color: var(--default-text-color);
}

.dark-mode .display-light {
display: none;
}
.display-dark {
display: none;
}
.dark-mode .display-dark {
display: block;
}

.tag-list .tag-list__item {
background: #E8F0FA;
padding: 4px;
Expand Down
14 changes: 13 additions & 1 deletion app/assets/v2/js/cart.js
Original file line number Diff line number Diff line change
Expand Up @@ -2561,7 +2561,19 @@ Vue.component('grants-cart', {
});

// Read array of grants in cart from localStorage
this.grantData = CartData.loadCart();
const grantData = CartData.loadCart();

// Make sure none have empty currencies, and if they do default to 0.001 ETH. This is done
// to prevent the cart from getting stuck loading if a currency is empty
grantData.forEach((grant, index) => {
if (!grant.grant_donation_currency) {
grantData[index].grant_donation_currency = 'ETH';
grantData[index].grant_donation_amount = '0.001';
}
});
CartData.setCart(grantData);
this.grantData = grantData;

// Initialize array of empty comments
this.comments = this.grantData.map(grant => undefined);

Expand Down
5 changes: 4 additions & 1 deletion app/assets/v2/js/onboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,10 +107,13 @@ if (document.getElementById('gc-onboard')) {
}
this.profileWidget();
this.$refs['onboard-modal'].closeModal();
if (typeof ga !== 'undefined') {
ga('send', 'event', 'Saved profile onboard', 'click', 'Person');
}

}).catch((err) => {
console.log(err);
_alert('Unable to create a bounty. Please try again later', 'error');
_alert('Unable to save your profile. Please login again', 'error');
});
},
fetchOnboardData(profileHandle) {
Expand Down
4 changes: 2 additions & 2 deletions app/dashboard/templates/dashboard/index-vue.html
Original file line number Diff line number Diff line change
Expand Up @@ -622,7 +622,7 @@ <h6 class="font-weight-bold mb-3">Invite [[numUsers]] Users to the Bounty</h6>
</div>
</user-directory>
</b-tab>
<b-tab class="col-12" title-item-class="navigation">
<b-tab class="col-12" title-item-class="navigation" v-if="hackathonObj.calendar_id">
<template v-slot:title>
<div class="mt-4">
{% trans "Events" %}
Expand All @@ -634,7 +634,7 @@ <h6 class="font-weight-bold mb-3">Invite [[numUsers]] Users to the Bounty</h6>
<div>
<h1 class="font-bigger-4 font-weight-bold">Events Schedule</h1>
{% if is_staff %}
<button class="btn btn-lg gc-border-blue">Add event</button>
<a href="https://www.addevent.com/calendars/{{ hackathon.calendar_id }}/event/new" class="btn btn-lg gc-border-blue">Add event</a>
{% endif %}
<hr style="color: black; height: 3px">
<div class="d-flex justify-content-between my-5" v-for="event in events">
Expand Down
8 changes: 7 additions & 1 deletion app/dashboard/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -6117,6 +6117,12 @@ def events(request, hackathon):
'msg': f'No exists Hackathon Event with id {hackathon}'
}, status=404)

if not hackathon_event.calendar_id:
return JsonResponse({
'error': True,
'msg': f'No exists calendar associated to Hackathon {hackathon}'
}, status=404)

calendar_unique = hackathon_event.calendar_id
token = settings.ADDEVENT_API_TOKEN
endpoint = f'https://www.addevent.com/api/v1/oe/events/list/'
Expand All @@ -6126,7 +6132,7 @@ def events(request, hackathon):
'token': token,
})

calendars = calendar_response.json()["calendars"]
calendars = calendar_response.json().get("calendars", [])
calendar_id = None

for calendar in calendars:
Expand Down
12 changes: 12 additions & 0 deletions app/grants/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -418,6 +418,18 @@ def safe_next_clr_calc_date(self):
def recurring_funding_supported(self):
return self.contract_version < 2

@property
def related_grants(self):
pkg = self.metadata.get('related', [])
pks = [ele[0] for ele in pkg]
rg = Grant.objects.filter(pk__in=pks)
return_me = []
for ele in pkg:
grant = rg.get(pk=ele[0])
return_me.append([grant, ele[1]])
return return_me


@property
def configured_to_receieve_funding(self):
if self.contract_version == 2:
Expand Down
15 changes: 15 additions & 0 deletions app/grants/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,21 @@ def update_grant_metadata(self, grant_id, retry: bool = True) -> None:
wall_of_love = sorted(wall_of_love.items(), key=lambda x: x[1], reverse=True)
instance.metadata['wall_of_love'] = wall_of_love

# save related addresses
# related = same contirbutor, same cart
related = {}
from django.utils import timezone
for subscription in instance.subscriptions.all():
_from = subscription.created_on - timezone.timedelta(hours=1)
_to = subscription.created_on + timezone.timedelta(hours=1)
profile = subscription.contributor_profile
for _subs in profile.grant_contributor.filter(created_on__gt=_from, created_on__lt=_to).exclude(grant__id=grant_id):
key = _subs.grant.pk
if key not in related.keys():
related[key] = 0
related[key] += 1
instance.metadata['related'] = sorted(related.items() , key=lambda x: x[1], reverse=True)

instance.save()


Expand Down
4 changes: 2 additions & 2 deletions app/grants/templates/grants/cart-vue.html
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ <h1 class="col-auto text-left font-bigger-2 black" style="font-weight: bold; mar
v-model="grant.grant_donation_amount" type="number" placeholder="Amount">
<select2 v-model="grant.grant_donation_currency" class="col-6 form-control"
style="margin-right:0.5rem" placeholder="Select token">
<option v-for="option in currencies[index]" v-bind:value="option" :disabled="!option">
<option v-for="(option, index) in currencies[index]" v-bind:value="option" :disabled="!option" :key="`currency-${index}`">
<span v-if="!option" style="height:1px; font-size:1px">&mdash;&mdash;&mdash;&mdash;</span>
<span v-else>[[ option ]]</span>
</option>
Expand Down Expand Up @@ -212,7 +212,7 @@ <h1 class="col-auto text-left font-bigger-2 black" style="font-weight: bold; mar
</div>
</div>
{% comment %} Cart Contents: NOT MOBILE {% endcomment %}
<div v-if="!isMobileDevice" v-for="(grant, index) in grantData" class="grant-row">
<div v-if="!isMobileDevice" v-for="(grant, index) in grantData" class="grant-row" :key="grant.grant_id">
<div class="grant-row-style">
<div class="row align-items-center justify-content-between" style="margin-left:0.5rem">
{% comment %} Title and logo {% endcomment %}
Expand Down
20 changes: 20 additions & 0 deletions app/grants/templates/grants/detail/tabs.html
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,13 @@
<span class="nav-badge">({{ activity_count }})</span>
</button>

{% if is_staff and grant.metadata.related %}
<button type="button" id="nav-related" href="{{grant.url}}?tab=related" class="section-tab {% if tab == "related" %} active {% endif %}">
{% trans "RELATED GRANTS" %}
<span class="nav-badge">({{ grant.metadata.related | length }})</span>
</button>
{% endif %}

{% if is_team_member %}
<button type="button" id="nav-stats" href="{{grant.url}}?tab=stats" class="section-tab {% if tab == "stats" %} active {% endif %}">
{% trans "TRENDS" %}
Expand Down Expand Up @@ -61,6 +68,19 @@
</div>
{% endif %}

{% if tab == "related" %}
<div id="section-nav-related" class="tab-section active">
{% for ele in grant.related_grants %}
<div id="" class="">
{{ele.1}} contributors of this grant also funded <a href="{{ele.0.url}}">{{ele.0.title}}</a>
</div>
{% endfor %}

</div>
{% endif %}



{% if tab == "description" %}
<div id="section-nav-description" class="tab-section active">
<h4 class="m-0 p-0">Description</h4>
Expand Down
26 changes: 0 additions & 26 deletions app/grants/templates/grants/shared/landing_announce.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,32 +23,6 @@ <h4 class="mb-0 mt-0 pt-1 font-weight-semibold">
</div>
</div>

{% if clr_active %}
<div class="container-fluid pt-0 pb-2 grants-matching announce_container">
<div class="container">
<div class="col-md-12 font-smaller-1 text-center pt-2">
<img style="width: 80px; height: 80px;" src="{% static 'v2/images/quests/enemies/mad_scientist.png' %}" data-toggle="tooltip">
<div class="announce announce4">
<h4 class="mb-0 mt-0 pt-1 font-weight-semibold">
<i class="fab fa-ethereum"></i> Matching Round {{clr_round}} LIVE NOW
</h4>
<p>
<BR>
${{total_clr_pot}} Quadratic Matching for Grants. --
Matching ends on {{round_end|date:'Y-m-d'}}
(<span class="m-0" data-time="{{round_end|date:'c'}}" data-base_time="{{now|date:'Y-m-d H:i'}}"></span>) so get started today!
<br>
<br>
Want to contribute?
<i class="fas fa-map"></i> |
<a style="font-weight: bold;" target="new" href="#content_navbar">Explore Grants</a>
</p>
</div>
</div>
</div>
</div>
{% endif %}

<div class="container-fluid pt-0 pb-2 grants-matching announce_container">
<div class="container">
<div class="col-md-12 font-smaller-1 text-center pt-2">
Expand Down
2 changes: 1 addition & 1 deletion app/grants/templates/grants/shared/landing_hero.html
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
<p class="pr-3 pl-3 font-header white">
<strong>$150k</strong> Infra Tech, <strong>$150k</strong> App Tech, <strong>$150k</strong> Community, <strong>$50k</strong> Matic |

<span class="title-round">Round 7 ends 10/2</span> (<span class="m-0" data-time="{{round_end|date:'c'}}" data-base_time="{{now|date:'Y-m-d H:i'}}"></span>)
<span class="title-round">Round 7 ends 10/2 at 12pm MST / 6pm UTC</span> (<span class="m-0" data-time="{{round_end|date:'Y-m-d H:i O'}}" data-time-future="{{now|date:'Y-m-d H:i O'}}"></span>)

</p>
</div>
Expand Down
2 changes: 1 addition & 1 deletion app/grants/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@
# TODO, also update grants.clr:CLR_START_DATE, PREV_CLR_START_DATE, PREV_CLR_END_DATE
next_round_start = timezone.datetime(2020, 9, 14, 15, 0) #tz=utc, not mst
after_that_next_round_begin = timezone.datetime(2020, 12, 2, 12, 0)
round_end = timezone.datetime(2020, 10, 2, 23, 0) #tz=utc, not mst
round_end = timezone.datetime(2020, 10, 2, 18, 0) #tz=utc, not mst

round_types = ['media', 'tech', 'change']
# TODO-SELF-SERVICE: END
Expand Down
Loading

0 comments on commit 03d1032

Please sign in to comment.