damned-lies r1421 - in trunk: . stats templates



Author: stephaner
Date: Mon Feb  2 22:26:45 2009
New Revision: 1421
URL: http://svn.gnome.org/viewvc/damned-lies?rev=1421&view=rev

Log:
2009-02-02  StÃphane Raimbault  <stephane raimbault gmail com>

	Add a new XML export for each release detail.
	
	* stats/views.py: New render_to_response.
	* templates/release_detail.xml: Added template.
	* urls.py: Optionally accept 'xml' as argument.


Added:
   trunk/templates/release_detail.xml
Modified:
   trunk/ChangeLog
   trunk/stats/views.py
   trunk/urls.py

Modified: trunk/stats/views.py
==============================================================================
--- trunk/stats/views.py	(original)
+++ trunk/stats/views.py	Mon Feb  2 22:26:45 2009
@@ -139,11 +139,14 @@
         }
         return render_to_response('release_list.html', context, context_instance=RequestContext(request))
 
-def release(request, release_name):
-    rel = get_object_or_404(Release, name=release_name)
-    context = {
-        'pageSection': "releases",
-        'release': rel
-    }
-    return render_to_response('release_detail.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))
 

Added: trunk/templates/release_detail.xml
==============================================================================
--- (empty file)
+++ trunk/templates/release_detail.xml	Mon Feb  2 22:26:45 2009
@@ -0,0 +1,13 @@
+<release id="{{ release.name }}">
+  {% for stat in release.get_global_stats %}
+  <language id="{{ stat.lang_locale }}">
+    <name>{{ stat.lang_name }}</name>
+    <ui_translated>{{ stat.ui_trans }}</ui_translated>
+    <ui_fuzzy>{{ stat.ui_fuzzy }}</ui_fuzzy>
+    <ui_untranslated>{{ stat.ui_untrans }}</ui_untranslated>
+    <doc_translated>{{ stat.doc_trans }}</doc_translated>
+    <doc_fuzzy>{{ stat.doc_fuzzy }}</doc_fuzzy>
+    <doc_untranslated>{{ stat.doc_untrans }}</doc_untranslated>
+  </language>
+  {% endfor %}
+</release>

Modified: trunk/urls.py
==============================================================================
--- trunk/urls.py	(original)
+++ trunk/urls.py	Mon Feb  2 22:26:45 2009
@@ -26,7 +26,7 @@
     (r'^module/(?P<module_name>[\w\-\+]+)/edit/branches/$', 'module_edit_branches'),
     (r'^module/(?P<module_name>[\w\-\+]+)/(?P<potbase>[\w-]+)/(?P<branch_name>[\w-]+)/(?P<langcode>[\w ]+)/images/$', 'docimages'),
     url(r'^releases/(?P<format>(html|json|xml))?/?$', 'releases', name='releases'),
-    (r'^releases/(?P<release_name>[\w-]+)$', 'release'),
+    (r'^releases/(?P<release_name>[\w-]+)/(?P<format>(html|xml))?/?$', 'release'),
 )
 
 if 'django_openid' in settings.INSTALLED_APPS:



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]