##// END OF EJS Templates
Add 'reset pedestal' option
Add 'reset pedestal' option

File last commit:

r444:d8e453ba0459
r444:d8e453ba0459
Show More
views.py
131 lines | 3.9 KiB | text/x-python | PythonLexer
Juan C. Espinoza
- Update rc app...
r79
Juan C. Espinoza
Add rc config mods...
r23 import json
from django.contrib import messages
Juan C. Espinoza
Update RC models, views, templates & statics...
r45 from django.utils.safestring import mark_safe
Juan C. Espinoza
Updates to models, views & forms for CR...
r25 from django.shortcuts import render, redirect, get_object_or_404, HttpResponse
Juan C. Espinoza
Update Views y several improvements
r316 from django.contrib.auth.decorators import login_required
Juan C. Espinoza
Add rc config mods...
r23
Juan C. Espinoza
Update code for django 1.10, python 3 and latest third party packages, review operation view ...
r172 from apps.main.models import Experiment, Device
Juan C. Espinoza
Updates to models, views & forms for CR...
r25 from apps.main.views import sidebar
Juan C. Espinoza
Add rc config mods...
r23
Limpieza de código y funcionalidades usrp
r346 from .models import PedestalConfiguration
from .forms import PedestalConfigurationForm, PedestalImportForm
Juan C. Espinoza
Add rc config mods...
r23
Juan C. Espinoza
Update RC models, views, templates & statics...
r45 def conf(request, conf_id):
Juan C. Espinoza
Add rc config mods...
r23
Limpieza de código y funcionalidades usrp
r346 conf = get_object_or_404(PedestalConfiguration, pk=conf_id)
Juan C. Espinoza
Update code for django 1.10, python 3 and latest third party packages, review operation view ...
r172
Juan C. Espinoza
Add rc config mods...
r23 kwargs = {}
kwargs['dev_conf'] = conf
Update pedestal views with validations
r369
if conf.mode == 'position':
kwargs['dev_conf_keys'] = ['mode', 'axis', 'angle']
elif conf.mode == 'speed':
kwargs['dev_conf_keys'] = ['mode', 'axis', 'speed']
else:
kwargs['dev_conf_keys'] = ['mode', 'axis', 'speed', 'angle', 'min_value', 'max_value']
Juan C. Espinoza
Update code for django 1.10, python 3 and latest third party packages, review operation view ...
r172
Juan C. Espinoza
Update Views y several improvements
r316 kwargs['title'] = 'Configuration'
kwargs['suptitle'] = 'Detail'
Juan C. Espinoza
Update code for django 1.10, python 3 and latest third party packages, review operation view ...
r172
Juan C. Espinoza
Add rc config mods...
r23 kwargs['button'] = 'Edit Configuration'
Generator parameter type fixed, devices status & warning messages
r350
conf.status_device()
Juan C. Espinoza
Add rc config mods...
r23 ###### SIDEBAR ######
Juan C. Espinoza
Update several views and models in main app...
r85 kwargs.update(sidebar(conf=conf))
Juan C. Espinoza
Update code for django 1.10, python 3 and latest third party packages, review operation view ...
r172
Limpieza de código y funcionalidades usrp
r346 return render(request, 'pedestal_conf.html', kwargs)
Juan C. Espinoza
Add rc config mods...
r23
Juan C. Espinoza
Update Views y several improvements
r316 @login_required
Juan C. Espinoza
Update RC models, views, templates & statics...
r45 def conf_edit(request, conf_id):
New experiment views
r360
Limpieza de código y funcionalidades usrp
r346 conf = get_object_or_404(PedestalConfiguration, pk=conf_id)
Clean code and update Pedestal model
r368
Juan C. Espinoza
Add rc config mods...
r23 if request.method=='GET':
Clean code and update Pedestal model
r368
Limpieza de código y funcionalidades usrp
r346 form = PedestalConfigurationForm(instance=conf)
Update pedestal views with validations
r369 if conf.mode == 'position':
form.fields['speed'].disabled = True
form.fields['max_value'].disabled = True
form.fields['min_value'].disabled = True
elif conf.mode == 'speed':
form.fields['angle'].disabled = True
form.fields['max_value'].disabled = True
form.fields['min_value'].disabled = True
Juan C. Espinoza
Update code for django 1.10, python 3 and latest third party packages, review operation view ...
r172
Juan C. Espinoza
Update RC models, views, templates & statics...
r45 elif request.method=='POST':
Clean code and update Pedestal model
r368
Juan C. Espinoza
Update RC models, views, templates & statics...
r45 line_data = {}
conf_data = {}
Juan C. Espinoza
Add compatibility with embed CGS in RC
r328 clock_data = {}
Juan C. Espinoza
Update RC models, views, templates & statics...
r45 extras = []
Clean code and update Pedestal model
r368
Juan C. Espinoza
Update RC models, views, templates & statics...
r45 #classified post fields
Clean code and update Pedestal model
r368
Update pedestal views with validations
r369 form = PedestalConfigurationForm(request.POST, instance=conf)
Juan C. Espinoza
Update RC models, views, templates & statics...
r45
Limpieza de código y funcionalidades usrp
r346 if form.is_valid():
Juan C. Espinoza
Add rc config mods...
r23 form.save()
Juan C. Espinoza
Update code for django 1.10, python 3 and latest third party packages, review operation view ...
r172
Pulse generator & USRP_Tx devices added
r348 messages.success(request, 'Pedestal configuration successfully updated')
Juan C. Espinoza
Update code for django 1.10, python 3 and latest third party packages, review operation view ...
r172
return redirect(conf.get_absolute_url())
Juan C. Espinoza
Add rc config mods...
r23 kwargs = {}
Juan C. Espinoza
Updates to models, views & forms for CR...
r25 kwargs['dev_conf'] = conf
Juan C. Espinoza
Add rc config mods...
r23 kwargs['form'] = form
Juan C. Espinoza
Update RC models, views, templates & statics...
r45 kwargs['edit'] = True
Juan C. Espinoza
Update code for django 1.10, python 3 and latest third party packages, review operation view ...
r172
Limpieza de código y funcionalidades usrp
r346 kwargs['title'] = 'Pedestal Configuration'
Juan C. Espinoza
Update code for django 1.10, python 3 and latest third party packages, review operation view ...
r172 kwargs['suptitle'] = 'Edit'
Juan C. Espinoza
Add rc config mods...
r23 kwargs['button'] = 'Update'
Juan C. Espinoza
Update code for django 1.10, python 3 and latest third party packages, review operation view ...
r172
Limpieza de código y funcionalidades usrp
r346 return render(request, 'pedestal_conf_edit.html', kwargs)
Juan C. Espinoza
Update code for django 1.10, python 3 and latest third party packages, review operation view ...
r172
Juan C. Espinoza
Update RC models, views, templates & statics...
r45 def import_file(request, conf_id):
Juan C. Espinoza
Update code for django 1.10, python 3 and latest third party packages, review operation view ...
r172
Limpieza de código y funcionalidades usrp
r346 conf = get_object_or_404(PedestalConfiguration, pk=conf_id)
Juan C. Espinoza
Update RC models, views, templates & statics...
r45 if request.method=='POST':
Limpieza de código y funcionalidades usrp
r346 form = PedestalImportForm(request.POST, request.FILES)
Juan C. Espinoza
Update code for django 1.10, python 3 and latest third party packages, review operation view ...
r172 if form.is_valid():
Juan C. Espinoza
- Improve display name for Devices & Configurations...
r121 try:
Fiorella Quino
RC files have been updated...
r264 data = conf.import_from_file(request.FILES['file_name'])
conf.dict_to_parms(data)
Juan C. Espinoza
Update RC models, views, templates & statics...
r45 messages.success(request, 'Configuration "%s" loaded succesfully' % request.FILES['file_name'])
Juan C. Espinoza
Optimize pulses's plot and generation ...
r111 return redirect(conf.get_absolute_url_edit())
Juan C. Espinoza
Update code for django 1.10, python 3 and latest third party packages, review operation view ...
r172
except Exception as e:
Fiorella Quino
RC files have been updated...
r264 messages.error(request, 'Error parsing file: "%s" - %s' % (request.FILES['file_name'], repr(e)))
Juan C. Espinoza
Update RC models, views, templates & statics...
r45 else:
messages.warning(request, 'Your current configuration will be replaced')
Limpieza de código y funcionalidades usrp
r346 form = PedestalImportForm()
Juan C. Espinoza
Update code for django 1.10, python 3 and latest third party packages, review operation view ...
r172
Juan C. Espinoza
Update RC models, views, templates & statics...
r45 kwargs = {}
kwargs['form'] = form
Limpieza de código y funcionalidades usrp
r346 kwargs['title'] = 'Pedestal Configuration'
Juan C. Espinoza
Update RC models, views, templates & statics...
r45 kwargs['suptitle'] = 'Import file'
kwargs['button'] = 'Upload'
kwargs['previous'] = conf.get_absolute_url()
Juan C. Espinoza
Update code for django 1.10, python 3 and latest third party packages, review operation view ...
r172
Limpieza de código y funcionalidades usrp
r346 return render(request, 'pedestal_import.html', kwargs)
Juan C. Espinoza
Update Views y several improvements
r316
Add 'reset pedestal' option
r444 @login_required
def conf_reset(request, conf_id):
conf = get_object_or_404(PedestalConfiguration, pk=conf_id)
if conf.reset_device():
messages.success(request, conf.message)
else:
messages.error(request, conf.message)
return redirect(conf.get_absolute_url())
Juan C. Espinoza
Update Views y several improvements
r316 def conf_raw(request, conf_id):
Limpieza de código y funcionalidades usrp
r346 conf = get_object_or_404(PedestalConfiguration, pk=conf_id)
Juan C. Espinoza
Update Views y several improvements
r316 raw = conf.write_device(raw=True)
return HttpResponse(raw, content_type='application/json')