Add absolute URL method for todo lists
Signed-off-by: Dan McGee <dan@archlinux.org>
This commit is contained in:
parent
41a5d1d566
commit
cb9c74eff8
@ -367,6 +367,9 @@ def package_names(self):
|
||||
class Meta:
|
||||
db_table = 'todolists'
|
||||
|
||||
def get_absolute_url(self):
|
||||
return '/todo/%i/' % self.id
|
||||
|
||||
class TodolistPkg(models.Model):
|
||||
id = models.AutoField(primary_key=True)
|
||||
list = models.ForeignKey('Todolist')
|
||||
|
@ -24,7 +24,7 @@ <h3>Package Todo Lists</h3>
|
||||
<tbody>
|
||||
{% for todo in todos %}
|
||||
<tr class="{% cycle 'odd' 'even' %}">
|
||||
<td class="key"><a href="/todo/{{ todo.id }}/"
|
||||
<td class="key"><a href="{{ todo.get_absolute_url }}/"
|
||||
title="View todo list: {{ todo.name }}">{{ todo.name }}</a></td>
|
||||
<td>{{ todo.date_added }}</td>
|
||||
<td>{{ todo.description }}</td>
|
||||
|
@ -25,7 +25,7 @@ <h2>Package Todo Lists</h2>
|
||||
<tbody>
|
||||
{% for list in lists %}
|
||||
<tr class="{% cycle 'odd' 'even' %}">
|
||||
<td><a href="/todo/{{ list.id }}/"
|
||||
<td><a href="{{ list.get_absolute_url }}/"
|
||||
title="View todo list: {{ list.name }}">{{ list.name }}</a></td>
|
||||
<td>{{ list.date_added }}</td>
|
||||
<td>{{ list.creator.get_full_name }}</td>
|
||||
|
@ -3,7 +3,7 @@
|
||||
from django.http import HttpResponse, HttpResponseRedirect
|
||||
from django.template import RequestContext
|
||||
from django.core.mail import send_mail
|
||||
from django.shortcuts import get_object_or_404, render_to_response
|
||||
from django.shortcuts import get_object_or_404, render_to_response, redirect
|
||||
from django.contrib.auth.decorators import login_required, permission_required
|
||||
from django.views.decorators.cache import never_cache
|
||||
from django.views.generic.create_update import delete_object
|
||||
@ -42,7 +42,7 @@ def flag(request, listid, pkgid):
|
||||
return HttpResponse(
|
||||
simplejson.dumps({'complete': pkg.complete}),
|
||||
mimetype='application/json')
|
||||
return HttpResponseRedirect('/todo/%s/' % (listid))
|
||||
return redirect(list)
|
||||
|
||||
@login_required
|
||||
@never_cache
|
||||
@ -113,7 +113,7 @@ def edit(request, list_id):
|
||||
list = todo_list, pkg = pkg)
|
||||
send_todolist_email(tpkg)
|
||||
|
||||
return HttpResponseRedirect('/todo/%d/' % todo_list.id)
|
||||
return redirect(todo_list)
|
||||
else:
|
||||
form = TodoListForm(initial={
|
||||
'name': todo_list.name,
|
||||
|
Loading…
Reference in New Issue
Block a user