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
danlipert committed Apr 22, 2020
2 parents 3a9fda3 + d31b1c3 commit c697d69
Show file tree
Hide file tree
Showing 22 changed files with 1,857 additions and 30 deletions.
8 changes: 8 additions & 0 deletions app/app/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -816,5 +816,13 @@ def callback(request):
AVATAR_ADDRESS = env('AVATAR_ADDRESS', default='0x00De4B13153673BCAE2616b67bf822500d325Fc3')
AVATAR_PRIVATE_KEY = env('AVATAR_PRIVATE_KEY', default='0x00De4B13153673BCAE2616b67bf822500d325Fc3')

GRANTS_PAYOUT_ADDRESS = env('GRANTS_PAYOUT_ADDRESS', default='0x00De4B13153673BCAE2616b67bf822500d325Fc3')
GRANTS_PAYOUT_PRIVATE_KEY = env('GRANTS_PAYOUT_PRIVATE_KEY', default='0x00De4B13153673BCAE2616b67bf822500d325Fc3')
GRANTS_PAYOUT_CLR_KYC_THRESHOLD = env('GRANTS_PAYOUT_CLR_KYC_THRESHOLD', default=0)

GRANTS_COUPON_25_OFF = env('GRANTS_COUPON_25_OFF', default='OWOCKIFOREVER')
GRANTS_COUPON_50_OFF = env('GRANTS_COUPON_50_OFF', default='OWOCKIFOREVER')
GRANTS_COUPON_100_OFF = env('GRANTS_COUPON_100_OFF', default='OWOCKIFOREVER')


ELASTIC_SEARCH_URL = env('ELASTIC_SEARCH_URL', default='')
27 changes: 22 additions & 5 deletions app/app/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,25 @@ def handle_location_request(request):
return geolocation_data, ip_address


geoIPobject = None
geoIPCountryobject = None


def get_geoIP_singleton():
global geoIPobject
if not geoIPobject:
geoIPobject = GeoIP2()
return geoIPobject


def get_geoIP_country_singleton():
global geoIPCountryobject
db = f'{settings.GEOIP_PATH}GeoLite2-Country.mmdb'
if not geoIPCountryobject:
geoIPCountryobject = geoip2.database.Reader(db)
return geoIPCountryobject


def get_location_from_ip(ip_address):
"""Get the location associated with the provided IP address.
Expand All @@ -391,7 +410,7 @@ def get_location_from_ip(ip_address):
return city

try:
geo = GeoIP2()
geo = get_geoIP_singleton()
try:
city = geo.city(ip_address)
except AddressNotFoundError:
Expand All @@ -401,17 +420,15 @@ def get_location_from_ip(ip_address):
return city


def get_country_from_ip(ip_address, db=None):
def get_country_from_ip(ip_address):
"""Get the user's country information from the provided IP address."""
country = {}
if db is None:
db = f'{settings.GEOIP_PATH}GeoLite2-Country.mmdb'

if not ip_address:
return country

try:
reader = geoip2.database.Reader(db)
reader = get_geoIP_country_singleton()
country = reader.country(ip_address)
except AddressNotFoundError:
pass
Expand Down
2 changes: 1 addition & 1 deletion app/assets/v2/css/scroll-carousel.css
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

