Skip to content

Commit

Permalink
Merge branch 'master' of github.com:gitcoinco/web
Browse files Browse the repository at this point in the history
  • Loading branch information
owocki committed Feb 6, 2020
2 parents 09fc878 + 2d626c0 commit ee48526
Show file tree
Hide file tree
Showing 189 changed files with 31,984 additions and 1,087 deletions.
2 changes: 2 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,5 @@ app/assets/v2/js/dataviz/*
app/assets/v2/js/ethereumjs-accounts.js
app/assets/onepager/js/tx.js
app/assets/onepager/js/bignumber.js

app/assets/v2/js/lib/emoji-button.js
8 changes: 4 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,13 @@ jobs:
- pip install codecov
# Fetch and Install GeoIP database files.
- sudo apt-get update && sudo apt-get install -y libmaxminddb-dev
- wget --output-document GeoLite2-City.mmdb.tar.gz "https://download.maxmind.com/app/geoip_download?edition_id=GeoLite2-City&date=20191231&license_key=7PZQgKNxgqTRhkWy&suffix=tar.gz"
- wget --output-document GeoLite2-Country.mmdb.tar.gz "https://download.maxmind.com/app/geoip_download?edition_id=GeoLite2-Country&date=20191231&license_key=7PZQgKNxgqTRhkWy&suffix=tar.gz"
# Download links no more valid
- cp dist/*.gz ./
- gunzip GeoLite2-City.mmdb.tar.gz && gunzip GeoLite2-Country.mmdb.tar.gz
- tar -xvf GeoLite2-City.mmdb.tar && tar -xvf GeoLite2-Country.mmdb.tar
- sudo mkdir -p /opt/GeoIP/
- sudo mv GeoLite2-City_20191231/*.mmdb /opt/GeoIP/
- sudo mv GeoLite2-Country_20191231/*.mmdb /opt/GeoIP/
- sudo mv GeoLite2-City_20200128/*.mmdb /opt/GeoIP/
- sudo mv GeoLite2-Country_20200128/*.mmdb /opt/GeoIP/
# Install libvips dependencies.
- sudo apt-get install -y libvips libvips-dev
# Install Node and Python dependencies.
Expand Down
8 changes: 4 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,16 @@ RUN apt-get install -y wget

RUN apt-get install -y python3-pip

COPY dist/* ./

# GeoIP2 Data Files
RUN mkdir -p /usr/share/GeoIP/ && \
wget --output-document GeoLite2-City.mmdb.tar.gz "https://download.maxmind.com/app/geoip_download?edition_id=GeoLite2-City&date=20191231&license_key=7PZQgKNxgqTRhkWy&suffix=tar.gz" && \
wget --output-document GeoLite2-Country.mmdb.tar.gz "https://download.maxmind.com/app/geoip_download?edition_id=GeoLite2-Country&date=20191231&license_key=7PZQgKNxgqTRhkWy&suffix=tar.gz" && \
gunzip GeoLite2-City.mmdb.tar.gz && \
gunzip GeoLite2-Country.mmdb.tar.gz && \
tar -xvf GeoLite2-City.mmdb.tar && \
tar -xvf GeoLite2-Country.mmdb.tar && \
mv GeoLite2-City_20191231/*.mmdb /usr/share/GeoIP/ && \
mv GeoLite2-Country_20191231/*.mmdb /usr/share/GeoIP/
mv GeoLite2-City_20200128/*.mmdb /usr/share/GeoIP/ && \
mv GeoLite2-Country_20200128/*.mmdb /usr/share/GeoIP/

# Upgrade package essentials.
RUN pip3 install --upgrade pip setuptools wheel dumb-init pipenv
Expand Down
48 changes: 40 additions & 8 deletions app/app/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,42 @@
import logging

from django.conf import settings
from django.core.cache import cache
from django.utils import timezone

import requests
from app.utils import get_location_from_ip
from cacheops import cached_as
from dashboard.models import Activity, Tip, UserAction
from dashboard.utils import _get_utm_from_cookie
from kudos.models import KudosTransfer
from marketing.utils import handle_marketing_callback
from retail.helpers import get_ip
from townsquare.models import Announcement

RECORD_VISIT_EVERY_N_SECONDS = 60 * 60

logger = logging.getLogger(__name__)

def fetchPost(qt='2'):
"""Fetch last post from wordpress blog."""
url = f"https://gitcoin.co/blog/wp-json/wp/v2/posts?_fields=excerpt,title,link,jetpack_featured_media_url&per_page={qt}"
last_posts = requests.get(url=url).json()
return last_posts

@cached_as(Announcement.objects.filter(key__in=['footer', 'header']), timeout=120)
def get_sitewide_announcements():
announcements = Announcement.objects.filter(key__in=['footer', 'header'])
announcement = announcements.filter(key='footer').first()
header_msg, footer_msg, nav_salt = '', '', 0
if announcement:
footer_msg = announcement.title + announcement.desc
announcement = announcements.filter(key='header').first()
if announcement:
header_msg = announcement.title + announcement.desc
nav_salt = announcement.rank
return header_msg, footer_msg, nav_salt


def preprocess(request):
"""Handle inserting pertinent data into the current context."""
Expand Down Expand Up @@ -93,20 +116,24 @@ def preprocess(request):

chat_unread_messages = False

if profile and profile.chat_id:
if profile and hasattr(profile, 'chat_id'):
try:
from chat.tasks import get_driver
chat_driver = get_driver()
make_external_api_call = False
if make_external_api_call:
from chat.tasks import get_driver
chat_driver = get_driver()

chat_unreads_request = chat_driver.teams.get_team_unreads_for_user(profile.chat_id)
chat_unreads_request = chat_driver.teams.get_team_unreads_for_user(profile.chat_id)

for teams in chat_unreads_request:
if teams['msg_count'] > 0 or teams['mention_count'] > 0:
chat_unread_messages = True
break
for teams in chat_unreads_request:
if teams['msg_count'] > 0 or teams['mention_count'] > 0:
chat_unread_messages = True
break
except Exception as e:
logger.error(str(e))

header_msg, footer_msg, nav_salt = get_sitewide_announcements()

context = {
'STATIC_URL': settings.STATIC_URL,
'MEDIA_URL': settings.MEDIA_URL,
Expand All @@ -119,6 +146,9 @@ def preprocess(request):
'raven_js_dsn': settings.SENTRY_JS_DSN,
'release': settings.RELEASE,
'env': settings.ENV,
'header_msg': header_msg,
'nav_salt': nav_salt,
'footer_msg': footer_msg,
'INFURA_V3_PROJECT_ID': settings.INFURA_V3_PROJECT_ID,
'email_key': email_key,
'orgs': profile.organizations if profile else [],
Expand All @@ -133,12 +163,14 @@ def preprocess(request):
'access_token': profile.access_token if profile else '',
'is_staff': request.user.is_staff if user_is_authenticated else False,
'is_moderator': profile.is_moderator if profile else False,
'is_alpha_tester': profile.is_alpha_tester if profile else False,
'persona_is_funder': profile.persona_is_funder if profile else False,
'persona_is_hunter': profile.persona_is_hunter if profile else False,
'profile_url': profile.url if profile else False,
'quests_live': settings.QUESTS_LIVE,
}
context['json_context'] = json.dumps(context)
context['last_posts'] = cache.get_or_set('last_posts', fetchPost, 5000)

if context['github_handle']:
context['unclaimed_tips'] = Tip.objects.filter(
Expand Down
1 change: 1 addition & 0 deletions app/app/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@
'event_ethdenver2019',
'inbox',
'feeswapper',
'search',
'oauth2_provider',
'townsquare',
'compliance',
Expand Down
25 changes: 25 additions & 0 deletions app/app/templates/shared/tip_dependancies.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{% 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 <http://www.gnu.org/licenses/>.
{% endcomment %}
{% load static %}
<script src="{% static "v2/js/tokens.js" %}"></script>
<script src="/dynamic/js/tokens_dynamic.js"></script>
<script src="{% static "v2/js/lib/ipfs-api.js" %}"></script>
<script src="{% static "v2/js/ipfs.js" %}"></script>
<script src="{% static "v2/js/lib/secrets.min.js" %}"></script>
<script src="{% static "v2/js/ethereumjs-accounts.js" %}"></script>
<script src="{% static "onepager/js/send.js" %}"></script>
<script src="{% static "v2/js/truncate-hash.js" %}"></script>
9 changes: 9 additions & 0 deletions app/app/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
import retail.emails
import retail.views
import revenue.views
import search.views
import tdi.views
import townsquare.views
from avatar.router import router as avatar_router
Expand Down Expand Up @@ -114,6 +115,8 @@
url(r'^api/v0.1/profile/(.*)?/viewers.csv', dashboard.views.profile_viewers, name='profile_viewers'),
url(r'^api/v0.1/profile/(.*)?/spent.csv', dashboard.views.profile_spent, name='profile_spent'),
url(r'^api/v0.1/profile/banner', dashboard.views.change_user_profile_banner, name='change_user_profile_banner'),
url(r'^api/v0.1/profile/settings', dashboard.views.profile_settings, name='profile_settings'),
url(r'^api/v0.1/profile/backup', dashboard.views.profile_backup, name='profile_backup'),
path('api/v0.1/activity/<int:activity_id>', townsquare.views.api, name='townsquare_api'),
path('api/v0.1/emailsettings/', townsquare.views.emailsettings, name='townsquare_emailsettings'),
url(r'^api/v0.1/activity', retail.views.create_status_update, name='create_status_update'),
Expand Down Expand Up @@ -145,6 +148,7 @@
url(r'^actions/api/v0.1/', include(dbrouter.urls)), # same as active
url(r'^api/v0.1/users_search/', dashboard.views.get_users, name='users_search'),
url(r'^api/v0.1/kudos_search/', dashboard.views.get_kudos, name='kudos_search'),
url(r'^api/v0.1/search/', search.views.search, name='search'),
url(r'^api/v0.1/choose_persona/', dashboard.views.choose_persona, name='choose_persona'),

# chat
Expand Down Expand Up @@ -388,6 +392,7 @@
re_path(r'^tribes', retail.views.tribes, name='tribes'),
path('tribe/<str:handle>/join/', dashboard.views.join_tribe, name='join_tribe'),
path('tribe/<str:handle>/save/', dashboard.views.save_tribe, name='save_tribe'),
path('tribe/title/', dashboard.views.set_tribe_title, name='set_tribe_title'),
path('tribe/leader/', dashboard.views.tribe_leader, name='tribe_leader'),

# basic redirect retail views
Expand All @@ -408,6 +413,8 @@
re_path(r'^livestream/?', retail.views.livestream, name='livestream'),
re_path(r'^feedback/?', retail.views.feedback, name='feedback'),
re_path(r'^twitter/?', retail.views.twitter, name='twitter'),
re_path(r'^wallpaper/?', retail.views.wallpaper, name='wallpaper'),
re_path(r'^wallpapers/?', retail.views.wallpaper, name='wallpapers'),
re_path(r'^gitter/?', retail.views.gitter, name='gitter'),
re_path(r'^refer/?', retail.views.refer, name='refer'),
re_path(r'^fb/?', retail.views.fb, name='fb'),
Expand All @@ -432,6 +439,8 @@

# bounty requests
re_path(r'^requests/?', bounty_requests.views.bounty_request, name='bounty_requests'),
url('^api/v1/bounty_request/create', bounty_requests.views.create_bounty_request_v1, name='create_bounty_request_v1'),
url('^api/v1/bounty_request/update', bounty_requests.views.update_bounty_request_v1, name='update_bounty_request_v1'),

# admin views
re_path(r'^_administration/?', admin.site.urls, name='admin'),
Expand Down
16 changes: 11 additions & 5 deletions app/assets/onepager/js/receive.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,16 @@ $(document).ready(function() {
if (err) {
_alert(err.message.split('\n')[0], 'error');
} else {
document.location.href = window.location.href.split('?')[0] +
'?receive_txid=' + txid +
'&forwarding_address=' + $('#forwarding_address').val() +
'&save_addr=' + ($('#save_addr').is(':checked') ? '1' : '0');
var url = window.location.href.split('?')[0];

var form = $('<form action="' + url + '" method="post">' +
'<input type="text" name="receive_txid" value="' + txid + '" />' +
'<input type="text" name="forwarding_address" value="' + $('#forwarding_address').val() + '" />' +
'<input type="text" name="save_addr" value="' + ($('#save_addr').is(':checked') ? '1' : '0') + '" />' +
'</form>');

$('body').append(form);
form.submit();
}
};

Expand Down Expand Up @@ -186,4 +192,4 @@ $(document).ready(function() {
});
});
});
});
});
2 changes: 1 addition & 1 deletion app/assets/onepager/js/send.js
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ function sendTip(email, github_url, from_name, username, amount, comments_public
}

var gas_multiplier = 1.008;
var gas_money = parseInt(Math.pow(10, (9 + 5)) * ((defaultGasPrice * gas_multiplier) / Math.pow(10, 9)));
var gas_money = parseInt(Math.pow(10, (9 + 5)) * ((get_gas_price() * gas_multiplier) / Math.pow(10, 9)));
var isSendingETH = (tokenAddress == '0x0' || tokenAddress == '0x0000000000000000000000000000000000000000');
var tokenDetails = tokenAddressToDetails(tokenAddress);
var tokenName = 'ETH';
Expand Down
48 changes: 41 additions & 7 deletions app/assets/v2/css/activity_stream.css
Original file line number Diff line number Diff line change
Expand Up @@ -22,31 +22,53 @@
font-size: smaller;
}

.activity_feed_kudos_image{
max-width: 70px;
}

.action i,
a .sup {
color: black;
}

.tip_activity,
.action:hover {
background-color: #fafafa;
}

.action.open {
background-color: #eeeeee;
}

.comment_container.filled {
.comment_container{
padding: 0px;
}

.comment_container.filled{
text-align: left;
background-color: #f4f4f4;
padding: 5px 10px;
border-radius: 3px;
width: 300px;
background-color: #f2f2f2;
padding: 0px;
border-radius: 5px;
}

.comment_container img {
border-radius: 20px;
max-width: 20px;
}

.comment_container li {
.comment_container li{
text-align: left;
list-style: none;
padding: 5px;
}

.comment_container li .comment{
padding-left: 25px;
}

.comment_container li:nth-child(even){
background-color: #fafafa;
}

.comment_container a {
Expand Down Expand Up @@ -74,10 +96,15 @@ a .sup {
font-weight: bold;
}

.tip_activity{
color: black;
}

.tip_activity:hover,
.like_activity:hover,
.flag_activity:hover,
.comment_activity:hover,
.copy_activity:hover{
.copy_activity:hover {
text-decoration: none;
font-weight: bolder;
}
Expand Down Expand Up @@ -130,6 +157,9 @@ a .sup {
}

@media (min-width: 768px) {
.activity_feed_kudos_image{
max-width: 110px;
}
.activity .secondary {
position: relative;
left: -10px;
Expand All @@ -141,10 +171,14 @@ a .sup {
text-align: center;
margin: 0px auto;
}

.activity-info {
text-align: center;
}

#activities .organizations{
text-align: center;
margin: 0px auto;
}
.activity_stream .activity .avatar.secondary_avatar {
position: unset;
margin-left: -20px;
Expand Down
12 changes: 12 additions & 0 deletions app/assets/v2/css/avatar.css
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,15 @@
margin: 0px auto;
padding-left: 40px;
}
#tdavatartarget.3d{
width: 400px;
height: 400px;
}
#tdavatartarget.bufficorn{
width: 500px;
height: 500px;
}

.tdselection{
height: 100px;
width: 100px;
Expand All @@ -79,6 +88,9 @@
border-bottom: 1px solid #9a9a9a;
margin: 0px auto;
}
.select_avatar_type.base{
display: none;
}
.select_avatar_type.frame{
display: none;
}
Expand Down
Loading

0 comments on commit ee48526

Please sign in to comment.