@@ -1,26 +1,26 | |||||
1 | from django.db import models |
|
1 | from django.db import models | |
2 | from apps.main.models import Configuration |
|
2 | from apps.main.models import Configuration | |
3 | #from json_field import JSONField |
|
3 | #from json_field import JSONField | |
4 | from django.core.validators import MinValueValidator, MaxValueValidator |
|
4 | from django.core.validators import MinValueValidator, MaxValueValidator | |
5 |
|
5 | |||
6 |
|
6 | |||
7 | from apps.main.models import Device, Experiment |
|
7 | from apps.main.models import Device, Experiment | |
8 |
|
8 | |||
9 | # Create your models here. |
|
9 | # Create your models here. | |
10 |
|
10 | |||
11 | class CGSConfiguration(Configuration): |
|
11 | class CGSConfiguration(Configuration): | |
12 |
|
12 | |||
13 | #device = models.ForeignKey(Device) |
|
13 | #device = models.ForeignKey(Device) | |
14 | #exp = models.ForeignKey(Experiment, default = None) |
|
14 | #exp = models.ForeignKey(Experiment, default = None) | |
15 | freq0 = models.FloatField(verbose_name='Frequency 0',validators=[MinValueValidator(62.5e6), MaxValueValidator(450e6)]) |
|
15 | freq0 = models.FloatField(verbose_name='Frequency 0',validators=[MinValueValidator(62.5e6), MaxValueValidator(450e6)], blank=True, null=True) | |
16 | freq1 = models.FloatField(verbose_name='Frequency 1',validators=[MinValueValidator(62.5e6), MaxValueValidator(450e6)]) |
|
16 | freq1 = models.FloatField(verbose_name='Frequency 1',validators=[MinValueValidator(62.5e6), MaxValueValidator(450e6)], blank=True, null=True) | |
17 | freq2 = models.FloatField(verbose_name='Frequency 2',validators=[MinValueValidator(62.5e6), MaxValueValidator(450e6)]) |
|
17 | freq2 = models.FloatField(verbose_name='Frequency 2',validators=[MinValueValidator(62.5e6), MaxValueValidator(450e6)], blank=True, null=True) | |
18 |
freq3 = models. |
|
18 | freq3 = models.FloatField(verbose_name='Frequency 3',validators=[MinValueValidator(62.5e6), MaxValueValidator(450e6)], blank=True, null=True) | |
19 | #jfreqs = JSONField(default={"frequencies":[{"f0":freq0,"f1":freq1,"f2":freq2,"f3":freq3}]}, blank=True) |
|
19 | #jfreqs = JSONField(default={"frequencies":[{"f0":freq0,"f1":freq1,"f2":freq2,"f3":freq3}]}, blank=True) | |
20 | #clk_in = models.PositiveIntegerField(default=10e6) |
|
20 | #clk_in = models.PositiveIntegerField(default=10e6) | |
21 | #mult = models.PositiveIntegerField(default=40) |
|
21 | #mult = models.PositiveIntegerField(default=40) | |
22 | #div = models.PositiveIntegerField(default=1) |
|
22 | #div = models.PositiveIntegerField(default=1) | |
23 |
|
23 | |||
24 |
|
24 | |||
25 | class Meta: |
|
25 | class Meta: | |
26 | db_table = 'cgs_configurations' |
|
26 | db_table = 'cgs_configurations' |
@@ -1,22 +1,48 | |||||
1 | {% extends "base.html" %} |
|
1 | {% extends "base.html" %} | |
2 | {% load bootstrap3 %} |
|
2 | {% load bootstrap3 %} | |
3 | {% block mainactive %}active{% endblock %} |
|
3 | {% block mainactive %}active{% endblock %} | |
4 |
|
4 | |||
5 | {% block content-title %}DEVICE CGS{% endblock %} |
|
5 | {% block content-title %}DEVICE CGS{% endblock %} | |
6 | {% block content-suptitle %}CLOCK GENERATOR AND SYNCHRONIZER{% endblock %} |
|
6 | {% block content-suptitle %}CLOCK GENERATOR AND SYNCHRONIZER{% endblock %} | |
7 |
|
7 | |||
8 | {% block content %} |
|
8 | {% block content %} | |
9 | <p class="text-justify"> |
|
9 | <p class="text-justify"> | |
10 | Ingresar Frecuencias |
|
10 | Ingresar Frecuencias | |
11 | </p> |
|
11 | </p> | |
|
12 | ||||
|
13 | ||||
|
14 | ||||
|
15 | <!-- Agregado 30-11-2015 --> | |||
|
16 | {% if form.is_multipart %} | |||
|
17 | ||||
|
18 | <script type="text/javascript"> | |||
|
19 | ||||
|
20 | </script> | |||
|
21 | ||||
|
22 | <form id="{{ idform }}" enctype="multipart/form-data" method="{{ submit_method|default:'post' }}" action="" class="form"> | |||
|
23 | {% else %} | |||
|
24 | <form method="{{ submit_method|default:'post' }}" action="" class="form"> | |||
|
25 | {% endif %} | |||
|
26 | ||||
|
27 | {% if step_field %} | |||
|
28 | <input type="hidden" name="{{ step_field }}" value="{{ step0 }}" /> | |||
|
29 | {% endif %} | |||
|
30 | ||||
|
31 | {% if submit_method != 'GET' and submit_method != 'get' %} | |||
|
32 | {% csrf_token %} | |||
|
33 | {% endif %} | |||
|
34 | <!-- Agregado 30-11-2015 --> | |||
|
35 | ||||
|
36 | ||||
|
37 | ||||
12 | <div class='col-md-8'> |
|
38 | <div class='col-md-8'> | |
13 | {% bootstrap_form form size='medium' %} |
|
39 | {% bootstrap_form form size='medium' %} | |
14 | <button type="submit" class="btn btn-primary pull-right">Submit</button> |
|
40 | <button type="submit" class="btn btn-primary pull-right">Submit</button> | |
15 | </div> |
|
41 | </div> | |
16 | {% endblock %} |
|
42 | {% endblock %} | |
17 |
|
43 | |||
18 | {% block sidebar%} |
|
44 | {% block sidebar%} | |
19 |
|
45 | |||
20 | {% endblock %} |
|
46 | {% endblock %} | |
21 |
|
47 | |||
22 |
|
48 |
@@ -1,33 +1,48 | |||||
1 | from django.shortcuts import render, render_to_response |
|
1 | from django.shortcuts import render, render_to_response | |
2 | from django.template import RequestContext |
|
2 | from django.template import RequestContext | |
3 |
|
3 | |||
4 | from .forms import CGSConfigurationForm |
|
4 | from .forms import CGSConfigurationForm | |
5 | from .models import CGSConfiguration |
|
5 | from .models import CGSConfiguration | |
6 | from apps.main.models import Device |
|
6 | from apps.main.models import Device | |
7 | # Create your views here. |
|
7 | # Create your views here. | |
8 |
|
8 | |||
9 | def configurate_frequencies(request, id=0): |
|
9 | def configurate_frequencies(request, id=0): | |
10 | kwargs = {} |
|
10 | kwargs = {} | |
11 | if id: |
|
11 | if id: | |
12 | conf = CGSConfiguration.objects.get(pk=id) |
|
12 | conf = CGSConfiguration.objects.get(pk=id) | |
13 | devices = Device.objects.filter(configuration__experiment=conf.experiment) |
|
13 | devices = Device.objects.filter(configuration__experiment=conf.experiment) | |
14 | devices = devices.values('configuration__id', 'device_type__alias', 'device_type__name') |
|
14 | devices = devices.values('configuration__id', 'device_type__alias', 'device_type__name') | |
15 | for device in devices: |
|
15 | for device in devices: | |
16 | if device['device_type__alias']=='cgs': |
|
16 | if device['device_type__alias']=='cgs': | |
17 | device['active'] = 'active' |
|
17 | device['active'] = 'active' | |
18 | form = CGSConfigurationForm(instance=conf) |
|
18 | form = CGSConfigurationForm(instance=conf) | |
19 | else: |
|
19 | else: | |
20 | form = CGSConfigurationForm() |
|
20 | form = CGSConfigurationForm() | |
21 |
|
21 | |||
22 | data = { |
|
22 | data = { | |
23 | 'form': form, |
|
23 | 'form': form, | |
24 | 'devices':devices, |
|
24 | 'devices':devices, | |
25 | 'title': ('YAP'), |
|
25 | 'title': ('YAP'), | |
26 | } |
|
26 | } | |
|
27 | ||||
|
28 | if request.method == 'POST': | |||
|
29 | form = CGSConfigurationForm(request.POST) #, initial={'purchase_request':purchase_request}) | |||
|
30 | if form.is_valid(): | |||
|
31 | instance = form.save(commit=False) | |||
|
32 | #if 'quote' in request.FILES: | |||
|
33 | # instance.quoe = request.FILES['quote'] | |||
|
34 | instance.save() | |||
|
35 | form.save_m2m() | |||
|
36 | msg = _(u'The frequencies have been activated successfully.') | |||
|
37 | messages.success(request, msg, fail_silently=True) | |||
|
38 | #return redirect(purchase_request.get_absolute_url()) | |||
|
39 | else: | |||
|
40 | form = CGSConfigurationForm() | |||
|
41 | ||||
27 |
|
42 | |||
28 | return render_to_response('index_cgs.html', data, context_instance=RequestContext(request)) |
|
43 | return render_to_response('index_cgs.html', data, context_instance=RequestContext(request)) | |
29 | #return render_to_response("index.html", kwargs, context_instance=RequestContext(request)) |
|
44 | #return render_to_response("index.html", kwargs, context_instance=RequestContext(request)) | |
30 | #return_to_response('index.html', {'title': 'Configura','form': form}, context_instance=RequestContext(request)) |
|
45 | #return_to_response('index.html', {'title': 'Configura','form': form}, context_instance=RequestContext(request)) | |
31 |
|
46 | |||
32 |
|
47 | |||
33 |
|
48 |
General Comments 0
You need to be logged in to leave comments.
Login now