Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Clean autoconfig #1698

Merged
merged 4 commits into from
Sep 5, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ ignore:
- "aimmo_runner/**/*"
- "test_utils/*"
- "setup.py"
- "aimmo/csp_config.py"

comment:
layout: "reach, diff, flags, files"
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ db.sqlite3
*.iml

# static folder
example_project/example_project/static/
static/

# Created during minikube testing
test-bin/
Expand Down
76 changes: 38 additions & 38 deletions Pipfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 0 additions & 16 deletions aimmo/csp_config.py

This file was deleted.

2 changes: 1 addition & 1 deletion aimmo_runner/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ def run(
capture_output=capture_output,
)
run_command(
["python", _MANAGE_PY, "collectstatic", "--noinput"],
["python", _MANAGE_PY, "collectstatic", "--noinput", "--clear"],
capture_output=capture_output,
)

Expand Down
2 changes: 1 addition & 1 deletion example_project/manage.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from kubernetes.config import load_kube_config

if __name__ == "__main__":
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "example_project.settings")
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "settings")

from django.core.management import execute_from_command_line

Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
"""Django settings for example_project project."""
import os
import mimetypes
import os

from django.http import Http404
from kubernetes.client.api.custom_objects_api import CustomObjectsApi
from kubernetes.client.api_client import ApiClient

from aimmo.csp_config import * # Still keeping the config file, seems cleaner?
BASE_DIR = os.path.dirname(os.path.dirname(__file__))

ALLOWED_HOSTS = ["*"]

Expand All @@ -29,36 +29,37 @@

TIME_ZONE = "Europe/London"
LANGUAGE_CODE = "en-gb"
STATIC_ROOT = os.path.join(os.path.dirname(__file__), "static")
STATIC_ROOT = os.path.join(BASE_DIR, "static")
STATIC_URL = "/static/"
SECRET_KEY = "not-a-secret"
STATICFILES_DIRS = [os.path.join(BASE_DIR, "aimmo/static")]

mimetypes.add_type("application/wasm", ".wasm", True)

ROOT_URLCONF = "example_project.urls"
SECRET_KEY = "not-a-secret"
ROOT_URLCONF = "urls"

WSGI_APPLICATION = "example_project.wsgi.application"

DEFAULT_AUTO_FIELD = "django.db.models.AutoField"

INSTALLED_APPS = [
"game",
"pipeline",
"portal",
"aimmo",
"common",
"django.contrib.admin",
"django.contrib.admindocs",
"django.contrib.auth",
"django.contrib.contenttypes",
"django.contrib.sessions",
"django.contrib.messages",
"django.contrib.sites",
"django.contrib.staticfiles",
"aimmo",
"game",
"portal",
"common",
"django_js_reverse",
"rest_framework",
"django_otp",
"django_otp.plugins.otp_static",
"django_otp.plugins.otp_totp",
"rest_framework",
"sekizai", # for javascript and css management
]

Expand Down Expand Up @@ -99,6 +100,37 @@
"django.contrib.messages.middleware.MessageMiddleware",
]

PIPELINE = {
"SASS_ARGUMENTS": "--quiet",
"COMPILERS": ("game.pipeline_compilers.LibSassCompiler",),
"STYLESHEETS": {
"css": {
"source_filenames": (
os.path.join(BASE_DIR, "static/portal/sass/bootstrap.scss"),
os.path.join(BASE_DIR, "static/portal/sass/colorbox.scss"),
os.path.join(BASE_DIR, "static/portal/sass/styles.scss"),
),
"output_filename": "portal.css",
},
"popup": {
"source_filenames": (os.path.join(BASE_DIR, "static/portal/sass/partials/_popup.scss"),),
"output_filename": "popup.css",
},
"game-scss": {
"source_filenames": (os.path.join(BASE_DIR, "static/game/sass/game.scss"),),
"output_filename": "game.css",
},
},
"CSS_COMPRESSOR": None,
}

