Commit 48666c57 authored by Zac Wood's avatar Zac Wood

Views refactor, add dotenv for easier manual setup

parent 235342e9
Pipeline #4795 passed with stages
in 2 minutes and 2 seconds
FROM python:3.6
FROM python:3.6.9
ENV PYTHONUNBUFFERED 1
RUN apt-get update
RUN apt-get install netcat python3-dev default-libmysqlclient-dev -y
# downgrade openssl security for login.gmu.edu compatibility
RUN sed -i -e 's/DEFAULT@SECLEVEL=2/DEFAULT@SECLEVEL=1/g' /etc/ssl/openssl.cnf
RUN mkdir /go
WORKDIR /go
ADD /requirements/ /go/
......
version: '3.7'
services:
web:
# build: .
build: .
restart: always
ports:
- '8000:8000'
command: /bin/bash ./startup_prod.sh
image: go-prod
command: /bin/bash ./startup.sh
volumes:
- .:/go
depends_on:
- db
environment:
- DOCKER=true
- GO_ENV=development
- GO_ALLOWED_HOSTS=*
- GO_EMAIL_DOMAIN=@masonlive.gmu.edu
......
......@@ -271,7 +271,7 @@ class EditForm(URLForm):
HTML("""
<br />"""),
StrictButton('Submit Changes', css_class="btn btn-primary btn-md col-md-4", type='submit')))
class Meta(URLForm.Meta):
# what attributes are included
fields = URLForm.Meta.fields
......
......@@ -98,7 +98,7 @@
<!-- define the table of current users -->
<div class="row">
<div class="col-md-12">
<input class="inputfilter" type="text" id="currentInput"
<input class="inputfilter" type="text" id="currentInput"
placeholder="Search Usernames or Full Names">
<h3>Current Users</h3>
<form method="post" action="useradmin">
......
......@@ -9,6 +9,8 @@ SRCT Go &bull; My Links
<!-- define the content block for the page -->
{% block content %}
{% load staticfiles %}
<!-- define the page header div -->
<div class="page-header" id="banner">
<div class="row">
......
......@@ -2,7 +2,7 @@
{% load go_extras %}
<!-- define our navbar -->
<div class="navbar navbar-default">
<nav class="navbar navbar-default">
<!-- define the main "header" of the navbar -->
<div class="navbar-header" style="margin-left:5%;">
<!-- responsive hamburger menu -->
......@@ -62,4 +62,4 @@
{% endif %}
</ul>
</div>
</div>
</nav>
This diff is collapsed.
#!/usr/bin/env python
import os
import sys
import dotenv
if __name__ == "__main__":
if not os.getenv('DOCKER'):
dotenv.read_dotenv('./.env')
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "settings.settings")
from django.core.management import execute_from_command_line
execute_from_command_line(sys.argv)
......@@ -9,7 +9,7 @@ import os
import sys
# DEV vs PROD
if os.environ["GO_ENV"] != "production":
if os.getenv('GO_ENV') != "production":
DEBUG = True
else:
DEBUG = False
......
......@@ -12,3 +12,4 @@ requests==2.18.4
simplejson==3.11.1
six
setuptools==36.4.0
django-dotenv
until nc -z db 3306; do
until nc -z localhost 3306 || nc -z db 3306; do
echo "waiting for database to start..."
sleep 1
done
export GO_SECRET_KEY=$(dd if=/dev/urandom count=100 | tr -dc "A-Za-z0-9" | fold -w 60 | head -n1 2>/dev/null)
python go/manage.py flush --no-input
python go/manage.py makemigrations
python go/manage.py makemigrations go
python go/manage.py migrate
python go/manage.py createsuperuser --noinput --username=$superuser --email=$superuser$GO_EMAIL_DOMAIN
echo "from django.contrib.auth import get_user_model; User = get_user_model(); me = User.objects.get(username='$superuser'); me.first_name = 'David'; me.last_name = 'Haynes'; me.save(); " | python go/manage.py shell
python go/manage.py runserver 0.0.0.0:8000
python3 go/manage.py flush --no-input
python3 go/manage.py makemigrations
python3 go/manage.py makemigrations go
python3 go/manage.py migrate
python3 go/manage.py createsuperuser --noinput --username=$superuser --email=$superuser$GO_EMAIL_DOMAIN
echo "from django.contrib.auth import get_user_model; User = get_user_model(); me = User.objects.get(username='$superuser'); me.first_name = 'David'; me.last_name = 'Haynes'; me.save(); " | python3 go/manage.py shell
python3 go/manage.py runserver 0.0.0.0:8000
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment