Skip to content

Commit

Permalink
Merge branch 'master' into new-bounty-detail
Browse files Browse the repository at this point in the history
  • Loading branch information
octavioamu committed Mar 11, 2020
2 parents a55b860 + 2bc9132 commit 1ff39b7
Show file tree
Hide file tree
Showing 78 changed files with 11,429 additions and 1,473 deletions.
53 changes: 15 additions & 38 deletions app/app/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import requests
from app.utils import get_location_from_ip
from cacheops import cached_as
from chat.tasks import get_chat_url
from dashboard.models import Activity, Tip, UserAction
from dashboard.utils import _get_utm_from_cookie
from kudos.models import KudosTransfer
Expand All @@ -40,6 +41,7 @@
logger = logging.getLogger(__name__)


@cached_as(JSONStore.objects.filter(view='posts', key='posts'), timeout=1200)
def fetchPost(qt='2'):
jsonstores = JSONStore.objects.filter(view='posts', key='posts')
if jsonstores.exists():
Expand Down Expand Up @@ -69,18 +71,12 @@ def preprocess(request):
if request.path == '/lbcheck':
return {}

from marketing.utils import get_stat
try:
num_slack = int(get_stat('slack_users'))
except Exception:
num_slack = 0
if num_slack > 1000:
num_slack = f'{str(round((num_slack) / 1000, 1))}k'
chat_url = get_chat_url(front_end=True)
chat_access_token = ''
chat_id = ''

user_is_authenticated = request.user.is_authenticated
profile = request.user.profile if user_is_authenticated and hasattr(request.user, 'profile') else None
email_subs = profile.email_subscriptions if profile else None
email_key = email_subs.first().priv if user_is_authenticated and email_subs and email_subs.exists() else ''
if user_is_authenticated and profile and profile.pk:
# what actions to take?
record_join = not profile.last_visit
Expand Down Expand Up @@ -117,36 +113,21 @@ def preprocess(request):
if record_join:
Activity.objects.create(profile=profile, activity_type='joined')

chat_access_token = profile.gitcoin_chat_access_token
chat_id = profile.chat_id
# handles marketing callbacks
if request.GET.get('cb'):
callback = request.GET.get('cb')
handle_marketing_callback(callback, request)

chat_unread_messages = False

if profile and hasattr(profile, 'chat_id'):
try:
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)

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,
'num_slack': num_slack,
'chat_unread_messages': chat_unread_messages,
'chat_url': chat_url,
'chat_id': chat_id,
'chat_access_token': chat_access_token,
'github_handle': request.user.username if user_is_authenticated else False,
'email': request.user.email if user_is_authenticated else False,
'name': request.user.get_full_name() if user_is_authenticated else False,
Expand All @@ -158,7 +139,6 @@ def preprocess(request):
'nav_salt': nav_salt,
'footer_msg': footer_msg,
'INFURA_V3_PROJECT_ID': settings.INFURA_V3_PROJECT_ID,
'email_key': email_key,
'giphy_key': settings.GIPHY_KEY,
'youtube_key': settings.YOUTUBE_API_KEY,
'orgs': profile.organizations if profile else [],
Expand All @@ -184,17 +164,14 @@ def preprocess(request):

if context['github_handle']:
context['unclaimed_tips'] = Tip.objects.filter(
expires_date__gte=timezone.now(),
receive_txid='',
username__iexact=context['github_handle'],
web3_type='v3',
).send_happy_path()
receive_txid='', username__iexact=context['github_handle'], web3_type='v3',
).send_happy_path().cache(timeout=60)
context['unclaimed_kudos'] = KudosTransfer.objects.filter(
receive_txid='', username__iexact="@" + context['github_handle'], web3_type='v3',
).send_happy_path()
).send_happy_path().cache(timeout=60)

if not settings.DEBUG:
context['unclaimed_tips'] = context['unclaimed_tips'].filter(network='mainnet')
context['unclaimed_kudos'] = context['unclaimed_kudos'].filter(network='mainnet')
context['unclaimed_tips'] = context['unclaimed_tips'].filter(network='mainnet').cache(timeout=60)
context['unclaimed_kudos'] = context['unclaimed_kudos'].filter(network='mainnet').cache(timeout=60)

return context
17 changes: 17 additions & 0 deletions app/app/fixtures/oauth_application.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
[
{
"model": "oauth2_provider.application",
"pk": 1,
"fields": {
"created": "2020-02-29 21:30:30Z",
"updated": "2020-02-29 21:30:30Z",
"client_id": "VkHFfFlxnVCMYtYCWRxphbvPQUJjmER4cWtwqe7Q",
"client_secret": "xhLXNqXnOlkUiGCDFJLxQJjPb3CltLZNFZtzOsLgFfvwbYY60kYWRRBmqyjzfrnNyT6WWdIbfQEPpU854K2UiofmXtybFD1QkfIR9VVQyK3ttJpET7GormIBjK9CQRap",
"redirect_uris": "http://localhost:8065/login/gitcoin/complete http://localhost:8065/signup/gitcoin/complete http://localhost:8065/oauth/gitcoin/complete",
"client_type": "confidential",
"authorization_grant_type": "authorization-code",
"skip_authorization": true,
"user_id": null,
"name": "Gitcoin Chat"
}
}]
3 changes: 2 additions & 1 deletion app/app/local.env
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ GITHUB_API_TOKEN=
GITHUB_CLIENT_ID=
GITHUB_CLIENT_SECRET=
GITHUB_APP_NAME=

CHAT_SERVER_URL=chat
CHAT_URL=localhost
# Etherscan API to get ETH and token trasaction history from an account address
ETHERSCAN_API_KEY=

