=== modified file 'lava_scheduler_app/models.py'
@@ -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'
@@ -84,18 +84,26 @@
</ul>
{% if show_cancel or show_failure %}
-<h2>Actions</h2>
+<h2>Job Actions</h2>
{% if show_cancel %}
<form method="POST"
action="{% url lava.scheduler.job.cancel job.pk %}">
{% csrf_token %}
- <button id="cancel-button">Cancel Job</button>
+ <button id="cancel-button">Cancel</button>
+</form>
+{% endif %}
+{% if show_resubmit %}
+<form method="POST"
+ action="{% url lava.scheduler.job.resubmit job.pk %}">
+ {% csrf_token %}
+ <button>Re-submit</button>
</form>
{% endif %}
{% if show_failure %}
-<ul>
- <li><a href="{% url lava.scheduler.job.annotate_failure job.pk %}">Annotate Failure</a></li>
-</ul>
+<form method="GET"
+ action="{% url lava.scheduler.job.annotate_failure job.pk %}">
+ <button>Annotate</button>
+</form>
{% endif %}
{% endif %}
=== modified file 'lava_scheduler_app/urls.py'
@@ -87,6 +87,9 @@
url(r'^job/(?P<pk>[0-9]+)/cancel$',
'job_cancel',
name='lava.scheduler.job.cancel'),
+ url(r'^job/(?P<pk>[0-9]+)/resubmit$',
+ 'job_resubmit',
+ name='lava.scheduler.job.resubmit'),
url(r'^job/(?P<pk>[0-9]+)/annotate_failure$',
'job_annotate_failure',
name='lava.scheduler.job.annotate_failure'),
=== modified file 'lava_scheduler_app/views.py'
@@ -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