Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

edits reqiured #1629

Open
wants to merge 1 commit into
base: staging
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 19 additions & 5 deletions inventory/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# Use an official Python runtime as a parent image
FROM python:3.11.4-slim-buster

# Use an official Python runtime as a parent image
FROM python:3.8

# Set the working directory to /app
WORKDIR /app

Expand All @@ -13,26 +16,37 @@ RUN pip install -r requirements.txt
# Install python-decouple to load environment variables from .env file
RUN pip install python-decouple


# Set environment variable
# Set environment variables
ARG DB_NAME
ARG DB_USER
ARG DB_PASSWORD
ARG DB_HOST

ENV SECRET_KEY=$SECRET_KEY
ENV DEBUG=$DEBUG
ENV EMAIL_HOST_PASSWORD=$EMAIL_HOST_PASSWORD
ENV EMAIL_FROM=$EMAIL_FROM
ENV EMAIL_PORT=$EMAIL_PORT
ENV EMAIL_USE_TLS=$EMAIL_USE_TLS
ENV EMAIL_HOST_USER=$EMAIL_HOST_USER
ENV DEFAULT_FROM_EMAIL=$DEFAULT_FROM_EMAIL
ENV PASSWORD_RESET_TIMEOUT=$PASSWORD_RESET_TIMEOUT
ENV POSTGRES_DB=$DB_NAME
ENV POSTGRES_USER=$DB_USER
ENV POSTGRES_PASSWORD=$DB_PASSWORD
ENV POSTGRES_HOST=$DB_HOST
ENV POSTGRES_PORT=5432
ENV POSTGRES_PORT=$DB_PORT


# # Apply database migrations
# Apply database migrations
RUN python manage.py makemigrations
RUN python manage.py migrate

# Create a superuser (replace 'admin' and 'password' with your desired superuser credentials)
#RUN echo "from django.contrib.auth import get_user_model; User = get_user_model(); User.objects.create_superuser('admin', '[email protected]', 'P@ss1234')" | python manage.py shell

# Collect static files to a folder inside the container
RUN python manage.py collectstatic --noinput
RUN python manage.py collectstatic --noinput

# Expose port 8000 for the Django development server
EXPOSE 8000
Expand Down
34 changes: 17 additions & 17 deletions inventory/Inventory/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,19 @@
# Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = Path(__file__).resolve().parent.parent

# env = environ.Env()
env = environ.Env()

# environ.Env.read_env()
env.read_env()


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

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

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

ALLOWED_HOSTS = ['*']

Expand Down Expand Up @@ -92,18 +92,18 @@
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql',
'NAME': config("DB_NAME"),
'USER': config("DB_USER"),
'PASSWORD': config("DB_PASSWORD"),
'HOST': config("DB_HOST"),
'NAME': env("DB_NAME"),
'USER': env("DB_USER"),
'PASSWORD': env("DB_PASSWORD"),
'HOST': env("DB_HOST"),
'PORT': '5432',
}
}


# DATABASES = {
# 'default' : dj_database_url.parse(os.environ.get('DATABASE_URL'))
# }
# "default": dj_database_url.config(default=env("DATABASE_URL"))
# }


CRISPY_ALLOWED_TEMPLATE_PACKS = 'bootstrap4'
Expand Down Expand Up @@ -164,13 +164,13 @@

EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
EMAIL_HOST = 'smtp.gmail.com'
EMAIL_FROM = config("EMAIL_FROM")
EMAIL_PORT = config("EMAIL_PORT", cast=int)
EMAIL_USE_TLS = config("EMAIL_USE_TLS", cast=bool)
EMAIL_HOST_USER = config("EMAIL_HOST_USER")
EMAIL_HOST_PASSWORD =config("EMAIL_HOST_PASSWORD")
DEFAULT_FROM_EMAIL = config("DEFAULT_FROM_EMAIL")
PASSWORD_RESET_TIMEOUT = config("PASSWORD_RESET_TIMEOUT", cast=int)
EMAIL_FROM = env("EMAIL_FROM")
EMAIL_PORT = env.int("EMAIL_PORT")
EMAIL_USE_TLS = env.bool("EMAIL_USE_TLS", default=True)
EMAIL_HOST_USER = env("EMAIL_HOST_USER")
EMAIL_HOST_PASSWORD =env("EMAIL_HOST_PASSWORD")
DEFAULT_FROM_EMAIL = env("DEFAULT_FROM_EMAIL")
PASSWORD_RESET_TIMEOUT = env.int("PASSWORD_RESET_TIMEOUT")


# Default primary key field type
Expand Down
2 changes: 1 addition & 1 deletion inventory/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ dj-database-url==2.0.0
Django==4.2.2
django-crispy-forms==2.0
django-environ==0.10.0
environ==1.0.0
dulwich==0.21.5
filelock==3.12.2
gunicorn==20.1.0
Expand All @@ -37,7 +38,6 @@ platformdirs==3.9.1
poetry==1.5.1
poetry-core==1.6.1
poetry-plugin-export==1.4.0
psycopg2==2.9.6
psycopg2-binary==2.9.6
ptyprocess==0.7.0
pypng==0.20220715.0
Expand Down
2 changes: 1 addition & 1 deletion inventory/templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
</ul>
<ul class="navbar-nav ml-auto">
<li class="nav-item active">
<a class="nav-link text-white" href="#">{{user.username}}<span class="sr-only">(current)</span></a>
<a class="nav-link text-white" href="#"><span class="sr-only">(current)</span></a>
</li>
<li class="nav-item">
<a class="nav-link text-white" href="{% url 'logout' %}">Log Out</a>
Expand Down