##// END OF EJS Templates
Task #716: ABS Views...
Task #716: ABS Views git-svn-id: http://jro-dev.igp.gob.pe/svn/jro_hard/radarsys/trunk/webapp@202 aa17d016-51d5-4e8b-934c-7b2bbb1bbe71

File last commit:

r175:a7fbf14a85a6
r179:127ca1c0468c
Show More
views.py
401 lines | 13.0 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
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
Juan C. Espinoza
Update RC models, views, templates & statics...
r45 from .models import RCConfiguration, RCLine, RCLineType, RCLineCode
Juan C. Espinoza
- Update rc app...
r79 from .forms import RCConfigurationForm, RCLineForm, RCLineViewForm, RCLineEditForm, RCImportForm, RCLineCodesForm
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
Juan C. Espinoza
Update RC models, views, templates & statics...
r45 conf = get_object_or_404(RCConfiguration, 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 lines = RCLine.objects.filter(rc_configuration=conf).order_by('channel')
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 for line in lines:
Juan C. Espinoza
Update RC models, views, templates & statics...
r45 params = json.loads(line.params)
line.form = RCLineViewForm(extra_fields=params, line=line)
if 'params' in params:
line.subforms = [RCLineViewForm(extra_fields=fields, line=line, subform=True) for fields in params['params']]
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
kwargs['rc_lines'] = lines
Juan C. Espinoza
Update code for django 1.10, python 3 and latest third party packages, review operation view ...
r172 kwargs['dev_conf_keys'] = ['name', 'ipp_unit', 'ntx', 'clock_in', 'clock_divider', 'clock',
Juan C. Espinoza
- Update rc app...
r79 'time_before', 'time_after', 'sync', 'sampling_reference', 'control_tx', 'control_sw']
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['title'] = 'RC Configuration'
kwargs['suptitle'] = 'Details'
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'
###### 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
Juan C. Espinoza
Add rc config mods...
r23 return render(request, 'rc_conf.html', kwargs)
Juan C. Espinoza
Update RC models, views, templates & statics...
r45
def conf_edit(request, 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
Update RC models, views, templates & statics...
r45 conf = get_object_or_404(RCConfiguration, 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
Update RC models, views, templates & statics...
r45 lines = RCLine.objects.filter(rc_configuration=conf).order_by('channel')
Juan C. Espinoza
Update code for django 1.10, python 3 and latest third party packages, review operation view ...
r172
for line in lines:
params = json.loads(line.params)
Juan C. Espinoza
- Update rc app...
r79 line.form = RCLineEditForm(conf=conf, line=line, extra_fields=params)
line.subform = False
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 if 'params' in params:
Juan C. Espinoza
- Update rc app...
r79 line.subforms = [RCLineEditForm(extra_fields=fields, line=line, subform=i) for i, fields in enumerate(params['params'])]
Juan C. Espinoza
Update RC models, views, templates & statics...
r45 line.subform = True
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 if request.method=='GET':
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 form = RCConfigurationForm(instance=conf)
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':
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 line_data = {}
conf_data = {}
extras = []
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 #classified post fields
for label,value in request.POST.items():
if label=='csrfmiddlewaretoken':
continue
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 if label.count('|')==0:
conf_data[label] = value
continue
Juan C. Espinoza
Update code for django 1.10, python 3 and latest third party packages, review operation view ...
r172
elif label.split('|')[0]!='-1':
Juan C. Espinoza
Update RC models, views, templates & statics...
r45 extras.append(label)
Juan C. Espinoza
Update code for django 1.10, python 3 and latest third party packages, review operation view ...
r172 continue
x, pk, name = label.split('|')
Juan C. Espinoza
- Update rc app...
r79 if name=='codes':
value = [s for s in value.split('\r\n') if s]
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 if pk in line_data:
line_data[pk][name] = value
else:
line_data[pk] = {name: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 RC models, views, templates & statics...
r45 #update conf
form = RCConfigurationForm(conf_data, instance=conf)
Juan C. Espinoza
Add rc config mods...
r23 if form.is_valid():
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 form.save()
Juan C. Espinoza
Update code for django 1.10, python 3 and latest third party packages, review operation view ...
r172
#update lines fields
Juan C. Espinoza
Update RC models, views, templates & statics...
r45 extras.sort()
for label in extras:
x, pk, name = label.split('|')
if pk not in line_data:
line_data[pk] = {}
if 'params' not in line_data[pk]:
line_data[pk]['params'] = []
if len(line_data[pk]['params'])<int(x)+1:
line_data[pk]['params'].append({})
line_data[pk]['params'][int(x)][name] = float(request.POST[label])
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 for pk, params in line_data.items():
line = RCLine.objects.get(pk=pk)
if line.line_type.name in ('windows', 'prog_pulses'):
if 'params' not in params:
params['params'] = []
line.params = json.dumps(params)
line.save()
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 #update pulses field
Juan C. Espinoza
Update code for django 1.10, python 3 and latest third party packages, review operation view ...
r172 conf.update_pulses()
Juan C. Espinoza
Update RC models, views, templates & statics...
r45 messages.success(request, 'RC 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['rc_lines'] = lines
kwargs['edit'] = 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 kwargs['title'] = 'RC 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'
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
Juan C. Espinoza
Add rc config mods...
r23 return render(request, 'rc_conf_edit.html', kwargs)
Juan C. Espinoza
- Update rc app...
r79 def add_line(request, conf_id, line_type_id=None, code_id=None):
Juan C. Espinoza
Update code for django 1.10, python 3 and latest third party packages, review operation view ...
r172
Juan C. Espinoza
Updates to models, views & forms for CR...
r25 conf = get_object_or_404(RCConfiguration, 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 if request.method=='GET':
Juan C. Espinoza
Updates to models, views & forms for CR...
r25 if line_type_id:
line_type = get_object_or_404(RCLineType, pk=line_type_id)
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 app...
r79 if code_id:
form = RCLineForm(initial={'rc_configuration':conf_id, 'line_type': line_type_id, 'code_id': code_id},
extra_fields=json.loads(line_type.params))
else:
form = RCLineForm(initial={'rc_configuration':conf_id, 'line_type': line_type_id},
extra_fields=json.loads(line_type.params))
Juan C. Espinoza
Updates to models, views & forms for CR...
r25 else:
Juan C. Espinoza
- Update rc app...
r79 line_type = {'id':0}
Juan C. Espinoza
Updates to models, views & forms for CR...
r25 form = RCLineForm(initial={'rc_configuration':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 if request.method=='POST':
Juan C. Espinoza
Update code for django 1.10, python 3 and latest third party packages, review operation view ...
r172
Juan C. Espinoza
Updates to models, views & forms for CR...
r25 line_type = get_object_or_404(RCLineType, pk=line_type_id)
Juan C. Espinoza
- Update rc app...
r79 form = RCLineForm(request.POST,
extra_fields=json.loads(line_type.params))
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 if form.is_valid():
form.save()
Juan C. Espinoza
Update RC models, views, templates & statics...
r45 form.instance.update_pulses()
return redirect('url_edit_rc_conf', 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['form'] = form
kwargs['title'] = 'RC Configuration'
kwargs['suptitle'] = 'Add Line'
kwargs['button'] = 'Add'
Juan C. Espinoza
Update RC models, views, templates & statics...
r45 kwargs['previous'] = conf.get_absolute_url_edit()
Juan C. Espinoza
Updates to models, views & forms for CR...
r25 kwargs['dev_conf'] = conf
Juan C. Espinoza
- Update rc app...
r79 kwargs['line_type'] = line_type
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 return render(request, 'rc_add_line.html', kwargs)
Juan C. Espinoza
- Update rc app...
r79 def edit_codes(request, conf_id, line_id, code_id=None):
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 app...
r79 conf = get_object_or_404(RCConfiguration, pk=conf_id)
Juan C. Espinoza
Update code for django 1.10, python 3 and latest third party packages, review operation view ...
r172 line = get_object_or_404(RCLine, pk=line_id)
Juan C. Espinoza
- Update rc app...
r79 params = json.loads(line.params)
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 app...
r79 if request.method=='GET':
if code_id:
code = get_object_or_404(RCLineCode, pk=code_id)
form = RCLineCodesForm(instance=code)
else:
Juan C. Espinoza
Update code for django 1.10, python 3 and latest third party packages, review operation view ...
r172 initial = {'code': params['code'],
Juan C. Espinoza
- Update rc app...
r79 'codes': params['codes'] if 'codes' in params else [],
'number_of_codes': len(params['codes']) if 'codes' in params else 0,
'bits_per_code': len(params['codes'][0]) if 'codes' in params else 0,
}
form = RCLineCodesForm(initial=initial)
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 app...
r79 if request.method=='POST':
form = RCLineCodesForm(request.POST)
if form.is_valid():
params['code'] = request.POST['code']
params['codes'] = [s for s in request.POST['codes'].split('\r\n') if s]
line.params = json.dumps(params)
line.save()
messages.success(request, 'Line: "%s" has been updated.' % line)
return redirect('url_edit_rc_conf', 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
- Update rc app...
r79 kwargs = {}
kwargs['form'] = form
kwargs['title'] = line
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
- Update rc app...
r79 kwargs['button'] = 'Update'
kwargs['dev_conf'] = conf
kwargs['previous'] = conf.get_absolute_url_edit()
kwargs['line'] = line
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 app...
r79 return render(request, 'rc_edit_codes.html', kwargs)
Juan C. Espinoza
Update RC models, views, templates & statics...
r45 def add_subline(request, conf_id, line_id):
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 conf = get_object_or_404(RCConfiguration, pk=conf_id)
line = get_object_or_404(RCLine, pk=line_id)
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 if request.method == 'POST':
if line:
params = json.loads(line.params)
Juan C. Espinoza
- Update rc app...
r79 subparams = json.loads(line.line_type.params)
if 'params' in subparams:
dum = {}
for key, value in subparams['params'].items():
dum[key] = value['value']
params['params'].append(dum)
Juan C. Espinoza
Update RC models, views, templates & statics...
r45 line.params = json.dumps(params)
line.save()
return redirect('url_edit_rc_conf', conf.id)
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 kwargs['title'] = 'Add new'
kwargs['suptitle'] = '%s to %s' % (line.line_type.name, line)
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 return render(request, 'confirm.html', kwargs)
Juan C. Espinoza
Add rc config mods...
r23
def remove_line(request, conf_id, line_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 conf = get_object_or_404(RCConfiguration, pk=conf_id)
line = get_object_or_404(RCLine, pk=line_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 if request.method == 'POST':
if line:
try:
channel = line.channel
line.delete()
for ch in range(channel+1, RCLine.objects.filter(rc_configuration=conf).count()+1):
l = RCLine.objects.get(rc_configuration=conf, channel=ch)
l.channel = l.channel-1
l.save()
messages.success(request, 'Line: "%s" has been deleted.' % line)
except:
Juan C. Espinoza
Update code for django 1.10, python 3 and latest third party packages, review operation view ...
r172 messages.error(request, 'Unable to delete line: "%s".' % line)
Juan C. Espinoza
Add rc config mods...
r23
Juan C. Espinoza
Update RC models, views, templates & statics...
r45 return redirect('url_edit_rc_conf', 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 = {}
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['object'] = line
Juan C. Espinoza
Avoid add mix line type to RC configurations...
r142 kwargs['delete'] = True
kwargs['title'] = 'Delete'
kwargs['suptitle'] = 'Line'
Juan C. Espinoza
Update RC models, views, templates & statics...
r45 kwargs['previous'] = conf.get_absolute_url_edit()
Juan C. Espinoza
Add rc config mods...
r23 return render(request, 'confirm.html', kwargs)
Juan C. Espinoza
- Update rc app...
r79
Juan C. Espinoza
Update RC models, views, templates & statics...
r45 def remove_subline(request, conf_id, line_id, subline_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 conf = get_object_or_404(RCConfiguration, pk=conf_id)
Juan C. Espinoza
Update RC models, views, templates & statics...
r45 line = get_object_or_404(RCLine, pk=line_id)
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 if request.method == 'POST':
if line:
params = json.loads(line.params)
params['params'].remove(params['params'][int(subline_id)-1])
Juan C. Espinoza
Updates to models, views & forms for CR...
r25 line.params = json.dumps(params)
Juan C. Espinoza
Update RC models, views, templates & statics...
r45 line.save()
return redirect('url_edit_rc_conf', conf.id)
Juan C. Espinoza
Add rc config mods...
r23
Juan C. Espinoza
Update RC models, views, templates & statics...
r45 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 kwargs['object'] = line
kwargs['object_name'] = line.line_type.name
kwargs['delete_view'] = True
kwargs['title'] = 'Confirm delete'
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 return render(request, 'confirm.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
Add rc config mods...
r23
Juan C. Espinoza
Update RC models, views, templates & statics...
r45 def update_lines_position(request, 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 conf = get_object_or_404(RCConfiguration, 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
Updates to models, views & forms for CR...
r25 if request.method=='POST':
ch = 0
Juan C. Espinoza
Update code for django 1.10, python 3 and latest third party packages, review operation view ...
r172 for item in request.POST['items'].split('&'):
Juan C. Espinoza
Updates to models, views & forms for CR...
r25 line = RCLine.objects.get(pk=item.split('=')[-1])
line.channel = ch
Juan C. Espinoza
Add rc config mods...
r23 line.save()
Juan C. Espinoza
Update code for django 1.10, python 3 and latest third party packages, review operation view ...
r172 ch += 1
Juan C. Espinoza
Updates to models, views & forms for CR...
r25 lines = RCLine.objects.filter(rc_configuration=conf).order_by('channel')
Juan C. Espinoza
Update code for django 1.10, python 3 and latest third party packages, review operation view ...
r172
Juan C. Espinoza
Updates to models, views & forms for CR...
r25 for line in lines:
Juan C. Espinoza
Update code for django 1.10, python 3 and latest third party packages, review operation view ...
r172 params = json.loads(line.params)
Juan C. Espinoza
- Update rc app...
r79 line.form = RCLineEditForm(conf=conf, line=line, extra_fields=params)
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 app...
r79 if 'params' in params:
line.subform = True
line.subforms = [RCLineEditForm(extra_fields=fields, line=line, subform=i) for i, fields in enumerate(params['params'])]
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 app...
r79 html = render(request, 'rc_lines.html', {'dev_conf':conf, 'rc_lines':lines, 'edit':True})
Juan C. Espinoza
Update code for django 1.10, python 3 and latest third party packages, review operation view ...
r172 data = {'html': html.content.decode('utf8')}
Juan C. Espinoza
Updates to models, views & forms for CR...
r25 return HttpResponse(json.dumps(data), content_type="application/json")
Juan C. Espinoza
Update RC models, views, templates & statics...
r45 return redirect('url_edit_rc_conf', conf.id)
Juan C. Espinoza
- Update rc app...
r79
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
Juan C. Espinoza
Update RC models, views, templates & statics...
r45 conf = get_object_or_404(RCConfiguration, pk=conf_id)
if request.method=='POST':
form = RCImportForm(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:
Juan C. Espinoza
sync repo...
r157 #if True:
Juan C. Espinoza
- Update rc app...
r79 conf.update_from_file(request.FILES['file_name'])
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:
Juan C. Espinoza
- Improve display name for Devices & Configurations...
r121 messages.error(request, 'Error parsing file: "%s" - %s' % (request.FILES['file_name'], e))
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 else:
messages.warning(request, 'Your current configuration will be replaced')
Juan C. Espinoza
Update code for django 1.10, python 3 and latest third party packages, review operation view ...
r172 form = RCImportForm()
Juan C. Espinoza
Update RC models, views, templates & statics...
r45 kwargs = {}
kwargs['form'] = form
kwargs['title'] = 'RC Configuration'
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
Juan C. Espinoza
Update RC models, views, templates & statics...
r45 return render(request, 'rc_import.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
Proyecto base en Django (refs #259) ...
r0
Juan C. Espinoza
Optimize pulses's plot and generation ...
r111 def plot_pulses(request, conf_id):
Juan C. Espinoza
Update code for django 1.10, python 3 and latest third party packages, review operation view ...
r172
conf = get_object_or_404(RCConfiguration, pk=conf_id)
Juan C. Espinoza
sync repo...
r157 km = True if 'km' in request.GET else False
Juan C. Espinoza
Update code for django 1.10, python 3 and latest third party packages, review operation view ...
r172
Juan C. Espinoza
sync repo...
r157 script, div = conf.plot_pulses(km=km)
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 app...
r79 kwargs = {}
Juan C. Espinoza
Improve RC pulses plot and Operation view...
r175 kwargs['no_sidebar'] = True
kwargs['title'] = 'RC Pulses'
kwargs['suptitle'] = conf.name
kwargs['div'] = mark_safe(div)
kwargs['script'] = mark_safe(script)
kwargs['units'] = conf.km2unit
kwargs['kms'] = 1/conf.km2unit
if km:
kwargs['km_selected'] = True
if 'json' in request.GET:
return HttpResponse(json.dumps({'div':mark_safe(div), 'script':mark_safe(script)}), content_type="application/json")
else:
return render(request, 'rc_pulses.html', kwargs)
def plot_pulses2(request, 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
Improve RC pulses plot and Operation view...
r175 conf = get_object_or_404(RCConfiguration, pk=conf_id)
km = True if 'km' in request.GET else False
script, div = conf.plot_pulses2(km=km)
kwargs = {}
kwargs['no_sidebar'] = True
Juan C. Espinoza
- Update rc app...
r79 kwargs['title'] = 'RC Pulses'
Juan C. Espinoza
Update code for django 1.10, python 3 and latest third party packages, review operation view ...
r172 kwargs['suptitle'] = conf.name
Juan C. Espinoza
- Update rc app...
r79 kwargs['div'] = mark_safe(div)
kwargs['script'] = mark_safe(script)
Juan C. Espinoza
- Add sequence mode in mix configurations....
r116 kwargs['units'] = conf.km2unit
kwargs['kms'] = 1/conf.km2unit
Juan C. Espinoza
Update code for django 1.10, python 3 and latest third party packages, review operation view ...
r172
Juan C. Espinoza
sync repo...
r157 if km:
kwargs['km_selected'] = True
Juan C. Espinoza
Update code for django 1.10, python 3 and latest third party packages, review operation view ...
r172
if 'json' in request.GET:
Juan C. Espinoza
Optimize pulses's plot and generation ...
r111 return HttpResponse(json.dumps({'div':mark_safe(div), 'script':mark_safe(script)}), content_type="application/json")
else:
return render(request, 'rc_pulses.html', kwargs)