Skip to content

Commit

Permalink
Merge branch 'develop' of https://github.com/hackforla/CivicTechJobs
Browse files Browse the repository at this point in the history
…into adding-prettier-and-eslint-frontend-588
  • Loading branch information
irais-valenzuela committed Nov 5, 2024
2 parents e0094b3 + 0b2399b commit da28a37
Show file tree
Hide file tree
Showing 63 changed files with 933 additions and 571 deletions.
2 changes: 1 addition & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ docs/
.gitignore

# Builds
backend/vite_assets_dist
backend/frontend/static/vite_assets_dist

# vite
frontend/vite.config.*.timestamp-*
71 changes: 43 additions & 28 deletions .github/workflows/mkdocs-build.yml
Original file line number Diff line number Diff line change
@@ -1,28 +1,43 @@
name: CI for MkDocs
on:
push:
branches:
- develop
permissions:
contents: write
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Configure Git Credentials
run: |
git config user.name github-actions[bot]
git config user.email 41898282+github-actions[bot]@users.noreply.github.com
- uses: actions/setup-python@v5
with:
python-version: 3.x
- run: echo "cache_id=$(date --utc '+%V')" >> $GITHUB_ENV
- uses: actions/cache@v4
with:
key: mkdocs-material-${{ env.cache_id }}
path: .cache
restore-keys: |
mkdocs-material-
- run: pip install mkdocs-material
- run: mkdocs gh-deploy --force
name: Build MkDocs site (develop)

on:
push:
branches:
# TODO: change to main when we merge develop to main
- develop
paths:
- "mkdocs/**/**.md"
- "mkdocs/mkdocs.yml"
workflow_dispatch:

permissions:
contents: write

jobs:
deploy-docs:
runs-on: ubuntu-latest
if: github.actor != 'github-actions[bot]'
steps:
- uses: actions/checkout@v4
- name: Configure Git Credentials
run: |
git config user.name github-actions[bot]
git config user.email 41898282+github-actions[bot]@users.noreply.github.com
- uses: actions/setup-python@v5
with:
python-version: 3.x
- run: echo "cache_id=$(date --utc '+%V')" >> $GITHUB_ENV
- uses: actions/cache@v4
with:
key: mkdocs-material-${{ env.cache_id }}
path: .cache
restore-keys: |
mkdocs-material-
- name: Install Dependencies
run: pip install \
mkdocs-material==9.1.17 \
mkdocs-autolinks-plugin==0.7.1
- name: Publish docs
run: |
cd mkdocs
mkdocs gh-deploy --force
9 changes: 9 additions & 0 deletions backend/.flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[flake8]
max-line-length = 88
extend-ignore = E203, W503
exclude =
.git,
__pycache__,
migrations,
venv,
settings.py
1 change: 1 addition & 0 deletions backend/.python-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.12.4
34 changes: 0 additions & 34 deletions backend/Dockerfile

This file was deleted.

2 changes: 1 addition & 1 deletion backend/backend/asgi.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@

from django.core.asgi import get_asgi_application

os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'backend.settings')
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "backend.settings")

