Skip to content

Commit

Permalink
Merge pull request #582 from hackforla/revert-574-feature/lint-python
Browse files Browse the repository at this point in the history
Revert "Feature: lint python"
  • Loading branch information
LoTerence authored Sep 26, 2024
2 parents e3ec821 + 3e5fc7e commit 02faf42
Show file tree
Hide file tree
Showing 25 changed files with 287 additions and 570 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ dev.env
stage.env
.env
__pycache__
.pytest_cache
.vscode/
*venv/
app/frontend/static/frontend/*
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ migrations:
docker compose exec django python manage.py makemigrations

migrate:
docker compose exec django python manage.py migrate
docker compose exec django python manage.py migrate

db-shell:
docker compose exec django python manage.py shell
Expand Down
10 changes: 0 additions & 10 deletions backend/.flake8

This file was deleted.

3 changes: 0 additions & 3 deletions backend/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,3 @@
.idea
DCIM
data

__pycache__
.pytest_cache
41 changes: 0 additions & 41 deletions backend/.pre-commit-config.yaml

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: 53 additions & 59 deletions backend/backend/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,9 @@
"""

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 @@ -24,68 +23,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 @@ -94,26 +93,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 @@ -123,32 +122,27 @@
# 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'
]
29 changes: 12 additions & 17 deletions backend/backend/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,33 +14,28 @@
1. Import the include() function: from django.urls import include, path
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
"""

from django.http import JsonResponse

# from django.contrib import admin
from django.urls import include, path, re_path
from django.urls import path, re_path, include
from django.http import JsonResponse
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"),
# Catch-all for incorrect API routes
re_path(r"^api/.*$", api_not_found),
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

# 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()
2 changes: 1 addition & 1 deletion backend/ctj_api/admin.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# from django.contrib import admin
from django.contrib import admin

# Register your models here.
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 02faf42

Please sign in to comment.