Skip to content

Add app configurations for all apps #1624

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

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
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
42 changes: 42 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,45 @@ openstax/settings/local.py
*.bk
.vscode/settings.json
.env

# Django
*.pot
*.py[cod]
__pycache__/
*.so
.Python
*.mo
*.sqlite3
db.sqlite3
db.sqlite3-journal
local_settings.py

# Wagtail
*.bak
*.swp
*.swo
*~

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
*.egg-info/
.installed.cfg
*.egg

# Unit test / coverage reports
.tox/
.coverage.*
coverage.xml
*.cover
5 changes: 5 additions & 0 deletions accounts/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
"""
Accounts app for OpenStax CMS.
"""

default_app_config = 'accounts.apps.AccountsConfig'
21 changes: 21 additions & 0 deletions accounts/apps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
"""
App configuration for the accounts app.
"""

from django.apps import AppConfig


class AccountsConfig(AppConfig):
"""
App configuration for the accounts app.
"""
name = 'accounts'
verbose_name = 'Accounts'

def ready(self):
"""
Perform initialization when the app is ready.
Import signal handlers here to avoid circular imports.
"""
# Import signal handlers
# import accounts.signals
5 changes: 5 additions & 0 deletions api/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
"""
API app for OpenStax CMS.
"""

default_app_config = 'api.apps.ApiConfig'
20 changes: 20 additions & 0 deletions api/apps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
"""
App configuration for the api app.
"""

from django.apps import AppConfig


class ApiConfig(AppConfig):
"""
App configuration for the api app.
"""
name = 'api'
verbose_name = 'API'

def ready(self):
"""
Perform initialization when the app is ready.
Import signal handlers here to avoid circular imports.
"""
pass
5 changes: 5 additions & 0 deletions books/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
"""
Books app for OpenStax CMS.
"""

default_app_config = 'books.apps.BooksConfig'
21 changes: 21 additions & 0 deletions books/apps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
"""
App configuration for the books app.
"""

from django.apps import AppConfig


class BooksConfig(AppConfig):
"""
App configuration for the books app.
"""
name = 'books'
verbose_name = 'Books'

def ready(self):
"""
Perform initialization when the app is ready.
Import signal handlers here to avoid circular imports.
"""
# Import signal handlers if they exist
# import books.signals
5 changes: 5 additions & 0 deletions donations/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
"""
Donations app for OpenStax CMS.
"""

default_app_config = 'donations.apps.DonationsConfig'
16 changes: 16 additions & 0 deletions donations/apps.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,21 @@
"""
App configuration for the donations app.
"""

from django.apps import AppConfig


class DonationsConfig(AppConfig):
"""
App configuration for the donations app.
"""
name = 'donations'
verbose_name = 'Donations'

def ready(self):
"""
Perform initialization when the app is ready.
Import signal handlers here to avoid circular imports.
"""
# Import signal handlers if they exist
# import donations.signals
5 changes: 5 additions & 0 deletions errata/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
"""
Errata app for OpenStax CMS.
"""

default_app_config = 'errata.apps.ErrataConfig'
19 changes: 19 additions & 0 deletions errata/apps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
"""
App configuration for the errata app.
"""

from django.apps import AppConfig


class ErrataConfig(AppConfig):
"""
App configuration for the errata app.
"""
name = 'errata'
verbose_name = 'Errata'

def ready(self):
"""
Perform initialization when the app is ready.
Import signal handlers here to avoid circular imports.
"""
6 changes: 5 additions & 1 deletion global_settings/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
#default_app_config = 'global_settings.apps.GlobalSettingsConfig'
"""
Global Settings app for OpenStax CMS.
"""

default_app_config = 'global_settings.apps.GlobalSettingsConfig'
16 changes: 13 additions & 3 deletions global_settings/apps.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,22 @@
"""
App configuration for the global_settings app.
"""

from django.apps import AppConfig


class GlobalSettingsConfig(AppConfig):
"""
App configuration for the global_settings app.
"""
name = 'global_settings'
verbose_name = 'global_settings'
default = True

verbose_name = 'Global Settings'

def ready(self):
"""
Perform initialization when the app is ready.
Import signal handlers here to avoid circular imports.
"""
import global_settings.signals # noqa
import api.signals
import donations.signals
Expand Down
5 changes: 5 additions & 0 deletions mail/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
"""
Mail app for OpenStax CMS.
"""

default_app_config = 'mail.apps.MailConfig'
21 changes: 21 additions & 0 deletions mail/apps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
"""
App configuration for the mail app.
"""

from django.apps import AppConfig


class MailConfig(AppConfig):
"""
App configuration for the mail app.
"""
name = 'mail'
verbose_name = 'Mail'

def ready(self):
"""
Perform initialization when the app is ready.
Import signal handlers here to avoid circular imports.
"""
# Import signal handlers if they exist
# import mail.signals
5 changes: 5 additions & 0 deletions news/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
"""
News app for OpenStax CMS.
"""

default_app_config = 'news.apps.NewsConfig'
21 changes: 21 additions & 0 deletions news/apps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
"""
App configuration for the news app.
"""

from django.apps import AppConfig


