@@ -0,0 +1,21 | |||||
|
1 | from django import forms | |||
|
2 | from .models import CGSConfiguration | |||
|
3 | ||||
|
4 | class CGSConfigurationForm(forms.ModelForm): | |||
|
5 | #freq0.widget = te | |||
|
6 | def __init__(self, *args, **kwargs): | |||
|
7 | #request = kwargs.pop('request') | |||
|
8 | super(CGSConfigurationForm, self).__init__(*args, **kwargs) | |||
|
9 | ||||
|
10 | def clean(self): | |||
|
11 | # Custom validation to force an integer when type of unit = "Unit" | |||
|
12 | form_data = self.cleaned_data | |||
|
13 | if (form_data['freq0'] or form_data['freq1'] or form_data['freq2'] or form_data['freq3'] < 0): | |||
|
14 | raise forms.ValidationError("Please introduce positive Number") | |||
|
15 | ||||
|
16 | return form_data | |||
|
17 | ||||
|
18 | class Meta: | |||
|
19 | model = CGSConfiguration | |||
|
20 | #exclude = ('freqs', 'clk_in', 'mult','div',) | |||
|
21 | exclude = ('freqs',) |
@@ -0,0 +1,22 | |||||
|
1 | {% extends "base.html" %} | |||
|
2 | {% load bootstrap3 %} | |||
|
3 | {% block mainactive %}active{% endblock %} | |||
|
4 | ||||
|
5 | {% block content-title %}DEVICE CGS{% endblock %} | |||
|
6 | {% block content-suptitle %}CLOCK GENERATOR AND SYNCHRONIZER{% endblock %} | |||
|
7 | ||||
|
8 | {% block content %} | |||
|
9 | <p class="text-justify"> | |||
|
10 | Ingresar Frecuencias | |||
|
11 | </p> | |||
|
12 | <div class='col-md-8'> | |||
|
13 | {% bootstrap_form form size='medium' %} | |||
|
14 | <button type="submit" class="btn btn-primary pull-right">Submit</button> | |||
|
15 | </div> | |||
|
16 | {% endblock %} | |||
|
17 | ||||
|
18 | {% block sidebar%} | |||
|
19 | ||||
|
20 | {% endblock %} | |||
|
21 | ||||
|
22 |
@@ -1,3 +1,23 | |||||
1 | from django.db import models |
|
1 | from django.db import models | |
2 |
|
2 | |||
|
3 | from json_field import JSONField | |||
|
4 | from django.core.validators import MinValueValidator, MaxValueValidator | |||
|
5 | ||||
|
6 | ||||
|
7 | from apps.main.models import Device, Experiment | |||
|
8 | ||||
3 | # Create your models here. |
|
9 | # Create your models here. | |
|
10 | class CGSConfiguration(models.Model): | |||
|
11 | ||||
|
12 | device = models.ForeignKey(Device) | |||
|
13 | exp = models.ForeignKey(Experiment, default = None) | |||
|
14 | freq0 = models.FloatField(verbose_name='Frequency 0',validators=[MinValueValidator(62.5e6), MaxValueValidator(450e6)]) | |||
|
15 | freq1 = models.FloatField(verbose_name='Frequency 1',validators=[MinValueValidator(62.5e6), MaxValueValidator(450e6)]) | |||
|
16 | freq2 = models.FloatField(verbose_name='Frequency 2',validators=[MinValueValidator(62.5e6), MaxValueValidator(450e6)]) | |||
|
17 | freq3 = models.PositiveIntegerField(verbose_name='Frequency 3',validators=[MinValueValidator(62.5e6), MaxValueValidator(450e6)]) | |||
|
18 | freqs = JSONField(default={"frequencies":[{"f0":freq0,"f1":freq1,"f2":freq2,"f3":freq3}]}, blank=True) | |||
|
19 | #clk_in = models.PositiveIntegerField(default=10e6) | |||
|
20 | #mult = models.PositiveIntegerField(default=40) | |||
|
21 | #div = models.PositiveIntegerField(default=1) | |||
|
22 | ||||
|
23 |
@@ -1,5 +1,14 | |||||
1 | from django.conf.urls import patterns, url |
|
1 | from django.conf.urls import patterns, url | |
2 |
|
2 | |||
3 | urlpatterns = patterns('apps.cgs.views', |
|
3 | from . import views | |
4 |
|
4 | |||
|
5 | #urlpatterns = patterns('apps.cgs.views', | |||
|
6 | # url(r'^$', views.index, name='index') | |||
|
7 | #) | |||
|
8 | ||||
|
9 | urlpatterns = ( | |||
|
10 | url(r'^configuration/$', 'apps.cgs.views.configurate_frequencies', name='new_device'), | |||
5 | ) |
|
11 | ) | |
|
12 | ||||
|
13 | #url(r'^new/experiment/$', 'apps.main.views.new_experiment', name='new_experiment') | |||
|
14 |
@@ -1,3 +1,22 | |||||
1 | from django.shortcuts import render |
|
1 | from django.shortcuts import render, render_to_response | |
|
2 | from django.template import RequestContext | |||
|
3 | ||||
|
4 | from .forms import CGSConfigurationForm | |||
2 |
|
5 | |||
3 | # Create your views here. |
|
6 | # Create your views here. | |
|
7 | ||||
|
8 | def configurate_frequencies(request): | |||
|
9 | kwargs = {} | |||
|
10 | form = CGSConfigurationForm() | |||
|
11 | ||||
|
12 | data = { | |||
|
13 | 'form': form, | |||
|
14 | 'title': ('YAP'), | |||
|
15 | } | |||
|
16 | ||||
|
17 | return render_to_response('index_cgs.html', data, context_instance=RequestContext(request)) | |||
|
18 | #return render_to_response("index.html", kwargs, context_instance=RequestContext(request)) | |||
|
19 | #return_to_response('index.html', {'title': 'Configura','form': form}, context_instance=RequestContext(request)) | |||
|
20 | ||||
|
21 | ||||
|
22 |
General Comments 0
You need to be logged in to leave comments.
Login now