@@ -49,7 +49,7 class JARSfilterForm(forms.ModelForm): | |||||
49 | instance = getattr(self, 'instance', None) |
|
49 | instance = getattr(self, 'instance', None) | |
50 |
|
50 | |||
51 | self.fields['fch_decimal'].widget.attrs['readonly'] = True |
|
51 | self.fields['fch_decimal'].widget.attrs['readonly'] = True | |
52 |
|
52 | |||
53 | if 'initial' in kwargs: |
|
53 | if 'initial' in kwargs: | |
54 | if 'filter_id' not in kwargs['initial']: |
|
54 | if 'filter_id' not in kwargs['initial']: | |
55 | self.fields.pop('name') |
|
55 | self.fields.pop('name') | |
@@ -64,9 +64,9 class JARSfilterForm(forms.ModelForm): | |||||
64 | self.fields['name'].label = "Filter Template Name" |
|
64 | self.fields['name'].label = "Filter Template Name" | |
65 | else: |
|
65 | else: | |
66 | self.fields['name'] = forms.ChoiceField(choices=create_choices_from_model(JARSfilter, kwargs['initial']['filter_id'])) |
|
66 | self.fields['name'] = forms.ChoiceField(choices=create_choices_from_model(JARSfilter, kwargs['initial']['filter_id'])) | |
67 |
jars_filter = JARSfilter.objects.get(pk=kwargs['initial']['filter_id']) |
|
67 | jars_filter = JARSfilter.objects.get(pk=kwargs['initial']['filter_id']) | |
68 | labels = [f.name for f in jars_filter._meta.get_fields()] |
|
68 | labels = [f.name for f in jars_filter._meta.get_fields()] | |
69 |
|
69 | |||
70 | for label in ['id']: |
|
70 | for label in ['id']: | |
71 | labels.remove(label) |
|
71 | labels.remove(label) | |
72 | for label in labels: |
|
72 | for label in labels: |
@@ -25,19 +25,19 def jars_conf(request, id_conf): | |||||
25 | kwargs['filter'] = filter_parms |
|
25 | kwargs['filter'] = filter_parms | |
26 | kwargs['filter_keys'] = ['clock', 'mult', 'fch', 'fch_decimal', |
|
26 | kwargs['filter_keys'] = ['clock', 'mult', 'fch', 'fch_decimal', | |
27 | 'filter_fir', 'filter_2', 'filter_5'] |
|
27 | 'filter_fir', 'filter_2', 'filter_5'] | |
28 |
|
28 | |||
29 | filter_resolution=conf.filter_resolution() |
|
29 | filter_resolution=conf.filter_resolution() | |
30 | kwargs['resolution'] = '{} (MHz)'.format(filter_resolution) |
|
30 | kwargs['resolution'] = '{} (MHz)'.format(filter_resolution) | |
31 | if filter_resolution < 1: |
|
31 | if filter_resolution < 1: | |
32 | kwargs['resolution'] = '{} (kHz)'.format(filter_resolution*1000) |
|
32 | kwargs['resolution'] = '{} (kHz)'.format(filter_resolution*1000) | |
33 |
|
33 | |||
34 | kwargs['status'] = conf.device.get_status_display() |
|
34 | kwargs['status'] = conf.device.get_status_display() | |
35 |
|
35 | |||
36 |
|
36 | |||
37 | kwargs['dev_conf'] = conf |
|
37 | kwargs['dev_conf'] = conf | |
38 | kwargs['dev_conf_keys'] = ['name', |
|
38 | kwargs['dev_conf_keys'] = ['name', | |
39 | 'cards_number', 'channels_number', 'channels', |
|
39 | 'cards_number', 'channels_number', 'channels', | |
40 |
'ftp_interval', 'data_type','acq_profiles', |
|
40 | 'ftp_interval', 'data_type','acq_profiles', | |
41 | 'profiles_block', 'raw_data_blocks', 'ftp_interval', |
|
41 | 'profiles_block', 'raw_data_blocks', 'ftp_interval', | |
42 | 'cohe_integr_str', 'cohe_integr', 'decode_data', 'post_coh_int', |
|
42 | 'cohe_integr_str', 'cohe_integr', 'decode_data', 'post_coh_int', | |
43 | 'incohe_integr', 'fftpoints', 'spectral_number', |
|
43 | 'incohe_integr', 'fftpoints', 'spectral_number', | |
@@ -117,7 +117,7 def import_file(request, conf_id): | |||||
117 | conf.dict_to_parms(data) |
|
117 | conf.dict_to_parms(data) | |
118 | messages.success(request, 'Configuration "%s" loaded succesfully' % request.FILES['file_name']) |
|
118 | messages.success(request, 'Configuration "%s" loaded succesfully' % request.FILES['file_name']) | |
119 | return redirect(conf.get_absolute_url_edit()) |
|
119 | return redirect(conf.get_absolute_url_edit()) | |
120 |
|
120 | |||
121 | except Exception as e: |
|
121 | except Exception as e: | |
122 | messages.error(request, 'Error parsing file: "%s" - %s' % (request.FILES['file_name'], repr(e))) |
|
122 | messages.error(request, 'Error parsing file: "%s" - %s' % (request.FILES['file_name'], repr(e))) | |
123 | else: |
|
123 | else: | |
@@ -176,11 +176,11 def read_conf(request, conf_id): | |||||
176 | def change_filter(request, conf_id, filter_id=None): |
|
176 | def change_filter(request, conf_id, filter_id=None): | |
177 |
|
177 | |||
178 | conf = get_object_or_404(JARSConfiguration, pk=conf_id) |
|
178 | conf = get_object_or_404(JARSConfiguration, pk=conf_id) | |
179 |
|
179 | |||
180 | if filter_id: |
|
180 | if filter_id: | |
181 | if filter_id.__class__.__name__ not in ['int', 'float']: |
|
181 | if filter_id.__class__.__name__ not in ['int', 'float']: | |
182 | filter_id = eval(filter_id) |
|
182 | filter_id = eval(filter_id) | |
183 |
|
183 | |||
184 | if filter_id == 0: |
|
184 | if filter_id == 0: | |
185 | return redirect('url_change_jars_filter', conf_id=conf.id) |
|
185 | return redirect('url_change_jars_filter', conf_id=conf.id) | |
186 |
|
186 | |||
@@ -224,17 +224,17 def get_log(request, conf_id): | |||||
224 | message = conf.message |
|
224 | message = conf.message | |
225 | messages.error(request, message) |
|
225 | messages.error(request, message) | |
226 | return redirect('url_jars_conf', id_conf=conf.id) |
|
226 | return redirect('url_jars_conf', id_conf=conf.id) | |
227 |
|
227 | |||
228 | try: |
|
228 | try: | |
229 | message = response.json()['message'] |
|
229 | message = response.json()['message'] | |
230 | messages.error(request, message) |
|
230 | messages.error(request, message) | |
231 | return redirect('url_jars_conf', id_conf=conf.id) |
|
231 | return redirect('url_jars_conf', id_conf=conf.id) | |
232 | except Exception as e: |
|
232 | except Exception as e: | |
233 | message = 'Restarting Report.txt has been downloaded successfully.' |
|
233 | message = 'Restarting Report.txt has been downloaded successfully.' | |
234 |
|
234 | |||
235 | content = response |
|
235 | content = response | |
236 | filename = 'Log_%s_%s.txt' %(conf.experiment.name, conf.experiment.id) |
|
236 | filename = 'Log_%s_%s.txt' %(conf.experiment.name, conf.experiment.id) | |
237 | response = HttpResponse(content,content_type='text/plain') |
|
237 | response = HttpResponse(content,content_type='text/plain') | |
238 | response['Content-Disposition'] = 'attachment; filename="%s"' %filename |
|
238 | response['Content-Disposition'] = 'attachment; filename="%s"' %filename | |
239 |
|
239 | |||
240 | return response No newline at end of file |
|
240 | return response |
General Comments 0
You need to be logged in to leave comments.
Login now