diff mbox

[Branch,~linaro-validation/lava-dashboard/trunk] Rev 314: merge with the Bug #877984 fix branch

Message ID 20120507120016.20069.98560.launchpad@ackee.canonical.com
State Accepted
Headers show

Commit Message

Yongqin Liu May 7, 2012, noon UTC
Merge authors:
  Yongqin Liu (liuyq0307)
Related merge proposals:
  https://code.launchpad.net/~liuyq0307/lava-dashboard/viem-png2/+merge/104566
  proposed by: Yongqin Liu (liuyq0307)
  review: Approve - Yongqin Liu (liuyq0307)
------------------------------------------------------------
revno: 314 [merge]
committer: Yongqin Liu <yongqin.liu@linaro.org>
branch nick: lava-dashboard
timestamp: Mon 2012-05-07 19:58:23 +0800
message:
  merge with the Bug #877984 fix branch
modified:
  dashboard_app/templates/dashboard_app/attachment_detail.html
  dashboard_app/views.py


--
lp:lava-dashboard
https://code.launchpad.net/~linaro-validation/lava-dashboard/trunk

You are subscribed to branch lp:lava-dashboard.
To unsubscribe from this branch go to https://code.launchpad.net/~linaro-validation/lava-dashboard/trunk/+edit-subscription
diff mbox

Patch

=== modified file 'dashboard_app/templates/dashboard_app/attachment_detail.html'
--- dashboard_app/templates/dashboard_app/attachment_detail.html	2011-07-12 02:34:12 +0000
+++ dashboard_app/templates/dashboard_app/attachment_detail.html	2012-05-07 11:51:01 +0000
@@ -7,7 +7,7 @@ 
 <div id="tabs">
   <ul>
     <li><a href="#tab-attachment-information">{% trans "Attachment Information" %}</a></li>
-    <li><a href="{% url dashboard_app.views.ajax_attachment_viewer attachment.pk %}">{% trans "Inline Viewer" %}</a></li>
+    <li><a id='inline_viewer_link' href="{% url dashboard_app.views.ajax_attachment_viewer attachment.pk %}">{% trans "Inline Viewer" %}</a></li>
   </ul>
   <div id="tab-attachment-information">
     <dl>
@@ -41,6 +41,11 @@ 
         }
       }
     });
+    {% ifnotequal attachment.mime_type  "text/plain" %}
+      $('#inline_viewer_link').attr('href', "{% url dashboard_app.views.ajax_attachment_viewer attachment.pk %}");
+      $('#inline_viewer_link').unbind( ".tabs" );
+    {% endifnotequal %}
+
   });
 </script>
 {% endblock %}

=== modified file 'dashboard_app/views.py'
--- dashboard_app/views.py	2012-04-20 22:55:12 +0000
+++ dashboard_app/views.py	2012-05-03 14:39:17 +0000
@@ -1,4 +1,4 @@ 
-# Copyright (C) 2010 Linaro Limited
+# Copyright (C) 2010-2012 Linaro Limited
 #
 # Author: Zygmunt Krynicki <zygmunt.krynicki@linaro.org>
 #
@@ -591,16 +591,21 @@ 
         request.user,
         pk=pk
     )
+    data = attachment.get_content_if_possible(
+        mirror=request.user.is_authenticated())
     if attachment.mime_type == "text/plain":
-        data = attachment.get_content_if_possible(mirror=request.user.is_authenticated())
+        return render_to_response(
+            "dashboard_app/_ajax_attachment_viewer.html", {
+                "attachment": attachment,
+                "lines": data.splitlines() if data else None,
+            },
+            RequestContext(request))
     else:
-        data = None
-    return render_to_response(
-        "dashboard_app/_ajax_attachment_viewer.html", {
-            "attachment": attachment,
-            "lines": data.splitlines() if data else None,
-        },
-        RequestContext(request))
+        response = HttpResponse(mimetype=attachment.mime_type)
+        response['Content-Disposition'] = 'attachment; filename=%s' % (
+                                           attachment.content_filename)
+        response.write(data)
+        return response
 
 
 @BreadCrumb("Reports", parent=index)
@@ -808,7 +813,7 @@ 
     except TestingEffort.DoesNotExist:
         raise Http404()
     if not effort.project.is_owned_by(request.user):
-        return HttpReseponse("not allowed")
+        return HttpResponse("not allowed")
     if request.method == 'POST':
         form = TestingEffortForm(request.POST)
         # Check the form