Commit 02560ef1 authored by David Haynes's avatar David Haynes 🙆

Merge branch '182-API-Init' into 'go-three'

Resolve "Initialize the API"

See merge request !122
parents 45be3a4f effeb834
Pipeline #2627 passed with stage
in 52 seconds
......@@ -6,7 +6,6 @@
venv
.venv
/provisioning/playbook.retry
/go/settings/settings.py
/go/settings/secret.py
/go/static/admin
/go/media
......
......@@ -36,9 +36,8 @@ before_script:
- python manage.py migrate
- echo "from django.contrib.auth import get_user_model; User = get_user_model(); User.objects.create_superuser('root', 'root@srct.gmu.edu', 'root') " | python manage.py shell
Go-py3.6:
image: library/python:3.6
Go-py3.7:
image: library/python:3.7
stage: test
script:
- coverage run --source=go --omit=*migrations/*,*admin.py,*manage.py,*wsgi.py,*settings.py,*secret.py,*__init__.py,*.pyc,*templates/*,*static/* manage.py test
- coverage html -i && grep pc_cov htmlcov/index.html | egrep -o "[0-9]+\%" | awk '{ print "covered " $1;}'
- echo "done :)"
# Build on top of the python image and install any external packages
FROM python:3.6
FROM python:3.7
RUN apt-get update
RUN apt-get install netcat -y
......
......@@ -14,9 +14,10 @@ django-crispy-forms = "==1.7.0"
django-ratelimit = "==1.0.1"
django-redis-cache = "==1.7.1"
hashids = "==1.2.0"
mysqlclient = "*"
django-cas-client = "*"
requests = "*"
mysqlclient = "*"
djangorestframework = "*"
[requires]
python_version = "3.6"
python_version = "3.7"
{
"_meta": {
"hash": {
"sha256": "c8aecf58c565d1e2d106d545721922331eb702b7014ecbaf035747291dd94d94"
"sha256": "bdea5532bb3583afe0508086a4acd7186b5c21fad2de7f9bcd73dd0381ee51e7"
},
"pipfile-spec": 6,
"requires": {
"python_version": "3.6"
"python_version": "3.7"
},
"sources": [
{
......@@ -32,11 +32,11 @@
},
"django": {
"hashes": [
"sha256:3eb25c99df1523446ec2dc1b00e25eb2ecbdf42c9d8b0b8b32a204a8db9011f8",
"sha256:69ff89fa3c3a8337015478a1a0744f52a9fef5d12c1efa01a01f99bcce9bf10c"
"sha256:97886b8a13bbc33bfeba2ff133035d3eca014e2309dff2b6da0bdfc0b8656613",
"sha256:e900b73beee8977c7b887d90c6c57d68af10066b9dac898e1eaf0f82313de334"
],
"index": "pypi",
"version": "==2.0.6"
"version": "==2.0.7"
},
"django-cas-client": {
"hashes": [
......@@ -69,6 +69,14 @@
"index": "pypi",
"version": "==1.7.1"
},
"djangorestframework": {
"hashes": [
"sha256:b6714c3e4b0f8d524f193c91ecf5f5450092c2145439ac2769711f7eba89a9d9",
"sha256:c375e4f95a3a64fccac412e36fb42ba36881e52313ec021ef410b40f67cddca4"
],
"index": "pypi",
"version": "==3.8.2"
},
"hashids": {
"hashes": [
"sha256:6539b892a426e75747a9c0ad69409e9566f9c21b79310fc3424b5b6726f28da6"
......@@ -78,28 +86,24 @@
},
"idna": {
"hashes": [
"sha256:2c6a5de3089009e3da7c5dde64a141dbc8551d5b7f6cf4ed7c2568d0cc520a8f",
"sha256:8c7309c718f94b3a625cb648ace320157ad16ff131ae0af362c9f21b80ef6ec4"
"sha256:156a6814fb5ac1fc6850fb002e0852d56c0c8d2531923a51032d1b70760e186e",
"sha256:684a38a6f903c1d71d6d5fac066b58d7768af4de2b832e426ec79c30daa94a16"
],
"version": "==2.6"
"version": "==2.7"
},
"mysqlclient": {
"hashes": [
"sha256:1e85e48b167e2af3bb08f273fdbd1ad6401cbe75057fa6513f97387dc7b282dc",
"sha256:2d9ec33de39f4d9c64ad7322ede0521d85829ce36a76f9dd3d6ab76a9c8648e5",
"sha256:371df79d000af56b4e540b7ce2120d1c9afb04b751bfce25a1eb609c50fd10ff",
"sha256:b3b1a7e4468180afb79289b54069d9499242946a4cedf3928cbf6b2a13800016",
"sha256:d56e379c03efad746e84705cbb97401f60d1f98b05e11a27f2d9c2d043936974"
"sha256:ff8ee1be84215e6c30a746b728c41eb0701a46ca76e343af445b35ce6250644f"
],
"index": "pypi",
"version": "==1.3.12"
"version": "==1.3.13"
},
"pytz": {
"hashes": [
"sha256:65ae0c8101309c45772196b21b74c46b2e5d11b6275c45d251b150d5da334555",
"sha256:c06425302f2cf668f1bba7a0a03f3c1d34d4ebeef2c72003da308b3947c7f749"
"sha256:a061aa0a9e06881eb8b3b2b43f05b9439d6583c206d0a6c340ff72a7b6669053",
"sha256:ffb9ef1de172603304d9d2819af6f5ece76f2e85ec10692a524dd876e72bf277"
],
"version": "==2018.4"
"version": "==2018.5"
},
"redis": {
"hashes": [
......@@ -110,37 +114,38 @@
},
"requests": {
"hashes": [
"sha256:6a1b267aa90cac58ac3a765d067950e7dbbf75b1da07e895d1f594193a40a38b",
"sha256:9c443e7324ba5b85070c4a818ade28bfabedf16ea10206da1132edaa6dda237e"
"sha256:63b52e3c866428a224f97cab011de738c36aec0185aa91cfacd418b5d58911d1",
"sha256:ec22d826a36ed72a7358ff3fe56cbd4ba69dd7a6718ffd450ff0e9df7a47ce6a"
],
"index": "pypi",
"version": "==2.18.4"
"version": "==2.19.1"
},
"urllib3": {
"hashes": [
"sha256:06330f386d6e4b195fbfc736b297f58c5a892e4440e54d294d7004e3a9bbea1b",
"sha256:cc44da8e1145637334317feebd728bd869a35285b93cbb4cca2577da7e62db4f"
"sha256:a68ac5e15e76e7e5dd2b8f94007233e01effe3e50e8daddf69acfd81cb686baf",
"sha256:b5725a0bd4ba422ab0e66e89e030c806576753ea3ee08554382c14e685d117b5"
],
"version": "==1.22"
"markers": "python_version != '3.0.*' and python_version != '3.3.*' and python_version != '3.2.*' and python_version < '4' and python_version >= '2.6' and python_version != '3.1.*'",
"version": "==1.23"
}
},
"develop": {
"astroid": {
"hashes": [
"sha256:0ef2bf9f07c3150929b25e8e61b5198c27b0dca195e156f0e4d5bdd89185ca1a",
"sha256:fc9b582dba0366e63540982c3944a9230cbc6f303641c51483fa547dcc22393a"
"sha256:0a0c484279a5f08c9bcedd6fa9b42e378866a7dcc695206b92d59dc9f2d9760d",
"sha256:218e36cf8d98a42f16214e8670819ce307fa707d1dcf7f9af84c7aede1febc7f"
],
"version": "==1.6.5"
"version": "==2.0.1"
},
"coverage": {
"hashes": [
"sha256:03481e81d558d30d230bc12999e3edffe392d244349a90f4ef9b88425fac74ba",
"sha256:0b136648de27201056c1869a6c0d4e23f464750fd9a9ba9750b8336a244429ed",
"sha256:104ab3934abaf5be871a583541e8829d6c19ce7bde2923b2751e0d3ca44db60a",
"sha256:15b111b6a0f46ee1a485414a52a7ad1d703bdf984e9ed3c288a4414d3871dcbd",
"sha256:10a46017fef60e16694a30627319f38a2b9b52e90182dddb6e37dcdab0f4bf95",
"sha256:198626739a79b09fa0a2f06e083ffd12eb55449b5f8bfdbeed1df4910b2ca640",
"sha256:1c383d2ef13ade2acc636556fd544dba6e14fa30755f26812f54300e401f98f2",
"sha256:23d341cdd4a0371820eb2b0bd6b88f5003a7438bbedb33688cd33b8eae59affd",
"sha256:28b2191e7283f4f3568962e373b47ef7f0392993bb6660d079c62bd50fe9d162",
"sha256:2a5b73210bad5279ddb558d9a2bfedc7f4bf6ad7f3c988641d83c40293deaec1",
"sha256:2eb564bbf7816a9d68dd3369a510be3327f1c618d2357fa6b1216994c2e3d508",
"sha256:337ded681dd2ef9ca04ef5d93cfc87e52e09db2594c296b4a0a3662cb1b41249",
"sha256:3a2184c6d797a125dca8367878d3b9a178b6fdd05fdc2d35d758c3006a1cd694",
......@@ -160,16 +165,11 @@
"sha256:7e1fe19bd6dce69d9fd159d8e4a80a8f52101380d5d3a4d374b6d3eae0e5de9c",
"sha256:8c3cb8c35ec4d9506979b4cf90ee9918bc2e49f84189d9bf5c36c0c1119c6558",
"sha256:9d6dd10d49e01571bf6e147d3b505141ffc093a06756c60b053a859cb2128b1f",
"sha256:9e112fcbe0148a6fa4f0a02e8d58e94470fc6cb82a5481618fea901699bf34c4",
"sha256:ac4fef68da01116a5c117eba4dd46f2e06847a497de5ed1d64bb99a5fda1ef91",
"sha256:b8815995e050764c8610dbc82641807d196927c3dbed207f0a079833ffcf588d",
"sha256:be6cfcd8053d13f5f5eeb284aa8a814220c3da1b0078fa859011c7fffd86dab9",
"sha256:c1bb572fab8208c400adaf06a8133ac0712179a334c09224fb11393e920abcdd",
"sha256:de4418dadaa1c01d497e539210cb6baa015965526ff5afc078c57ca69160108d",
"sha256:e05cb4d9aad6233d67e0541caa7e511fa4047ed7750ec2510d466e806e0255d6",
"sha256:e4d96c07229f58cb686120f168276e434660e4358cc9cf3b0464210b04913e77",
"sha256:f3f501f345f24383c0000395b26b726e46758b71393267aeae0bd36f8b3ade80",
"sha256:f8a923a85cb099422ad5a2e345fe877bbc89a8a8b23235824a93488150e45f6e"
"sha256:f3f501f345f24383c0000395b26b726e46758b71393267aeae0bd36f8b3ade80"
],
"index": "pypi",
"version": "==4.5.1"
......@@ -180,6 +180,7 @@
"sha256:b9c40e9750f3d77e6e4d441d8b0266cf555e7cdabdcff33c4fd06366ca761ef8",
"sha256:ec9ef8f4a9bc6f71eec99e1806bfa2de401650d996c59330782b89a5555c1497"
],
"markers": "python_version != '3.2.*' and python_version != '3.1.*' and python_version != '3.0.*' and python_version != '3.3.*' and python_version >= '2.7'",
"version": "==4.3.4"
},
"lazy-object-proxy": {
......@@ -225,11 +226,11 @@
},
"pylint": {
"hashes": [
"sha256:a48070545c12430cfc4e865bf62f5ad367784765681b3db442d8230f0960aa3c",
"sha256:fff220bcb996b4f7e2b0f6812fd81507b72ca4d8c4d05daf2655c333800cb9b3"
"sha256:248a7b19138b22e6390cba71adc0cb03ac6dd75a25d3544f03ea1728fa20e8f4",
"sha256:9cd70527ef3b099543eeabeb5c80ff325d86b477aa2b3d49e264e12d12153bc8"
],
"index": "pypi",
"version": "==1.9.2"
"version": "==2.0.0"
},
"pylint-django": {
"hashes": [
......@@ -241,9 +242,9 @@
},
"pylint-plugin-utils": {
"hashes": [
"sha256:053ade7c76f83242225b49d47624d9ecb803c60347e2c5127e97a19bf0c9f95e"
"sha256:8ad25a82bcce390d1d6b7c006c123e0cb18051839c9df7b8bdb7823c53fe676e"
],
"version": "==0.2.6"
"version": "==0.4"
},
"six": {
"hashes": [
......
# Go 3
[![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.6-blue.svg)]()
[![Django version](https://img.shields.io/badge/Django-2.0-brightgreen.svg)]()
A project of [GMU SRCT](https://srct.gmu.edu).
Go is a drop-in URL shortening service. This project aims to provide an easy to
use URL branding service for institutions that wish to widely disseminate
information without unnecessarily outsourcing branding.
Go is currently a `Python 3` project written in the `Django` web framework,
with `MySQL` as our backend database.
## Setup instructions for local development
Go currently supports developers on Linux, macOS and Windows platforms through
the Docker container platform. We have included instructions for manual setup
as well. Here's our walk-through of steps we will take:
1. Install `git` on your system.
1. Clone the Go codebase.
1. Get Go up and running with the method of your choice.
### 1) Install `git` on your system
`git` is the version control system used for SRCT projects.
#### On Linux Based Systems
**with apt:**
Open a terminal and run the following command:
sudo apt update
This retrieves links to the most up-to-date and secure versions of your
packages.
Next, with:
sudo apt install git
you install `git` onto your system.
#### On macOS
We recommend that you use the third party Homebrew package manager for macOS,
which allows you to install packages from your terminal just as easily as you
could on a Linux based system. You could use another package manager (or not
use one at all), but Homebrew is highly reccomended.
To get homebrew, run the following command in a terminal:
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)
**Note**: You do NOT need to use `sudo` when running any Homebrew commands, and
it likely won't work if you do.
Next, to make sure Homebrew is up to date, run:
brew update
Finally we can install git with:
brew install git
#### On Windows
We recommend that if you are on Windows 10 to make use of the Windows Subsystem
for Linux (WSL). The following link should get you up and running:
[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:
[https://git-scm.com/download/win](https://git-scm.com/download/win)
I have 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
Now, we're going to clone down a copy of the Go codebase from
[git.gmu.edu](https://git.gmu.edu/srct/go), the SRCT code respository with SSH.
**a)** Configure your ssh keys by following the directions at:
[git.gmu.edu/help/ssh/README](https://git.gmu.edu/help/ssh/README).
**b)** Now, on your computer, navigate to the directory in which you want to
download the project (ie. perhaps one called `development/SRCT`), and run
git clone git@git.gmu.edu:srct/go.git
### 3) Get Go up and running with the method of your choice
Now that we have `git` setup and cloned down the code you can
cd go/
and get to working on setting up a development environment!
#### Docker
Docker is an emerging containerization platform written in Google's Go
language. Instead of running a full VM that runs Go, we package up all the
various bits that make up Go and run that as a container (two containers: one
for Go and the other for mysql) that act as normal processes to the OS.
Check out [docker.com](https://www.docker.com/what-docker) for more details.
Pros:
* Lightweight
* Can be run on most machines without needing significant resources.
* SRCT members report minimal battery impact on laptops.
* Fast
* Compared to other methods, Docker is comparatively faster to setup than
manual setup.
* Minimal setup
* You run one command. Really easy to get up and running once you install
Docker.
* Good cross platform support
* Runs smoothly on macOS, Linux, and Windows
* Great docs to help if you get stuck.
* Can easily destroy and rebuild the docker images
* Loads in changes to code on the fly
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).
#### 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 Docker except it automates 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:
https://git.gmu.edu/srct/go/wikis/manual-setup
## Some words about contributing to Go
### Testing
You are _very strongly_ encouraged to write test cases where applicible for
code that you contribute to the repo. This is not a rule at the moment but
rather a strong suggestion. It's good practice for corporate land and will also
ensure your code works. Additionally, there are quite a few example ones to
look at in the repo and on Google.
### Running Unit Tests
Unit tests are run on every commit sent to gitlab though that can be a pain to
rely on. Here's how to run them locally:
### Docker
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.
### Manual Setup
Assuming you are within your virtualenv:
python manage.py test
### CONTRIBUTING.md
This document goes into detail about how to contribute to the repo, plus some
opinions about using `git`.
### Opening issues
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
## DISCLAIMER
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`.
Go 3 is a major refactor of the project with an emphasis on extensibility.
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.
Things might not work quite right.
### Coding style
Docs may not exist.
TODO
I wouldn't go so far as to say we are hitting the reset button.
### Getting Help
But it's close.
I encourage you to join the
[#go channel](https://srct.slack.com/messages/go/details/) in SRCT's
[Slack Group](https://srct.slack.com) if you have any questions on setup or
would like to contribute.
```sh
pipenv install
pipenv shell
code .
docker-compose up
```
......@@ -3,12 +3,12 @@ go/cas_callbacks.py
Parse the CAS/PF responses and create users in the database.
"""
# Other Imports
import requests
# Django Imports
from django.conf import settings
from django.contrib.auth.models import User
# Other Imports
import requests
def pfparse(pf_name_result: str) -> list:
"""
......
......@@ -14,10 +14,14 @@ from django.db import models
from django.db.models.signals import post_save
from django.dispatch import receiver
from django.utils import timezone
from django.conf import settings
from django.db.models.signals import post_save
from django.dispatch import receiver
# Other Imports
from hashids import Hashids
from .validators import regex_short_validator, unique_short_validator
from rest_framework.authtoken.models import Token
# Generate the salt and initialize Hashids
# Note: the Hashids library already implements several restrictions oncharacter
......@@ -88,6 +92,12 @@ def handle_reguser_creation(sender, instance, created, **kwargs):
if created:
RegisteredUser.objects.create(user=instance)
@receiver(post_save, sender=settings.AUTH_USER_MODEL)
def create_auth_token(sender, instance=None, created=False, **kwargs):
if created:
token = Token.objects.create(user=instance)
print(token.key)
class URL(models.Model):
"""
The representation of a stored URL redirection rule. Each URL has
......
"""
go/serializers.py
Define how data is translated from the database to json/API representation.
"""
from django.contrib.auth.models import User, Group
from rest_framework import serializers
class UserSerializer(serializers.HyperlinkedModelSerializer):
class Meta:
model = User
fields = ('url', 'username', 'email', 'groups')
class GroupSerializer(serializers.HyperlinkedModelSerializer):
class Meta:
model = Group
fields = ('url', 'name')
......@@ -17,15 +17,33 @@ from django.http import HttpResponseServerError # Http404
from django.http import HttpResponseRedirect
from django.shortcuts import get_object_or_404, redirect, render
from django.utils import timezone
# Other imports
from ratelimit.decorators import ratelimit
# App Imports
from .forms import SignupForm, URLForm, EditForm
from .forms import EditForm, SignupForm, URLForm
from .models import URL, RegisteredUser
from django.contrib.auth.models import User, Group
from rest_framework import viewsets
from .serializers import UserSerializer, GroupSerializer
class UserViewSet(viewsets.ModelViewSet):
"""
API endpoint that allows users to be viewed or edited.
"""
queryset = User.objects.all().order_by('-date_joined')
serializer_class = UserSerializer
class GroupViewSet(viewsets.ModelViewSet):
"""
API endpoint that allows groups to be viewed or edited.
"""
queryset = Group.objects.all()
serializer_class = GroupSerializer
def index(request):
"""
If a user is logged in, this view displays all the information about all
......
......@@ -2,13 +2,8 @@
import os
import sys
if os.environ['GO_ENV'] == 'production':
settings = "settings.production"
else:
settings = "settings.local"
if __name__ == "__main__":
os.environ.setdefault("DJANGO_SETTINGS_MODULE", settings)
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "settings.settings")
from django.core.management import execute_from_command_line
......
"""
settings/local.py
Local development settings and globals.
"""
from .base import *
# DEBUG mode is used to view more details when errors occur
# Do not have set True in production
DEBUG = True
#CAS_SERVER_URL = "https://cas.srct.gmu.edu/"
CAS_SERVER_URL = "https://login.gmu.edu"
# dummy cache for development-- doesn't actually cache things
CACHES = {
'default': {
'BACKEND': 'django.core.cache.backends.dummy.DummyCache',
}
}
"""
settings/production.py
Production settings and globals.
"""
from .base import *
# DEBUG mode is used to view more details when errors occur
# Do not have set True in production
DEBUG = False
CAS_SERVER_URL = "https://login.gmu.edu"
CACHES = {
'default': {
'BACKEND': 'redis_cache.RedisCache',
'LOCATION': 'localhost:6379',
},
}
"""
settings/base.py
settings/settings.py
Base Settings.
Settings that are applied project wide.
"""
# Python stdlib Imports
import os
import sys
# DEV vs PROD
if os.environ['GO_ENV'] != 'production':
DEBUG = True
# dummy cache for development-- doesn't actually cache things
CACHES = {
'default': {
'BACKEND': 'django.core.cache.backends.dummy.DummyCache',
}
}
else:
DEBUG = False
CACHES = {
'default': {
'BACKEND': 'redis_cache.RedisCache',
'LOCATION': 'localhost:6379',
},
}
# STANDALONE VARS
BASE_DIR = os.path.dirname(os.path.dirname(__file__))
......@@ -109,6 +127,8 @@ INSTALLED_APPS = (
# Third party
'crispy_forms',
'cas',
'rest_framework',
'rest_framework.authtoken'
)
CRISPY_TEMPLATE_PACK = 'bootstrap4'
......@@ -166,6 +186,7 @@ CAS_RESPONSE_CALLBACKS = (
'go.cas_callbacks.create_user',
)
CAS_SERVER_URL = "https://login.gmu.edu"
"""
Mail Settings
......@@ -180,3 +201,16 @@ EMAIL_TO = os.environ['GO_EMAIL_TO']
# Domain used to email to users. See implementation in views.py
# ie. '@gmu.edu'
EMAIL_DOMAIN = os.environ['GO_EMAIL_DOMAIN']
"""
Django Rest Framework Settings
"""
REST_FRAMEWORK = {
'DEFAULT_PERMISSION_CLASSES': [
'rest_framework.permissions.IsAuthenticated'
],
'DEFAULT_AUTHENTICATION_CLASSES': [
'rest_framework.authentication.TokenAuthentication',
'rest_framework.authentication.SessionAuthentication',
],
}
This diff is collapsed.
......@@ -5,66 +5,74 @@ The URLs of the project and their associated view that requests are routed to.
"""
# Django Imports
import django.contrib.auth.views
from django.urls import path, re_path
from django.urls import path, re_path, include
from django.contrib import admin
from django.views.decorators.cache import cache_page
from django.views.generic import TemplateView
# App Imports
import go.views
from go import views
# Third Party
from rest_framework import routers
router = routers.DefaultRouter()
router.register('users', views.UserViewSet)
router.register('groups', views.GroupViewSet)
# This function attempts to import an admin module in each installed
# application. Such modules are expected to register models with the admin.
admin.autodiscover()
urlpatterns = [
# / - Homepage url. Cached for 1 second (this is the page you see after
# logging in, so having it show as not logged in is strange)
path('', cache_page(1)(go.views.index), name='index'),
# # / - Homepage url. Cached for 1 second (this is the page you see after
# # logging in, so having it show as not logged in is strange)
# path('', cache_page(1)(go.views.index), name='index'),
# /view/<short> - View URL data. Cached for 15 minutes
re_path(r'^view/(?P<short>([\U00010000-\U0010ffff][\U0000200D]?)+)$',
cache_page(60 * 15)(go.views.view), name='view'),
re_path(r'^view/(?P<short>[-\w]+)$',
cache_page(60 * 15)(go.views.view), name='view'),
# # /view/<short> - View URL data. Cached for 15 minutes
# re_path(r'^view/(?P<short>([\U00010000-\U0010ffff][\U0000200D]?)+)$',
# cache_page(60 * 15)(go.views.view), name='view'),
# re_path(r'^view/(?P<short>[-\w]+)$',
# cache_page(60 * 15)(go.views.view), name='view'),
# /about - About page. Cached for 15 minutes
path('about', cache_page(60 * 15)
(TemplateView.as_view(template_name='core/about.html')), name='about'),
# # /about - About page. Cached for 15 minutes
# path('about', cache_page(60 * 15)
# (TemplateView.as_view(template_name='core/about.html')), name='about'),
# /signup - Signup page for access. Cached for 15 minutes
path('signup', cache_page(60 * 15)(go.views.signup), name='signup'),
# # /signup - Signup page for access. Cached for 15 minutes
# path('signup', cache_page(60 * 15)(go.views.signup), name='signup'),
# /new - Create a new Go Link
path('new', go.views.new_link, name='new_link'),
# # /new - Create a new Go Link
# path('new', go.views.new_link, name='new_link'),
# /my - My-Links page, view and review links.
path('my', go.views.my_links, name='my_links'),
# # /my - My-Links page, view and review links.
# path('my', go.views.my_links, name='my_links'),
# /edit/<short> - Edit link form
path('edit/<slug:short>', go.views.edit, name='edit'),
# # /edit/<short> - Edit link form
# path('edit/<slug:short>', go.views.edit, name='edit'),
# /delete/<short> - Delete a link, no content display.
path('delete/<slug:short>', go.views.delete, name='delete'),
# # /delete/<short> - Delete a link, no content display.
# path('delete/<slug:short>', go.views.delete, name='delete'),
# /registered - registration complete page. Cached for 15 minutes
path('registered', cache_page(60 * 15)
(TemplateView.as_view(template_name='registered.html')), name='registered'),
# # /registered - registration complete page. Cached for 15 minutes
# path('registered', cache_page(60 * 15)
# (TemplateView.as_view(template_name='registered.html')), name='registered'),
# /admin - Administrator interface.
path('admin', admin.site.urls, name='go_admin'),
# # /admin - Administrator interface.