[damned-lies] Implement fix for bug 590122, xml output for teams page
- From: Olav Vitters <ovitters src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [damned-lies] Implement fix for bug 590122, xml output for teams page
- Date: Thu, 30 Jul 2009 13:28:25 +0000 (UTC)
commit 61620d63415b6ecf0d6a26c78df5ebfebd75f1c3
Author: Olav Vitters <olav bkor dhs org>
Date: Thu Jul 30 15:27:53 2009 +0200
Implement fix for bug 590122, xml output for teams page
teams/views.py | 20 ++++++++++++++------
1 files changed, 14 insertions(+), 6 deletions(-)
---
diff --git a/teams/views.py b/teams/views.py
index c1e23bb..acf3936 100644
--- a/teams/views.py
+++ b/teams/views.py
@@ -23,18 +23,26 @@ from django.utils.translation import ugettext_lazy as _
from django.shortcuts import render_to_response, get_object_or_404
from django.template import RequestContext
from common import utils
+from django.core import serializers
from teams.models import Team, FakeTeam, Role
from teams.forms import EditMemberRoleForm
from languages.models import Language
+MIME_TYPES = {'json': 'application/json',
+ 'xml': 'text/xml'
+ }
def teams(request):
teams = Team.objects.all_with_coordinator()
-
- context = {
- 'pageSection': 'teams',
- 'teams': utils.trans_sort_object_list(teams, 'description')
- }
- return render_to_response('teams/team_list.html', context, context_instance=RequestContext(request))
+ format = request.GET.get('format', 'html')
+ if format in ('json', 'xml'):
+ data = serializers.serialize(format, teams)
+ return HttpResponse(data, mimetype=MIME_TYPES[format])
+ else:
+ context = {
+ 'pageSection': 'teams',
+ 'teams': utils.trans_sort_object_list(teams, 'description')
+ }
+ return render_to_response('teams/team_list.html', context, context_instance=RequestContext(request))
def team(request, team_slug):
try:
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]