=== 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 %}
+{% endif %}
+{% if show_resubmit %}
+
{% 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