Commit c31a9907 authored by David Haynes's avatar David Haynes 🙆

Project cleanup + updates + docker yarn build

parent b67231a2
......@@ -2,7 +2,6 @@
*.swp
*.pyc
.virtualenv
.vagrant/
venv
.venv
/provisioning/playbook.retry
......@@ -14,7 +13,122 @@ htmlcov/
.idea
__pycache__/
.vscode
go/sourceme.sh
.DS_STORE
node_modules/
go/static/main.js
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class
# C extensions
*.so
# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST
# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec
# Installer logs
pip-log.txt
pip-delete-this-directory.txt
# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
.hypothesis/
.pytest_cache/
# Translations
*.mo
*.pot
# Django stuff:
*.log
local_settings.py
db.sqlite3
# Flask stuff:
instance/
.webassets-cache
# Scrapy stuff:
.scrapy
# Sphinx documentation
docs/_build/
# PyBuilder
target/
# Jupyter Notebook
.ipynb_checkpoints
# IPython
profile_default/
ipython_config.py
# pyenv
.python-version
# celery beat schedule file
celerybeat-schedule
# SageMath parsed files
*.sage.py
# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/
# Spyder project settings
.spyderproject
.spyproject
# Rope project settings
.ropeproject
# mkdocs documentation
/site
# mypy
.mypy_cache/
.dmypy.json
dmypy.json
# Pyre type checker
.pyre/
......@@ -14,3 +14,9 @@ ADD . /go/
# Install pip dependecies
RUN pip install pipenv
RUN pipenv install --system --deploy
RUN curl -sL https://deb.nodesource.com/setup_10.x | bash -
RUN apt-get install -y nodejs
RUN apt-get install -y build-essential
RUN npm install -g yarn
\ No newline at end of file
......@@ -32,19 +32,19 @@
},
"django": {
"hashes": [
"sha256:25df265e1fdb74f7e7305a1de620a84681bcc9c05e84a3ed97e4a1a63024f18d",
"sha256:d6d94554abc82ca37e447c3d28958f5ac39bd7d4adaa285543ae97fb1129fd69"
"sha256:0292a7ad7d8ffc9cfc6a77f043d2e81f5bbc360c0c4a1686e130ef3432437d23",
"sha256:e89f613e3c1f7ff245ffee3560472f9fa9c07060b11f65e1de3cb763f8dcd4b9"
],
"index": "pypi",
"version": "==2.0.9"
"version": "==2.0.10"
},
"django-cas-client": {
"hashes": [
"sha256:2a190c9e651df3a65840206b38a9fc1c2c404696fcaf66fc69a684591f56d978",
"sha256:4d941d58769437e56656464c91461e61eee27ff2dac3ed53766e0042bc33169a"
"sha256:6d71d59db35f8a7677ee654dc9d4eac5c8aea3205273710fb71e077d139f6f7d",
"sha256:f1b3106447c4e0920ffaf9a7d8fd63829c7105e88b89bbdc90fbf65112897131"
],
"index": "pypi",
"version": "==1.4.0"
"version": "==1.5.0"
},
"django-crispy-forms": {
"hashes": [
......@@ -100,10 +100,10 @@
},
"pytz": {
"hashes": [
"sha256:31cb35c89bd7d333cd32c5f278fca91b523b0834369e757f4c5641ea252236ca",
"sha256:8e0f8568c118d3077b46be7d654cc8167fa916092e28320cde048e54bfc9f1e6"
"sha256:32b0891edff07e28efe91284ed9c31e123d84bea3fd98e1f72be2508f43ef8d9",
"sha256:d5f05e487007e29e03409f9398d074e158d920d36eb82eaf66fb1136b0c5374c"
],
"version": "==2018.7"
"version": "==2018.9"
},
"redis": {
"hashes": [
......
#! /bin/bash
export GO_SECRET_KEY
until nc -z db 3306; do
echo "waiting for database to start..."
sleep 1
done
export GO_SECRET_KEY
export GO_CREATE_SUPERUSER
GO_SECRET_KEY=$(dd if=/dev/urandom count=100 | tr -dc "A-Za-z0-9" | fold -w 60 | head -n1 2>/dev/null)
yarn build
python go/manage.py makemigrations
python go/manage.py makemigrations go_back
python go/manage.py makemigrations go_ahead
python go/manage.py migrate
python go/manage.py runserver 0.0.0.0:8000
\ No newline at end of file
"""
go_ahead/urls.py
"""
from django.urls import path
from . import views
......
......@@ -17,6 +17,7 @@ class RegisteredUserInline(admin.StackedInline):
Allow for RegisteredUsers to be displayed alongside their Django user
objects.
"""
model = RegisteredUser
can_delete = False
......@@ -25,7 +26,8 @@ class RegUserAdmin(UserAdmin):
"""
Stick information about RegisteredUsers into its own Admin panel.
"""
inlines = (RegisteredUserInline, )
inlines = (RegisteredUserInline,)
# Default ModelAdmin
......
This diff is collapsed.
"""
go/commands/expirelinks.py
Remove expired links from the database.
"""
# Django Imports
from django.core.management.base import BaseCommand
from django.utils import timezone
# App Imports
from go_back.models import URL
class Command(BaseCommand):
"""
Define a new custom django-admin command to remove expired links from the
database.
"""
help = 'Removes expired links from the database'
def handle(self, *args, **options):
"""
Handle the main component of the django-admin command. Loop
through a list of all URL objects that have expired (expires field is
less than or equal [lte] to today's date)
"""
for expired_url in URL.objects.filter(expires__lte=timezone.now()):
expired_url.delete()
"""
go/commands/test_expirelinks.py
Test that the function to expire Go links actually works.
"""
# Python stdlib Imports
from datetime import timedelta
# Django Imports
from django.contrib.auth.models import User
from django.core.management import call_command
from django.test import TestCase
from django.utils import timezone
# App Imports
from go_back.models import URL, RegisteredUser
# class ExpireLinksTest(TestCase):
# def setUp(self):
# """
# Set up any variables such as dummy objects that will be utilized in
# testing methods
# """
# # Setup a blank URL object with an owner
# User.objects.create(username='dhaynes', password='password')
# get_user = User.objects.get(username='dhaynes')
# get_registered_user = RegisteredUser.objects.get(user=get_user)
# URL.objects.create(owner=get_registered_user, short='test')
# URL.objects.create(owner=get_registered_user, short='test-2')
# # Get some dates
# yesterday = timezone.now() - timedelta(days=1)
# tomorrow = timezone.now() + timedelta(days=1)
# # Get the URL to apply it to
# current_url = URL.objects.get(short='test')
# second_url = URL.objects.get(short='test-2')
# # Apply the dates
# current_url.expires = yesterday
# second_url.expires = tomorrow
# current_url.save()
# second_url.save()
# def test_expirelinks(self):
# """
# Make a call to expire Go links and assert that the number of links has
# been reduced.
# """
# call_command('expirelinks')
# self.assertTrue(len(URL.objects.all()) == 1) TODO
......@@ -18,8 +18,8 @@ from django.conf import settings
# Other Imports
from hashids import Hashids
from .validators import regex_short_validator, unique_short_validator
from rest_framework.authtoken.models import Token
from .validators import regex_short_validator, unique_short_validator
# Generate the salt and initialize Hashids
# Note: the Hashids library already implements several restrictions oncharacter
......
......@@ -3,12 +3,11 @@ go/serializers.py
Define how data is translated from the database to json/API representation.
"""
# App Imports
from .models import URL, RegisteredUser
# Third Party Imports
from rest_framework import serializers
from rest_framework.authtoken.models import Token
# App Imports
from .models import URL
class URLSerializer(serializers.HyperlinkedModelSerializer):
......
<!-- include the base html template -->
{% extends 'layouts/base.html' %}
<!-- define the page title block -->
{% block title %}
403 Error &bull; Forbidden
{% endblock %}
<!-- Tell Django to load static files -->
{% load staticfiles %}
<!-- define the content block for the page -->
{% block content %}
<!-- define the page header div -->
<div class="page-header" id="banner">
<div class="row">
<div class="col-md-12">
<h1>
<span class="fa-stack fa-lg">
<i class="fa fa-circle fa-stack-2x"></i>
<i class="fa fa-exclamation-triangle fa-stack-1x fa-inverse"></i>
</span>
403 Error!
</h1>
</div>
</div>
</div>
<!-- div that contains the 404 page content -->
<div class="row">
<div class="col-md-10 col-md-offset-1 text-center">
<h1>403 Error - Forbidden</h1>
<h3>You are not permitted to access this page, or you have exceeded the maximum limit of submitted links.</h3>
<h3>
Click <a href="{% url 'index' %}">here</a> to return to the home page.
</h3>
<img id="squirrels" src="{% static "img/acorn.png" %}">
<a href="/"><img src="{% static "img/acorn.png" %}" style="width:10vw;"></a>
</div>
</div>
{% endblock %}
<!-- include the base html template -->
{% extends 'layouts/base.html' %}
<!-- define the page title block -->
{% block title %}
404 Error &bull; Page Not Found
{% endblock %}
<!-- Tell Django to load static files -->
{% load staticfiles %}
<!-- define the content block for the page -->
{% block content %}
<!-- define the page header div -->
<div class="page-header" id="banner">
<div class="row">
<div class="col-md-12">
<h1>
<span class="fa-stack fa-lg">
<i class="fa fa-circle fa-stack-2x"></i>
<i class="fa fa-exclamation-triangle fa-stack-1x fa-inverse"></i>
</span>
404 Error!
</h1>
</div>
</div>
</div>
<!-- div that contains the 404 page content -->
<div class="row">
<div class="col-md-10 col-md-offset-1 text-center">
<h1>404 Error - Page Not Found</h1>
<h3>The link you provided is invalid or may have been deleted.</h3>
<h3>
If you are registered to use Go, you can verify your links
<a href="{% url 'my_links' %}">here</a>.
</h3>
<img id="squirrels" src="{% static "img/acorn.png" %}">
<a href="/"><img src="{% static "img/acorn.png" %}" style="width:10vw;"></a>
</div>
</div>
{% endblock %}
<!-- include the base html template -->
{% extends 'layouts/base.html' %}
<!-- define the page title block -->
{% block title %}
500 Error &bull; Internal Server Error
{% endblock %}
<!-- Tell Django to load static files -->
{% load staticfiles %}
<!-- define the content block for the page -->
{% block content %}
<!-- define the page header div -->
<div class="page-header" id="banner">
<div class="row">
<div class="col-md-12">
<h1>
<span class="fa-stack fa-lg">
<i class="fa fa-circle fa-stack-2x"></i>
<i class="fa fa-exclamation-triangle fa-stack-1x fa-inverse"></i>
</span>
500 Error!
</h1>
</div>
</div>
</div>
<!-- div that contains the 500 page content -->
<div class="row">
<div class="col-md-10 col-md-offset-1 text-center">
<h1>500 Error - Internal Server Error</h1>
<img id="squirrels" src="{% static "img/acorn.png" %}">
<a href="/"><img src="{% static "img/acorn.png" %}" style="width:10vw;"></a>
</div>
</div>
{% endblock %}
{% extends 'layouts/base.html' %}
{% block title %}
SRCT Go &bull; Account Blocked
{% endblock %}
{% block content %}
<div class="page-header" id="banner">
<div class="row">
<div class="col-md-12">
<h1>
<span class="fa-stack fa-lg">
<i class="fa fa-circle fa-stack-2x"></i>
<i class="fa fa-ban fa-stack-1x fa-inverse"></i>
</span>
Account Is Blocked
</h1>
</div>
</div>
</div>
<div class="row">
<div class="col-md-12">
{% block name %}
<p>
You have been banned from Go: <strong>{{ request.user.registereduser.full_name }}</strong>.
</p>
{% endblock %}
<br />
<p>
If you believe this is an error, please contact the <a href="mailto:srct@gmu.edu">Go Admins</a>
<br />
<br />
Thank you, and have a nice day!
</p>
<br />
<br />
</div>
</div>
{% endblock %}
<!-- include the base html template -->
{% extends 'layouts/base.html' %}
{% load staticfiles %}
{% block title %}
SRCT Go &bull; About
{% endblock %}
{% block content %}
<!-- page header -->
<div class="page-header" id="banner">
<div class="row">
<div class="col-md-12">
<h1>
<span class="fa-stack fa-lg">
<i class="fa fa-circle fa-stack-2x"></i>
<i class="fa fa-question fa-stack-1x fa-inverse"></i>
</span> About
</h1>
</div>
</div>
</div>
<!-- terms of use -->
<div class="row" id="terms">
<div class="col-md-12">
<h2>Terms of Use</h2>
<p>
By using Go you acknowledge that you are a current George Mason Student or faculty
member.
Additionally, any link that you create is subject to removal by Go admins if it is
deemed to associate the university with any derogatory or controversial matters.
Go admins also reserve the right to remove and ban any users who attempt to abuse
the link creation system in any manner.
Since Go falls under the gmu.edu domain, users who use this service will act in compliance
with the GMU <a href="https://universitypolicy.gmu.edu/policies/responsible-use-of-computing/">Responsible Use of Computing</a> policies.
</p>
</div>
</div>
<!-- who made go? -->
<div class="row">
<div class="col-md-12">
<h2>Who made Go?</h2>
<p>
Members of the
<a href="//srct.gmu.edu">Student-Run Computing and Technology</a> registered
student organization at <a href="//gmu.edu">George Mason University</a> are
the clever, talented student developers behind Go.
</p>
<p>
We are a group of creative people that like making software and want to give back
to the Mason community at the same time.
</p>
<p>
<a href="//srct.gmu.edu/contact/">Contact us</a> to get involved!
</p>
</div>
</div>
<!-- define the thanks! div -->
<div class="row">
<div class="col-md-12">
<h2>Thanks!</h2>
<p>
This project was made possible through the collective contributions of
multiple Mason SRCT members.
<a href="https://git.gmu.edu/srct/go/milestones/3">Go 2.2</a>:
<a href="https://github.com/dhaynespls">David Haynes</a>,
<a href="https://github.com/ocelotsloth">Mark Stenglein</a>,
<a href="https://www.youtube.com/watch?v=dQw4w9WgXcQ">Andres Villogas</a>,
<a href="https://github.com/IAmEyad">Eyad Hasan</a>,
<a href="https://github.com/zosman1">Zach Osman</a>,
<a href="">Leo Grandinetti</a>,
<a href="https://mason.gmu.edu/~gmoran/">Grady Moran</a>,
<a href="https://github.com/zmknox">Zach Knox</a>,
<a href="https://github.com/mike-bailey">Michael Bailey</a>,
<a href="https://github.com/jrouly">Michel Rouly</a>,
<a href="https://github.com/nanderson94">Nicholas Anderson</a>,
<a href="">Kevin Mckigney</a>,
and <a href="https://github.com/dwbond">Daniel Bond</a>.
<a href="https://git.gmu.edu/srct/go/milestones/2">Go 2.1</a>:
<a href="https://github.com/dhaynespls">David Haynes</a>,
<a href="https://github.com/zosman1">Zach Osman</a>,
<a href="https://github.com/roberthitt">Robert Hitt</a>,
<a href="https://github.com/nanderson94">Nicholas Anderson</a>,
<a href="https://github.com/zmknox">Zach Knox</a>,
<a href="https://github.com/mike-bailey">Michael Bailey</a>,
<a href="https://github.com/mdsecurity">Mattias Duffy</a>,
<a href="https://github.com/IAmEyad">Eyad Hasan</a>,
and <a href="https://github.com/danielkim1">Danny Kim</a>.
<a href="https://git.gmu.edu/srct/go/milestones/1">Go 2.0</a>:
<a href="https://github.com/dhaynespls">David Haynes</a>,
<a href="">Matthew Rodgers</a>,
<a href="https://github.com/nanderson94">Nicholas Anderson</a>,
and <a href="https://github.com/dwbond">Daniel Bond</a>.
Go 1.0:
<a href="https://github.com/jrouly">Michel Rouly</a>,
<a href="https://github.com/creffett">Chris Reffett</a>,
<a href="https://github.com/nanderson94">Nicholas Anderson</a>, and <a href="https://github.com/akshaykarthik">Akshay Karthik</a>.
</p>
<p>
Additional thanks are due to the <a href="https://wiki.srct.gmu.edu/Executive_Board">
Student-Run Computing and Technology executive
board from 2014-present</a>,and our academic advisor,
<a href="https://cs.gmu.edu/~kdobolyi/">Professor Kinga Dobolyi</a>.
</p>
</div>
</div>
{% endblock %}
<!-- include the base html template -->
{% extends 'layouts/base.html' %}
<!-- Tell Django to load static files -->
{% load staticfiles %}
<!-- load django crispy forms' tags -->
{% load crispy_forms_tags %}
<!-- define the page title block -->
{% block title %}
SRCT Go &bull; Edit Link
{% endblock %}
<!-- define the content block for the page -->
{% block content %}
<!-- define the page header div -->
<div class="page-header" id="banner">
<div class="row">
<div class="col-md-12">
<h1>
<span class="fa-stack fa-lg">
<i class="fa fa-circle fa-stack-2x"></i>
<i class="fa fa-wrench fa-stack-1x fa-inverse"></i>
</span>
Edit Link
</h1>
</div>
</div>
</div>
<!-- call django crispy forms to render the go link creation form here -->
{% crispy form %}
<!-- load some JS to hide/show the custom date field -->
<script src="{% static "js/new_link.js" %}"></script>
{% endblock %}
<!-- include the base html template -->
{% extends 'layouts/base.html' %}
<!-- define the page title block -->
{% block title %}
SRCT Go &bull; My Links
{% endblock %}
<!-- define the content block for the page -->
{% block content %}
<!-- define the page header div -->
<div class="page-header" id="banner">
<div class="row">
<div class="col-md-12">
<h1>
<span class="fa-stack fa-lg">
<i class="fa fa-circle fa-stack-2x"></i>
<i class="fa fa-link fa-stack-1x fa-inverse"></i>
</span>
My Links
</h1>
</div>
</div>
<div class="newlink" style="text-align: right;">
<a href="{% url 'new_link' %}"><i class="fa fa-plus" aria-hidden="true"></i> Add new link</a>
</div>
</div>
<!-- display sort menu if there are any links -->
{% if urls %}
<div class="dropdown" style="text-align:right;">
<!-- button for the dropdown menu -->
<button class="btn btn-primary dropdown-toggle" type="button" data-toggle="dropdown">
Sort By <i class="fa fa-caret-down fa-fw"></i>
</button>
<!-- generate the list of sorting options based on given sort_methods -->
<ul class="dropdown-menu dropdown-menu-right" style="margin-top: 2px;">
{% for method, name in sort_methods.items %}
<!-- check if currently selected sort method is this one to highlight -->
{% if request.GET.sort == method %}
<li style="background: #eee;" {# class="active" Properly implmenet the .active class#}>
<!-- if there is no currently selected sort method, highlight the default case "Most Recent" -->
{% elif request.GET.sort == null and method == "-date_created" %}
<li style="background: #eee;" {# class="active" Properly implmenet the .active class#}>
<!-- no styling -->
{% else %}
<li>
{% endif %}
<!-- create link to sort method -->
<a href="?sort={{ method }}" style="color: #262626;">{{ name }}</a>
</li>
{% endfor %}
</ul>
</div>
{% endif %}
<!-- show all of the links -->
<div class="row">
<!-- for every url in the urls list-->
{% for url in urls %}
<legend>
<!-- include the link box for this url -->
{% include 'link_box.html' %}
</legend>
<!-- unless the list is empty -->
{% empty %}
<h3>&nbsp;&nbsp;&nbsp;None found <i class="fa fa-frown-o"></i></h3>
{% endfor %}
</div>
{% endblock %}
<!-- include the base html template -->