Expand Down
7 changes: 4 additions & 3 deletions app/app/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,12 +94,12 @@
'health_check.contrib.s3boto3_storage',
'app',
'avatar',
'chat',
'retail',
'rest_framework',
'marketing',
'economy',
'dashboard',
'chat',
'quests',
'enssubdomain',
'faucet',
Expand Down Expand Up @@ -568,10 +568,11 @@
# Chat
CHAT_PORT = env('CHAT_PORT', default=8065) # port of where mattermost is hosted
CHAT_URL = env('CHAT_URL', default='localhost') # location of where mattermost is hosted
CHAT_SERVER_URL = env('CHAT_SERVER_URL', default='chat') # location of where mattermost is hosted
CHAT_DRIVER_TOKEN = env('CHAT_DRIVER_TOKEN', default='') # driver token
GITCOIN_HACK_CHAT_TEAM_ID = env('GITCOIN_HACK_CHAT_TEAM_ID', default='')
GITCOIN_CHAT_TEAM_ID = env('GITCOIN_CHAT_TEAM_ID', default='')

GITCOIN_LEADERBOARD_CHANNEL_ID = env('GITCOIN_LEADERBOARD_CHANNEL_ID', default='')
# Social Auth
LOGIN_URL = 'gh_login'
LOGOUT_URL = 'logout'
Expand Down Expand Up @@ -763,7 +764,7 @@

WIKI_ACCOUNT_HANDLING = True
WIKI_ACCOUNT_SIGNUP_ALLOWED = True

WIKI_CACHE_TIMEOUT = True

# Sending an email when a bounty is funded below a threshold
LOWBALL_BOUNTY_THRESHOLD = env.float('LOWBALL_BOUNTY_THRESHOLD', default=10.00)
Expand Down
1 change: 1 addition & 0 deletions app/app/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@
# chat
url(r'^chat/landing', chat.views.chat, name='landing_chat'),
url(r'^chat/landing/', chat.views.chat, name='landing_chat2'),
url(r'^api/v0.1/chat/presence', chat.views.chat_presence, name='chat_presence'),
re_path(r'^chat/?', chat.views.embed, name='chat'),
# Health check endpoint
re_path(r'^health/', include('health_check.urls')),
Expand Down
11 changes: 11 additions & 0 deletions app/app/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,17 @@ def sync_profile(handle, user=None, hide_profile=True):
profile.handle = data['login']
profile.email = user.email
profile.save()

if profile is not None and (profile.chat_id is '' or profile.gitcoin_chat_access_token is ''):

try:
from chat.tasks import associate_chat_to_profile
created, profile = associate_chat_to_profile(profile)

except Exception as e:
logger.error(str(e))
raise ValueError(e)

except UserSocialAuth.DoesNotExist:
pass
else:
Expand Down
33 changes: 22 additions & 11 deletions app/assets/v2/css/base.css
Original file line number Diff line number Diff line change
Expand Up @@ -1671,13 +1671,10 @@ div.busyOverlay {
}
.chat_presence_indicator {
font-size: 12px;
padding: 5px;
padding: 0px;
list-style: none;
display: inline-block;
background-color: #eee;
border: 1px solid #ddd;
cursor: pointer;
border-radius: 5px;
margin-bottom: 0px;
margin-left: 5px;
font-weight: normal;
Expand All @@ -1686,24 +1683,38 @@ div.busyOverlay {
.chat_presence_indicator .indicator {
vertical-align: middle;
content: "\2022";
font-size: 20px;
font-size: 42px;
color: #aaa;
font-weight: bold;
display: inline-block;
margin-top: -10px;
margin-bottom: -5px;
margin-top: -12px;
margin-bottom: 0px;
}
.chat_presence_indicator.online .indicator {
color: #0fce7c;
}
.chat_presence_indicator.mini li,
.chat_presence_indicator.away .indicator {
color: orange;
}
.chat_presence_indicator.dnd .indicator {
color: red;
}
.chat_presence_indicator.mini {
padding: 0px 1px;
font-size: 10px;
margin-left: 0px;
}
.chat_presence_indicator.mini .indicator {
font-size: 12px;
margin-top: 0px;
margin-bottom: 0px;
font-size: 24px;
line-height: 0px
}
.navbar .chat_presence_indicator{
position: relative;
left: -16px;
top: -4px;
cursor: default;
}
.navbar .chat_presence_indicator .indicator{
font-size: 22px;
}

17 changes: 0 additions & 17 deletions app/assets/v2/css/profile.css
Original file line number Diff line number Diff line change
Expand Up @@ -294,23 +294,6 @@
background-color: transparent;
}

.profile-header__sync {
margin-top: -140px;
position: relative;
}

.profile-header__sync.inactive {
display: none;
}

.profile-header__sync img {
width: 32px;
}

.profile-header__sync img.loading {
display: none;
}

.card-header::after {
content: '';
position: relative;
Expand Down
8 changes: 7 additions & 1 deletion app/assets/v2/css/town_square.css
Original file line number Diff line number Diff line change
Expand Up @@ -884,8 +884,14 @@ body.green.offer_view .announce {
font-size: 0.9rem;
color: #626365;
text-transform: uppercase;
cursor: pointer;
}
.townsquare_block-header::after {
content: ""
}
.townsquare_block-header.closed::after {
content: "^"
}

#status .btn-group-toggle .btn-radio {
background-color: var(--badge-blue-bg);
color: var(--badge-blue-text);
Expand Down
4,284 changes: 4,284 additions & 0 deletions app/assets/v2/images/avatar3d/avatar_barbarian.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 1ff39b7

Please sign in to comment.