add gridftp view
[qcg-portal.git] / qcg / views.py
index 0be3d73..b8947b3 100644 (file)
@@ -160,20 +160,27 @@ def job_new(request):
 
         if form.is_valid() and env_formset.is_valid():
             print form.cleaned_data
+            print env_formset.cleaned_data
 
             desc = JobDescription(Credential(request.session['proxy']))
 
-            direct_map = ('application', 'arguments', 'note', 'grant', 'hosts', 'properties', 'queue', 'procs', 'nodes',
-                          'wall_time', 'memory', 'memory_per_slot', 'modules', 'native', 'notify', 'preprocess',
-                          'postprocess', 'persistent')
+            direct_map = ('arguments', 'note', 'grant', 'hosts', 'properties', 'queue', 'procs', 'wall_time', 'memory',
+                          'memory_per_slot', 'modules', 'native', 'notify', 'preprocess', 'postprocess', 'persistent')
 
             for name in direct_map:
                 if form.cleaned_data[name]:
                     setattr(desc, name, form.cleaned_data[name])
 
-            desc.reservation = ('LOCAL', form.cleaned_data['reservation'])
-            desc.watch_output = (form.cleaned_data['watch_output'], form.cleaned_data['watch_output_pattern'])
-            desc.env_variables += [(env['name'], env['value']) for env in env_formset.cleaned_data if not env['DELETE']]
+            if form.cleaned_data['application']:
+                desc.set_application(*form.cleaned_data['application'])
+            if form.cleaned_data['nodes']:
+                desc.set_nodes(*form.cleaned_data['nodes'])
+            if form.cleaned_data['reservation']:
+                desc.set_reservation(form.cleaned_data['reservation'])
+            if form.cleaned_data['watch_output']:
+                desc.set_watch_output(form.cleaned_data['watch_output'], form.cleaned_data['watch_output_pattern'])
+            desc.env_variables += [(env['name'], env['value'])
+                                   for env in env_formset.cleaned_data if env and not env['DELETE']]
             # TODO script
             # TODO executable
             # TODO input
@@ -181,7 +188,7 @@ def job_new(request):
             # TODO stage_out
             # TODO monitoring
 
-            for prop in direct_map + ('env_variables', 'reservation', 'watch_output'):
+            for prop in direct_map + ('application', 'nodes', 'env_variables', 'reservation', 'watch_output'):
                 print prop, type(getattr(desc, prop)), repr(getattr(desc, prop))
 
             print desc.xml_description
@@ -195,3 +202,7 @@ def job_new(request):
     errors = form.errors or (env_formset.is_bound and not env_formset.is_valid)
 
     return render(request, 'qcg/job_new.html', {'form': form, 'env_formset': env_formset, 'errors': errors})
+
+
+def gridftp(request):
+    return render(request, 'qcg/gridftp.html')