From patchwork Tue Jan 15 20:54:12 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Doan X-Patchwork-Id: 14077 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 10E5F4C15B4 for ; Tue, 15 Jan 2013 20:54:16 +0000 (UTC) Received: from mail-vb0-f43.google.com (mail-vb0-f43.google.com [209.85.212.43]) by fiordland.canonical.com (Postfix) with ESMTP id 59E7AA18606 for ; Tue, 15 Jan 2013 20:54:15 +0000 (UTC) Received: by mail-vb0-f43.google.com with SMTP id fs19so607620vbb.2 for ; Tue, 15 Jan 2013 12:54:14 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:x-forwarded-to:x-forwarded-for:delivered-to:x-received :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=HDxpm4foEGHjIefbM3d22ESuqb0ASJMx5rxQUt+lki0=; b=ndwWQ+HZ0DNgZmo7q4ZEhsVyF4Z4NUOHnga/+VxVRGcd64ASVQ46bLLtzQ7lBLEUId +fal9IN738H9BKv15yrT2lZPHDAK7yw0XqzyyKyZEJ3nEwuWhPc4xqie4xBTTZFlH0ME zc3u2jNjcjX8W2DAkzNQMRY+tqDxz7v4kawGwhIyYZ6eDecLtoWyUhLxujXeonEWhTDl pRyy1KdXc8Ba5ygIEttoYQAc2K70mCEkIY+Mj2WuxL0elPq0Vsef6guzrWGcjwi56lWK gVXONTITr2bYHpHS1yQJYpLeJLO623d8wLgXDPlrV/d9HMHk9boeXIcibs1HW/oDcMe2 vfXA== X-Received: by 10.220.238.139 with SMTP id ks11mr104697454vcb.49.1358283254500; Tue, 15 Jan 2013 12:54:14 -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.58.145.101 with SMTP id st5csp133310veb; Tue, 15 Jan 2013 12:54:13 -0800 (PST) X-Received: by 10.194.172.228 with SMTP id bf4mr52566451wjc.38.1358283252821; Tue, 15 Jan 2013 12:54:12 -0800 (PST) Received: from indium.canonical.com (indium.canonical.com. [91.189.90.7]) by mx.google.com with ESMTPS id e16si5856288wiw.28.2013.01.15.12.54.12 (version=TLSv1 cipher=RC4-SHA bits=128/128); Tue, 15 Jan 2013 12:54:12 -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 1TvDWO-0006MF-4q for ; Tue, 15 Jan 2013 20:54:12 +0000 Received: from ackee.canonical.com (localhost [127.0.0.1]) by ackee.canonical.com (Postfix) with ESMTP id 16631E034E for ; Tue, 15 Jan 2013 20:54:12 +0000 (UTC) MIME-Version: 1.0 X-Launchpad-Project: lava-scheduler X-Launchpad-Branch: ~linaro-validation/lava-scheduler/trunk X-Launchpad-Message-Rationale: Subscriber X-Launchpad-Branch-Revision-Number: 236 X-Launchpad-Notification-Type: branch-revision To: Linaro Patch Tracker From: noreply@launchpad.net Subject: [Branch ~linaro-validation/lava-scheduler/trunk] Rev 236: add a re-submit button to jobs in UI Message-Id: <20130115205412.9956.19497.launchpad@ackee.canonical.com> Date: Tue, 15 Jan 2013 20:54:12 -0000 Reply-To: noreply@launchpad.net Sender: bounces@canonical.com Errors-To: bounces@canonical.com Precedence: bulk X-Generated-By: Launchpad (canonical.com); Revision="16420"; Instance="launchpad-lazr.conf" X-Launchpad-Hash: 389a3cc16baf1a4ffc8c6ce02ef26bf102d8146c X-Gm-Message-State: ALoCoQmZWy6Q7amW8XUhPviU0xmELjAelFOFwCaIUIgX3VjYJoqzgfNCsns/vf4bAKNlF9c5+NoO Merge authors: Andy Doan (doanac) Related merge proposals: https://code.launchpad.net/~doanac/lava-scheduler/resubmit-button/+merge/143372 proposed by: Andy Doan (doanac) ------------------------------------------------------------ revno: 236 [merge] committer: Andy Doan branch nick: lava-scheduler timestamp: Tue 2013-01-15 14:53:29 -0600 message: add a re-submit button to jobs in UI modified: lava_scheduler_app/models.py lava_scheduler_app/templates/lava_scheduler_app/job_sidebar.html lava_scheduler_app/urls.py lava_scheduler_app/views.py --- lp:lava-scheduler https://code.launchpad.net/~linaro-validation/lava-scheduler/trunk You are subscribed to branch lp:lava-scheduler. To unsubscribe from this branch go to https://code.launchpad.net/~linaro-validation/lava-scheduler/trunk/+edit-subscription === modified file 'lava_scheduler_app/models.py' --- lava_scheduler_app/models.py 2013-01-14 21:01:59 +0000 +++ lava_scheduler_app/models.py 2013-01-15 20:53:29 +0000 @@ -463,10 +463,15 @@ """ Permission required for user to add failure information to a job """ - return self._can_admin(user) + states = [TestJob.COMPLETE, TestJob.INCOMPLETE, TestJob.CANCELED] + return self._can_admin(user) and self.status in states def can_cancel(self, user): - return self._can_admin(user) + return self._can_admin(user) and self.status <= TestJob.RUNNING + + def can_resubmit(self, user): + states = [TestJob.COMPLETE, TestJob.INCOMPLETE, TestJob.CANCELED] + return self._can_admin(user) and self.status in states def cancel(self): if self.status == TestJob.RUNNING: === modified file 'lava_scheduler_app/templates/lava_scheduler_app/job_sidebar.html' --- lava_scheduler_app/templates/lava_scheduler_app/job_sidebar.html 2013-01-02 19:27:56 +0000 +++ lava_scheduler_app/templates/lava_scheduler_app/job_sidebar.html 2013-01-15 17:44:36 +0000 @@ -84,18 +84,26 @@ {% if show_cancel or show_failure %} -

