Skip to content

Commit

Permalink
fix environment
Browse files Browse the repository at this point in the history
  • Loading branch information
Edmaroff committed Mar 24, 2024
1 parent 2aa5cb2 commit 04b9f87
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 57 deletions.
32 changes: 32 additions & 0 deletions retail_order_api/.env.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Django
SECRET_KEY=your_secret_key
DEBUG=True

# PostgreSQL
ALLOWED_HOSTS=localhost,127.0.0.1
DB_ENGINE=django.db.backends.postgresql
DB_NAME=your_db_name
DB_USER=your_db_user
DB_PASSWORD=your_db_password
DB_HOST=your_db_host
DB_PORT=your_db_port

# SMTP
EMAIL_BACKEND=django.core.mail.backends.smtp.EmailBackend
EMAIL_HOST=your_email_host
EMAIL_HOST_USER=your_email_host_user
EMAIL_HOST_PASSWORD=your_email_host_password
EMAIL_PORT=your_email_port
EMAIL_USE_TLS=True

# Google Auth
SOCIAL_AUTH_GOOGLE_OAUTH2_KEY=your_google_oauth2_key
SOCIAL_AUTH_GOOGLE_OAUTH2_SECRET=your_google_oauth2_secret

# GitHub Auth
SOCIAL_AUTH_GITHUB_KEY=your_github_key
SOCIAL_AUTH_GITHUB_SECRET=your_github_secret

# Celery
CELERY_BROKER_URL=your_celery_broker_url
CELERY_RESULT_BACKEND=your_celery_result_backend
32 changes: 0 additions & 32 deletions retail_order_api/.env_example

This file was deleted.

Binary file modified retail_order_api/requirements.txt
Binary file not shown.
52 changes: 27 additions & 25 deletions retail_order_api/retail_order_api/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,16 @@
from datetime import timedelta
from pathlib import Path

from dotenv import load_dotenv

load_dotenv()
import environ

BASE_DIR = Path(__file__).resolve().parent.parent
SECRET_KEY = os.getenv("SECRET_KEY")
DEBUG = os.getenv("DEBUG").lower() == "true"
ALLOWED_HOSTS = os.getenv("ALLOWED_HOSTS").split(",")

env = environ.Env()
environ.Env.read_env(os.path.join(BASE_DIR, ".env"))

SECRET_KEY = env.str("SECRET_KEY", "")
DEBUG = env.bool("DEBUG", True)
ALLOWED_HOSTS = env.list("ALLOWED_HOSTS")

INSTALLED_APPS = [
"baton",
Expand Down Expand Up @@ -44,7 +46,7 @@
TEMPLATES = [
{
"BACKEND": "django.template.backends.django.DjangoTemplates",
"DIRS": [os.path.join(BASE_DIR, "templates")],
"DIRS": [],
"APP_DIRS": True,
"OPTIONS": {
"context_processors": [
Expand All @@ -65,12 +67,12 @@

DATABASES = {
"default": {
"ENGINE": os.getenv("DB_ENGINE"),
"NAME": os.getenv("DB_NAME"),
"HOST": os.getenv("DB_HOST"),
"PORT": os.getenv("DB_PORT"),
"USER": os.getenv("DB_USER"),
"PASSWORD": os.getenv("DB_PASSWORD"),
"ENGINE": env.str("DB_ENGINE", "django.db.backends.sqlite3"),
"NAME": env.str("DB_NAME", os.path.join(BASE_DIR, "db.sqlite3")),
"USER": env.str("DB_USER", "user"),
"PASSWORD": env.str("DB_PASSWORD", "password"),
"HOST": env.str("DB_HOST", "localhost"),
"PORT": env.str("DB_PORT", "5432"),
}
}

Expand Down Expand Up @@ -129,12 +131,12 @@


# SMTP
EMAIL_BACKEND = os.getenv("EMAIL_BACKEND")
EMAIL_HOST = os.getenv("EMAIL_HOST")
EMAIL_HOST_USER = os.getenv("EMAIL_HOST_USER")
EMAIL_HOST_PASSWORD = os.getenv("EMAIL_HOST_PASSWORD")
EMAIL_PORT = os.getenv("EMAIL_PORT")
EMAIL_USE_TLS = os.getenv("DEBUG").lower() == "true"
EMAIL_BACKEND = env.str("EMAIL_BACKEND", "")
EMAIL_HOST = env.str("EMAIL_HOST", "")
EMAIL_HOST_USER = env.str("EMAIL_HOST_USER", "")
EMAIL_HOST_PASSWORD = env.str("EMAIL_HOST_PASSWORD", "")
EMAIL_PORT = env.str("EMAIL_PORT", "")
EMAIL_USE_TLS = env.str("EMAIL_USE_TLS", "")


# Djoser
Expand Down Expand Up @@ -174,12 +176,12 @@

# Google OAuth2
SOCIAL_AUTH_USER_MODEL = "backend.CustomUser"
SOCIAL_AUTH_GOOGLE_OAUTH2_KEY = os.getenv("SOCIAL_AUTH_GOOGLE_OAUTH2_KEY")
SOCIAL_AUTH_GOOGLE_OAUTH2_SECRET = os.getenv("SOCIAL_AUTH_GOOGLE_OAUTH2_SECRET")
SOCIAL_AUTH_GOOGLE_OAUTH2_KEY = env.str("SOCIAL_AUTH_GOOGLE_OAUTH2_KEY", "")
SOCIAL_AUTH_GOOGLE_OAUTH2_SECRET = env.str("SOCIAL_AUTH_GOOGLE_OAUTH2_SECRET", "")

# Github OAuth2
SOCIAL_AUTH_GITHUB_KEY = os.getenv("SOCIAL_AUTH_GITHUB_KEY")
SOCIAL_AUTH_GITHUB_SECRET = os.getenv("SOCIAL_AUTH_GITHUB_SECRET")
SOCIAL_AUTH_GITHUB_KEY = env.str("SOCIAL_AUTH_GITHUB_KEY", "")
SOCIAL_AUTH_GITHUB_SECRET = env.str("SOCIAL_AUTH_GITHUB_SECRET", "")
SOCIAL_AUTH_GITHUB_SCOPE = ["read:user", "user:email"]

AUTHENTICATION_BACKENDS = (
Expand All @@ -205,8 +207,8 @@
}

# Celery
CELERY_RESULT_BACKEND = os.getenv("CELERY_RESULT_BACKEND")
CELERY_BROKER_URL = os.getenv("CELERY_BROKER_URL")
CELERY_RESULT_BACKEND = env.str("CELERY_RESULT_BACKEND", "redis://localhost:6379")
CELERY_BROKER_URL = env.str("CELERY_BROKER_URL", "redis://localhost:6379")


# django-baton
Expand Down

0 comments on commit 04b9f87

Please sign in to comment.