1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
# Create your views here
from django.contrib.auth.decorators import login_required
from django.contrib.auth import logout
from django.shortcuts import render_to_response
from django.http import HttpResponseRedirect
from ircTrack.bt.models import UserProfile,Event,Issue,IssueForm
@login_required(redirect_field_name='/openid/login/')
def ban_index(request):
return render_to_response('bt/events.html', {
'profile' : request.user.get_profile(),
'user' : request.user,
'openid' : request,
'events' : Event.objects.all()[:50],
})
@login_required(redirect_field_name='/openid/login/')
def issue_index(request):
return render_to_response('bt/issues.html', {
'profile' : request.user.get_profile(),
'user' : request.user,
'openid' : request,
'issues' : Issue.objects.all()[:50],
})
@login_required(redirect_field_name='/openid/login/')
def settings(request):
return render_to_response('bt/settings.html', {
'profile' : request.user.get_profile(),
'user' : request.user,
'openid' : request,
})
def logout_view(request):
logout(request)
return HttpResponseRedirect('/')
def issue_new(request):
if request.method == 'POST':
form = IssueForm(request.POST)
if form.is_valid():
issue = form.save(commit=False)
issue.author = request.user
issue.save()
return HttpResponseRedirect('/issue/')
else:
form = IssueForm()
return render_to_response('bt/newissue.html', {
'form' : form
})
|