@@ -26,62 +26,4 class JARSConfigurationForm(forms.ModelForm): | |||||
26 |
|
26 | |||
27 | class Meta: |
|
27 | class Meta: | |
28 | model = JARSConfiguration |
|
28 | model = JARSConfiguration | |
29 |
exclude = ('type', 'parameters', 'status' |
|
29 | exclude = ('type', 'parameters', 'status') No newline at end of file | |
30 | 'channels_number', 'channels', 'rd_directory', 'raw_data_blocks', |
|
|||
31 | 'data_type', 'acq_profiles', 'profiles_block', 'filter', |
|
|||
32 | 'create_directory', 'include_expname', 'acq_link', |
|
|||
33 | 'view_raw_data') |
|
|||
34 |
|
||||
35 |
|
||||
36 | class JARSConfigurationForm_Raw(forms.ModelForm): |
|
|||
37 | def __init__(self, *args, **kwargs): |
|
|||
38 | super(JARSConfigurationForm, self).__init__(*args, **kwargs) |
|
|||
39 | instance = getattr(self, 'instance', None) |
|
|||
40 |
|
||||
41 | if instance and instance.pk: |
|
|||
42 | devices = Device.objects.filter(device_type__name='jars') |
|
|||
43 |
|
||||
44 | if instance.experiment: |
|
|||
45 | experiments = Experiment.objects.filter(pk=instance.experiment.id) |
|
|||
46 | self.fields['experiment'].widget.choices = [(experiment.id, experiment) for experiment in experiments] |
|
|||
47 |
|
||||
48 | self.fields['device'].widget.choices = [(device.id, device) for device in devices] |
|
|||
49 |
|
||||
50 | #-------------JARS Configuration needs an Experiment----------------- |
|
|||
51 | def clean(self): |
|
|||
52 | cleaned_data = super(JARSConfigurationForm, self).clean() |
|
|||
53 | experiment = cleaned_data.get('experiment') |
|
|||
54 | if experiment == None: |
|
|||
55 | msg = "Error: Jars Configuration needs an Experiment" |
|
|||
56 | self.add_error('experiment', msg) |
|
|||
57 |
|
||||
58 | class Meta: |
|
|||
59 | model = JARSConfiguration |
|
|||
60 | exclude = ('type', 'parameters', 'status') |
|
|||
61 |
|
||||
62 |
|
||||
63 | class JARSConfigurationForm_Pro(forms.ModelForm): |
|
|||
64 | def __init__(self, *args, **kwargs): |
|
|||
65 | super(JARSConfigurationForm, self).__init__(*args, **kwargs) |
|
|||
66 | instance = getattr(self, 'instance', None) |
|
|||
67 |
|
||||
68 | if instance and instance.pk: |
|
|||
69 | devices = Device.objects.filter(device_type__name='jars') |
|
|||
70 |
|
||||
71 | if instance.experiment: |
|
|||
72 | experiments = Experiment.objects.filter(pk=instance.experiment.id) |
|
|||
73 | self.fields['experiment'].widget.choices = [(experiment.id, experiment) for experiment in experiments] |
|
|||
74 |
|
||||
75 | self.fields['device'].widget.choices = [(device.id, device) for device in devices] |
|
|||
76 |
|
||||
77 | #-------------JARS Configuration needs an Experiment----------------- |
|
|||
78 | def clean(self): |
|
|||
79 | cleaned_data = super(JARSConfigurationForm, self).clean() |
|
|||
80 | experiment = cleaned_data.get('experiment') |
|
|||
81 | if experiment == None: |
|
|||
82 | msg = "Error: Jars Configuration needs an Experiment" |
|
|||
83 | self.add_error('experiment', msg) |
|
|||
84 |
|
||||
85 | class Meta: |
|
|||
86 | model = JARSConfiguration |
|
|||
87 | exclude = ('type', 'parameters', 'status') |
|
General Comments 0
You need to be logged in to leave comments.
Login now