Commit ac819e83 authored by Zac Wood's avatar Zac Wood

Merge branch 'v2.3' into 199-remove-signup

parents 35945f04 249aaa01
Pipeline #4811 passed with stages
in 1 minute and 58 seconds
GO_ENV=development
GO_ALLOWED_HOSTS=*
GO_EMAIL_DOMAIN=@masonlive.gmu.edu
GO_CAS_URL=https://login.gmu.edu/
GO_DB_NAME=go
GO_DB_USER=go
GO_DB_PASSWORD=go
GO_DB_HOST=localhost
GO_DB_PORT=3306
GO_EMAIL_HOST=
GO_EMAIL_PORT=
GO_EMAIL_HOST_USER=
GO_EMAIL_HOST_PASSWORD=
GO_EMAIL_FROM=
GO_EMAIL_TO=
GO_SECRET_KEY=spookyspecret
superuser=zwood2
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/
......
FROM python:3.7
ENV PYTHONUNBUFFERED 1
RUN apt-get update
RUN apt-get install netcat python3-dev default-libmysqlclient-dev -y
RUN mkdir /go
WORKDIR /go
ADD /requirements/ /go/
RUN pip install -r prod.txt
ADD . /go/
RUN mkdir /static
# Go 2
[![build status](https://git.gmu.edu/srct/go/badges/master/build.svg)](https://git.gmu.edu/srct/go/commits/master) [![coverage report](https://git.gmu.edu/srct/go/badges/master/coverage.svg)](https://git.gmu.edu/srct/go/commits/master) [![python version](https://img.shields.io/badge/python-2.7,3.4+-blue.svg)]() [![Django version](https://img.shields.io/badge/Django-1.11-brightgreen.svg)]() [![SemVer version](https://img.shields.io/badge/SemVer Version-2.2.3-yellowgreen.svg)]()
[![build status](https://git.gmu.edu/srct/go/badges/master/build.svg)](https://git.gmu.edu/srct/go/commits/master) [![coverage report](https://git.gmu.edu/srct/go/badges/master/coverage.svg)](https://git.gmu.edu/srct/go/commits/master) [![python version](https://img.shields.io/badge/python-3.4+-blue.svg)]() [![Django version](https://img.shields.io/badge/Django-2.2-brightgreen.svg)]()
#### A project of [GMU SRCT](https://srct.gmu.edu).
......@@ -65,29 +65,13 @@ Finally we can install git with:
brew install git
### On Windows
We recommend that if you are on Windows 10 AE (Anniversary Edition) or above to make use of the
Windows Subsystem for Linux (WSL). The following link should get you up and running:
### Windows
[https://msdn.microsoft.com/en-us/commandline/wsl/install_guide](https://msdn.microsoft.com/en-us/commandline/wsl/install_guide)
#### Contributing with Windows
After that is setup, you should be able to follow the Linux instructions for _manual setup_ to
contribute to the project.
If you are not on Windows 10 or would rather prefer to not use the WSL you may download Git for
Windows here:
Download Git for Windows here:
[https://git-scm.com/download/win](https://git-scm.com/download/win)
You'll want to follow the Vagrant setup method as it is designed to run on all platforms
including Windows.
I have also successfully ran the project with Docker, though you need
access to Hyper-V which is only available on "Professional" versions of Windows.
## 2) Clone the Go codebase.
......@@ -145,49 +129,20 @@ Cons:
interact with the database.
There are instructions on how to setup/develop with Docker at the [docker-configuration page in the Go project wiki](https://git.gmu.edu/srct/go/wikis/docker-configuration).
### Vagrant + Ansible
Vagrant boots up a full virtual machine (VM) through VirtualBox that then runs Go. A
script written with Ansible will then run on that VM to automate the setup process
for you. It is similar in a way to running Go on a legitimate server.
Pros:
- Very similar to a production environment
- Can use `vagrant ssh` to "ssh" into the VM to debug things such as the
database.
- Relatively straightforward and easy setup.
- One Command.
- Can easily destroy and rebuild the VM.
- Loads in changes to code on the fly.
- Fast-ish (Initial provision takes a bit).
Cons:
- Heavier on resources.
- It's literally a full VM.
- Occasional issues/hiccups.
- Documented fixes are in the wiki.
There are instructions on how to setup with Vagrant at the [vagrant-configuration
page in the Go project wiki](https://git.gmu.edu/srct/go/wikis/vagrant-configuration).
Additionally, there is documentation about developing with Vagrant at
the [vagrant-usage page in the Go project wiki](https://git.gmu.edu/srct/go/wikis/vagrant-usage).
**NOTE**: On Windows, Docker only works if you have Windows 10 Eductaion or Pro,
as it requires HyperV.
### Manual Setup
Manual setup (or: the old fashioned way) is where you install all dependecies on
your system and run Go as a local server with Django. Granted you are technically
doing that with Vagrant and Docker except those platforms automate the steps that
doing that with Docker except those platforms automate the steps that
are laid out in this section.
Pros:
- Experience setting up a Django project for local development
Cons:
- Greater potential for things to go wrong
- Way more steps
Head to:
......@@ -215,15 +170,6 @@ rely on. Here's how to run them locally:
Docker is not supported currently for running unit tests. If you're able to get
it set up, open a merge request and I'll merge it in.
#### Vagrant
vagrant up
vagrant ssh
cd /vagrant
source venv/bin/activate
cd go
source sourceme.sh
python manage.py test
#### Manual Setup
......@@ -241,16 +187,6 @@ opinions about using `git`.
There is a template for issue descriptions located on the new issue page. I will
close issues with poor descriptions or who do not follow the standard.
## Authentication
The authentication service used for Go is CAS. In local development however we
utilize a test server. You can log in with just your CAS username to simulate logging
in. By default, the Django superuser is set to `dhaynes3`.
In order to approve yourself to be an 'approved user' you must navigate to 127.0.0.1:8000/admin and log in.
Once in the admin page go to "registered users", and create a new registered user in the top right. Be sure to
use the same username and Full Name as your main account and select "approved" in the bottom row.
## Coding style
You should adhere to the style of the repo code. Consistancy is key! PEP8 guidelines
......
......@@ -5,12 +5,13 @@ services:
restart: always
ports:
- '8000:8000'
command: /bin/bash ./startup.sh -python go/manage.py runserver 0.0.0.0:8000
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">
......
......@@ -5,7 +5,7 @@
<!DOCTYPE html>
<!-- Start the HTML page for Go -->
<html>
<html lang="en-us">
<!-- load in our header content for every page -->
<head>
<!-- load in the title block defined on each html page -->
......@@ -51,6 +51,22 @@
<script src="{% static "js/jquery.min.js" %}"></script>
<script src="{% static "js/bootstrap.min.js" %}"></script>
<script src="{% static "js/clipboard.min.js" %}"></script>
<!-- Matomo -->
<script type="text/javascript">
var _paq = _paq || [];
/* tracker methods like "setCustomDimension" should be called before "trackPageView" */
_paq.push(['trackPageView']);
_paq.push(['enableLinkTracking']);
(function() {
var u="//matomo.srct.gmu.edu/";
_paq.push(['setTrackerUrl', u+'piwik.php']);
_paq.push(['setSiteId', '4']);
var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];
g.type='text/javascript'; g.async=true; g.defer=true; g.src=u+'piwik.js'; s.parentNode.insertBefore(g,s);
})();
</script>
<!-- End Matomo Code -->
</head>
<!-- Load in the body of a Go page -->
......
......@@ -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
......@@ -50,7 +50,7 @@ MEDIAFILES_DIRS = (
)
STATIC_URL = '/static/'
STATIC_ROOT = ''
STATIC_ROOT = '/static'
STATICFILES_DIRS = (
os.path.join(BASE_DIR, 'static/'),
)
......
......@@ -12,3 +12,4 @@ requests==2.18.4
simplejson==3.11.1
six
setuptools==36.4.0
django-dotenv
......@@ -2,4 +2,4 @@
# production that isn't in development.
-r base.txt
gunicorn==19.6.0
gunicorn
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
......@@ -4,4 +4,6 @@ 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
python go/manage.py collectstatic --noinput
gunicorn -b ":8000" --chdir /go/go settings.wsgi
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