Created
April 23, 2010 07:16
-
-
Save sweemeng/376304 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.shortcuts import render_to_response | |
from forms import IssueForm | |
from django.http import HttpResponseRedirect | |
from models import * | |
# Create your views here. | |
def add_issue(request): | |
if request.method == 'GET': | |
form = IssueForm() | |
return render_to_response('issue/add.html',{'form':form}) | |
else: | |
issue = Issue() | |
issue.votes = 0 | |
issue.closed = False | |
form = IssueForm(request.POST,instance=issue) | |
if form.is_valid(): | |
newissue = form.save() | |
else: | |
return render_to_response('issue/add.html',{'form':form}) | |
return HttpResponseRedirect('/issue/view/?id='+str(newissue.id)) | |
def view_issue(request): | |
id = request.GET.get('id') | |
issue = Issue.objects.get(id=id) | |
return render_to_response('issue/view.html',{'issue':issue}) | |
def list_issue(request): | |
issue = Issue.objects.all() | |
return render_to_response('issue/list.html',{'issue':issue}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment