views.py 1012 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
# My-Links page.
@login_required
16
def my_links(request, permission = True):
17
18
19
20
    links = URL.objects.filter( owner = request.user )

    return render(request, 'my_links.html', {
        'links' : links,
21
        'permission' : permission,
22
23
24
25
    },
    )

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

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

    },
    )
Jean Michel Rouly's avatar
Jean Michel Rouly committed
41
42
43
44
45
46
47

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

    },
    )