This commit is contained in:
Eugene Pankov
2021-07-28 22:14:34 +02:00
parent b3bb9fdd40
commit 0484b4c8d7
13 changed files with 146 additions and 15 deletions

View File

@@ -131,7 +131,7 @@ class UserSerializer(ModelSerializer):
read_only_fields = ('id', 'username')
def get_is_pro(self, obj):
return check_is_sponsor_cached(obj) or obj.force_pro
return obj.force_pro or not settings.GITHUB_ELIGIBLE_SPONSORSHIPS or check_is_sponsor_cached(obj)
def get_is_sponsor(self, obj):
return check_is_sponsor_cached(obj)

View File

@@ -8,6 +8,8 @@ from urllib.parse import urlparse
class IndexView(APIView):
def get(self, request, format=None):
if settings.FRONTEND_URL:
return HttpResponseRedirect(settings.FRONTEND_URL)
return static.serve(request, 'index.html', document_root=str(settings.FRONTEND_BUILD_DIR))

View File

@@ -100,6 +100,12 @@ AUTH_PASSWORD_VALIDATORS = [
AUTH_USER_MODEL = 'app.User'
REST_FRAMEWORK = {
'DEFAULT_RENDERER_CLASSES': (
'rest_framework.renderers.JSONRenderer',
)
}
# Internationalization
# https://docs.djangoproject.com/en/3.2/topics/i18n/
@@ -174,10 +180,12 @@ APP_DIST_STORAGE = os.getenv('APP_DIST_STORAGE', 'file://' + str(BASE_DIR / 'app
NPM_REGISTRY = os.getenv('NPM_REGISTRY', 'https://registry.npmjs.org').rstrip('/')
FRONTEND_URL = None
BACKEND_URL = None
GITHUB_ELIGIBLE_SPONSORSHIPS = None
for key in [
'FRONTEND_URL',
'BACKEND_URL',
'SOCIAL_AUTH_GITHUB_KEY',
'SOCIAL_AUTH_GITHUB_SECRET',
'SOCIAL_AUTH_GITLAB_KEY',
@@ -243,6 +251,8 @@ if FRONTEND_URL:
]
frontend_domain = urlparse(FRONTEND_URL).hostname
CSRF_TRUSTED_ORIGINS = [frontend_domain]
if BACKEND_URL:
CSRF_TRUSTED_ORIGINS.append(urlparse(BACKEND_URL).hostname)
SESSION_COOKIE_DOMAIN = frontend_domain
CSRF_COOKIE_DOMAIN = frontend_domain