Skip to content

Actions workflow updates + settings module cleanup #45

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

Merged
merged 3 commits into from
Mar 24, 2025
Merged
Show file tree
Hide file tree
Changes from all 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
11 changes: 4 additions & 7 deletions .github/workflows/pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,14 @@ concurrency:
cancel-in-progress: true

jobs:
# Build job
build:
runs-on: ubuntu-latest
defaults:
run:
working-directory: docs
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Setup Ruby
uses: ruby/setup-ruby@v1
with:
Expand All @@ -45,19 +44,17 @@ jobs:
working-directory: '${{ github.workspace }}/docs' # Use docs/ directory
- name: Setup Pages
id: pages
uses: actions/configure-pages@v3
uses: actions/configure-pages@v4
- name: Build with Jekyll
# Outputs to the './_site' directory by default
run: bundle exec jekyll build --baseurl "${{ steps.pages.outputs.base_path }}"
env:
JEKYLL_ENV: production
- name: Upload artifact
# Automatically uploads an artifact from the './_site' directory by default
uses: actions/upload-pages-artifact@v1
uses: actions/upload-pages-artifact@v3
with:
path: "docs/_site/"

# Deployment job
deploy:
environment:
name: github-pages
Expand All @@ -67,4 +64,4 @@ jobs:
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v2
uses: actions/deploy-pages@v4
3 changes: 1 addition & 2 deletions src/contestsuite/context_processors.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from .settings import CACHE_TIMEOUT, DEBUG, GTAG, PCS_DOCS_URL

from contestsuite.settings import CACHE_TIMEOUT, DEBUG, GTAG, PCS_DOCS_URL

def app_settings(request):
"""
Expand Down
3 changes: 1 addition & 2 deletions src/contestsuite/flowerconfig.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from contestsuite.settings import get_secret


# Celery Flower configuration
# https://flower.readthedocs.io/en/latest/config.html

Expand All @@ -13,7 +12,7 @@

if not debug:
basic_auth = [
get_secret('FLOWER_USER', 'contestadmin') + ':' + get_secret('FLOWER_PASSWORD', 'seminoles1!')
f"{get_secret('FLOWER_USER', 'contestadmin')}:{get_secret('FLOWER_PASSWORD', 'seminoles1!')}"
]

if get_secret('FLOWER_COOKIE_KEY'):
Expand Down
27 changes: 13 additions & 14 deletions src/contestsuite/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,14 @@
Generated by 'django-admin startproject' using Django 2.2.5.

For more information on this file, see
https://docs.djangoproject.com/en/2.2/topics/settings/
https://docs.djangoproject.com/en/4.2/topics/settings/

For the full list of settings and their values, see
https://docs.djangoproject.com/en/2.2/ref/settings/
https://docs.djangoproject.com/en/4.2/ref/settings/
"""

import os