STATICFILES_FINDERS = [
"pipeline.finders.PipelineFinder",
"django.contrib.staticfiles.finders.FileSystemFinder",
"django.contrib.staticfiles.finders.AppDirectoriesFinder",
]
STATICFILES_STORAGE = "pipeline.storage.PipelineStorage"

# This is used in common to enable/disable the OneTrust cookie management script
COOKIE_MANAGEMENT_ENABLED = False

Expand Down Expand Up @@ -138,3 +170,5 @@ def get_game_url_base_and_path(game_id: int) -> str:
from example_project.local_settings import * # pylint: disable=E0611
except ImportError:
pass

from common.csp_config import *
54 changes: 45 additions & 9 deletions test_settings.py → example_project/test_settings.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
import os

BASE_DIR = os.path.dirname(os.path.dirname(__file__))

DATABASES = {"default": {"ENGINE": "django.db.backends.sqlite3"}}

TEMPLATES = [
Expand All @@ -17,33 +21,34 @@
]

INSTALLED_APPS = [
"game",
"pipeline",
"portal",
"aimmo",
"common",
"django.contrib.admin",
"django.contrib.admindocs",
"django.contrib.auth",
"django.contrib.contenttypes",
"django.contrib.sessions",
"django.contrib.messages",
"django.contrib.sites",
"django.contrib.staticfiles",
"aimmo",
"game",
"portal",
"common",
"django_js_reverse",
"rest_framework",
"django_otp",
"django_otp.plugins.otp_static",
"django_otp.plugins.otp_totp",
"rest_framework",
"sekizai", # for javascript and css management
]

PIPELINE_ENABLED = False
ROOT_URLCONF = "example_project.example_project.urls"
STATIC_ROOT = "example_project/example_project/static"
ROOT_URLCONF = "example_project.urls"
STATIC_ROOT = os.path.join(BASE_DIR, "static")
STATIC_URL = "/static/"
STATICFILES_DIRS = [os.path.join(BASE_DIR, "aimmo/static")]
SECRET_KEY = "bad_test_secret"

WSGI_APPLICATION = "example_project.wsgi.application"
WSGI_APPLICATION = "wsgi.application"

MIDDLEWARE = [
"django.contrib.sessions.middleware.SessionMiddleware",
Expand All @@ -54,6 +59,37 @@
"django.contrib.messages.middleware.MessageMiddleware",
]

PIPELINE = {
"SASS_ARGUMENTS": "--quiet",
"COMPILERS": ("game.pipeline_compilers.LibSassCompiler",),
"STYLESHEETS": {
"css": {
"source_filenames": (
os.path.join(BASE_DIR, "static/portal/sass/bootstrap.scss"),
os.path.join(BASE_DIR, "static/portal/sass/colorbox.scss"),
os.path.join(BASE_DIR, "static/portal/sass/styles.scss"),
),
"output_filename": "portal.css",
},
"popup": {
"source_filenames": (os.path.join(BASE_DIR, "static/portal/sass/partials/_popup.scss"),),
"output_filename": "popup.css",
},
"game-scss": {
"source_filenames": (os.path.join(BASE_DIR, "static/game/sass/game.scss"),),
"output_filename": "game.css",
},
},
"CSS_COMPRESSOR": None,
}

STATICFILES_FINDERS = [
"pipeline.finders.PipelineFinder",
"django.contrib.staticfiles.finders.FileSystemFinder",
"django.contrib.staticfiles.finders.AppDirectoriesFinder",
]
STATICFILES_STORAGE = "pipeline.storage.PipelineStorage"

GAME_SERVER_URL_FUNCTION = lambda game_id: ("base %s" % game_id, "path %s" % game_id)
GAME_SERVER_PORT_FUNCTION = lambda game_id: 8001
GAME_SERVER_SSL_FLAG = False
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"""
import os

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "example_project.settings")
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "settings")

from django.core.wsgi import get_wsgi_application

Expand Down
Loading