.scroll-carousel {
display: flex;
overflow-x: scroll;
overflow-x: auto;
scroll-snap-type: x mandatory;
flex: 1 1 50%;
flex-direction: row;
Expand Down
1,234 changes: 1,234 additions & 0 deletions app/assets/v2/images/avatar3d/lego.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions app/assets/v2/js/search.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@ if (document.getElementById('gc-search')) {
this.search();
},
methods: {
init: function() {
setTimeout(() => {
$('.has-search input').focus();
}, 100);
},
search: async function() {
let vm = this;

Expand Down
3 changes: 3 additions & 0 deletions app/assets/v2/js/shared.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,9 @@ var loading_button = function(button) {

var cb_address;
var reloadCbAddress = function() {
if (typeof web3 == 'undefined') {
return;
}
web3.eth.getCoinbase(function(error, result) {
if (!error) {
cb_address = result;
Expand Down
2 changes: 1 addition & 1 deletion app/assets/v2/js/user_card.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const renderPopOverData = function(data) {
<img src="/dynamic/avatar/${_organization}" alt="${_organization}" class="rounded-circle border" width="24" height="24">
</a>`;
} else if (index < 6) {
return `<span class="m-1">+${data.orgs.length - 5}</span>`;
return `<span class="m-1">+${unique_orgs.length - 5}</span>`;
}
}).join(' ');

Expand Down
10 changes: 10 additions & 0 deletions app/avatar/views_3d.py
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,16 @@ def get_avatar_attrs(theme, key):
'tone_maps': [],
'path': 'assets/v2/images/avatar3d/orc_gitcoin.svg',
},
'lego': {
'preview_viewbox': {
'background': '0 0 350 350',
},
'skin_tones': [],
'hair_tones': [],
'skin_tones': [],
'tone_maps': [],
'path': 'assets/v2/images/avatar3d/lego.svg',
},
'PixelBot': {
'preview_viewbox': {
'background': '0 0 350 350',
Expand Down
10 changes: 5 additions & 5 deletions app/dashboard/templates/dashboard/index-vue.html
Original file line number Diff line number Diff line change
Expand Up @@ -302,10 +302,11 @@
</div>
<div class="col-12 col-md-9 p-2 ml-sm-4">
{% if not hackathon_not_started %}
<div class="px-2" id="bounties">
<div id="dashboard-title" class="hidden">
{% include 'shared/search_bar.html' %}
</div>
<div class="px-2" id="bounties">
<div id="dashboard-title" class="hidden">
{% include 'shared/search_bar.html' %}
</div>
{% include 'dashboard/featured_bounties.html' %}
</div>
<div class="row loading justify-content-center align-items-center loading_img">
<img src="{% static "v2/images/loading_v2.gif" %}" alt="Loading ...">
Expand All @@ -325,7 +326,6 @@ <h1 class="font-title font-weight-semibold">Hackathon Coming Soon!</h1>
{% include 'shared/hackathon_sponsors.html' %}

</div>
{% include 'dashboard/featured_bounties.html' %}
{% else %}
<div class="text-center mx-auto">
<h1 class="font-title font-weight-semibold">Hackathon Coming Soon!</h1>
Expand Down
2 changes: 1 addition & 1 deletion app/dashboard/templates/shared/search.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
{% load i18n static humanize %}

<div id="gc-search" class="nav-item dropdown gc-search order-md-last">
<a href="" class="gc-search__icon nav-link dropdown-toggle" id="searchDropdown" role="button"
<a href="" class="gc-search__icon nav-link dropdown-toggle" id="searchDropdown" role="button" @click="init"
data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<i class="fas fa-search fa-fw"></i>
</a>
Expand Down
2 changes: 1 addition & 1 deletion app/dashboard/tip_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ def receive_tip_v3(request, key, txid, network):


@csrf_exempt
@ratelimit(key='ip', rate='5/m', method=ratelimit.UNSAFE, block=True)
@ratelimit(key='ip', rate='25/m', method=ratelimit.UNSAFE, block=True)
def send_tip_4(request):
"""Handle the fourth stage of sending a tip (the POST).
Expand Down
2 changes: 1 addition & 1 deletion app/dashboard/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -3623,7 +3623,7 @@ def hackathon(request, hackathon='', panel='prizes'):
'org_name': sponsor_profile.handle,
'follower_count': sponsor_profile.tribe_members.all().count(),
'followed': True if sponsor_profile.handle in following_tribes else False,
'bounty_count': Bounty.objects.filter(bounty_owner_github_username=sponsor_profile.handle).count()
'bounty_count': sponsor_profile.bounties.count()
}
orgs.append(org)

Expand Down
9 changes: 8 additions & 1 deletion app/grants/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,13 @@ class MatchPledgeAdmin(admin.ModelAdmin):
list_display =['pk', 'profile', 'active','pledge_type','amount']


class CLRMatchAdmin(admin.ModelAdmin):
"""Define the CLRMatch administration layout."""

ordering = ['-id']
raw_id_fields = ['grant', 'payout_contribution', 'test_payout_contribution']


class GrantAdmin(GeneralAdmin):
"""Define the Grant administration layout."""

Expand Down Expand Up @@ -277,6 +284,6 @@ def from_ip_address(self, instance):
admin.site.register(MatchPledge, MatchPledgeAdmin)
admin.site.register(Grant, GrantAdmin)
admin.site.register(Flag, FlagAdmin)
admin.site.register(CLRMatch, GeneralAdmin)
admin.site.register(CLRMatch, CLRMatchAdmin)
admin.site.register(Subscription, SubscriptionAdmin)
admin.site.register(Contribution, ContributionAdmin)
22 changes: 21 additions & 1 deletion app/grants/management/commands/ingest_givingblock_txns.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from django.core.management.base import BaseCommand
from django.utils import timezone

from dashboard.models import Profile
from dashboard.models import Activity, Profile
from grants.models import Contribution, Grant, Subscription


Expand Down Expand Up @@ -71,5 +71,25 @@ def handle(self, *args, **kwargs):
)
print(f"ingested {subscription.pk} / {contrib.pk}")

metadata = {
'id': subscription.id,
'value_in_token': str(subscription.amount_per_period),
'value_in_usdt_now': str(round(subscription.amount_per_period_usdt,2)),
'token_name': subscription.token_symbol,
'title': subscription.grant.title,
'grant_url': subscription.grant.url,
'num_tx_approved': subscription.num_tx_approved,
'category': 'grant',
}
kwargs = {
'profile': profile,
'subscription': subscription,
'grant': subscription.grant,
'activity_type': 'new_grant_contribution',
'metadata': metadata,
}

Activity.objects.create(**kwargs)

except Exception as e:
print(e)
Loading

0 comments on commit c697d69

Please sign in to comment.