class NewsConfig(AppConfig):
"""
App configuration for the news app.
"""
name = 'news'
verbose_name = 'News'

def ready(self):
"""
Perform initialization when the app is ready.
Import signal handlers here to avoid circular imports.
"""
# Import signal handlers if they exist
Comment on lines +19 to +20
Copy link
Preview

Copilot AI May 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] If the commented-out signal import is not needed, consider removing it to reduce clutter, or add a note explaining its anticipated future use.

Suggested change
"""
# Import signal handlers if they exist
If signal handlers are added in the future, uncomment the line below to import them.
"""

Copilot uses AI. Check for mistakes.

# import news.signals
26 changes: 26 additions & 0 deletions openstax/settings/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,27 @@
"""
OpenStax CMS Settings

This module imports the appropriate settings based on the environment.
"""

import os

# Determine the environment
ENVIRONMENT = os.getenv('ENVIRONMENT', 'local')

# Import the base settings
from .base import *

# Import environment-specific settings
if ENVIRONMENT == 'prod':
from .prod import *
elif ENVIRONMENT == 'test':
from .test import *
elif ENVIRONMENT == 'docker':
from .docker import *
else:
# Local development
try:
from .local import *
except ImportError:
pass
20 changes: 20 additions & 0 deletions openstax/settings/components/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
"""
Settings components for OpenStax CMS.

This package contains modular settings components that can be imported
and combined to create the final settings for different environments.
"""

from . import core
from . import apps
from . import database
from . import storage
from . import security
from . import logging
from . import api
from . import accounts
from . import cron
from . import i18n
from . import sentry
from . import wagtail
from . import caching
35 changes: 35 additions & 0 deletions openstax/settings/components/accounts.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
"""
OpenStax Accounts settings for OpenStax CMS.

This module contains settings related to OpenStax Accounts integration.
"""

import os

# Base URL for accounts
BASE_URL = os.getenv('BASE_URL', 'https://openstax.org')

# OpenStax Accounts settings
ACCOUNTS_URL = os.getenv('ACCOUNTS_DOMAIN', f'{BASE_URL}/accounts')
AUTHORIZATION_URL = os.getenv('ACCOUNTS_AUTHORIZATION_URL', f'{ACCOUNTS_URL}/oauth/authorize')
ACCESS_TOKEN_URL = os.getenv('ACCOUNTS_ACCESS_TOKEN_URL', f'{ACCOUNTS_URL}/oauth/token')
USER_QUERY = os.getenv('ACCOUNTS_USER_QUERY', f'{ACCOUNTS_URL}/api/user?')
USERS_QUERY = os.getenv('ACCOUNTS_USERS_QUERY', f'{ACCOUNTS_URL}/api/users?')

# Social auth settings
SOCIAL_AUTH_OPENSTAX_KEY = os.getenv('SOCIAL_AUTH_OPENSTAX_KEY')
SOCIAL_AUTH_OPENSTAX_SECRET = os.getenv('SOCIAL_AUTH_OPENSTAX_SECRET')
SOCIAL_AUTH_LOGIN_REDIRECT_URL = os.getenv('SOCIAL_AUTH_LOGIN_REDIRECT_URL', BASE_URL)
SOCIAL_AUTH_SANITIZE_REDIRECTS = os.getenv('SOCIAL_AUTH_SANITIZE_REDIRECTS') == 'True'

# SSO settings
SSO_COOKIE_NAME = os.getenv('SSO_COOKIE_NAME', 'oxa')
SIGNATURE_PUBLIC_KEY = os.getenv('SSO_SIGNATURE_PUBLIC_KEY', """
-----BEGIN PUBLIC KEY-----
MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDjvO/E8lO+ZJ7JMglbJyiF5/Ae
IIS2NKbIAMLBMPVBQY7mSqo6j/yxdVNKZCzYAMDWc/VvEfXQQJ2ipIUuDvO+SOwz
MewQ70hC71hC4s3dmOSLnixDJlnsVpcnKPEFXloObk/fcpK2Vw27e+yY+kIFmV2X
zrvTnmm9UJERp6tVTQIDAQAB
-----END PUBLIC KEY-----
""")
ENCRYPTION_PRIVATE_KEY = os.getenv('SSO_ENCRYPTION_PRIVATE_KEY', "c6d9b8683fddce8f2a39ac0565cf18ee")
20 changes: 20 additions & 0 deletions openstax/settings/components/api.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
"""
REST Framework settings for OpenStax CMS.

This module contains settings for Django REST Framework.
"""

# Django Rest Framework settings
REST_FRAMEWORK = {
'DEFAULT_FILTER_BACKENDS': ('django_filters.rest_framework.DjangoFilterBackend',),
'DEFAULT_AUTHENTICATION_CLASSES': (
'rest_framework.authentication.TokenAuthentication',
),
'DEFAULT_PERMISSION_CLASSES': (
'rest_framework.permissions.AllowAny',
),
'DEFAULT_VERSIONING_CLASS': 'rest_framework.versioning.URLPathVersioning',
'DEFAULT_VERSION': 'v1',
'DEFAULT_PAGINATION_CLASS': 'rest_framework.pagination.PageNumberPagination',
'PAGE_SIZE': 100
}
Loading