application = get_asgi_application()
112 changes: 59 additions & 53 deletions backend/backend/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@
"""

from pathlib import Path

from decouple import config

VERSION = '1.0.0'
VERSION = "1.0.0"

# Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = Path(__file__).resolve().parent.parent
Expand All @@ -23,68 +24,68 @@
# See https://docs.djangoproject.com/en/5.0/howto/deployment/checklist/

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = config('SECRET_KEY')
SECRET_KEY = config("SECRET_KEY")

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = config('DEBUG', default=False, cast=bool)
DEBUG = config("DEBUG", default=False, cast=bool)

ALLOWED_HOSTS = config("DJANGO_ALLOWED_HOSTS", default="localhost").split(" ")

# Application definition

INSTALLED_APPS = [
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'ctj_api.apps.CtjApiConfig',
'rest_framework',
"django.contrib.auth",
"django.contrib.contenttypes",
"django.contrib.sessions",
"django.contrib.messages",
"django.contrib.staticfiles",
"ctj_api.apps.CtjApiConfig",
"rest_framework",
"django_vite",
]

MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
"django.middleware.security.SecurityMiddleware",
"django.contrib.sessions.middleware.SessionMiddleware",
"django.middleware.common.CommonMiddleware",
"django.middleware.csrf.CsrfViewMiddleware",
"django.contrib.auth.middleware.AuthenticationMiddleware",
"django.contrib.messages.middleware.MessageMiddleware",
"django.middleware.clickjacking.XFrameOptionsMiddleware",
]

ROOT_URLCONF = 'backend.urls'
ROOT_URLCONF = "backend.urls"

TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [BASE_DIR / 'frontend/templates/frontend'],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
"BACKEND": "django.template.backends.django.DjangoTemplates",
"DIRS": [BASE_DIR / "frontend/templates/frontend"],
"APP_DIRS": True,
"OPTIONS": {
"context_processors": [
"django.template.context_processors.debug",
"django.template.context_processors.request",
"django.contrib.auth.context_processors.auth",
"django.contrib.messages.context_processors.messages",
],
},
},
]

WSGI_APPLICATION = 'backend.wsgi.application'
WSGI_APPLICATION = "backend.wsgi.application"


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

DATABASES = {
'default': {
'ENGINE': config('SQL_ENGINE'),
'NAME': config('SQL_DATABASE'),
'USER': config('SQL_USER'),
'PASSWORD': config('SQL_PASSWORD'),
'HOST': config('SQL_HOST'),
'PORT': config('SQL_PORT'),
"default": {
"ENGINE": config("SQL_ENGINE"),
"NAME": config("SQL_DATABASE"),
"USER": config("SQL_USER"),
"PASSWORD": config("SQL_PASSWORD"),
"HOST": config("SQL_HOST"),
"PORT": config("SQL_PORT"),
}
}

Expand All @@ -93,26 +94,26 @@

AUTH_PASSWORD_VALIDATORS = [
{
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
"NAME": "django.contrib.auth.password_validation.UserAttributeSimilarityValidator",
},
{
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
"NAME": "django.contrib.auth.password_validation.MinimumLengthValidator",
},
{
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
"NAME": "django.contrib.auth.password_validation.CommonPasswordValidator",
},
{
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
"NAME": "django.contrib.auth.password_validation.NumericPasswordValidator",
},
]


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

LANGUAGE_CODE = 'en-us'
LANGUAGE_CODE = "en-us"

TIME_ZONE = 'UTC'
TIME_ZONE = "UTC"

USE_I18N = True

Expand All @@ -122,27 +123,32 @@
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/5.0/howto/static-files/

STATIC_URL = 'static/'
STATIC_URL = "static/"

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

DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
DEFAULT_AUTO_FIELD = "django.db.models.BigAutoField"


# django-vite settings
# https://github.com/MrBin99/django-vite
DJANGO_VITE = {
"default": {
# enable vite HMR in dev mode
"dev_mode": config("DEBUG", default=False, cast=bool),
"dev_server_port": 5175,
# resolve static asset paths in production
"manifest_path": Path(BASE_DIR / "frontend" / "static" / "vite_assets_dist" / ".vite" / "manifest.json").resolve()
}
"default": {
# enable vite HMR in dev mode
"dev_mode": config("DEBUG", default=False, cast=bool),
"dev_server_port": 5175,
# resolve static asset paths in production
"manifest_path": Path(
BASE_DIR
/ "frontend"
/ "static"
/ "vite_assets_dist"
/ ".vite"
/ "manifest.json"
).resolve(),
}
}
# Add the build.outDir from vite.config.js to STATICFILES_DIRS
# so that collectstatic can collect your compiled vite assets.
STATICFILES_DIRS = [
BASE_DIR / 'frontend/static/vite_assets_dist'
]
STATICFILES_DIRS = [BASE_DIR / "frontend/static/vite_assets_dist"]
27 changes: 16 additions & 11 deletions backend/backend/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,28 +14,33 @@
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 path, re_path, include

from django.http import JsonResponse

# from django.contrib import admin
from django.urls import include, path, re_path
from django.views.generic import TemplateView


# Custom handler for incorrect API routes
def api_not_found(request, exception=None):
return JsonResponse({
'error': 'API endpoint not found',
'status_code': 404,
'message': 'The requested API endpoint does not exist'
}, status=404)
return JsonResponse(
{
"error": "API endpoint not found",
"status_code": 404,
"message": "The requested API endpoint does not exist",
},
status=404,
)


urlpatterns = [
path('api/', include('ctj_api.urls'), name="api"),
path("api/", include("ctj_api.urls"), name="api"),
# Custom error handler for invalid API routes
re_path(r'^api/.*$', api_not_found), # Catch-all for incorrect API routes

re_path(r"^api/.*$", api_not_found), # Catch-all for incorrect API routes
# Catch-all for frontend (React)
re_path(
r'^.*$',
r"^.*$",
TemplateView.as_view(template_name="index.html"),
name="index",
),
Expand Down
2 changes: 1 addition & 1 deletion backend/backend/wsgi.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@

from django.core.wsgi import get_wsgi_application

os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'backend.settings')
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "backend.settings")

application = get_wsgi_application()
3 changes: 3 additions & 0 deletions backend/ctj_api/admin.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
from django.contrib import admin

from .models import Opportunities

# Register your models here.
admin.site.register(Opportunities)
4 changes: 2 additions & 2 deletions backend/ctj_api/apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@


class CtjApiConfig(AppConfig):
default_auto_field = 'django.db.models.BigAutoField'
name = 'ctj_api'
default_auto_field = "django.db.models.BigAutoField"
name = "ctj_api"
Loading

0 comments on commit da28a37

Please sign in to comment.