From patchwork Thu Nov 15 03:06:13 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael-Doyle Hudson X-Patchwork-Id: 12848 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id 352DC23E28 for ; Thu, 15 Nov 2012 03:06:17 +0000 (UTC) Received: from mail-ie0-f180.google.com (mail-ie0-f180.google.com [209.85.223.180]) by fiordland.canonical.com (Postfix) with ESMTP id A918EA18020 for ; Thu, 15 Nov 2012 03:06:16 +0000 (UTC) Received: by mail-ie0-f180.google.com with SMTP id e10so1612155iej.11 for ; Wed, 14 Nov 2012 19:06:16 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-forwarded-to:x-forwarded-for:delivered-to:received-spf :content-type:mime-version:x-launchpad-project:x-launchpad-branch :x-launchpad-message-rationale:x-launchpad-branch-revision-number :x-launchpad-notification-type:to:from:subject:message-id:date :reply-to:sender:errors-to:precedence:x-generated-by :x-launchpad-hash:x-gm-message-state; bh=8WSkiJgH7GmDzqqSLPpxnfHS2tTipjJWcr9EI2lAnpQ=; b=jyYtz2pINp3l4eBDoxffXkBpUnrUmaXnNQSqSKjf8kRh35xML3OYvY8TSuKUre9Le+ waUJOXXFBHbhUcXUAPwP8sQQh6vGdpXWOC5BJPHsX2nDTDWQ1qc2Wfg1gSuZjgVHg4pr R4PqpWndD8OQajpo1fjUQElFKeEqFABzlVxiSRkteLBMoZgzzKL2N8Vpjd5z4k9X/B/d DIMnWsjzd5M9DQTSJrBdvUL6WIVOuN+YyLskTQlfAaJkbXpxtfviG6FiaYhR/V7IITR7 vq8F5rAg9NY9at5b+YErttOr+Hy9xo3cZ42nuMzkQvWVNeC8KoEs8OxBsPnUGcp0GEif kMZQ== Received: by 10.50.152.137 with SMTP id uy9mr1128793igb.62.1352948776139; Wed, 14 Nov 2012 19:06:16 -0800 (PST) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.50.67.148 with SMTP id n20csp762925igt; Wed, 14 Nov 2012 19:06:15 -0800 (PST) Received: by 10.180.92.103 with SMTP id cl7mr28767785wib.16.1352948774857; Wed, 14 Nov 2012 19:06:14 -0800 (PST) Received: from indium.canonical.com (indium.canonical.com. [91.189.90.7]) by mx.google.com with ESMTPS id d43si7669720weq.28.2012.11.14.19.06.14 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 14 Nov 2012 19:06:14 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of bounces@canonical.com designates 91.189.90.7 as permitted sender) client-ip=91.189.90.7; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of bounces@canonical.com designates 91.189.90.7 as permitted sender) smtp.mail=bounces@canonical.com Received: from ackee.canonical.com ([91.189.89.26]) by indium.canonical.com with esmtp (Exim 4.71 #1 (Debian)) id 1TYpmQ-0003p4-1V for ; Thu, 15 Nov 2012 03:06:14 +0000 Received: from ackee.canonical.com (localhost [127.0.0.1]) by ackee.canonical.com (Postfix) with ESMTP id EC51BE041B for ; Thu, 15 Nov 2012 03:06:13 +0000 (UTC) MIME-Version: 1.0 X-Launchpad-Project: lava-dashboard X-Launchpad-Branch: ~linaro-validation/lava-dashboard/trunk X-Launchpad-Message-Rationale: Subscriber X-Launchpad-Branch-Revision-Number: 358 X-Launchpad-Notification-Type: branch-revision To: Linaro Patch Tracker From: noreply@launchpad.net Subject: [Branch ~linaro-validation/lava-dashboard/trunk] Rev 358: a simple ui for viewing test result attachments Message-Id: <20121115030613.4682.5869.launchpad@ackee.canonical.com> Date: Thu, 15 Nov 2012 03:06:13 -0000 Reply-To: noreply@launchpad.net Sender: bounces@canonical.com Errors-To: bounces@canonical.com Precedence: bulk X-Generated-By: Launchpad (canonical.com); Revision="16265"; Instance="launchpad-lazr.conf" X-Launchpad-Hash: 182be1d36f5c26f79dbe2364c92b7ae5cd82011e X-Gm-Message-State: ALoCoQlA8A2zArmPTuK8OxJPkR1JvseOVR43Schy0VkXDThRCBAexyjVdpdsCMXhrYp8FdrCFYpU Merge authors: Michael Hudson-Doyle (mwhudson) Related merge proposals: https://code.launchpad.net/~mwhudson/lava-dashboard/result-attachment-ui/+merge/133596 proposed by: Michael Hudson-Doyle (mwhudson) review: Approve - Zygmunt Krynicki (zkrynicki) ------------------------------------------------------------ revno: 358 [merge] committer: Michael Hudson-Doyle branch nick: trunk timestamp: Thu 2012-11-15 16:05:05 +1300 message: a simple ui for viewing test result attachments modified: dashboard_app/models.py dashboard_app/templates/dashboard_app/test_result_detail.html dashboard_app/urls.py dashboard_app/views/__init__.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 === modified file 'dashboard_app/models.py' --- dashboard_app/models.py 2012-11-07 02:49:00 +0000 +++ dashboard_app/models.py 2012-11-08 23:10:05 +0000 @@ -57,10 +57,10 @@ from dashboard_app.helpers import BundleDeserializer from dashboard_app.managers import BundleManager, TestRunDenormalizationManager -from dashboard_app.repositories import RepositoryItem +from dashboard_app.repositories import RepositoryItem from dashboard_app.repositories.data_report import DataReportRepository from dashboard_app.repositories.data_view import DataViewRepository -from dashboard_app.signals import bundle_was_deserialized +from dashboard_app.signals import bundle_was_deserialized # Fix some django issues we ran into @@ -737,7 +737,7 @@ help_text = _(u"Date and time of the commit (optional)"), verbose_name = _(u"Commit Timestamp") ) - + def __unicode__(self): return _(u"{project_name} from branch {branch_url} at revision {branch_revision}").format( project_name=self.project_name, branch_url=self.branch_url, branch_revision=self.branch_revision) @@ -1009,7 +1009,7 @@ mime_type = models.CharField( verbose_name = _(u"MIME type"), max_length = 64) - + public_url = models.URLField( verbose_name = _(u"Public URL"), max_length = 512, @@ -1053,11 +1053,30 @@ self.content_type.model == 'testrun'): return True + def is_test_result_attachment(self): + if (self.content_type.app_label == 'dashboard_app' and + self.content_type.model == 'testresult'): + return True + @property def test_run(self): if self.is_test_run_attachment(): return self.content_object + @property + def test_result(self): + if self.is_test_result_attachment(): + return self.content_object + + @property + def bundle(self): + if self.is_test_result_attachment(): + run = self.test_result.test_run + elif self.is_test_run_attachment(): + run = self.test_run + return run.bundle + + @models.permalink def get_absolute_url(self): if self.is_test_run_attachment(): @@ -1066,6 +1085,13 @@ self.test_run.bundle.content_sha1, self.test_run.analyzer_assigned_uuid, self.pk]) + elif self.is_test_result_attachment(): + return ("dashboard_app.views.result_attachment_detail", + [self.test_result.test_run.bundle.bundle_stream.pathname, + self.test_result.test_run.bundle.content_sha1, + self.test_result.test_run.analyzer_assigned_uuid, + self.test_result.relative_index, + self.pk]) class TestResult(models.Model): @@ -1768,7 +1794,7 @@ # given filter: # select from testrun - # where testrun.bundle in filter.bundle_streams ^ accessible_bundles + # where testrun.bundle in filter.bundle_streams ^ accessible_bundles # and testrun has attribute with key = key1 and value = value1 # and testrun has attribute with key = key2 and value = value2 # and ... === modified file 'dashboard_app/templates/dashboard_app/test_result_detail.html' --- dashboard_app/templates/dashboard_app/test_result_detail.html 2012-05-28 08:01:53 +0000 +++ dashboard_app/templates/dashboard_app/test_result_detail.html 2012-11-08 22:56:59 +0000 @@ -153,5 +153,17 @@ {% endif %} {% endwith %} +
+ Test result attachments +
+
+
    + {% for attachment in test_result.attachments.all %} +
  • + {{ attachment }} +
  • + {% endfor %} +
+
{% endblock %} === modified file 'dashboard_app/urls.py' --- dashboard_app/urls.py 2012-10-01 08:08:51 +0000 +++ dashboard_app/urls.py 2012-11-08 23:10:05 +0000 @@ -67,6 +67,8 @@ url(r'^streams(?P/[a-zA-Z0-9/._-]+)bundles/(?P[0-9a-z]+)/(?P[a-zA-Z0-9-]+)/attachments$', 'attachment_list'), url(r'^streams(?P/[a-zA-Z0-9/._-]+)bundles/(?P[0-9a-z]+)/(?P[a-zA-Z0-9-]+)/attachments/(?P[0-9]+)/$', 'attachment_detail'), url(r'^streams(?P/[a-zA-Z0-9/._-]+)bundles/(?P[0-9a-z]+)/(?P[a-zA-Z0-9-]+)/result/(?P[0-9]+)/$', 'test_result_detail'), + url(r'^streams(?P/[a-zA-Z0-9/._-]+)bundles/(?P[0-9a-z]+)/(?P[a-zA-Z0-9-]+)/result/(?P[0-9]+)/attachments$', 'result_attachment_list'), + url(r'^streams(?P/[a-zA-Z0-9/._-]+)bundles/(?P[0-9a-z]+)/(?P[a-zA-Z0-9-]+)/result/(?P[0-9]+)/attachment/(?P[0-9]+)$', 'result_attachment_detail'), url(r'^streams(?P/[a-zA-Z0-9/._-]+)bundles/(?P[0-9a-z]+)/(?P[a-zA-Z0-9-]+)/hardware-context/$', 'test_run_hardware_context'), url(r'^streams(?P/[a-zA-Z0-9/._-]+)bundles/(?P[0-9a-z]+)/(?P[a-zA-Z0-9-]+)/software-context/$', 'test_run_software_context'), url(r'^streams(?P/[a-zA-Z0-9/._-]+)test-runs/$', 'test_run_list'), === modified file 'dashboard_app/views/__init__.py' --- dashboard_app/views/__init__.py 2012-10-01 08:08:51 +0000 +++ dashboard_app/views/__init__.py 2012-11-08 23:10:05 +0000 @@ -562,6 +562,31 @@ analyzer_assigned_uuid=analyzer_assigned_uuid), 'test_run': test_run}) +@BreadCrumb( + "Attachments", + parent=test_result_detail, + needs=['pathname', 'content_sha1', 'analyzer_assigned_uuid', 'relative_index']) +def result_attachment_list(request, pathname, content_sha1, analyzer_assigned_uuid, relative_index): + test_result = get_restricted_object_or_404( + TestResult, + lambda test_result: test_result.test_run.bundle.bundle_stream, + request.user, + test_run__analyzer_assigned_uuid=analyzer_assigned_uuid, + relative_index=relative_index, + ) + return object_list( + request, + queryset=test_result.attachments.all(), + template_name="dashboard_app/attachment_list.html", + template_object_name="attachment", + extra_context={ + 'bread_crumb_trail': BreadCrumbTrail.leading_to( + result_attachment_list, + pathname=pathname, + content_sha1=content_sha1, + analyzer_assigned_uuid=analyzer_assigned_uuid, + relative_index=relative_index) + }) @BreadCrumb( "{content_filename}", @@ -570,7 +595,7 @@ def attachment_detail(request, pathname, content_sha1, analyzer_assigned_uuid, pk): attachment = get_restricted_object_or_404( Attachment, - lambda attachment: attachment.test_run.bundle.bundle_stream, + lambda attachment: attachment.bundle.bundle_stream, request.user, pk = pk ) @@ -587,10 +612,35 @@ }, RequestContext(request)) +@BreadCrumb( + "{content_filename}", + parent=result_attachment_list, + needs=['pathname', 'content_sha1', 'analyzer_assigned_uuid', 'relative_index', 'pk']) +def result_attachment_detail(request, pathname, content_sha1, analyzer_assigned_uuid, relative_index, pk): + attachment = get_restricted_object_or_404( + Attachment, + lambda attachment: attachment.bundle.bundle_stream, + request.user, + pk = pk + ) + return render_to_response( + "dashboard_app/attachment_detail.html", { + 'bread_crumb_trail': BreadCrumbTrail.leading_to( + result_attachment_detail, + pathname=pathname, + content_sha1=content_sha1, + analyzer_assigned_uuid=analyzer_assigned_uuid, + relative_index=relative_index, + pk=pk, + content_filename=attachment.content_filename), + "attachment": attachment, + }, RequestContext(request)) + + def ajax_attachment_viewer(request, pk): attachment = get_restricted_object_or_404( Attachment, - lambda attachment: attachment.test_run.bundle.bundle_stream, + lambda attachment: attachment.bundle.bundle_stream, request.user, pk=pk )