[cig-commits] commit: Add in SU_cost
Mercurial
hg at geodynamics.org
Sun Jul 3 20:04:38 PDT 2011
changeset: 20:4c0d4e185f29
user: Walter Landry <wlandry at caltech.edu>
date: Tue Jun 28 15:51:58 2011 -0700
files: SeismoWebPortal/models.py SeismoWebPortal/templates/SeismoWebPortal/run_SU_cost.html SeismoWebPortal/urls.py SeismoWebPortal/views.py
description:
Add in SU_cost
diff -r 7596e82a7551 -r 4c0d4e185f29 SeismoWebPortal/models.py
--- a/SeismoWebPortal/models.py Tue Jun 28 15:36:15 2011 -0700
+++ b/SeismoWebPortal/models.py Tue Jun 28 15:51:58 2011 -0700
@@ -694,11 +694,13 @@ class ArchivedRun(Model):
started = models.DateTimeField(auto_now_add=True, editable=False)
finished = models.DateTimeField(null=True)
+ SU_cost = models.FloatField(max_digits=19, decimal_places=10, default=-1)
+
user = models.ForeignKey(User) # the user who submitted the request
cluster = models.ForeignKey('Cluster', null=True) # the cluster on which it ran
class Admin:
- list_display = ('status', 'started', 'finished')
+ list_display = ('status', 'started', 'finished', 'SU_cost')
def __str__(self):
return "Archived Run %04d" % self.id
@@ -706,6 +708,8 @@ class ArchivedRun(Model):
code = property(lambda self: self.parameters.code)
def cost(self):
+ if self.SU_cost>=0:
+ return self.SU_cost
if self.cluster:
return self.parameters.cost(self, self.cluster)
return self.parameters.estimatedCost(self)
diff -r 7596e82a7551 -r 4c0d4e185f29 SeismoWebPortal/templates/SeismoWebPortal/run_SU_cost.html
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/SeismoWebPortal/templates/SeismoWebPortal/run_SU_cost.html Tue Jun 28 15:51:58 2011 -0700
@@ -0,0 +1,14 @@
+<html>
+ <head>
+ <title>Run SU_cost</title>
+ </head>
+
+ <body>
+
+ <form method="post" action="{{action}}">
+ <p>{{ form.SU_cost }}
+ <p><input type="submit" value="Save">
+ </form>
+
+ </body>
+</html>
diff -r 7596e82a7551 -r 4c0d4e185f29 SeismoWebPortal/urls.py
--- a/SeismoWebPortal/urls.py Tue Jun 28 15:36:15 2011 -0700
+++ b/SeismoWebPortal/urls.py Tue Jun 28 15:51:58 2011 -0700
@@ -31,6 +31,7 @@ urlpatterns = patterns('',
# runs
(r'^(?P<daemonCode>\w+)/runs/list\.py$', 'SeismoWebPortal.views.runList'),
(r'^(?P<daemonCode>\w+)/runs/(?P<objectId>\d+)/status/$', 'SeismoWebPortal.views.updateRunStatus'),
+ (r'^(?P<daemonCode>\w+)/runs/(?P<objectId>\d+)/SU_cost/$', 'SeismoWebPortal.views.updateSU_cost'),
(r'^(?P<daemonCode>\w+)/runs/(?P<objectId>\d+)/(?P<filename>.*)$', 'SeismoWebPortal.views.downloadInputFile'),
# jobs
diff -r 7596e82a7551 -r 4c0d4e185f29 SeismoWebPortal/views.py
--- a/SeismoWebPortal/views.py Tue Jun 28 15:36:15 2011 -0700
+++ b/SeismoWebPortal/views.py Tue Jun 28 15:51:58 2011 -0700
@@ -335,6 +335,38 @@ def updateRunStatus(request, daemonCode,
{'form': form, 'action': request.path},
RequestContext(request, {}))
+def updateSU_cost(request, daemonCode, objectId):
+ root = rootURL(request, "%s/runs/" % daemonCode)
+
+ manipulator = forms.Manipulator()
+ manipulator.fields.extend([
+ forms.TextField(field_name='SU_cost', is_required=True),
+ ])
+
+ cluster = daemonConnect(daemonCode)
+ run = get_object_or_404(models.ArchivedRun, id=objectId)
+ assert run.cluster == cluster
+
+ if request.method == 'POST':
+ response = HttpResponse(mimetype='text/plain')
+ new_data = request.POST.copy()
+ errors = manipulator.get_validation_errors(new_data)
+ if errors:
+ response.write(repr(errors))
+ else:
+ manipulator.do_html2python(new_data)
+ run.SU_cost = new_data['SU_cost']
+ run.save()
+ response.write(repr('OK'))
+ return response
+
+ errors = {}
+ new_data = {'SU_cost': run.SU_cost}
+ form = forms.FormWrapper(manipulator, new_data, errors)
+ return render_to_response('SeismoWebPortal/run_SU_cost.html',
+ {'form': form, 'action': request.path},
+ RequestContext(request, {}))
+
def notifyEveryoneOfCompletion(run, request, root):
from django.core.mail import send_mail
from django.core.mail import mail_admins
More information about the CIG-COMMITS
mailing list