~bnrubin/bantrackertwo/devel

« back to all changes in this revision

Viewing changes to bt/views.py

  • Committer: Benjamin Rubin
  • Date: 2009-09-02 02:14:31 UTC
  • Revision ID: bnrubin@romulus-20090902021431-02x226yec1d5sxal
- Cleaned up Event code and presentation
- Added basic Issue and Settings forms and presentation

Show diffs side-by-side

added added

removed removed

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