Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/stable'
Browse files Browse the repository at this point in the history
  • Loading branch information
gdixon committed Mar 11, 2021
2 parents 382b1f8 + 1dc8fd0 commit 1086b93
Show file tree
Hide file tree
Showing 44 changed files with 529 additions and 281 deletions.
10 changes: 4 additions & 6 deletions app/app/static_storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def save(self, name, content):
# Record the clean file content (pre gzip)
file_content = content.file
# Save remote copy to S3
super(SilentFileStorage, self).save(name, content)
super(SilentFileStorage, self).save(name, content)
# Only save files that are part of the compress blocks locally
if ".scss" in name or ".js" in name or ".css" in name:
# restore the clean file_content
Expand All @@ -52,14 +52,12 @@ def exists(self, name):
# Check file exists on S3
exists = super(SilentFileStorage, self).exists(name)
# This is a hack to get a status report during S3ManifestStaticStorage._postProcess
print("INFO " + datetime.now().strftime("%Y-%m-%d %H:%M:%S") +
" - Checking for matching file hash on S3 - " + name + ": " + (
"Skipping based on matching file hashes" if exists else "Hashes did not match"
)
print(
"INFO " + datetime.now().strftime("%Y-%m-%d %H:%M:%S") + " - Checking for matching file hash on S3 - " +
name + ": " + ("Skipping based on matching file hashes" if exists else "Hashes did not match")
)
return exists


def url(self, name, force=True):
"""Handle catching bad URLs and return the name if route is unavailable."""
try:
Expand Down
10 changes: 5 additions & 5 deletions app/app/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
from avatar.router import router as avatar_router
from dashboard.router import router as dbrouter
from grants.router import router as grant_router
from grants.views import cart_thumbnail
from kudos.router import router as kdrouter

from .sitemaps import sitemaps
Expand Down Expand Up @@ -120,6 +121,9 @@
re_path(r'^dynamic/kudos/(?P<kudos_id>\d+)/(?P<name>\w*)', kudos.views.image, name='kudos_dynamic_img'),
re_path(r'^kudos/new/?', kudos.views.newkudos, name='newkudos'),


path('dynamic/grants_cart_thumb/<str:profile>/<str:grants>', cart_thumbnail, name='cart_thumbnail'),

# mailing list
url('mailing_list/funders/', dashboard.views.funders_mailing_list),
url('mailing_list/hunters/', dashboard.views.hunters_mailing_list),
Expand Down Expand Up @@ -160,11 +164,7 @@
dashboard.views.authenticate_idena,
name='authenticate_idena'
),
url(
r'^api/v0.1/profile/(?P<handle>.*)/logout_idena',
dashboard.views.logout_idena,
name='logout_idena'
),
url(r'^api/v0.1/profile/(?P<handle>.*)/logout_idena', dashboard.views.logout_idena, name='logout_idena'),
url(
r'^api/v0.1/profile/(?P<handle>.*)/recheck_idena_status',
dashboard.views.recheck_idena_status,
Expand Down
Binary file added app/assets/v2/images/grants/trust-bonus.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion app/assets/v2/js/activity.js
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ $(document).ready(function() {

// refresh activity page
document.buffered_rows = [];
var refresh_interval = 7000;
var refresh_interval = 55000;
var max_pk = null;
var run_longpoller = function(recursively) {
if (document.hidden || !document.long_poller_live) {
Expand Down
5 changes: 3 additions & 2 deletions app/assets/v2/js/grants/components.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ Vue.component('grant-card', {
CartData.removeIdFromCart(vm.grant.id);
showSideCart();
},
addToCollection: async function({collection, grant}) {
addToCollection: async function(collection, grant) {
const collectionAddGrantURL = `/grants/v1/api/collections/${collection.id}/grants/add`;
const response = await fetchData(collectionAddGrantURL, 'POST', {
'grant': grant.id
Expand All @@ -115,8 +115,9 @@ Vue.component('grant-card', {
});

Vue.component('grant-collection', {
template: '#grant-collection',
delimiters: [ '[[', ']]' ],
props: [ 'collection', 'small' ],
props: [ 'collection', 'small', 'activeCollection' ],
methods: {
shareCollection: function() {
let testingCodeToCopy = document.querySelector(`#collection-${this.collection.id}`);
Expand Down
20 changes: 20 additions & 0 deletions app/assets/v2/js/grants/contribution-trust-bonus.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@

Vue.component('contribution-trust-bonus', {
delimiters: [ '[[', ']]' ],
data: function() {
return {
modalId: 'trust-bonus'
};
},
methods: {
show() {
this.$bvModal.show(this.modalId);
},
close() {
this.$bvModal.hide(this.modalId);
},
goToTrustBonus() {
document.location = '/profile/trust';
}
}
});
9 changes: 9 additions & 0 deletions app/assets/v2/js/grants/grant-thanks-modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ Vue.component('contribution-thanks-modal', {
data: function() {
return {
modalId: 'contribution-thanks',
imgURL: '',
numberOfContributions: 0,
donations: [],
tweetUrl: ''
Expand All @@ -12,6 +13,13 @@ Vue.component('contribution-thanks-modal', {
const checkoutData = CartData.loadCheckedOut();
const shouldShow = checkoutData.length > 0;

let grant_ids = '';

for (let i = 0; i < checkoutData.length; i++) {
grant_ids = grant_ids + checkoutData[i]['grant_id'] + ',';
}

this.imgURL = '/dynamic/grants_cart_thumb/' + document.contxt['github_handle'] + '/' + grant_ids;
this.numberOfContributions = checkoutData.length;

this.tweetUrl = `https://twitter.com/intent/tweet?text=I just funded ${this.numberOfContributions} grants on @gitcoin ${CartData.share_url()}`;
Expand All @@ -25,6 +33,7 @@ Vue.component('contribution-thanks-modal', {
methods: {
close() {
this.$bvModal.hide(this.modalId);
this.$bvModal.show('trust-bonus');
},
handleHide() {
CartData.clearCheckedOut();
Expand Down
8 changes: 4 additions & 4 deletions app/assets/v2/js/grants/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ Vue.component('grant-sidebar', {
this.filter_grants(me);

this.search = me.keyword;
console.log('searchkey', this.search);
},
filterLink: function(params) {

Expand All @@ -79,7 +78,6 @@ Vue.component('grant-sidebar', {
}

this.timeout = setTimeout(() => {
console.log('searchkey', this.search);
this.filter_grants({keyword: this.search});
}, 1000);
},
Expand Down Expand Up @@ -323,12 +321,13 @@ if (document.getElementById('grants-showcase')) {
this.setCurrentType(this.current_type);
this.fetchGrants(this.page);

},
changeBanner: function() {
this.regex_style = document.all_routing_policies &&
document.all_routing_policies.find(policy => {
return new RegExp(policy.url_pattern).test(window.location.href);
});
this.toggleStyle(this.regex_style || current_style);

this.toggleStyle(this.regex_style || document.current_style);
},
clearSingleCollection: function() {
this.grants = [];
Expand Down Expand Up @@ -430,6 +429,7 @@ if (document.getElementById('grants-showcase')) {
vm.grantsNumPages = getGrants.num_pages;
vm.grantsHasNext = getGrants.has_next;
vm.numGrants = getGrants.count;
vm.changeBanner();

if (vm.grantsHasNext) {
vm.page = ++vm.page;
Expand Down
2 changes: 1 addition & 1 deletion app/assets/v2/js/vue-components.js
Original file line number Diff line number Diff line change
Expand Up @@ -644,7 +644,7 @@ Vue.component('project-card', {
<img v-else class="card-project-logo m-auto rounded shadow" height="87" width="87" :src="project.bounty.avatar_url" alt="Bounty Logo" />
</div>
<div class="card-body">
<h5 class="card-title font-weight-bold text-left">[[ project.name ]]</h5>
<h5 class="card-title font-weight-bold text-left" v-html="project.name"></h5>
<div class="my-2">
<p class="text-left text-muted font-smaller-1">
[[ project.summary | truncate(500) ]]
Expand Down
2 changes: 1 addition & 1 deletion app/dashboard/templates/bounty/details2.html
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
<div v-if="bounty.event" class="font-subheader hackathon-alt text-center text-lg-left" id="event_name">
Hackathon: [[bounty.event.name]]
</div>
<h4 id="title" class="font-title p-0 text-center text-lg-left">[[bounty.title]]</h4>
<h4 id="title" class="font-title p-0 text-center text-lg-left" v-html="bounty.title"></h4>
<div class="text-center text-lg-left">
<div class="tags font-caption d-inline-flex d-md-flex">
<div class="tag token" data-toggle="tooltip" data-html="true" :title='`<div class="tooltip-info">${bounty.value_true} ${bounty.token_name} in funding from original funder.</div>`'>
Expand Down
3 changes: 1 addition & 2 deletions app/dashboard/templates/dashboard/explorer.html
Original file line number Diff line number Diff line change
Expand Up @@ -427,8 +427,7 @@ <h3 class="featured-bounties__title">
<div class="col-12 col-md-8 d-flex flex-column">
<div class="bounty-detail">

<div class="title font-subheader">
[[ bounty.title ]]
<div class="title font-subheader" v-html="bounty.title">
</div>
<div class="bounty-summary">
<div class="info font-caption">
Expand Down
2 changes: 1 addition & 1 deletion app/dashboard/templates/project/detail/info.html
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
<img class="project__logo mr-3" v-if="project.logo_url" :src="project.logo_url">
<img class="project__logo mr-3" v-else :src="project.prize.avatar">
<div class="ml-md-3">
<a class="text-decoration-none" :href="project.url"><h1 class="project-title mb-2 font-weight-bold">[[ project.name ]]</h1></a>
<a class="text-decoration-none" :href="project.url"><h1 class="project-title mb-2 font-weight-bold" v-html="project.name"></h1></a>
<div class="d-flex align-items-baseline">
<i class="fab fa-github mr-2"></i> <a class="project__url link-white font-body" :href="project.work_url">[[project.work_url]]</a>
</div>
Expand Down
2 changes: 1 addition & 1 deletion app/dashboard/templates/shared/menu.html
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
<img class="mw-100 logo-static p-2" src="{% static "v2/images/top-bar/grants-symbol-pos.svg" %}" alt="Grants" height="48">
<b class="gc-megamenu-title">{% trans "Grants" %}</b>
</a>
<p class="px-2 m-0 mb-2 text-wrap font-smaller-2">{% trans "Recurring funding for Open Source" %}</p>
<p class="px-2 m-0 mb-2 text-wrap font-smaller-2">{% trans "Crowdfunding for Open Source" %}</p>
</li>
<li>
<a class="dropdown-item dropdown-item-small" href="{% url 'grants:grants' %}">{% trans "Explore Grants" %}</a>
Expand Down
15 changes: 15 additions & 0 deletions app/grants/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -479,6 +479,21 @@ def response_change(self, request, obj):
class GrantCollectionAdmin(admin.ModelAdmin):
list_display = ['pk', 'title', 'description', 'hidden', 'cache', 'featured']
raw_id_fields = ['profile', 'grants', 'curators']
readonly_fields = ['img']


def response_change(self, request, obj):
if "_generate_cache" in request.POST:
obj.generate_cache()
self.message_user(request, "generated cache")
return redirect(obj.admin_url)

def img(self, instance):
try:
html = f'<img src="{instance.cover.url}">'
return mark_safe(html)
except:
return "N/A"


class GrantBrandingRoutingPolicyAdmin(admin.ModelAdmin):
Expand Down
36 changes: 36 additions & 0 deletions app/grants/management/commands/grant_collections_shuffle.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# -*- coding: utf-8 -*-
"""Define the Grant subminer management command.
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 <http://www.gnu.org/licenses/>.
"""

import random

from django.core.management.base import BaseCommand

from grants.models import GrantCollection


class Command(BaseCommand):

help = 'grant collection shuffle'

def handle(self, *args, **options):
for gc in GrantCollection.objects.filter(hidden=False):
gc.shuffle_rank = random.randint(0,99999)
gc.save()
print('done')
18 changes: 18 additions & 0 deletions app/grants/migrations/0114_grantcollection_shuffle_rank.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 2.2.4 on 2021-03-09 17:34

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('grants', '0113_grantapikey'),
]

operations = [
migrations.AddField(
model_name='grantcollection',
name='shuffle_rank',
field=models.PositiveIntegerField(db_index=True, default=1),
),
]
18 changes: 18 additions & 0 deletions app/grants/migrations/0115_auto_20210310_0532.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 2.2.4 on 2021-03-10 05:32

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('grants', '0114_grantcollection_shuffle_rank'),
]

operations = [
migrations.AlterField(
model_name='grantbrandingroutingpolicy',
name='url_pattern',
field=models.CharField(help_text='A regex url pattern', max_length=255),
),
]
Loading

0 comments on commit 1086b93

Please sign in to comment.