Skip to content

Commit

Permalink
Merge pull request #527 from jbernal0019/master
Browse files Browse the repository at this point in the history
Upgrade to Django 4.2.5 and postgres:16
  • Loading branch information
jbernal0019 authored Sep 21, 2023
2 parents 2a509d6 + 345a34d commit b7e7840
Show file tree
Hide file tree
Showing 11 changed files with 56 additions and 54 deletions.
2 changes: 1 addition & 1 deletion chris_backend/config/asgi.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
It exposes the ASGI callable as a module-level variable named ``application``.
For more information on this file, see
https://docs.djangoproject.com/en/4.0/howto/deployment/asgi/
https://docs.djangoproject.com/en/4.2/howto/deployment/asgi/
"""

import os, sys
Expand Down
26 changes: 14 additions & 12 deletions chris_backend/config/settings/common.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
# -*- coding: utf-8 -*-
"""
Django settings for mysite project.
Django settings for chris_backend project.
Generated by 'django-admin startproject' using Django 4.0.
Generated by 'django-admin startproject' using Django 4.2.5.
For more information on this file, see
https://docs.djangoproject.com/en/4.0/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/4.0/ref/settings/
https://docs.djangoproject.com/en/4.2/ref/settings/
"""

from pathlib import Path
Expand Down Expand Up @@ -105,7 +105,7 @@


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

DATABASES = {
'default': {
Expand All @@ -115,7 +115,7 @@


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

AUTH_PASSWORD_VALIDATORS = [
{
Expand All @@ -134,31 +134,33 @@


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

LANGUAGE_CODE = 'en-us'

TIME_ZONE = 'America/New_York'

USE_I18N = True

USE_L10N = True

USE_TZ = True


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

STATIC_URL = '/static/'

# https://whitenoise.readthedocs.io/en/stable/django.html
STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage'
STORAGES = {
'staticfiles': {
'BACKEND': 'whitenoise.storage.CompressedManifestStaticFilesStorage',
},
}

# `./manage.py collectstatic` is run during build
STATIC_ROOT = '/opt/app-root/var/staticfiles'

# Default primary key field type
# https://docs.djangoproject.com/en/4.0/ref/settings/#default-auto-field
# https://docs.djangoproject.com/en/4.2/ref/settings/#default-auto-field

DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
14 changes: 7 additions & 7 deletions chris_backend/config/settings/local.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,20 @@
from django.core.exceptions import ImproperlyConfigured

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

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 'w1kxu^l=@pnsf!5piqz6!!5kdcdpo79y6jebbp+2244yjm*#+k'

# Hosts/domain names that are valid for this site
# See https://docs.djangoproject.com/en/4.0/ref/settings/#allowed-hosts
# See https://docs.djangoproject.com/en/4.2/ref/settings/#allowed-hosts
ALLOWED_HOSTS = ['*']

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True

# LOGGING CONFIGURATION
# See https://docs.djangoproject.com/en/4.0/topics/logging/ for
# See https://docs.djangoproject.com/en/4.2/topics/logging/ for
# more details on how to customize your logging configuration.
LOGGING = {
'version': 1,
Expand Down Expand Up @@ -87,7 +87,7 @@
if STORAGE_ENV not in ('swift', 'filesystem'):
raise ImproperlyConfigured(f"Unsupported value '{STORAGE_ENV}' for STORAGE_ENV")

DEFAULT_FILE_STORAGE = 'swift.storage.SwiftStorage'
STORAGES['default'] = {'BACKEND': 'swift.storage.SwiftStorage'}
SWIFT_AUTH_URL = 'http://swift_service:8080/auth/v1.0' # Swift service settings
SWIFT_USERNAME = 'chris:chris1234'
SWIFT_KEY = 'testing'
Expand All @@ -97,12 +97,12 @@
'authurl': SWIFT_AUTH_URL}
MEDIA_ROOT = None
if STORAGE_ENV == 'filesystem':
DEFAULT_FILE_STORAGE = 'django.core.files.storage.FileSystemStorage'
STORAGES['default'] = {'BACKEND': 'django.core.files.storage.FileSystemStorage'}
MEDIA_ROOT = '/var/chris' # local filesystem storage settings

try:
verify_storage_connection(
DEFAULT_FILE_STORAGE=DEFAULT_FILE_STORAGE,
DEFAULT_FILE_STORAGE=STORAGES['default']['BACKEND'],
MEDIA_ROOT=MEDIA_ROOT,
SWIFT_CONTAINER_NAME=SWIFT_CONTAINER_NAME,
SWIFT_CONNECTION_PARAMS=SWIFT_CONNECTION_PARAMS
Expand All @@ -114,7 +114,7 @@
CHRIS_STORE_URL = 'http://chris-store.local:8010/api/v1/'

# Database
# https://docs.djangoproject.com/en/4.0/ref/settings/#databases
# https://docs.djangoproject.com/en/4.2/ref/settings/#databases
DATABASES['default']['NAME'] = 'chris_dev'
DATABASES['default']['USER'] = 'chris'
DATABASES['default']['PASSWORD'] = 'Chris1234'
Expand Down
15 changes: 7 additions & 8 deletions chris_backend/config/settings/production.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,22 +30,21 @@ def get_secret(setting, secret_type=env):

# SECRET CONFIGURATION
# ------------------------------------------------------------------------------
# See: https://docs.djangoproject.com/en/4.0/ref/settings/#secret-key
# See: https://docs.djangoproject.com/en/4.2/ref/settings/#secret-key
# Raises ImproperlyConfigured exception if DJANGO_SECRET_KEY not in os.environ
SECRET_KEY = get_secret('DJANGO_SECRET_KEY')


# SITE CONFIGURATION
# ------------------------------------------------------------------------------
# Hosts/domain names that are valid for this site
# See https://docs.djangoproject.com/en/4.0/ref/settings/#allowed-hosts
# See https://docs.djangoproject.com/en/4.2/ref/settings/#allowed-hosts
ALLOWED_HOSTS = get_secret('DJANGO_ALLOWED_HOSTS', env.list)
# END SITE CONFIGURATION


# DATABASE CONFIGURATION
# ------------------------------------------------------------------------------
# Raises ImproperlyConfigured exception if DATABASE_URL not set
DATABASES['default']['NAME'] = get_secret('POSTGRES_DB')
DATABASES['default']['USER'] = get_secret('POSTGRES_USER')
DATABASES['default']['PASSWORD'] = get_secret('POSTGRES_PASSWORD')
Expand All @@ -60,7 +59,7 @@ def get_secret(setting, secret_type=env):
raise ImproperlyConfigured(f"Unsupported value '{STORAGE_ENV}' for STORAGE_ENV")

if STORAGE_ENV == 'swift':
DEFAULT_FILE_STORAGE = 'swift.storage.SwiftStorage'
STORAGES['default'] = {'BACKEND': 'swift.storage.SwiftStorage'}
SWIFT_AUTH_URL = get_secret('SWIFT_AUTH_URL')
SWIFT_USERNAME = get_secret('SWIFT_USERNAME')
SWIFT_KEY = get_secret('SWIFT_KEY')
Expand All @@ -69,14 +68,14 @@ def get_secret(setting, secret_type=env):
'key': SWIFT_KEY,
'authurl': SWIFT_AUTH_URL}
verify_storage = lambda: verify_storage_connection(
DEFAULT_FILE_STORAGE=DEFAULT_FILE_STORAGE,
DEFAULT_FILE_STORAGE=STORAGES['default']['BACKEND'],
SWIFT_CONTAINER_NAME=SWIFT_CONTAINER_NAME,
SWIFT_CONNECTION_PARAMS=SWIFT_CONNECTION_PARAMS
)
elif STORAGE_ENV == 'filesystem':
DEFAULT_FILE_STORAGE = 'django.core.files.storage.FileSystemStorage'
STORAGES['default'] = {'BACKEND': 'django.core.files.storage.FileSystemStorage'}
MEDIA_ROOT = get_secret('MEDIA_ROOT')
verify_storage = lambda: verify_storage_connection(DEFAULT_FILE_STORAGE=DEFAULT_FILE_STORAGE,
verify_storage = lambda: verify_storage_connection(DEFAULT_FILE_STORAGE=STORAGES['default']['BACKEND'],
MEDIA_ROOT=MEDIA_ROOT)
else:
verify_storage = lambda: verify_storage_connection()
Expand All @@ -92,7 +91,7 @@ def get_secret(setting, secret_type=env):


# LOGGING CONFIGURATION
# See https://docs.djangoproject.com/en/4.0/topics/logging/ for
# See https://docs.djangoproject.com/en/4.2/topics/logging/ for
# more details on how to customize your logging configuration.
ADMINS = [('FNNDSC Developers', '[email protected]')]
LOGGING = {
Expand Down
5 changes: 3 additions & 2 deletions chris_backend/config/urls.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
"""chris_backend URL Configuration
"""
URL configuration for chris_backend project.
The `urlpatterns` list routes URLs to views. For more information please see:
https://docs.djangoproject.com/en/4.0/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 Down
4 changes: 2 additions & 2 deletions chris_backend/config/wsgi.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
"""
WSGI config for mysite project.
WSGI config for chris_backend project.
It exposes the WSGI callable as a module-level variable named ``application``.
For more information on this file, see
https://docs.djangoproject.com/en/4.0/howto/deployment/wsgi/
https://docs.djangoproject.com/en/4.2/howto/deployment/wsgi/
"""

import os, sys
Expand Down
4 changes: 2 additions & 2 deletions docker-compose_dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ services:
role: "Backend development periodic tasks scheduler"

chris_dev_db:
image: postgres:13
image: postgres:16
volumes:
- chris_dev_db_data:/var/lib/postgresql/data
environment:
Expand Down Expand Up @@ -246,7 +246,7 @@ services:
role: "Chris store service"

chris_store_db:
image: postgres:13
image: postgres:16
volumes:
- chris_store_db_data:/var/lib/postgresql/data
environment:
Expand Down
4 changes: 2 additions & 2 deletions docker-compose_noswift.yml
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ services:
role: "Backend development periodic tasks scheduler"

chris_dev_db:
image: postgres:13
image: postgres:16
volumes:
- chris_dev_db_data:/var/lib/postgresql/data
environment:
Expand Down Expand Up @@ -214,7 +214,7 @@ services:
role: "Chris store service"

chris_store_db:
image: postgres:13
image: postgres:16
volumes:
- chris_store_db_data:/var/lib/postgresql/data
environment:
Expand Down
2 changes: 1 addition & 1 deletion make.sh
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ rm -f dc.out ; title -d 1 "Pulling non-'local/' core containers where needed"
printf "${LightCyan}%13s${Green}%-67s${Yellow}\n" \
"$ docker pull" " library/postgres" | ./boxes.sh
windowBottom
docker pull postgres:13 >& dc.out
docker pull postgres:16 >& dc.out
dc_check $? "PRINT"
echo "" | ./boxes.sh
printf "${LightCyan}%13s${Green}%-67s${Yellow}\n" \
Expand Down
20 changes: 10 additions & 10 deletions requirements/base.txt
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
Django==4.0
django-filter==22.1
djangorestframework==3.13.1
django-cors-headers==3.13.0
psycopg2==2.9.3
Django==4.2.5
django-filter==23.3
djangorestframework==3.14.0
django-cors-headers==4.2.0
psycopg[binary,pool]
environs==9.5.0
python-swiftclient==4.1.0
django-storage-swift==1.2.19
celery==5.2.7
django-celery-beat==2.3.0
python-swiftclient==4.4.0
django-storage-swift==1.3.0
celery==5.3.4
django-celery-beat==2.5.0
python-chrisstoreclient==1.0.0
python-pfconclient==3.2.0
django-auth-ldap==4.1.0
django-auth-ldap==4.5.0
PyYAML==6.0.1
whitenoise[brotli]==6.5.0
14 changes: 7 additions & 7 deletions requirements/local.txt
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# Local development dependencies go here
-r base.txt
django-debug-toolbar==3.6.0
django-extensions==3.2.0
django-debug-toolbar==4.2.0
django-extensions==3.2.3
collection-json==0.1.1
coverage==6.4.4
pylint==2.15.0
flake8==5.0.4
isort==5.10.1
pudb>=2019.1
coverage==7.3.1
pylint==2.17.5
flake8==6.1.0
isort==5.12.0
pudb==2022.1.3
https://github.com/msbrogli/rpudb/archive/master.zip

0 comments on commit b7e7840

Please sign in to comment.