This repository has been archived on 2019-11-11. You can view files and clone it, but you cannot make any changes to it's state, such as pushing and creating new issues, pull requests or comments.
tofu/issues/views.py

34 lines
835 B
Python
Raw Normal View History

2019-06-03 00:14:40 +02:00
from django.http import HttpResponseRedirect
from django.shortcuts import get_object_or_404, render
2019-06-03 00:14:40 +02:00
from .forms import IssueForm
from .models import Issue
2019-03-20 22:14:36 +01:00
def index(request):
issue_list = Issue.objects.order_by('create_date')
return render(request, 'issues/index.html', {
'issue_list': issue_list,
})
def detail(request, issue_id):
issue = get_object_or_404(Issue, pk=issue_id)
return render(request, 'issues/detail.html', {
'issue': issue,
})
2019-06-03 00:14:40 +02:00
def new(request):
if request.method == 'POST':
form = IssueForm(request.POST)
if form.is_valid():
new_issue = form.save()
return HttpResponseRedirect('/issues/{}'.format(new_issue.id))
else:
form = IssueForm()
return render(request, 'issues/new.html', {
'form': form,
})