initial work on submitting job logic
[qcg-portal.git] / qcg / forms.py
index 3109419..7c715d9 100644 (file)
@@ -4,7 +4,6 @@ from django.core.validators import RegexValidator
 from django.template.defaultfilters import capfirst
 from pyqcg.utils import TaskStatus
 
-from qcg.fields import PredefinedChoiceField, MultiplePredefinedChoiceField
 from qcg.models import Task, Allocation
 
 
@@ -84,8 +83,9 @@ class JobDescriptionForm(forms.Form):
     APPLICATION_CHOICES = (
         CHOICES_PLACEHOLDER,
         ('bash', 'BASH'),
-        ('python', 'Python'),
+        ('gromacs/4.6.3', 'GROMACS 4.6.3'),
         ('matlab', 'MATLAB'),
+        ('python', 'Python'),
     )
     QUEUE_CHOICES = (
         CHOICES_PLACEHOLDER,
@@ -109,36 +109,28 @@ class JobDescriptionForm(forms.Form):
     )
 
     application = forms.ChoiceField(choices=APPLICATION_CHOICES, label=u"Aplikacja", required=False)  # TODO choices
-    executable = forms.CharField(label=u"Polecenie", max_length=500, required=False)  # TODO grid ftp
-    arguments = forms.CharField(label=u"Argumenty", max_length=1000, required=False)
-
-    name = forms.CharField(label=u"Nazwa", max_length=100, required=False)
-    note = forms.CharField(label=u"Notatka", widget=forms.Textarea(attrs={'rows': 2, 'cols': 40}), required=False)
+    executable = forms.CharField(label=u"Plik wykonywalny", max_length=500, required=False)  # TODO grid ftp
+    script = forms.CharField(label=u"Skrypt", widget=forms.Textarea(attrs={'rows': 2, 'cols': 40}), required=False)  # TODO saving to grid ftp
+    arguments = forms.MultipleChoiceField(label=u"Argumenty", required=False)
+    note = forms.CharField(label=u"Opis", widget=forms.Textarea(attrs={'rows': 2, 'cols': 40}), required=False)
     grant = forms.CharField(label=u"Grant", max_length=100, required=False)
 
     host = forms.ChoiceField(label=u"Host", choices=Host.CHOICES, required=False)
-    queue = PredefinedChoiceField(choices=QUEUE_CHOICES, label=u"Kolejka", required=False)
+    properties = forms.MultipleChoiceField(label=u"Właściwości węzłów", required=False)
+    queue = forms.ChoiceField(choices=QUEUE_CHOICES, label=u"Kolejka", required=False)
     procs = forms.IntegerField(label=u"Liczba procesów", min_value=0, required=False)
     nodes = forms.CharField(label=u"Topologia węzłów", max_length=10, validators=[nodes_validator], required=False)
     wall_time = forms.IntegerField(label=u"Wall time (s)", min_value=0, required=False)  # TODO duration field
     memory = forms.IntegerField(label=u"Pamięć (MB)", min_value=0, required=False)
     memory_per_slot = forms.IntegerField(label=u"Pamięci per proces (MB)", min_value=0, required=False)
+    modules = forms.MultipleChoiceField(label=u"Moduły", choices=MODULES_CHOICES, required=False)  # TODO choices
+    reservation = forms.CharField(label=u"Rezerwacja", max_length=100, required=False)
 
     # TODO grid ftp
     input = forms.CharField(label=u"Standardowe wejście", max_length=500, required=False)
-    output = forms.CharField(label=u"Standardowe wyjście", max_length=500, required=False)
-    error = forms.CharField(label=u"Standardowe wyjście błędów", max_length=500, required=False)
     stage_in = forms.CharField(label=u"Stage in", max_length=500, required=False)
     stage_out = forms.CharField(label=u"Stage out", max_length=500, required=False)
 
-    properties = MultiplePredefinedChoiceField(label=u"Właściwości węzłów", required=False)
-    modules = forms.MultipleChoiceField(label=u"Moduły", choices=MODULES_CHOICES, required=False)  # TODO choices
-
-    not_after = forms.DateTimeField(label=u"Nie później niż", required=False)
-    not_before = forms.DateTimeField(label=u"Nie wcześniej niż", required=False)
-    deadline = forms.IntegerField(label=u"Deadline (s)", min_value=0, required=False)  # TODO duration field
-    reservation = forms.CharField(label=u"Rezerwacja", max_length=100, required=False)
-
     monitoring = forms.BooleanField(label=u"Portal QCG-Monitoring", required=False)
     notify_type = forms.ChoiceField(label=u"Monitorowanie stanu", choices=NOTIFY_CHOICES, required=False, initial=0,
                                     widget=forms.RadioSelect)
@@ -156,9 +148,18 @@ class JobDescriptionForm(forms.Form):
                                          widget=forms.RadioSelect)
     postprocess_cmd = forms.CharField(label=u"Polecenie", max_length=1000, required=False)
     postprocess_script = forms.CharField(label=u"Skrypt", max_length=500, required=False)  # TODO grid ftp
-    native = MultiplePredefinedChoiceField(label=u"Parametry natywne", required=False)
+    native = forms.MultipleChoiceField(label=u"Opcje systemu kolejkowego", required=False)
     persistent = forms.BooleanField(label=u"Trwałe", required=False)
-    use_scratch = forms.BooleanField(label=u"Scratch", required=False)
+
+    def __init__(self, data=None, *args, **kwargs):
+        super(JobDescriptionForm, self).__init__(data, *args, **kwargs)
+
+        if data is not None:
+            # accept user defined choices
+            self.fields['queue'].choices += ((data.get('queue'), data.get('queue')), )
+            self.fields['arguments'].choices += ((v, v) for v in data.getlist('arguments'))
+            self.fields['properties'].choices += ((v, v) for v in data.getlist('properties'))
+            self.fields['native'].choices += ((v, v) for v in data.getlist('native'))
 
 
 class EnvForm(forms.Form):