def get_secret(key, default=None):
"""
Simple function to read an environment variable and return a default if the variable
Expand All @@ -26,13 +25,12 @@ def get_secret(key, default=None):
return f.read().strip()
return value


# Build paths inside the project like this: os.path.join(BASE_DIR, ...)

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

# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/2.2/howto/deployment/checklist/
# See https://docs.djangoproject.com/en/4.2/howto/deployment/checklist/

# SECURITY WARNING: keep the secret key used in production secret!
# Raises django's ImproperlyConfigured exception if SECRET_KEY not in os.environ
Expand All @@ -56,7 +54,7 @@ def get_secret(key, default=None):
if os.getenv('ALLOWED_HOSTS'):
ALLOWED_HOSTS = ALLOWED_HOSTS + get_secret('ALLOWED_HOSTS').split(',')
CSRF_TRUSTED_ORIGINS = [
'https://'+hostname if 'https://' not in hostname else hostname for hostname in ALLOWED_HOSTS]
f"https://{hostname}" if 'https://' not in hostname else hostname for hostname in ALLOWED_HOSTS]


# Application definition
Expand Down Expand Up @@ -120,7 +118,7 @@ def get_secret(key, default=None):


# Database
# https://docs.djangoproject.com/en/2.2/ref/settings/#databases
# https://docs.djangoproject.com/en/4.2/ref/settings/#databases

# Parse database connection url strings like psql://user:pass@127.0.0.1:8458/db
# read os.environ['DATABASE_URL'] and raises ImproperlyConfigured exception if not found
Expand All @@ -144,7 +142,7 @@ def get_secret(key, default=None):


# Cache
# https://docs.djangoproject.com/en/2.2/ref/settings/#caches
# https://docs.djangoproject.com/en/4.2/ref/settings/#caches

CACHES = {
'default': {
Expand All @@ -160,7 +158,7 @@ def get_secret(key, default=None):


# Password validation
# https://docs.djangoproject.com/en/2.2/ref/settings/#auth-password-validators
# https://docs.djangoproject.com/en/4.2/ref/settings/#auth-password-validators

AUTH_PASSWORD_VALIDATORS = [
{
Expand All @@ -179,7 +177,7 @@ def get_secret(key, default=None):


# Internationalization
# https://docs.djangoproject.com/en/2.2/topics/i18n/
# https://docs.djangoproject.com/en/4.2/topics/i18n/

LANGUAGE_CODE = 'en-us'

Expand All @@ -193,7 +191,7 @@ def get_secret(key, default=None):


# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/2.2/howto/static-files/
# https://docs.djangoproject.com/en/4.2/howto/static-files/

STATIC_ROOT = os.path.join(BASE_DIR, 'static')
STATIC_URL = 'static/'
Expand All @@ -214,7 +212,7 @@ def get_secret(key, default=None):


# Sessions
# https://docs.djangoproject.com/en/3.2/topics/http/sessions/
# https://docs.djangoproject.com/en/4.2/topics/http/sessions/

SESSION_ENGINE = 'django.contrib.sessions.backends.cache'

Expand All @@ -223,13 +221,13 @@ def get_secret(key, default=None):


# Messages
# https://docs.djangoproject.com/en/3.2/ref/contrib/messages/
# https://docs.djangoproject.com/en/4.2/ref/contrib/messages/

MESSAGE_STORAGE = 'django.contrib.messages.storage.session.SessionStorage'


# Email
# https://docs.djangoproject.com/en/3.1/topics/email/
# https://docs.djangoproject.com/en/4.2/topics/email/

if DEBUG:
EMAIL_BACKEND = get_secret('EMAIL_BACKEND', 'django.core.mail.backends.console.EmailBackend')
Expand Down Expand Up @@ -272,6 +270,7 @@ def get_secret(key, default=None):

CELERY_BEAT_SCHEDULE = {}


# Discord
# https://discordpy.readthedocs.io/en/stable/

Expand Down
5 changes: 2 additions & 3 deletions src/contestsuite/urls.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""contestsuite URL Configuration

The `urlpatterns` list routes URLs to views. For more information please see:
https://docs.djangoproject.com/en/2.2/topics/http/urls/
https://docs.djangoproject.com/en/4.2/topics/http/urls/
Examples:
Function views
1. Add an import: from my_app import views
Expand All @@ -13,11 +13,10 @@
1. Import the include() function: from django.urls import include, path
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
"""

from django.contrib import admin
from django.urls import include, path

from .settings import DEBUG

urlpatterns = [
path('', include('core.urls')),
path('accounts/', include('django.contrib.auth.urls')),
Expand Down
2 changes: 1 addition & 1 deletion src/contestsuite/wsgi.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
It exposes the WSGI callable as a module-level variable named ``application``.

For more information on this file, see
https://docs.djangoproject.com/en/3.2/howto/deployment/wsgi/
https://docs.djangoproject.com/en/4.2/howto/deployment/wsgi/
"""

import os
Expand Down