Actions

+

Job Actions

{% if show_cancel %}
{% csrf_token %} - + +
+{% endif %} +{% if show_resubmit %} +
+ {% csrf_token %} +
{% endif %} {% if show_failure %} - +
+ +
{% endif %} {% endif %} === modified file 'lava_scheduler_app/urls.py' --- lava_scheduler_app/urls.py 2013-01-02 22:07:30 +0000 +++ lava_scheduler_app/urls.py 2013-01-15 17:44:36 +0000 @@ -87,6 +87,9 @@ url(r'^job/(?P[0-9]+)/cancel$', 'job_cancel', name='lava.scheduler.job.cancel'), + url(r'^job/(?P[0-9]+)/resubmit$', + 'job_resubmit', + name='lava.scheduler.job.resubmit'), url(r'^job/(?P[0-9]+)/annotate_failure$', 'job_annotate_failure', name='lava.scheduler.job.annotate_failure'), === modified file 'lava_scheduler_app/views.py' --- lava_scheduler_app/views.py 2013-01-03 16:15:48 +0000 +++ lava_scheduler_app/views.py 2013-01-15 17:44:36 +0000 @@ -560,8 +560,9 @@ data = { 'job': job, - 'show_cancel': job.status <= TestJob.RUNNING and job.can_cancel(request.user), - 'show_failure': job.status > TestJob.COMPLETE and job.can_annotate(request.user), + 'show_cancel': job.can_cancel(request.user), + 'show_failure': job.can_annotate(request.user), + 'show_resubmit': job.can_resubmit(request.user), 'bread_crumb_trail': BreadCrumbTrail.leading_to(job_detail, pk=pk), 'show_reload_page': job.status <= TestJob.RUNNING, } @@ -728,6 +729,18 @@ "you cannot cancel this job", content_type="text/plain") +@post_only +def job_resubmit(request, pk): + job = get_restricted_job(request.user, pk) + if job.can_resubmit(request.user): + definition = job.definition + job = TestJob.from_json_and_user(definition, request.user) + return redirect(job) + else: + return HttpResponseForbidden( + "you cannot re-submit this job", content_type="text/plain") + + class FailureForm(forms.ModelForm): class Meta: model = TestJob