Commit 76d358c7 authored by David Haynes's avatar David Haynes 🙆
Browse files

Merge branch '120-masonstrap-4' into 2.3-dev

parents fd262ff6 d6f2bc64
Pipeline #2110 passed with stages
in 3 minutes and 21 seconds
...@@ -5,7 +5,7 @@ about the current issue. Maybe a picture? Some details that could best help some ...@@ -5,7 +5,7 @@ about the current issue. Maybe a picture? Some details that could best help some
especially someone new, understand the goal of the issue and how they should best especially someone new, understand the goal of the issue and how they should best
approach the problem. approach the problem.
# Helpful Links ## Helpful Links
Here you should include a bullet point list of links to documentation, stack overflow, Here you should include a bullet point list of links to documentation, stack overflow,
whatever, that could help guide someone on what it is they are trying to do. whatever, that could help guide someone on what it is they are trying to do.
......
...@@ -18,13 +18,15 @@ the issues page. ...@@ -18,13 +18,15 @@ the issues page.
If you decide to take on an issue for Go you will need to work in a branch off If you decide to take on an issue for Go you will need to work in a branch off
of the current development branch (ie. `2.3-dev` with 2.3 being the version in of the current development branch (ie. `2.3-dev` with 2.3 being the version in
development). development).
This can be done with the following chain of `git` commands within `go/`: This can be done with the following chain of `git` commands within `go/`:
git pull ```sh
git checkout 2.3-dev git pull
git checkout -B ##-shortdescription git checkout 2.3-dev
git checkout -B ##-shortdescription
```
**Note:** **Note:**
...@@ -34,9 +36,11 @@ does. ...@@ -34,9 +36,11 @@ does.
**Example:** **Example:**
git pull ```sh
git checkout 2.3-dev git pull
git checkout -B 102-readmeUpdates git checkout 2.3-dev
git checkout -B 102-readmeUpdates
```
If you are working on something that does not have an issue please open a new If you are working on something that does not have an issue please open a new
issue before creating your branch. issue before creating your branch.
......
...@@ -221,6 +221,18 @@ repository and is named go-cleanlinks.cron. Drop this in cron.hourly and ...@@ -221,6 +221,18 @@ repository and is named go-cleanlinks.cron. Drop this in cron.hourly and
change the paths so that they point to the virtualenv activate script and change the paths so that they point to the virtualenv activate script and
manage.py. manage.py.
## Production cron job
```sh
#!/bin/bash
# Cron job to automatically expire outdated links, put this in cron.hourly
ACTIVATE_PATH=/path/to/virtualenv/activate
MANAGE_PATH=/path/to/go/manage.py
source ${ACTIVATE_PATH}
python ${MANAGE_PATH} expirelinks
```
--- ---
**Note:** **Note:**
......
...@@ -7,7 +7,7 @@ services: ...@@ -7,7 +7,7 @@ services:
restart_policy: restart_policy:
condition: on-failure condition: on-failure
networks: networks:
- gonet - go
ports: ports:
- "3306:3306" - "3306:3306"
environment: environment:
...@@ -23,10 +23,10 @@ services: ...@@ -23,10 +23,10 @@ services:
restart_policy: restart_policy:
condition: on-failure condition: on-failure
networks: networks:
- gonet - go
ports: ports:
- '8000:8000' - '8000:8000'
command: /bin/bash ./startup.sh command: ./startup.sh
volumes: volumes:
- .:/go - .:/go
depends_on: depends_on:
...@@ -46,7 +46,7 @@ services: ...@@ -46,7 +46,7 @@ services:
- GO_EMAIL_HOST_PASSWORD= - GO_EMAIL_HOST_PASSWORD=
- GO_EMAIL_FROM= - GO_EMAIL_FROM=
- GO_EMAIL_TO= - GO_EMAIL_TO=
- superuser=dhaynes3 - SUPERUSER=dhaynes3
networks: networks:
gonet: go:
#!/bin/bash
# Cron job to automatically expire outdated links, put this in cron.hourly
ACTIVATE_PATH=/path/to/virtualenv/activate
MANAGE_PATH=/path/to/go/manage.py
source ${ACTIVATE_PATH}
python ${MANAGE_PATH} expirelinks
""" """
go/commands/expirelinks.py go/commands/expirelinks.py
"""
Remove expired links from the database.
"""
# Future Imports # Future Imports
from __future__ import (absolute_import, division, print_function, from __future__ import (absolute_import, division, print_function,
unicode_literals) unicode_literals)
...@@ -16,20 +17,15 @@ from go.models import URL ...@@ -16,20 +17,15 @@ from go.models import URL
class Command(BaseCommand): class Command(BaseCommand):
""" """
Define a new custom django-admin command to remove expired links from the Define a new custom django-admin command to remove expired links from the
database database.
""" """
# Define help text for this command
help = 'Removes expired links from the database' help = 'Removes expired links from the database'
def handle(self, *args, **options): def handle(self, *args, **options):
""" """
The handle function handles the main component of the django-admin Handle the main component of the django-admin command. Loop
command. 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()):
# Loop through a list of all URL objects that have expired expired_url.delete()
# (expires field is less than or equal to today's date)
for toexpire in URL.objects.filter(expires__lte=timezone.now()):
# Delete the current URL
toexpire.delete()
""" """
go/commands/test_expirelinks.py go/commands/test_expirelinks.py
"""
Test that the function to expire Go links actually works.
"""
# Future Imports # Future Imports
from __future__ import (absolute_import, division, print_function, from __future__ import (absolute_import, division, print_function,
unicode_literals) unicode_literals)
...@@ -19,16 +20,11 @@ from django.utils import timezone ...@@ -19,16 +20,11 @@ from django.utils import timezone
from go.models import URL, RegisteredUser from go.models import URL, RegisteredUser
class ExpireLinksTest(TestCase): class ExpireLinksTest(TestCase):
"""
Test cases for the functions in expirelinks
"""
def setUp(self): def setUp(self):
""" """
Set up any variables such as dummy objects that will be utilised in Set up any variables such as dummy objects that will be utilized in
testing methods testing methods
""" """
# Setup a blank URL object with an owner # Setup a blank URL object with an owner
User.objects.create(username='dhaynes', password='password') User.objects.create(username='dhaynes', password='password')
get_user = User.objects.get(username='dhaynes') get_user = User.objects.get(username='dhaynes')
...@@ -52,9 +48,8 @@ class ExpireLinksTest(TestCase): ...@@ -52,9 +48,8 @@ class ExpireLinksTest(TestCase):
def test_expirelinks(self): def test_expirelinks(self):
""" """
Test that the expirelinks django admin command functions as intentioned. Make a call to expire Go links and assert that the number of links has
been reduced.
""" """
call_command('expirelinks') call_command('expirelinks')
self.assertTrue(len(URL.objects.all()) == 1) self.assertTrue(len(URL.objects.all()) == 1)
<!-- include the base html template --> <!-- include the base html template -->
{% extends 'layouts/base.html' %} {% extends 'layouts/base.html' %}
<!-- Tell Django to load static files -->
{% load staticfiles %} {% load staticfiles %}
<!-- define the page title block -->
{% block title %} {% block title %}
SRCT Go &bull; About SRCT Go &bull; About
{% endblock %} {% endblock %}
<!-- define the content block for the page -->
{% block content %} {% block content %}
<!-- define the page header div --> <!-- page header -->
<div class="page-header" id="banner"> <div class="page-header" id="banner">
<div class="row"> <div class="row">
<div class="col-md-12"> <div class="col-md-12">
...@@ -26,41 +23,32 @@ SRCT Go &bull; About ...@@ -26,41 +23,32 @@ SRCT Go &bull; About
</div> </div>
</div> </div>
<!-- define the terms of use div --> <!-- terms of use -->
<div class="row" id="terms"> <div class="row" id="terms">
<div class="col-md-12"> <div class="col-md-12">
<h4>Terms of Use</h4> <h2>Terms of Use</h2>
<legend></legend>
<p> <p>
By using Go you acknowledge that you are a current George Mason Student or faculty By using Go you acknowledge that you are a current George Mason Student or faculty
member. member.
<br></br>
Additionally, any link that you create is subject to removal by Go admins if it is Additionally, any link that you create is subject to removal by Go admins if it is
deemed to associate the univeristy with any deemed to associate the univeristy with any derogatory or controversial matters.
<br /> derogatory or controversial matters.
<br></br>
Go admins also reserve the right to remove and ban any users who attempt to abuse Go admins also reserve the right to remove and ban any users who attempt to abuse
the link creation system in any manner. the link creation system in any manner.
<br></br>
Since Go falls under the gmu.edu domain, users who use this service will act in compliance 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/"> with the GMU <a href="https://universitypolicy.gmu.edu/policies/responsible-use-of-computing/">Responsible Use of Computing</a> policies.
Responsible Use of Computing</a> policies.
</p> </p>
<br />
</div> </div>
</div> </div>
<!-- define the who made go? div --> <!-- who made go? -->
<div class="row"> <div class="row">
<div class="col-md-12"> <div class="col-md-12">
<h4>Who made Go?</h4> <h2>Who made Go?</h2>
<legend></legend>
<p> <p>
Members of the Members of the
<a href="//srct.gmu.edu">Student-Run Computing and Technology</a> registered <a href="//srct.gmu.edu">Student-Run Computing and Technology</a> registered
student organization at <a href="//gmu.edu">George Mason University</a> are student organization at <a href="//gmu.edu">George Mason University</a> are
the clever, the clever, talented student developers behind Go.
<br /> talented student developers behind Go.
</p> </p>
<p> <p>
We are a group of creative people that like making software and want to give back We are a group of creative people that like making software and want to give back
...@@ -68,22 +56,18 @@ SRCT Go &bull; About ...@@ -68,22 +56,18 @@ SRCT Go &bull; About
</p> </p>
<p> <p>
<a href="//srct.gmu.edu/contact/">Contact us</a> to get involved! <a href="//srct.gmu.edu/contact/">Contact us</a> to get involved!
<p> </p>
<br />
</div> </div>
</div> </div>
<!-- define the thanks! div --> <!-- define the thanks! div -->
<div class="row"> <div class="row">
<div class="col-md-12"> <div class="col-md-12">
<h4>Thanks!</h4> <h2>Thanks!</h2>
<legend></legend>
<p> <p>
This project was made possible through the collective contributions of multiple Mason This project was made possible through the collective contributions of
SRCT members. multiple Mason SRCT members.
<br></br>
<a href="https://git.gmu.edu/srct/go/milestones/3">Go 2.2</a>: <a href="https://git.gmu.edu/srct/go/milestones/3">Go 2.2</a>:
<br />
<a href="https://github.com/dhaynespls">David Haynes</a>, <a href="https://github.com/dhaynespls">David Haynes</a>,
<a href="https://github.com/ocelotsloth">Mark Stenglein</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://www.youtube.com/watch?v=dQw4w9WgXcQ">Andres Villogas</a>,
...@@ -97,9 +81,7 @@ SRCT Go &bull; About ...@@ -97,9 +81,7 @@ SRCT Go &bull; About
<a href="https://github.com/nanderson94">Nicholas Anderson</a>, <a href="https://github.com/nanderson94">Nicholas Anderson</a>,
<a href="">Kevin Mckigney</a>, <a href="">Kevin Mckigney</a>,
and <a href="https://github.com/dwbond">Daniel Bond</a>. and <a href="https://github.com/dwbond">Daniel Bond</a>.
<br></br>
<a href="https://git.gmu.edu/srct/go/milestones/2">Go 2.1</a>: <a href="https://git.gmu.edu/srct/go/milestones/2">Go 2.1</a>:
<br />
<a href="https://github.com/dhaynespls">David Haynes</a>, <a href="https://github.com/dhaynespls">David Haynes</a>,
<a href="https://github.com/zosman1">Zach Osman</a>, <a href="https://github.com/zosman1">Zach Osman</a>,
<a href="https://github.com/roberthitt">Robert Hitt</a>, <a href="https://github.com/roberthitt">Robert Hitt</a>,
...@@ -109,85 +91,23 @@ SRCT Go &bull; About ...@@ -109,85 +91,23 @@ SRCT Go &bull; About
<a href="https://github.com/mdsecurity">Mattias Duffy</a>, <a href="https://github.com/mdsecurity">Mattias Duffy</a>,
<a href="https://github.com/IAmEyad">Eyad Hasan</a>, <a href="https://github.com/IAmEyad">Eyad Hasan</a>,
and <a href="https://github.com/danielkim1">Danny Kim</a>. and <a href="https://github.com/danielkim1">Danny Kim</a>.
<br></br>
<a href="https://git.gmu.edu/srct/go/milestones/1">Go 2.0</a>: <a href="https://git.gmu.edu/srct/go/milestones/1">Go 2.0</a>:
<br />
<a href="https://github.com/dhaynespls">David Haynes</a>, <a href="https://github.com/dhaynespls">David Haynes</a>,
<a href="">Matthew Rodgers</a>, <a href="">Matthew Rodgers</a>,
<a href="https://github.com/nanderson94">Nicholas Anderson</a>, <a href="https://github.com/nanderson94">Nicholas Anderson</a>,
and <a href="https://github.com/dwbond">Daniel Bond</a>. and <a href="https://github.com/dwbond">Daniel Bond</a>.
<br></br>
Go 1.0: Go 1.0:
<br />
<a href="https://github.com/jrouly">Michel Rouly</a>, <a href="https://github.com/jrouly">Michel Rouly</a>,
<a href="https://github.com/creffett">Chris Reffett</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>. <a href="https://github.com/nanderson94">Nicholas Anderson</a>, and <a href="https://github.com/akshaykarthik">Akshay Karthik</a>.
<br></br>
</p> </p>
<p> <p>
Additional thanks are due to the <a href="https://wiki.srct.gmu.edu/Executive_Board"> Additional thanks are due to the <a href="https://wiki.srct.gmu.edu/Executive_Board">
Student-Run Computing and Technology executive Student-Run Computing and Technology executive
board from 2014-present</a>, and our academic advisor, board from 2014-present</a>,and our academic advisor,
<a href="https://cs.gmu.edu/~kdobolyi/">Professor Kinga Dobolyi</a>. <a href="https://cs.gmu.edu/~kdobolyi/">Professor Kinga Dobolyi</a>.
</p> </p>
</div> </div>
</div> </div>
<!-- define the LibreJS License Table -->
<div class="row">
<div class="col-md-12">
<h4>JavaScript License Information</h4>
<legend></legend>
<table class="table" id="jslicense-labels1">
<thead>
<tr>
<th>Source File</th>
<th>License</th>
<th>Uncompressed Source</th>
</tr>
</thead>
<tr>
<td><a href="{% static "js/jquery.min.js" %}">jquery.min.js</a></td>
<td><a href="http://jquery.org/license">Expat</a></td>
<td><a href="http://code.jquery.com/jquery-2.1.1.js">jquery-2.1.1.js</a></td>
</tr>
<tr>
<td><a href="{% static "js/bootstrap.min.js" %}">bootstrap.js</a></td>
<td><a href="http://www.apache.org/licenses/LICENSE-2.0">Apache-2.0</a></td>
<td><a href="{% static "js/bootstrap.js" %}">bootstrap.js</a></td>
</tr>
<tr>
<td><a href="{% static "js/clipboard.min.js" %}">clipboard.min.js</a></td>
<td><a href="https://zenorocha.mit-license.org/">Expat</a></td>
<td><a href="{% static "js/clipboard.js" %}">clipboard.js</a></td>
</tr>
<tr>
<td><a href="{% static "js/copy.js" %}">copy.js</a></td>
<td><a href="http://www.apache.org/licenses/LICENSE-2.0">Apache-2.0</a></td>
<td><a href="{% static "js/copy.js" %}">copy.js</a></td>
</tr>
<tr>
<td><a href="{% static "js/new_link.js" %}">new_link.js</a></td>
<td><a href="http://www.apache.org/licenses/LICENSE-2.0">Apache-2.0</a></td>
<td><a href="{% static "js/new_link.js" %}">new_link.js</a></td>
</tr>
<tr>
<td><a href="{% static "js/tab.js" %}">tab.js</a></td>
<td><a href="https://github.com/twbs/bootstrap/blob/master/LICENSE">Expat</a></td>
<td><a href="{% static "js/tab.js" %}">tab.js</a></td>
</tr>
<tr>
<td><a href="{% static "js/tooltip.js" %}">tooltip.js</a></td>
<td><a href="https://github.com/twbs/bootstrap/blob/master/LICENSE">Expat</a></td>
<td><a href="{% static "js/tooltip.js" %}">tooltip.js</a></td>
</tr>
<tr>
<td><a href="{% static "js/useradmin.js" %}">useradmin.js</a></td>
<td><a href="http://www.apache.org/licenses/LICENSE-2.0">Apache-2.0</a></td>
<td><a href="{% static "js/useradmin.js" %}">useradmin.js</a></td>
</tr>
</table>
</div>
</div>
{% endblock %} {% endblock %}
{% extends 'layouts/base.html' %}
{% block title %}
SRCT Go &bull; Welcome
{% endblock %}
{% block content %}
<div class="page-header mb-5">
<div class="row">
<div class="col">
<h1><i class="fas fa-link"></i> Go</h1>
<p class="lead">University-branded URL shortening</p>
</div>
</div>
</div>
<div class="row mb-5 ">
<div class="col-md-4 d-flex align-items-stretch">
<div class="card landing-card shadow-hover mb-3">
<div class="card-header">
<h5>What is Go?</h5>
</div>
<div class="card-body">
<p class="card-text">
Go provides University-branded URL shortening for student organizations, administration,
and ULife groups. Any approved user can generate a
<a href="https://go.gmu.edu">go.gmu.edu</a> address that can redirect to a longer URL.
</p>
<p class="card-text">
Go is a product of the George Mason University
<a href="https://srct.gmu.edu">Student-Run Computing and Technology</a>
student organization.
</p>
</div>
</div>
</div>
<div class="col-md-4 d-flex align-items-stretch">
<div class="card landing-card shadow-hover mb-3">
<div class="card-header">
<h5>Why should I use Go?</h5>
</div>
<div class="card-body">
<p class="card-text">
Go features:
<ul class="fa-ul">
<li>
<span class="fa-li mt-1">
<i class="fas fa-check-square"></i>
</span>Data tracking on the number of clicks a Go link gets.</li>
<li>
<span class="fa-li mt-1">
<i class="fas fa-check-square"></i>
</span>Options to share Go links across various social media platforms.
</li>
<li>
<span class="fa-li mt-1">
<i class="fas fa-check-square"></i>
</span>QR Code generation at various resolutions, ready to be shared.
</li>
<li>
<span class="fa-li mt-1">
<i class="fas fa-check-square"></i>
</span>Optional expiration for links after particular times.</li>
</ul>
</p>
</div>
</div>
</div>
<div class="col-md-4 d-flex align-items-stretch">
<div class="card landing-card shadow-hover mb-3">
<div class="card-header">
<h5>How do I access Go?</h5>
</div>
<div class="card-body">
<p class="card-text">
In order to prevent abuse of the URL shortener, access to Go is moderated by SRCT
administrators. New users will need to fill out a registration form in
order to become an approved user.
</p>
<p class="card-text">
Additionally, only users with a current, valid Mason username and password may request
to be approved.
</p>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-md-6">
<a href="{% url 'go_login' %}" class="btn btn-outline-primary btn-block shadow-hover mb-3">
<i class="fas fa-sign-in-alt"></i> Log In</a>
</div>
<div class="col-md-6">
<a href="{% url 'signup' %}" class="btn btn-outline-primary btn-block shadow-hover mb-3">
<i class="fas fa-user-plus"></i> Sign Up</a>
</div>
</div>
{% endblock %}
\ No newline at end of file
<!-- Tell Django to load static files --> <!-- Tell Django to load static files -->
{% load staticfiles %} {% load staticfiles %}
<!-- HTML 5 definition -->
<!DOCTYPE html>
<!-- Start the HTML page for Go -->
<html> <html>
<!-- load in our header content for every page -->
<head> <head>
<!-- load in the title block defined on each html page --> <!-- title block defined on each html page -->
<title>