From 1a55e92824d56a34a677c1f764a5393038e66955 Mon Sep 17 00:00:00 2001 From: Leon Sandøy Date: Sat, 22 Aug 2020 01:40:55 +0200 Subject: Add a context processor that outputs the git SHA. This will make the SHA available in all templates. --- pydis_site/settings.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'pydis_site/settings.py') diff --git a/pydis_site/settings.py b/pydis_site/settings.py index 2c87007c..afa097be 100644 --- a/pydis_site/settings.py +++ b/pydis_site/settings.py @@ -157,8 +157,8 @@ TEMPLATES = [ 'django.template.context_processors.static', 'django.contrib.auth.context_processors.auth', 'django.contrib.messages.context_processors.messages', - "sekizai.context_processors.sekizai", + "pydis_site.context_processors.git_sha_processor" ], }, }, -- cgit v1.2.3 From 212a06f400bfce95281e4c8d11baf6cb09e70861 Mon Sep 17 00:00:00 2001 From: Leon Sandøy Date: Sat, 22 Aug 2020 02:05:24 +0200 Subject: Set the sentry_sdk.init release to git_sha. This is the first step in implementing releases for Sentry. --- pydis_site/settings.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'pydis_site/settings.py') diff --git a/pydis_site/settings.py b/pydis_site/settings.py index afa097be..ff2942f0 100644 --- a/pydis_site/settings.py +++ b/pydis_site/settings.py @@ -20,6 +20,7 @@ import sentry_sdk from django.contrib.messages import constants as messages from sentry_sdk.integrations.django import DjangoIntegration +from pydis_site import GIT_SHA if typing.TYPE_CHECKING: from django.contrib.auth.models import User @@ -33,7 +34,8 @@ env = environ.Env( sentry_sdk.init( dsn=env('SITE_SENTRY_DSN'), integrations=[DjangoIntegration()], - send_default_pii=True + send_default_pii=True, + release=f"pydis-site@{GIT_SHA}" ) # Build paths inside the project like this: os.path.join(BASE_DIR, ...) -- cgit v1.2.3 From 416a0874187fdf96346e3f504d6542b3214957db Mon Sep 17 00:00:00 2001 From: Leon Sandøy Date: Sat, 22 Aug 2020 02:49:28 +0200 Subject: Move git SHA fetcher into utils. --- pydis_site/__init__.py | 5 ----- pydis_site/context_processors.py | 4 ++-- pydis_site/settings.py | 4 ++-- pydis_site/utils/resources.py | 10 ++++++++++ 4 files changed, 14 insertions(+), 9 deletions(-) (limited to 'pydis_site/settings.py') diff --git a/pydis_site/__init__.py b/pydis_site/__init__.py index f0702577..df67cf71 100644 --- a/pydis_site/__init__.py +++ b/pydis_site/__init__.py @@ -1,4 +1,3 @@ -import git from wiki.plugins.macros.mdx import toc # Remove the toc header prefix. There's no option for this, so we gotta monkey patch it. @@ -8,7 +7,3 @@ toc.HEADER_ID_PREFIX = '' # by a string because Allauth won't let us just give it a list _there_, we have to point # at a list _somewhere else_ instead. VALIDATORS = [] - -# Git SHA -repo = git.Repo(search_parent_directories=True) -GIT_SHA = repo.head.object.hexsha diff --git a/pydis_site/context_processors.py b/pydis_site/context_processors.py index bb66f21d..e905d9c7 100644 --- a/pydis_site/context_processors.py +++ b/pydis_site/context_processors.py @@ -1,8 +1,8 @@ from django.template import RequestContext -from pydis_site import GIT_SHA +from pydis_site.utils.resources import get_git_sha def git_sha_processor(_: RequestContext) -> dict: """Expose the git SHA for this repo to all views.""" - return {'git_sha': GIT_SHA} + return {'git_sha': get_git_sha()} diff --git a/pydis_site/settings.py b/pydis_site/settings.py index ff2942f0..e707a526 100644 --- a/pydis_site/settings.py +++ b/pydis_site/settings.py @@ -20,7 +20,7 @@ import sentry_sdk from django.contrib.messages import constants as messages from sentry_sdk.integrations.django import DjangoIntegration -from pydis_site import GIT_SHA +from pydis_site.utils.resources import get_git_sha if typing.TYPE_CHECKING: from django.contrib.auth.models import User @@ -35,7 +35,7 @@ sentry_sdk.init( dsn=env('SITE_SENTRY_DSN'), integrations=[DjangoIntegration()], send_default_pii=True, - release=f"pydis-site@{GIT_SHA}" + release=f"pydis-site@{get_git_sha()}" ) # Build paths inside the project like this: os.path.join(BASE_DIR, ...) diff --git a/pydis_site/utils/resources.py b/pydis_site/utils/resources.py index 637fd785..d36c4b77 100644 --- a/pydis_site/utils/resources.py +++ b/pydis_site/utils/resources.py @@ -4,8 +4,13 @@ import glob import typing from dataclasses import dataclass +import git import yaml +# Git SHA +repo = git.Repo(search_parent_directories=True) +GIT_SHA = repo.head.object.hexsha + @dataclass class URL: @@ -89,3 +94,8 @@ def load_categories(order: typing.List[str]) -> typing.List[Category]: categories.append(Category.construct_from_directory(direc)) return categories + + +def get_git_sha() -> str: + """Get the Git SHA for this repo.""" + return GIT_SHA -- cgit v1.2.3 From 503bfba6855d3019a2739bb1adce69c457a8b26e Mon Sep 17 00:00:00 2001 From: Leon Sandøy Date: Sat, 22 Aug 2020 03:18:25 +0200 Subject: Move git SHA fetcher into its own file. Fix tests. --- pydis_site/context_processors.py | 2 +- pydis_site/settings.py | 2 +- pydis_site/tests/test_utils.py | 11 +++++++++++ pydis_site/utils/__init__.py | 3 +++ pydis_site/utils/resources.py | 10 ---------- pydis_site/utils/utils.py | 10 ++++++++++ 6 files changed, 26 insertions(+), 12 deletions(-) create mode 100644 pydis_site/tests/test_utils.py create mode 100644 pydis_site/utils/__init__.py create mode 100644 pydis_site/utils/utils.py (limited to 'pydis_site/settings.py') diff --git a/pydis_site/context_processors.py b/pydis_site/context_processors.py index e905d9c7..ab5a4168 100644 --- a/pydis_site/context_processors.py +++ b/pydis_site/context_processors.py @@ -1,6 +1,6 @@ from django.template import RequestContext -from pydis_site.utils.resources import get_git_sha +from pydis_site.utils import get_git_sha def git_sha_processor(_: RequestContext) -> dict: diff --git a/pydis_site/settings.py b/pydis_site/settings.py index e707a526..0a5b0eed 100644 --- a/pydis_site/settings.py +++ b/pydis_site/settings.py @@ -20,7 +20,7 @@ import sentry_sdk from django.contrib.messages import constants as messages from sentry_sdk.integrations.django import DjangoIntegration -from pydis_site.utils.resources import get_git_sha +from pydis_site.utils import get_git_sha if typing.TYPE_CHECKING: from django.contrib.auth.models import User diff --git a/pydis_site/tests/test_utils.py b/pydis_site/tests/test_utils.py new file mode 100644 index 00000000..f1419860 --- /dev/null +++ b/pydis_site/tests/test_utils.py @@ -0,0 +1,11 @@ +from django.test import TestCase + +from pydis_site.utils import get_git_sha +from pydis_site.utils.utils import GIT_SHA + + +class UtilsTests(TestCase): + + def test_git_sha(self): + """Test that the get_git_sha returns the correct SHA.""" + self.assertEqual(get_git_sha(), GIT_SHA) diff --git a/pydis_site/utils/__init__.py b/pydis_site/utils/__init__.py new file mode 100644 index 00000000..bb91b3d8 --- /dev/null +++ b/pydis_site/utils/__init__.py @@ -0,0 +1,3 @@ +from .utils import get_git_sha + +__all__ = ['get_git_sha'] diff --git a/pydis_site/utils/resources.py b/pydis_site/utils/resources.py index d36c4b77..637fd785 100644 --- a/pydis_site/utils/resources.py +++ b/pydis_site/utils/resources.py @@ -4,13 +4,8 @@ import glob import typing from dataclasses import dataclass -import git import yaml -# Git SHA -repo = git.Repo(search_parent_directories=True) -GIT_SHA = repo.head.object.hexsha - @dataclass class URL: @@ -94,8 +89,3 @@ def load_categories(order: typing.List[str]) -> typing.List[Category]: categories.append(Category.construct_from_directory(direc)) return categories - - -def get_git_sha() -> str: - """Get the Git SHA for this repo.""" - return GIT_SHA diff --git a/pydis_site/utils/utils.py b/pydis_site/utils/utils.py new file mode 100644 index 00000000..2033ea19 --- /dev/null +++ b/pydis_site/utils/utils.py @@ -0,0 +1,10 @@ +import git + +# Git SHA +repo = git.Repo(search_parent_directories=True) +GIT_SHA = repo.head.object.hexsha + + +def get_git_sha() -> str: + """Get the Git SHA for this repo.""" + return GIT_SHA -- cgit v1.2.3 From a71c38f07bba0191ba28eef12eea56e8a9265349 Mon Sep 17 00:00:00 2001 From: Leon Sandøy Date: Sat, 22 Aug 2020 03:54:51 +0200 Subject: Move the SHA into constants.py. The util was redundant. Thanks @MarkKoz --- pydis_site/constants.py | 5 +++++ pydis_site/context_processors.py | 4 ++-- pydis_site/settings.py | 4 ++-- pydis_site/tests/test_utils.py | 11 ----------- pydis_site/utils/__init__.py | 3 --- pydis_site/utils/utils.py | 10 ---------- 6 files changed, 9 insertions(+), 28 deletions(-) create mode 100644 pydis_site/constants.py delete mode 100644 pydis_site/tests/test_utils.py delete mode 100644 pydis_site/utils/__init__.py delete mode 100644 pydis_site/utils/utils.py (limited to 'pydis_site/settings.py') diff --git a/pydis_site/constants.py b/pydis_site/constants.py new file mode 100644 index 00000000..0b76694a --- /dev/null +++ b/pydis_site/constants.py @@ -0,0 +1,5 @@ +import git + +# Git SHA +repo = git.Repo(search_parent_directories=True) +GIT_SHA = repo.head.object.hexsha diff --git a/pydis_site/context_processors.py b/pydis_site/context_processors.py index ab5a4168..6937a3db 100644 --- a/pydis_site/context_processors.py +++ b/pydis_site/context_processors.py @@ -1,8 +1,8 @@ from django.template import RequestContext -from pydis_site.utils import get_git_sha +from pydis_site.constants import GIT_SHA def git_sha_processor(_: RequestContext) -> dict: """Expose the git SHA for this repo to all views.""" - return {'git_sha': get_git_sha()} + return {'git_sha': GIT_SHA} diff --git a/pydis_site/settings.py b/pydis_site/settings.py index 0a5b0eed..1f042c1b 100644 --- a/pydis_site/settings.py +++ b/pydis_site/settings.py @@ -20,7 +20,7 @@ import sentry_sdk from django.contrib.messages import constants as messages from sentry_sdk.integrations.django import DjangoIntegration -from pydis_site.utils import get_git_sha +from pydis_site.constants import GIT_SHA if typing.TYPE_CHECKING: from django.contrib.auth.models import User @@ -35,7 +35,7 @@ sentry_sdk.init( dsn=env('SITE_SENTRY_DSN'), integrations=[DjangoIntegration()], send_default_pii=True, - release=f"pydis-site@{get_git_sha()}" + release=f"pydis-site@{GIT_SHA}" ) # Build paths inside the project like this: os.path.join(BASE_DIR, ...) diff --git a/pydis_site/tests/test_utils.py b/pydis_site/tests/test_utils.py deleted file mode 100644 index f1419860..00000000 --- a/pydis_site/tests/test_utils.py +++ /dev/null @@ -1,11 +0,0 @@ -from django.test import TestCase - -from pydis_site.utils import get_git_sha -from pydis_site.utils.utils import GIT_SHA - - -class UtilsTests(TestCase): - - def test_git_sha(self): - """Test that the get_git_sha returns the correct SHA.""" - self.assertEqual(get_git_sha(), GIT_SHA) diff --git a/pydis_site/utils/__init__.py b/pydis_site/utils/__init__.py deleted file mode 100644 index bb91b3d8..00000000 --- a/pydis_site/utils/__init__.py +++ /dev/null @@ -1,3 +0,0 @@ -from .utils import get_git_sha - -__all__ = ['get_git_sha'] diff --git a/pydis_site/utils/utils.py b/pydis_site/utils/utils.py deleted file mode 100644 index 2033ea19..00000000 --- a/pydis_site/utils/utils.py +++ /dev/null @@ -1,10 +0,0 @@ -import git - -# Git SHA -repo = git.Repo(search_parent_directories=True) -GIT_SHA = repo.head.object.hexsha - - -def get_git_sha() -> str: - """Get the Git SHA for this repo.""" - return GIT_SHA -- cgit v1.2.3 From 3e4661e984d85d4df6c2e12655bbde078efbaeb8 Mon Sep 17 00:00:00 2001 From: Joe Banks Date: Fri, 2 Oct 2020 23:45:27 +0100 Subject: Only request the identify scope with Discord on OAuth2 login --- pydis_site/settings.py | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'pydis_site/settings.py') diff --git a/pydis_site/settings.py b/pydis_site/settings.py index 1f042c1b..eee559e4 100644 --- a/pydis_site/settings.py +++ b/pydis_site/settings.py @@ -401,3 +401,10 @@ ACCOUNT_USERNAME_VALIDATORS = "pydis_site.VALIDATORS" LOGIN_REDIRECT_URL = "home" SOCIALACCOUNT_ADAPTER = "pydis_site.utils.account.SocialAccountAdapter" +SOCIALACCOUNT_PROVIDERS = { + 'discord': { + 'SCOPE': [ + 'identify', + ], + } +} -- cgit v1.2.3 From 4b07fe054215d9cfd5a66214761c74608f6448d5 Mon Sep 17 00:00:00 2001 From: Joe Banks Date: Sat, 3 Oct 2020 00:04:28 +0100 Subject: Display no prompt to users who have already authenticated --- pydis_site/settings.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'pydis_site/settings.py') diff --git a/pydis_site/settings.py b/pydis_site/settings.py index eee559e4..3769fa25 100644 --- a/pydis_site/settings.py +++ b/pydis_site/settings.py @@ -402,9 +402,10 @@ ACCOUNT_USERNAME_VALIDATORS = "pydis_site.VALIDATORS" LOGIN_REDIRECT_URL = "home" SOCIALACCOUNT_ADAPTER = "pydis_site.utils.account.SocialAccountAdapter" SOCIALACCOUNT_PROVIDERS = { - 'discord': { - 'SCOPE': [ - 'identify', + "discord": { + "SCOPE": [ + "identify", ], + "AUTH_PARAMS": {"prompt": "none"} } } -- cgit v1.2.3 From 33d3d1abce8f6e41772021fb1be5d459d5717046 Mon Sep 17 00:00:00 2001 From: ks129 <45097959+ks129@users.noreply.github.com> Date: Sat, 3 Oct 2020 09:50:17 +0300 Subject: Logs Cleanup: Remove site internal logging to DB --- pydis_site/apps/api/dblogger.py | 22 ---------------------- pydis_site/apps/api/tests/test_dblogger.py | 27 --------------------------- pydis_site/settings.py | 3 --- 3 files changed, 52 deletions(-) delete mode 100644 pydis_site/apps/api/dblogger.py delete mode 100644 pydis_site/apps/api/tests/test_dblogger.py (limited to 'pydis_site/settings.py') diff --git a/pydis_site/apps/api/dblogger.py b/pydis_site/apps/api/dblogger.py deleted file mode 100644 index 4b4e3a9d..00000000 --- a/pydis_site/apps/api/dblogger.py +++ /dev/null @@ -1,22 +0,0 @@ -from logging import LogRecord, StreamHandler - - -class DatabaseLogHandler(StreamHandler): - """Logs entries into the database.""" - - def emit(self, record: LogRecord) -> None: - """Write the given `record` into the database.""" - # This import needs to be deferred due to Django's application - # registry instantiation logic loading this handler before the - # application is ready. - from pydis_site.apps.api.models.log_entry import LogEntry - - entry = LogEntry( - application='site', - logger_name=record.name, - level=record.levelname.lower(), - module=record.module, - line=record.lineno, - message=self.format(record) - ) - entry.save() diff --git a/pydis_site/apps/api/tests/test_dblogger.py b/pydis_site/apps/api/tests/test_dblogger.py deleted file mode 100644 index bb19f297..00000000 --- a/pydis_site/apps/api/tests/test_dblogger.py +++ /dev/null @@ -1,27 +0,0 @@ -import logging -from datetime import datetime - -from django.test import TestCase - -from ..dblogger import DatabaseLogHandler -from ..models import LogEntry - - -class DatabaseLogHandlerTests(TestCase): - def test_logs_to_database(self): - module_basename = __name__.split('.')[-1] - logger = logging.getLogger(__name__) - logger.handlers = [DatabaseLogHandler()] - logger.warning("I am a test case!") - - # Ensure we only have a single record in the database - # after the logging call above. - [entry] = LogEntry.objects.all() - - self.assertEqual(entry.application, 'site') - self.assertEqual(entry.logger_name, __name__) - self.assertIsInstance(entry.timestamp, datetime) - self.assertEqual(entry.level, 'warning') - self.assertEqual(entry.module, module_basename) - self.assertIsInstance(entry.line, int) - self.assertEqual(entry.message, "I am a test case!") diff --git a/pydis_site/settings.py b/pydis_site/settings.py index 3769fa25..b2e1e7f4 100644 --- a/pydis_site/settings.py +++ b/pydis_site/settings.py @@ -260,9 +260,6 @@ LOGGING = { 'handlers': { 'console': { 'class': 'logging.StreamHandler' - }, - 'database': { - 'class': 'pydis_site.apps.api.dblogger.DatabaseLogHandler' } }, 'loggers': { -- cgit v1.2.3 From 28300128516369de2f235cc7d0427ebceb6aa28d Mon Sep 17 00:00:00 2001 From: ks129 <45097959+ks129@users.noreply.github.com> Date: Sat, 3 Oct 2020 10:09:26 +0300 Subject: Logs Cleanup: Remove another entry of site internal logging to DB --- pydis_site/settings.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'pydis_site/settings.py') diff --git a/pydis_site/settings.py b/pydis_site/settings.py index b2e1e7f4..5eb812ac 100644 --- a/pydis_site/settings.py +++ b/pydis_site/settings.py @@ -264,7 +264,7 @@ LOGGING = { }, 'loggers': { 'django': { - 'handlers': ['console', 'database'], + 'handlers': ['console'], 'propagate': True, 'level': env( 'LOG_LEVEL', -- cgit v1.2.3 From c8c6cb8754bd0917e35eb157925028a9b6f1dcb9 Mon Sep 17 00:00:00 2001 From: Lucas Lindström Date: Tue, 6 Oct 2020 21:29:34 +0200 Subject: Added metricity db connection and user bot API --- docker-compose.yml | 3 +++ postgres/init.sql | 34 +++++++++++++++++++++++ pydis_site/apps/api/viewsets/bot/user.py | 46 ++++++++++++++++++++++++++++++++ pydis_site/settings.py | 3 ++- 4 files changed, 85 insertions(+), 1 deletion(-) create mode 100644 postgres/init.sql (limited to 'pydis_site/settings.py') diff --git a/docker-compose.yml b/docker-compose.yml index 73d2ff85..7287d8d5 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -18,6 +18,8 @@ services: POSTGRES_DB: pysite POSTGRES_PASSWORD: pysite POSTGRES_USER: pysite + volumes: + - ./postgres/init.sql:/docker-entrypoint-initdb.d/init.sql web: build: @@ -40,6 +42,7 @@ services: - staticfiles:/var/www/static environment: DATABASE_URL: postgres://pysite:pysite@postgres:5432/pysite + METRICITY_DB_URL: postgres://pysite:pysite@postgres:5432/metricity SECRET_KEY: suitable-for-development-only STATIC_ROOT: /var/www/static diff --git a/postgres/init.sql b/postgres/init.sql new file mode 100644 index 00000000..fd29ddbc --- /dev/null +++ b/postgres/init.sql @@ -0,0 +1,34 @@ +CREATE DATABASE metricity; + +\c metricity; + +CREATE TABLE users ( + id varchar(255), + name varchar(255) not null, + avatar_hash varchar(255), + joined_at timestamp not null, + created_at timestamp not null, + is_staff boolean not null, + opt_out boolean default false, + bot boolean default false, + is_guild boolean default true, + is_verified boolean default false, + public_flags text default '{}', + verified_at timestamp, + primary key(id) +); + +INSERT INTO users VALUES ( + 0, + 'foo', + 'bar', + current_timestamp, + current_timestamp, + false, + false, + false, + true, + false, + '{}', + NULL +); diff --git a/pydis_site/apps/api/viewsets/bot/user.py b/pydis_site/apps/api/viewsets/bot/user.py index 9571b3d7..0eeacbb3 100644 --- a/pydis_site/apps/api/viewsets/bot/user.py +++ b/pydis_site/apps/api/viewsets/bot/user.py @@ -1,3 +1,10 @@ +import json + +from django.db import connections +from rest_framework import status +from rest_framework.decorators import action +from rest_framework.request import Request +from rest_framework.response import Response from rest_framework.viewsets import ModelViewSet from rest_framework_bulk import BulkCreateModelMixin @@ -53,6 +60,29 @@ class UserViewSet(BulkCreateModelMixin, ModelViewSet): - 200: returned on success - 404: if a user with the given `snowflake` could not be found + ### GET /bot/users//metricity_data + Gets metricity data for a single user by ID. + + #### Response format + >>> { + ... "id": "0", + ... "name": "foo", + ... "avatar_hash": "bar", + ... "joined_at": "2020-10-06T18:17:30.101677", + ... "created_at": "2020-10-06T18:17:30.101677", + ... "is_staff": False, + ... "opt_out": False, + ... "bot": False, + ... "is_guild": True, + ... "is_verified": False, + ... "public_flags": {}, + ... "verified_at": null + ...} + + #### Status codes + - 200: returned on success + - 404: if a user with the given `snowflake` could not be found + ### POST /bot/users Adds a single or multiple new users. The roles attached to the user(s) must be roles known by the site. @@ -115,7 +145,23 @@ class UserViewSet(BulkCreateModelMixin, ModelViewSet): #### Status codes - 204: returned on success - 404: if a user with the given `snowflake` does not exist + + """ serializer_class = UserSerializer queryset = User.objects + + @action(detail=True) + def metricity_data(self, request: Request, pk: str = None) -> Response: + """Request handler for metricity_data endpoint.""" + user = self.get_object() + column_keys = ["id", "name", "avatar_hash", "joined_at", "created_at", "is_staff", + "opt_out", "bot", "is_guild", "is_verified", "public_flags", "verified_at"] + with connections['metricity'].cursor() as cursor: + query = f"SELECT {','.join(column_keys)} FROM users WHERE id = '%s'" + cursor.execute(query, [user.id]) + values = cursor.fetchone() + data = dict(zip(column_keys, values)) + data["public_flags"] = json.loads(data["public_flags"]) + return Response(data, status=status.HTTP_200_OK) diff --git a/pydis_site/settings.py b/pydis_site/settings.py index 3769fa25..2e78e458 100644 --- a/pydis_site/settings.py +++ b/pydis_site/settings.py @@ -172,7 +172,8 @@ WSGI_APPLICATION = 'pydis_site.wsgi.application' # https://docs.djangoproject.com/en/2.1/ref/settings/#databases DATABASES = { - 'default': env.db() + 'default': env.db(), + 'metricity': env.db('METRICITY_DB_URL'), } # Password validation -- cgit v1.2.3 From b53ac936d947ffed135bf5ebde50e043a56adbb2 Mon Sep 17 00:00:00 2001 From: scragly <29337040+scragly@users.noreply.github.com> Date: Mon, 19 Oct 2020 22:25:02 +1000 Subject: Allow requesting API data from internal DNS --- pydis_site/settings.py | 1 + 1 file changed, 1 insertion(+) (limited to 'pydis_site/settings.py') diff --git a/pydis_site/settings.py b/pydis_site/settings.py index 1ae97b86..2b9f77fb 100644 --- a/pydis_site/settings.py +++ b/pydis_site/settings.py @@ -80,6 +80,7 @@ else: 'api.pydis.com', 'admin.pydis.com', 'staff.pydis.com', + 'api.site', ] ) SECRET_KEY = env('SECRET_KEY') -- cgit v1.2.3 From d1dfcc15afef1953b6bede65ff61ccfc1918669e Mon Sep 17 00:00:00 2001 From: Joe Banks Date: Sun, 15 Nov 2020 20:16:20 +0000 Subject: Default to HTTPS for account URLs --- pydis_site/settings.py | 1 + 1 file changed, 1 insertion(+) (limited to 'pydis_site/settings.py') diff --git a/pydis_site/settings.py b/pydis_site/settings.py index 2b9f77fb..204ce58f 100644 --- a/pydis_site/settings.py +++ b/pydis_site/settings.py @@ -393,6 +393,7 @@ AUTHENTICATION_BACKENDS = ( ACCOUNT_ADAPTER = "pydis_site.utils.account.AccountAdapter" ACCOUNT_EMAIL_REQUIRED = False # Undocumented allauth setting; don't require emails ACCOUNT_EMAIL_VERIFICATION = "none" # No verification required; we don't use emails for anything +ACCOUNT_DEFAULT_HTTP_PROTOCOL = "https" # We use this validator because Allauth won't let us actually supply a list with no validators # in it, and we can't just give it a lambda - that'd be too easy, I suppose. -- cgit v1.2.3 From e2e4222ecc52a8743a3829454261ce549bd2408c Mon Sep 17 00:00:00 2001 From: Sebastiaan Zeeff <33516116+SebastiaanZ@users.noreply.github.com> Date: Sat, 12 Dec 2020 00:37:55 +0100 Subject: Change env var from SITE_SENTRY_DSN to SITE_DSN The name of the environment variable was shortened during our refactor of the Sentry secrets. Changed `settings.py` to reflect that change. --- pydis_site/settings.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'pydis_site/settings.py') diff --git a/pydis_site/settings.py b/pydis_site/settings.py index 204ce58f..2b1bfa58 100644 --- a/pydis_site/settings.py +++ b/pydis_site/settings.py @@ -28,7 +28,7 @@ if typing.TYPE_CHECKING: env = environ.Env( DEBUG=(bool, False), - SITE_SENTRY_DSN=(str, "") + SITE_DSN=(str, "") ) sentry_sdk.init( -- cgit v1.2.3 From 233c7904e1e276d78d96dd1c26594f19c162f1f0 Mon Sep 17 00:00:00 2001 From: Sebastiaan Zeeff <33516116+SebastiaanZ@users.noreply.github.com> Date: Sat, 12 Dec 2020 00:42:36 +0100 Subject: Fix incorrectly specified environment variable When I changed the name of SITE_SENTRY_DSN to SITE_DSN, I accidentally left an old reference in place. --- pydis_site/settings.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'pydis_site/settings.py') diff --git a/pydis_site/settings.py b/pydis_site/settings.py index 2b1bfa58..449a343f 100644 --- a/pydis_site/settings.py +++ b/pydis_site/settings.py @@ -32,7 +32,7 @@ env = environ.Env( ) sentry_sdk.init( - dsn=env('SITE_SENTRY_DSN'), + dsn=env('SITE_DSN'), integrations=[DjangoIntegration()], send_default_pii=True, release=f"pydis-site@{GIT_SHA}" -- cgit v1.2.3 From ad6d901a8d2713107d8adf99a9545984106a0683 Mon Sep 17 00:00:00 2001 From: ks129 <45097959+ks129@users.noreply.github.com> Date: Mon, 21 Dec 2020 16:52:55 +0200 Subject: Change pydis-site to site in Sentry SDK initialization --- pydis_site/settings.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'pydis_site/settings.py') diff --git a/pydis_site/settings.py b/pydis_site/settings.py index 449a343f..9b840406 100644 --- a/pydis_site/settings.py +++ b/pydis_site/settings.py @@ -35,7 +35,7 @@ sentry_sdk.init( dsn=env('SITE_DSN'), integrations=[DjangoIntegration()], send_default_pii=True, - release=f"pydis-site@{GIT_SHA}" + release=f"site@{GIT_SHA}" ) # Build paths inside the project like this: os.path.join(BASE_DIR, ...) -- cgit v1.2.3 From 57f389d396ea96b563206935a1d73837b98895ed Mon Sep 17 00:00:00 2001 From: Mark Date: Mon, 4 Jan 2021 16:58:41 -0800 Subject: Use wildcard for ALLOWED_HOSTS in debug mode --- pydis_site/settings.py | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-) (limited to 'pydis_site/settings.py') diff --git a/pydis_site/settings.py b/pydis_site/settings.py index 9b840406..50caab80 100644 --- a/pydis_site/settings.py +++ b/pydis_site/settings.py @@ -47,21 +47,7 @@ DEBUG = env('DEBUG') # SECURITY WARNING: keep the secret key used in production secret! if DEBUG: - ALLOWED_HOSTS = env.list( - 'ALLOWED_HOSTS', - default=[ - 'pythondiscord.local', - 'api.pythondiscord.local', - 'admin.pythondiscord.local', - 'staff.pythondiscord.local', - '0.0.0.0', # noqa: S104 - 'localhost', - 'web', - 'api.web', - 'admin.web', - 'staff.web' - ] - ) + ALLOWED_HOSTS = env.list('ALLOWED_HOSTS', default=['*']) SECRET_KEY = "yellow polkadot bikini" # noqa: S105 elif 'CI' in os.environ: -- cgit v1.2.3 From c00aeb96e1566b7f71ef15cd840895f4e44d5181 Mon Sep 17 00:00:00 2001 From: Joe Banks Date: Wed, 10 Feb 2021 00:36:43 +0000 Subject: Update ALLOWED_HOSTS Add internal domain for API routing and remove legacy routes for pydis.com domains (which are now redirected at the edge) --- pydis_site/settings.py | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) (limited to 'pydis_site/settings.py') diff --git a/pydis_site/settings.py b/pydis_site/settings.py index 50caab80..300452fa 100644 --- a/pydis_site/settings.py +++ b/pydis_site/settings.py @@ -62,11 +62,7 @@ else: 'admin.pythondiscord.com', 'api.pythondiscord.com', 'staff.pythondiscord.com', - 'pydis.com', - 'api.pydis.com', - 'admin.pydis.com', - 'staff.pydis.com', - 'api.site', + 'pydis-api.default.svc.cluster.local', ] ) SECRET_KEY = env('SECRET_KEY') -- cgit v1.2.3