views.py 891 Bytes
Newer Older
Jean Michel Rouly's avatar
Jean Michel Rouly committed
1 2
from go.models import URL
from django.contrib.auth.models import User
3
from django.contrib.auth.decorators import login_required
Jean Michel Rouly's avatar
Jean Michel Rouly committed
4
from django.shortcuts import render, get_object_or_404, redirect
5

Jean Michel Rouly's avatar
Jean Michel Rouly committed
6
# Homepage view.
7
@login_required
Jean Michel Rouly's avatar
Jean Michel Rouly committed
8 9 10 11 12 13
def index(request):
    return render(request, 'index.html', {

    },
    )

14 15 16 17 18 19 20 21 22 23 24
# My-Links page.
@login_required
def my_links(request):
    links = URL.objects.filter( owner = request.user )

    return render(request, 'my_links.html', {
        'links' : links,
    },
    )

# Delete link page.
25
@login_required
26
def delete(request, short):
27 28 29 30
    url = URL.objects.get( short = short )
    if url.owner == request.user:
        url.delete()
    return redirect('my_links')
31

Jean Michel Rouly's avatar
Jean Michel Rouly committed
32 33 34 35 36 37
# About page, static.
def about(request):
    return render(request, 'about.html', {

    },
    )
Jean Michel Rouly's avatar
Jean Michel Rouly committed
38 39 40 41 42 43 44

# Signup page.
def signup(request):
    return render(request, 'signup.html', {

    },
    )