@@ -1,26 +1,26 | |||
|
1 | 1 | from django.db import models |
|
2 | 2 | from apps.main.models import Configuration |
|
3 | 3 | #from json_field import JSONField |
|
4 | 4 | from django.core.validators import MinValueValidator, MaxValueValidator |
|
5 | 5 | |
|
6 | 6 | |
|
7 | 7 | from apps.main.models import Device, Experiment |
|
8 | 8 | |
|
9 | 9 | # Create your models here. |
|
10 | 10 | |
|
11 | 11 | class CGSConfiguration(Configuration): |
|
12 | 12 | |
|
13 | 13 | #device = models.ForeignKey(Device) |
|
14 | 14 | #exp = models.ForeignKey(Experiment, default = None) |
|
15 | freq0 = models.FloatField(verbose_name='Frequency 0',validators=[MinValueValidator(62.5e6), MaxValueValidator(450e6)]) | |
|
16 | freq1 = models.FloatField(verbose_name='Frequency 1',validators=[MinValueValidator(62.5e6), MaxValueValidator(450e6)]) | |
|
17 | freq2 = models.FloatField(verbose_name='Frequency 2',validators=[MinValueValidator(62.5e6), MaxValueValidator(450e6)]) | |
|
18 |
freq3 = models. |
|
|
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)], blank=True, null=True) | |
|
17 | freq2 = models.FloatField(verbose_name='Frequency 2',validators=[MinValueValidator(62.5e6), MaxValueValidator(450e6)], blank=True, null=True) | |
|
18 | freq3 = models.FloatField(verbose_name='Frequency 3',validators=[MinValueValidator(62.5e6), MaxValueValidator(450e6)], blank=True, null=True) | |
|
19 | 19 | #jfreqs = JSONField(default={"frequencies":[{"f0":freq0,"f1":freq1,"f2":freq2,"f3":freq3}]}, blank=True) |
|
20 | 20 | #clk_in = models.PositiveIntegerField(default=10e6) |
|
21 | 21 | #mult = models.PositiveIntegerField(default=40) |
|
22 | 22 | #div = models.PositiveIntegerField(default=1) |
|
23 | 23 | |
|
24 | 24 | |
|
25 | 25 | class Meta: |
|
26 | 26 | db_table = 'cgs_configurations' |
@@ -1,22 +1,48 | |||
|
1 | 1 | {% extends "base.html" %} |
|
2 | 2 | {% load bootstrap3 %} |
|
3 | 3 | {% block mainactive %}active{% endblock %} |
|
4 | 4 | |
|
5 | 5 | {% block content-title %}DEVICE CGS{% endblock %} |
|
6 | 6 | {% block content-suptitle %}CLOCK GENERATOR AND SYNCHRONIZER{% endblock %} |
|
7 | 7 | |
|
8 | 8 | {% block content %} |
|
9 | 9 | <p class="text-justify"> |
|
10 | 10 | Ingresar Frecuencias |
|
11 | 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 | 38 | <div class='col-md-8'> |
|
13 | 39 | {% bootstrap_form form size='medium' %} |
|
14 | 40 | <button type="submit" class="btn btn-primary pull-right">Submit</button> |
|
15 | 41 | </div> |
|
16 | 42 | {% endblock %} |
|
17 | 43 | |
|
18 | 44 | {% block sidebar%} |
|
19 | 45 | |
|
20 | 46 | {% endblock %} |
|
21 | 47 | |
|
22 | 48 |
@@ -1,33 +1,48 | |||
|
1 | 1 | from django.shortcuts import render, render_to_response |
|
2 | 2 | from django.template import RequestContext |
|
3 | 3 | |
|
4 | 4 | from .forms import CGSConfigurationForm |
|
5 | 5 | from .models import CGSConfiguration |
|
6 | 6 | from apps.main.models import Device |
|
7 | 7 | # Create your views here. |
|
8 | 8 | |
|
9 | 9 | def configurate_frequencies(request, id=0): |
|
10 | 10 | kwargs = {} |
|
11 | 11 | if id: |
|
12 | 12 | conf = CGSConfiguration.objects.get(pk=id) |
|
13 | 13 | devices = Device.objects.filter(configuration__experiment=conf.experiment) |
|
14 | 14 | devices = devices.values('configuration__id', 'device_type__alias', 'device_type__name') |
|
15 | 15 | for device in devices: |
|
16 | 16 | if device['device_type__alias']=='cgs': |
|
17 | 17 | device['active'] = 'active' |
|
18 | 18 | form = CGSConfigurationForm(instance=conf) |
|
19 | 19 | else: |
|
20 | 20 | form = CGSConfigurationForm() |
|
21 | 21 | |
|
22 | 22 | data = { |
|
23 | 23 | 'form': form, |
|
24 | 24 | 'devices':devices, |
|
25 | 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 | 43 | return render_to_response('index_cgs.html', data, context_instance=RequestContext(request)) |
|
29 | 44 | #return render_to_response("index.html", kwargs, context_instance=RequestContext(request)) |
|
30 | 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