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 Jul 19, 2021
2 parents c337180 + fe23823 commit 5f26ecc
Show file tree
Hide file tree
Showing 178 changed files with 639 additions and 6,800 deletions.
51 changes: 18 additions & 33 deletions app/app/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@
from django.http import HttpRequest
from django.utils import timezone

import requests
from app.bundle_context import context as bundleContext
from app.utils import get_location_from_ip
from cacheops import cached_as
from dashboard.models import Activity, Tip, UserAction
from dashboard.tasks import record_join, record_visit
from dashboard.utils import _get_utm_from_cookie
from kudos.models import KudosTransfer
from marketing.utils import handle_marketing_callback
Expand Down Expand Up @@ -81,41 +81,26 @@ def preprocess(request):
profile = request.user.profile if user_is_authenticated and hasattr(request.user, 'profile') else None
if user_is_authenticated and profile and profile.pk:
# what actions to take?
record_join = not profile.last_visit
record_visit = not profile.last_visit or profile.last_visit < (
should_record_join = not profile.last_visit
should_record_visit = not profile.last_visit or profile.last_visit < (
timezone.now() - timezone.timedelta(seconds=RECORD_VISIT_EVERY_N_SECONDS)
)
if record_visit:
try:
profile.last_visit = timezone.now()
profile.save()
except Exception as e:
logger.exception(e)
try:
from dashboard.tasks import profile_dict
profile_dict.delay(profile.pk)
except Exception as e:
logger.exception(e)
metadata = {
'visitorId': request.COOKIES.get("visitorId", None),
'useragent': request.META['HTTP_USER_AGENT'],
'referrer': request.META.get('HTTP_REFERER', None),
'path': request.META.get('PATH_INFO', None),
'session_key': request.session._session_key,
}

if should_record_visit:
# values to pass to celery from the request
ip_address = get_ip(request)
UserAction.objects.create(
user=request.user,
profile=profile,
action='Visit',
location_data=get_location_from_ip(ip_address),
ip_address=ip_address,
utm=_get_utm_from_cookie(request),
metadata=metadata,
)

if record_join:
Activity.objects.create(profile=profile, activity_type='joined')
visitorId = request.COOKIES.get("visitorId", None)
useragent = request.META['HTTP_USER_AGENT']
referrer = request.META.get('HTTP_REFERER', None)
path = request.META.get('PATH_INFO', None)
session_key = request.session._session_key
utm = _get_utm_from_cookie(request)
# record the visit as a celery task
record_visit.delay(request.user.pk, profile.pk, ip_address, visitorId, useragent, referrer, path, session_key, utm)

if should_record_join:
# record the joined action as a celery task
record_join.delay(profile.pk)

ptoken = PersonalToken.objects.filter(token_owner_profile=profile).first()

Expand Down
2 changes: 0 additions & 2 deletions app/app/services.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import random

from django.conf import settings

from app.settings import account_sid, auth_token, verify_service
Expand Down
21 changes: 0 additions & 21 deletions app/app/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import json
import os
import socket
import subprocess
import warnings

from django.utils.translation import gettext_noop
Expand All @@ -29,7 +28,6 @@
import raven
import sentry_sdk
from boto3.session import Session
from easy_thumbnails.conf import Settings as easy_thumbnails_defaults
from sentry_sdk.integrations.celery import CeleryIntegration
from sentry_sdk.integrations.django import DjangoIntegration

Expand Down Expand Up @@ -102,7 +100,6 @@
'django.contrib.sites',
'autotranslate',
'django_extensions',
'easy_thumbnails',
'health_check',
'health_check.db',
'health_check.cache',
Expand Down Expand Up @@ -422,7 +419,6 @@ def callback(request):

if ENV in ['prod', 'stage']:
DEFAULT_FILE_STORAGE = env('DEFAULT_FILE_STORAGE', default='app.static_storage.MediaFileStorage')
THUMBNAIL_DEFAULT_STORAGE = DEFAULT_FILE_STORAGE
STATICFILES_STORAGE = env('STATICFILES_STORAGE', default='app.static_storage.SilentFileStorage')
STATIC_HOST = env('STATIC_HOST', default='https://s.gitcoin.co/')
STATIC_URL = STATIC_HOST + env('STATIC_URL', default=f'{STATICFILES_LOCATION}{"/" if STATICFILES_LOCATION else ""}')
Expand All @@ -446,22 +442,6 @@ def callback(request):
'django.contrib.staticfiles.finders.AppDirectoriesFinder'
]

THUMBNAIL_PROCESSORS = easy_thumbnails_defaults.THUMBNAIL_PROCESSORS + ('app.thumbnail_processors.circular_processor',)

THUMBNAIL_ALIASES = {
'': {
'graph_node': {
'size': (30, 30),
'crop': True
},
'graph_node_circular': {
'size': (30, 30),
'crop': True,
'circle': True
}
}
}

CACHEOPS_DEGRADE_ON_FAILURE = env.bool('CACHEOPS_DEGRADE_ON_FAILURE', default=True)
CACHEOPS_REDIS = env.str('CACHEOPS_REDIS', default='redis://redis:6379/0')

Expand Down Expand Up @@ -617,7 +597,6 @@ def callback(request):
# Github
GITHUB_API_BASE_URL = env('GITHUB_API_BASE_URL', default='https://api.github.com')
GITHUB_AUTH_BASE_URL = env('GITHUB_AUTH_BASE_URL', default='https://github.com/login/oauth/authorize')
GITHUB_TOKEN_URL = env('GITHUB_TOKEN_URL', default='https://github.com/login/oauth/access_token')
GITHUB_SCOPE = env('GITHUB_SCOPE', default='read:user,user:email')
GITHUB_CLIENT_ID = env('GITHUB_CLIENT_ID', default='') # TODO
GITHUB_CLIENT_SECRET = env('GITHUB_CLIENT_SECRET', default='') # TODO
Expand Down
3 changes: 0 additions & 3 deletions app/app/static_storage.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
# -*- coding: utf-8 -*-
"""Define the custom static storage to surpress bad URL references."""
import os
from datetime import datetime
from os.path import basename
from secrets import token_hex

from django.conf import settings

Expand Down
2 changes: 0 additions & 2 deletions app/app/templates/search/indexes/dashboard/bounty_text.txt

This file was deleted.

This file was deleted.

This file was deleted.

173 changes: 0 additions & 173 deletions app/app/templates/search/search.html

This file was deleted.

27 changes: 0 additions & 27 deletions app/app/thumbnail_processors.py

This file was deleted.

9 changes: 0 additions & 9 deletions app/app/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -606,10 +606,6 @@
url(r'^l/(.*)$/?', linkshortener.views.linkredirect, name='redirect'),
url(r'^credit/(.*)$/?', credits.views.credits, name='credit'),

# token distribution event
# re_path(r'^whitepaper/accesscode/?', tdi.views.whitepaper_access, name='whitepaper_access'),
# re_path(r'^whitepaper/?', tdi.views.whitepaper_new, name='whitepaper'),

# faucet views
re_path(r'^faucet/?', faucet.views.faucet, name='faucet'),

Expand Down Expand Up @@ -722,11 +718,6 @@
retail.emails.tribe_hackathon_prizes,
name='tribe_hackathon_prizes'
),
path(
'_administration/email/day_email_campaign/<int:day>',
marketing.views.day_email_campaign,
name='day_email_campaign'
),
re_path(
r'^_administration/process_accesscode_request/(.*)$',
tdi.views.process_accesscode_request,
Expand Down
Loading

0 comments on commit 5f26ecc

Please sign in to comment.