Commit c2acaebe authored by Claude Paroz's avatar Claude Paroz

Add some more xml/json interfaces

XML/JSON APIs are currently documented on:
http://live.gnome.org/DamnedLies
parent 64b86bd8
......@@ -34,8 +34,11 @@ from stats.forms import ModuleBranchForm
from stats import utils
from languages.models import Language
def modules(request):
def modules(request, format='html'):
all_modules = Module.objects.all()
if format in ('json', 'xml'):
data = serializers.serialize(format, all_modules)
return HttpResponse(data, mimetype=MIME_TYPES[format])
context = {
'pageSection': "module",
'modules': utils.sort_object_list(all_modules, 'get_description'),
......@@ -226,28 +229,26 @@ def releases(request, format='html'):
old_releases = Release.objects.filter(weight__lt=0).order_by('status', '-weight', '-name')
if format in ('json', 'xml'):
from itertools import chain
data = serializers.serialize(format, chain(active_releases, old_releases))
data = serializers.serialize(format, itertools.chain(active_releases, old_releases))
return HttpResponse(data, mimetype=MIME_TYPES[format])
else:
context = {
'pageSection' : "releases",
'active_releases': active_releases,
'old_releases' : old_releases,
'bug_url' : settings.ENTER_BUG_URL,
}
return render_to_response('release_list.html', context, context_instance=RequestContext(request))
context = {
'pageSection' : "releases",
'active_releases': active_releases,
'old_releases' : old_releases,
'bug_url' : settings.ENTER_BUG_URL,
}
return render_to_response('release_list.html', context, context_instance=RequestContext(request))
def release(request, release_name, format='html'):
release = get_object_or_404(Release, name=release_name)
if format == 'xml':
return render_to_response('release_detail.xml', { 'release' : release },
mimetype=MIME_TYPES[format])
else:
context = {
'pageSection': "releases",
'release': release
}
return render_to_response('release_detail.html', context, context_instance=RequestContext(request))
context = {
'pageSection': "releases",
'release': release
}
return render_to_response('release_detail.html', context, context_instance=RequestContext(request))
def compare_by_releases(request, dtype, rels_to_compare):
releases = []
......
......@@ -12,7 +12,7 @@ info_dict = {
urlpatterns = patterns('',
url(
regex = r'^$',
regex = r'^(?P<format>(xml))?/?$',
view = 'teams.views.teams',
name = 'teams'),
url(
......
......@@ -30,9 +30,9 @@ from teams.models import Team, FakeTeam, Role
from teams.forms import EditMemberRoleForm, EditTeamDetailsForm
from languages.models import Language
def teams(request):
def teams(request, format='html'):
teams = Team.objects.all_with_coordinator()
format = request.GET.get('format', 'html')
format = request.GET.get('format') or format
if format == 'xml':
return render_to_response(
'teams/team_list.xml',
......
......@@ -53,7 +53,7 @@ urlpatterns = patterns('',
urlpatterns += patterns('stats.views',
url(
regex = r'^module/$',
regex = r'^module/(?P<format>(html|json|xml))?/?$',
view = 'modules',
name = 'modules'),
url(
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment