X-Git-Url: http://mmka.chem.univ.gda.pl/gitweb/?a=blobdiff_plain;f=qcg%2Fforms.py;h=d4b0dd343f93b213fc3d941c86f95fd9986e5b4b;hb=0999f502fbda6a6efa22b02e395ebb2269b1be12;hp=077b6530e3fa4ca2d0703e2c16a5e7b860894d15;hpb=2208e0ac4504a21b8debda6984b06ee6ca4503d2;p=qcg-portal.git diff --git a/qcg/forms.py b/qcg/forms.py index 077b653..d4b0dd3 100644 --- a/qcg/forms.py +++ b/qcg/forms.py @@ -64,20 +64,6 @@ class FiltersForm(forms.Form): class JobDescriptionForm(forms.Form): - class Host(object): - GALERA = 'galera.task.gda.pl' - HYDRA = 'hydra.icm.edu.pl' - INULA = 'inula.man.poznan.pl' - MOSS = 'moss.man.poznan.pl' - NOVA = 'nova.wcss.wroc.pl' - REEF = 'reef.man.poznan.pl' - ZEUS = 'zeus.cyfronet.pl' - - CHOICES = ( - CHOICES_PLACEHOLDER, - (INULA, u'Inula'), - ) - class Process(object): NONE = '' CMD = 'c' @@ -89,28 +75,28 @@ class JobDescriptionForm(forms.Form): (SCRIPT, u'Skrypt'), ) + APPLICATION_CHOICES = ( CHOICES_PLACEHOLDER, - ('bash', 'BASH'), - ('python', 'Python'), + ('unres-gab', 'UNRES GAB'), + ('unres-e0ll2y', 'UNRES E0LL2Y'), ) + QUEUE_CHOICES = ( CHOICES_PLACEHOLDER, ('plgrid', 'plgrid'), ('plgrid-long', 'plgrid-long'), ('plgrid-testing', 'plgrid-testing'), ) - MODULES_CHOICES = ( - ('plgrid/apps/python', 'plgrid/apps/python'), - ('plgrid/apps/matlab', 'plgrid/apps/matlab'), - ) + PROTOCOL_CHOICES = ( ('', u'Brak'), ('mailto', u'E-mail'), ('xmpp', u'XMPP'), ) + FORCE_FIELD_CHOICES = ( ('GAB', u'GAB'), ('E0LL2Y', u'E0LL2Y'), @@ -121,20 +107,24 @@ class JobDescriptionForm(forms.Form): ntwx = forms.IntegerField(label=u"NTWX", help_text=u"Częstość zapisu współrzędnych w krokach", min_value=0, initial=1000, required=False) dt = forms.DecimalField(label=u"DT", help_text=u"Krok czasowy. Wartość kroku równa jedności to 48.9 fs", max_digits=5, decimal_places=2, min_value=0.01, initial=0.1, required=False) damax = forms.DecimalField(label=u"DAMAX", help_text=u"Maksymalna dopuszczalna zmiana przyspieszenia podczas jednego kroku czasowego", max_digits=5, decimal_places=2, min_value=0.01, initial=1.0, required=False) - force_field = forms.ChoiceField(choices=FORCE_FIELD_CHOICES, label=u"Pole siłowe", required=False) - nrep = forms.IntegerField(label=u"NREP", help_text=u"Liczba replik", min_value=2, initial=16, required=False) - nstex = forms.IntegerField(label=u"NSTEX", help_text=u"Liczba kroków po których następuje wymiana replik", min_value=2, initial=1000, required=False) + force_field = forms.ChoiceField(choices=FORCE_FIELD_CHOICES, label=u"Pole siłowe", required=False, initial='GAB') + pdb_file = forms.CharField(label=u"Plik PDB", max_length=500, required=False) + #retmin = forms.IntegerField(label=u"RETMIN", help_text=u"Dolny zakres temparatur dla wymiany replik", min_value=2, initial=250, required=False) + #retmax = forms.IntegerField(label=u"RETMAX", help_text=u"Górny zakres temperatur dla wymiany replik", min_value=2, initial=450, required=False) + sequence = forms.CharField(label=u"Sekwencja", help_text=u"Sekwencja aminokwasów w zapisie jednoliterowym", widget=forms.Textarea(attrs={'rows': 2, 'cols': 40}), required=False) - 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) + + application = forms.ChoiceField(choices=APPLICATION_CHOICES, label=u"Aplikacja", required=False, initial='unres-gab') + #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) 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) - hosts = forms.MultipleChoiceField(label=u"Host", choices=Host.CHOICES, required=False) + hosts = forms.MultipleChoiceField(label=u"Host", required=False) properties = forms.CharField(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) @@ -142,7 +132,7 @@ class JobDescriptionForm(forms.Form): wall_time = TimeRangeField(label=u"Wall time", required=False) 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 + modules = forms.MultipleChoiceField(label=u"Moduły", required=False) reservation = forms.CharField(label=u"Rezerwacja", max_length=100, required=False) input = forms.CharField(label=u"Standardowe wejście", max_length=500, required=False) @@ -168,27 +158,44 @@ class JobDescriptionForm(forms.Form): native = forms.MultipleChoiceField(label=u"Opcje systemu kolejkowego", required=False) persistent = forms.BooleanField(label=u"Trwałe", required=False) - def __init__(self, data=None, initial=None, *args, **kwargs): + def __init__(self, data=None, initial=None, hosts=(), applications=(), modules=(), *args, **kwargs): super(JobDescriptionForm, self).__init__(data, initial=initial, *args, **kwargs) + self.fields['hosts'].choices = hosts + self.fields['application'].choices = applications + self.fields['modules'].choices = modules + if data or initial: - self._init_user_choices('queue', data, initial) - self._init_user_choices('arguments', data, initial) - self._init_user_choices('native', data, initial) - self._init_user_choices('stage_in', data, initial) + self._init_user_choices('queue') + self._init_user_choices('arguments') + self._init_user_choices('native') + self._init_user_choices('stage_in') + self._init_user_choices('force_field') + + if not hosts: + self._init_user_choices('hosts') + self._init_user_choices('application') + self._init_user_choices('modules') + + + self.fields['monitoring'].widget.attrs['disabled'] = True def clean(self): data = super(JobDescriptionForm, self).clean() force_field = data.get('force_field') - if force_field == self.FORCE_FIELD_CHOICES[0]: + + if force_field == u'GAB': data['application'] = [u'unres-gab'] else: data['application'] = [u'unres-e0ll2y'] - if data['master_file']: - self.add_error('master_file', u"Należy podać plik główny") + if data['pdb_file']== None: + self.add_error('pdb_file', u"Należy podać plik PDB.") + if data['sequence']== '': + self.add_error('sequence', u"Należy podać sekwencję aminokwasów.") + if data['procs'] and data['nodes']: self.add_error(None, u"Zdefiniuj tylko jedno z pól: liczbę procesów lub topologię węzłów") @@ -242,19 +249,21 @@ class JobDescriptionForm(forms.Form): def clean_pdb_file(self): return self._gsiftp_suffix(self.cleaned_data['pdb_file']) + + def clean_sequence(self): + return self.cleaned_data['sequence'].strip(' \t\n\r') @staticmethod def _gsiftp_suffix(url): if url: return url if url.startswith('gsiftp://') else 'gsiftp://' + url - def _init_user_choices(self, name, data, initial): - initial = initial.get(name) if initial is not None else None - choices = data.getlist(name)[:] if data is not None else [] + def _init_user_choices(self, name): + initial = self.initial.get(name) + choices = self.data.getlist(name)[:] if self.data else [] if initial: choices += initial if isinstance(initial, list) else [initial] - self.fields[name].initial = initial if choices: self.fields[name].choices += ((v, v) for v in choices)