##// END OF EJS Templates
Views: Display "Page not found (404)" in case there is no object with the given pk....
Views: Display "Page not found (404)" in case there is no object with the given pk. git-svn-id: http://jro-dev.igp.gob.pe/svn/jro_hard/radarsys/trunk/webapp@34 aa17d016-51d5-4e8b-934c-7b2bbb1bbe71

File last commit:

r14:5d617c8cd56b
r20:391e0c460449
Show More
views.py
51 lines | 1.6 KiB | text/x-python | PythonLexer
Fiorella Quino
CGS model, form, view, url and html have been added....
r4 from django.shortcuts import render, render_to_response
from django.template import RequestContext
from .forms import CGSConfigurationForm
Juan C. Espinoza
Updating base models and views ...
r6 from .models import CGSConfiguration
from apps.main.models import Device
Juan C. Espinoza
Proyecto base en Django (refs #259) ...
r0 # Create your views here.
Fiorella Quino
CGS model, form, view, url and html have been added....
r4
Juan C. Espinoza
Updating base models and views ...
r6 def configurate_frequencies(request, id=0):
Miguel Urco
Campaign has been added to RadarSys Model...
r13
Juan C. Espinoza
Updating base models and views ...
r6 if id:
conf = CGSConfiguration.objects.get(pk=id)
devices = Device.objects.filter(configuration__experiment=conf.experiment)
Miguel Urco
Campaign has been added to RadarSys Model...
r13 devices = devices.values('configuration__id', 'device_type__name')
Juan C. Espinoza
Updating base models and views ...
r6 for device in devices:
Miguel Urco
Campaign has been added to RadarSys Model...
r13 if device['device_type__name']=='cgs':
Juan C. Espinoza
Updating base models and views ...
r6 device['active'] = 'active'
Miguel Urco
CGS view updated...
r11 break
device = device
Juan C. Espinoza
Updating base models and views ...
r6 form = CGSConfigurationForm(instance=conf)
else:
form = CGSConfigurationForm()
Fiorella Quino
CGS model, form, view, url and html have been added....
r4
data = {
'form': form,
Miguel Urco
CGS view updated...
r11 'device': device,
Juan C. Espinoza
Updating base models and views ...
r6 'devices':devices,
Fiorella Quino
CGS model, form, view, url and html have been added....
r4 'title': ('YAP'),
}
Fiorella Quino
SIR Task #95 Modelo CGS: ...
r8
Miguel Urco
Campaign has been added to RadarSys Model...
r13 data['dev_conf'] = conf
data['dev_conf_keys'] = ['experiment', 'device']
Fiorella Quino
SIR Task #95 Modelo CGS: ...
r8 if request.method == 'POST':
form = CGSConfigurationForm(request.POST) #, initial={'purchase_request':purchase_request})
if form.is_valid():
instance = form.save(commit=False)
#if 'quote' in request.FILES:
# instance.quoe = request.FILES['quote']
instance.save()
form.save_m2m()
msg = _(u'The frequencies have been activated successfully.')
messages.success(request, msg, fail_silently=True)
#return redirect(purchase_request.get_absolute_url())
else:
form = CGSConfigurationForm()
Miguel Urco
Campaign has been added to RadarSys Model...
r13 return render(request, 'cgs_conf.html', data)
Fiorella Quino
CGS model, form, view, url and html have been added....
r4