From cb9c74eff8f7c3469cc5e84477074c138ed555df Mon Sep 17 00:00:00 2001 From: Dan McGee Date: Mon, 5 Jul 2010 22:20:28 -0500 Subject: Add absolute URL method for todo lists Signed-off-by: Dan McGee --- main/models.py | 3 +++ templates/devel/index.html | 2 +- templates/todolists/list.html | 2 +- todolists/views.py | 6 +++--- 4 files changed, 8 insertions(+), 5 deletions(-) diff --git a/main/models.py b/main/models.py index 208ea1a7..b6922680 100644 --- a/main/models.py +++ b/main/models.py @@ -367,6 +367,9 @@ class Todolist(models.Model): 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') diff --git a/templates/devel/index.html b/templates/devel/index.html index 25429ecf..d2dd155d 100644 --- a/templates/devel/index.html +++ b/templates/devel/index.html @@ -24,7 +24,7 @@ {% for todo in todos %} - {{ todo.name }} {{ todo.date_added }} {{ todo.description }} diff --git a/templates/todolists/list.html b/templates/todolists/list.html index e4b426bb..95eb3ee8 100644 --- a/templates/todolists/list.html +++ b/templates/todolists/list.html @@ -25,7 +25,7 @@ {% for list in lists %} - {{ list.name }} {{ list.date_added }} {{ list.creator.get_full_name }} diff --git a/todolists/views.py b/todolists/views.py index d60535b1..83dd87d6 100644 --- a/todolists/views.py +++ b/todolists/views.py @@ -3,7 +3,7 @@ from django import forms 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, -- cgit v1.2.3-55-g3dc8