handling master file for application type jobs
[qcg-portal.git] / qcg / forms.py
index 35b34d7..4cd49e7 100644 (file)
@@ -117,7 +117,7 @@ class JobDescriptionForm(forms.Form):
     )
 
     application = forms.ChoiceField(choices=APPLICATION_CHOICES, label=u"Aplikacja", required=False)  # TODO choices
-    master_file = forms.CharField(label=u"Plik główny", max_length=500, required=False)  # TODO grid ftp
+    master_file = forms.CharField(label=u"Plik główny", max_length=500, required=False)
     executable = forms.CharField(label=u"Plik wykonywalny", max_length=500, required=False)
     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)
@@ -174,6 +174,9 @@ class JobDescriptionForm(forms.Form):
     def clean(self):
         data = super(JobDescriptionForm, self).clean()
 
+        if data['application'] and not data['master_file']:
+            self.add_error('master_file', u"W trybie uruchamiania aplikacji należy podać plik główny")
+
         notify_type = data.get('notify_type')
         data['notify'] = u'{}:{}'.format(notify_type, data['notify_address']) if notify_type else ''
 
@@ -204,6 +207,9 @@ class JobDescriptionForm(forms.Form):
     def clean_executable(self):
         return self._gsiftp_suffix(self.cleaned_data['executable'])
 
+    def clean_master_file(self):
+        return self._gsiftp_suffix(self.cleaned_data['master_file'])
+
     def clean_nodes(self):
         return map(int, self.cleaned_data['nodes'].split(':', 2)) if self.cleaned_data['nodes'] else ''