Skip to content

Commit

Permalink
Init
Browse files Browse the repository at this point in the history
  • Loading branch information
kwanok committed Mar 25, 2024
1 parent 9d589a4 commit fe05a4e
Show file tree
Hide file tree
Showing 7 changed files with 66 additions and 6 deletions.
25 changes: 24 additions & 1 deletion poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 2 additions & 3 deletions project/jinja2conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,14 @@
from django.template.backends.jinja2 import jinja2
from jinja2 import Environment
from django.urls import reverse

STATIC_PREFIX = "/static/"
from project import settings


def environment(**options):
env = Environment(**options)
env.globals.update(
{
"static": STATIC_PREFIX,
"static": settings.STATIC_URL,
"csrf_input": csrf_input,
"url": reverse,
}
Expand Down
27 changes: 27 additions & 0 deletions project/project/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ class Env(str, Enum):

_env = Env(os.getenv("ENVIRONMENT", Env.Local))


def _get_config(secret_arn: str, key=None):
client = boto3.client(
service_name="secretsmanager",
Expand All @@ -36,6 +37,8 @@ def _get_allowed_hosts():
return [
"dev.duofinder.kr",
"duofinder.kr",
"localhost",
"127.0.0.1",
]
else:
return [
Expand Down Expand Up @@ -107,12 +110,36 @@ def __init__(self, env: Env):
self.secret_key = _get_config(_secret_arn, "WEB_SECRET_KEY")


class S3:
def __init__(self, env: Env):
if env == Env.Local:
self.bucket_name = os.getenv("S3_BUCKET_NAME")
self.s3_domain = os.getenv("S3_DOMAIN")
self.s3_object_parameters = {
"CacheControl": "max-age=86400", # 1 day
}
else:
self.bucket_name = os.getenv("S3_BUCKET_NAME")
self.s3_domain = os.getenv("S3_DOMAIN")
self.s3_object_parameters = {
"CacheControl": "max-age=86400", # 1 day
}
# _secret_arn = os.getenv("S3_SECRET_ARN")
#
# self.bucket_name = _get_config(_secret_arn, "S3_BUCKET_NAME")
# self.s3_domain = _get_config(_secret_arn, "S3_DOMAIN")
# self.s3_object_parameters = {
# "CacheControl": "max-age=86400", # 1 day
# }


class Config:
def __init__(self):
self.Env = _env
self.db = Database(_env)
self.riot = Riot(_env)
self.discord = Discord(_env)
self.s3 = S3(_env)

self.Debug = True if _env == Env.Local else False
self.secret_key = SecretKey(_env).secret_key
Expand Down
13 changes: 11 additions & 2 deletions project/project/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
"django.contrib.sessions",
"django.contrib.messages",
"django.contrib.staticfiles",
"storages",
"app",
"users",
"rest_framework",
Expand Down Expand Up @@ -151,12 +152,20 @@
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/5.0/howto/static-files/

STATIC_URL = "/static/"
AWS_STORAGE_BUCKET_NAME = config.s3.bucket_name

STATIC_URL = "https://cdn.duofinder.kr/"

STATIC_DIR = os.path.join(BASE_DIR, "static")

STATICFILES_DIRS = [
BASE_DIR / "static",
STATIC_DIR,
]

STATICFILES_STORAGE = "storages.backends.s3.S3Storage"
DEFAULT_FILE_STORAGE = "storages.backends.s3.S3Storage"
AWS_LOCATION = "static"

STATIC_ROOT = BASE_DIR / "staticfiles"

# Default primary key field type
Expand Down
Binary file added project/static/images/favicon.ico
Binary file not shown.
1 change: 1 addition & 0 deletions project/templates/base/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="icon" href="{{ static }}favicon.ico" type="image/x-icon">
<title>DUO FINDER
{% block title %}
{% endblock title %}
Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ django-allauth = "^0.61.1"
psycopg-binary = "^3.1.18"
boto3 = "^1.34.69"
python-dotenv = "^1.0.1"
django-storages = "^1.14.2"


[build-system]
Expand Down

0 comments on commit fe05a4e

Please sign in to comment.