@@ -0,0 +1,55 | |||||
|
1 | {% extends "base.html" %} | |||
|
2 | {% load bootstrap3 %} | |||
|
3 | {% load static %} | |||
|
4 | {% load main_tags %} | |||
|
5 | ||||
|
6 | {% block search-active %}active{% endblock %} | |||
|
7 | ||||
|
8 | {% block content-title %}{{title}}{% endblock %} | |||
|
9 | {% block content-suptitle %}{{suptitle}}{% endblock %} | |||
|
10 | ||||
|
11 | {% block content %} | |||
|
12 | ||||
|
13 | {% block menu-actions %} | |||
|
14 | ||||
|
15 | {% endblock %} | |||
|
16 | ||||
|
17 | <table class="table table-bordered"> | |||
|
18 | ||||
|
19 | {% for key in dev_conf_keys %} | |||
|
20 | <tr> | |||
|
21 | <th>{% get_verbose_field_name dev_conf key %}</th> | |||
|
22 | <td>{{dev_conf|attr:key}}</td> | |||
|
23 | </tr> | |||
|
24 | {% endfor %} | |||
|
25 | </table> | |||
|
26 | {% if button %} | |||
|
27 | <div class="pull-right"> | |||
|
28 | <button type="button" class="btn btn-primary" id="back_button">{% if cancel %}{{cancel}}{% else %}Back{% endif %}</button> | |||
|
29 | <button type="button" id="edit_button" class="btn btn-primary">{{edit_button}}</button> | |||
|
30 | <button type="button" id="add_button" class="btn btn-primary">{{add_button}}</button> | |||
|
31 | </div> | |||
|
32 | {% endif %} | |||
|
33 | ||||
|
34 | {% block extra-content %} | |||
|
35 | {% endblock %} | |||
|
36 | ||||
|
37 | {% endblock %} | |||
|
38 | ||||
|
39 | {% block sidebar%} | |||
|
40 | {% include "sidebar_devices.html" %} | |||
|
41 | {% endblock %} | |||
|
42 | ||||
|
43 | {% block extra-js%} | |||
|
44 | <script type="text/javascript"> | |||
|
45 | ||||
|
46 | $("#edit_button").click(function() { | |||
|
47 | document.location = "{% url 'url_edit_jars_filter' conf.id filter.id%}"; | |||
|
48 | }); | |||
|
49 | ||||
|
50 | $("#back_button").click(function() { | |||
|
51 | document.location = "{% url 'url_edit_jars_conf' conf.id%}"; | |||
|
52 | }); | |||
|
53 | ||||
|
54 | </script> | |||
|
55 | {% endblock %} No newline at end of file |
@@ -0,0 +1,17 | |||||
|
1 | {% extends "dev_conf_edit.html" %} | |||
|
2 | {% load bootstrap3 %} | |||
|
3 | {% load static %} | |||
|
4 | {% load main_tags %} | |||
|
5 | ||||
|
6 | {% block content %} | |||
|
7 | <form class="form" method="post"> | |||
|
8 | {% csrf_token %} | |||
|
9 | {% bootstrap_form form layout='horizontal' size='medium' %} | |||
|
10 | <div style="clear: both;"></div> | |||
|
11 | <br> | |||
|
12 | <div class="pull-right"> | |||
|
13 | <button type="button" class="btn btn-primary" onclick="{% if previous %}window.location.replace('{{ previous }}');{% else %}history.go(-1);{% endif %}">Cancel</button> | |||
|
14 | <button type="submit" class="btn btn-primary">{{button}}</button> | |||
|
15 | </div> | |||
|
16 | </form> | |||
|
17 | {% endblock %} No newline at end of file |
@@ -1,6 +1,6 | |||||
1 | from django import forms |
|
1 | from django import forms | |
2 | from apps.main.models import Device, Experiment |
|
2 | from apps.main.models import Device, Experiment | |
3 | from .models import JARSConfiguration |
|
3 | from .models import JARSConfiguration, JARSfilter | |
4 | from .widgets import SpectralWidget |
|
4 | from .widgets import SpectralWidget | |
5 |
|
5 | |||
6 | class JARSConfigurationForm(forms.ModelForm): |
|
6 | class JARSConfigurationForm(forms.ModelForm): | |
@@ -28,4 +28,14 class JARSConfigurationForm(forms.ModelForm): | |||||
28 |
|
28 | |||
29 | class Meta: |
|
29 | class Meta: | |
30 | model = JARSConfiguration |
|
30 | model = JARSConfiguration | |
|
31 | exclude = ('type', 'parameters', 'status') | |||
|
32 | ||||
|
33 | ||||
|
34 | class JARSfilterForm(forms.ModelForm): | |||
|
35 | def __init__(self, *args, **kwargs): | |||
|
36 | super(JARSfilterForm, self).__init__(*args, **kwargs) | |||
|
37 | instance = getattr(self, 'instance', None) | |||
|
38 | ||||
|
39 | class Meta: | |||
|
40 | model = JARSfilter | |||
31 | exclude = ('type', 'parameters', 'status') No newline at end of file |
|
41 | exclude = ('type', 'parameters', 'status') |
@@ -51,7 +51,7 class JARSConfiguration(Configuration): | |||||
51 | profiles_block = models.PositiveIntegerField(verbose_name='Profiles Per Block', validators=[MaxValueValidator(5000)], default=400) |
|
51 | profiles_block = models.PositiveIntegerField(verbose_name='Profiles Per Block', validators=[MaxValueValidator(5000)], default=400) | |
52 | fftpoints = models.PositiveIntegerField(verbose_name='FFT Points',default=16) |
|
52 | fftpoints = models.PositiveIntegerField(verbose_name='FFT Points',default=16) | |
53 | incohe_integr = models.PositiveIntegerField(verbose_name='Incoherent Integrations',validators=[MinValueValidator(1)], default=30) |
|
53 | incohe_integr = models.PositiveIntegerField(verbose_name='Incoherent Integrations',validators=[MinValueValidator(1)], default=30) | |
54 |
filter = models.ForeignKey(JARSfilter, on_delete=models.CASCADE, null=True |
|
54 | filter = models.ForeignKey(JARSfilter, on_delete=models.CASCADE, null=True) | |
55 | spectral_number = models.PositiveIntegerField(verbose_name='# Spectral Combinations',validators=[MinValueValidator(1)], default=1) |
|
55 | spectral_number = models.PositiveIntegerField(verbose_name='# Spectral Combinations',validators=[MinValueValidator(1)], default=1) | |
56 | spectral = models.CharField(verbose_name='Combinations', max_length=5000, default = '[0, 0],') |
|
56 | spectral = models.CharField(verbose_name='Combinations', max_length=5000, default = '[0, 0],') | |
57 | create_directory = models.BooleanField(verbose_name='Create Directory Per Day', default=True) |
|
57 | create_directory = models.BooleanField(verbose_name='Create Directory Per Day', default=True) |
@@ -10,7 +10,7 | |||||
10 | <div style="clear: both;"></div> |
|
10 | <div style="clear: both;"></div> | |
11 | <br> |
|
11 | <br> | |
12 | <div class="pull-right"> |
|
12 | <div class="pull-right"> | |
13 |
<button type="button" class="btn btn-primary" id="bt_ |
|
13 | <button type="button" class="btn btn-primary" id="bt_view_filter">View Filter</button> | |
14 | <button type="button" class="btn btn-primary" onclick="{% if previous %}window.location.replace('{{ previous }}');{% else %}history.go(-1);{% endif %}">Cancel</button> |
|
14 | <button type="button" class="btn btn-primary" onclick="{% if previous %}window.location.replace('{{ previous }}');{% else %}history.go(-1);{% endif %}">Cancel</button> | |
15 | <button type="submit" class="btn btn-primary">{{button}}</button> |
|
15 | <button type="submit" class="btn btn-primary">{{button}}</button> | |
16 | </div> |
|
16 | </div> | |
@@ -19,4 +19,10 | |||||
19 |
|
19 | |||
20 | {% block extra-js%} |
|
20 | {% block extra-js%} | |
21 | <script src="{% static 'js/jars.js' %}"></script> |
|
21 | <script src="{% static 'js/jars.js' %}"></script> | |
|
22 | ||||
|
23 | <script type="text/javascript"> | |||
|
24 | $("#bt_view_filter").click(function() { | |||
|
25 | document.location = "{% url 'url_jars_filter' id_dev filter_id%}"; | |||
|
26 | }); | |||
|
27 | </script> | |||
22 | {% endblock %} No newline at end of file |
|
28 | {% endblock %} |
@@ -3,4 +3,6 from django.conf.urls import url | |||||
3 | urlpatterns = ( |
|
3 | urlpatterns = ( | |
4 | url(r'^(?P<id_conf>-?\d+)/$', 'apps.jars.views.jars_conf', name='url_jars_conf'), |
|
4 | url(r'^(?P<id_conf>-?\d+)/$', 'apps.jars.views.jars_conf', name='url_jars_conf'), | |
5 | url(r'^(?P<id_conf>-?\d+)/edit/$', 'apps.jars.views.jars_conf_edit', name='url_edit_jars_conf'), |
|
5 | url(r'^(?P<id_conf>-?\d+)/edit/$', 'apps.jars.views.jars_conf_edit', name='url_edit_jars_conf'), | |
|
6 | url(r'^(?P<conf_id>-?\d+)/view_filter/(?P<filter_id>-?\d+)/$', 'apps.jars.views.view_filter', name='url_jars_filter'), | |||
|
7 | url(r'^(?P<conf_id>-?\d+)/view_filter/(?P<filter_id>-?\d+)/edit$', 'apps.jars.views.edit_filter', name='url_edit_jars_filter'), | |||
6 | ) |
|
8 | ) |
@@ -1,12 +1,13 | |||||
1 | from django.shortcuts import render_to_response |
|
1 | from django.shortcuts import render_to_response | |
2 | from django.template import RequestContext |
|
2 | from django.template import RequestContext | |
3 | from django.shortcuts import redirect, render, get_object_or_404 |
|
3 | from django.shortcuts import redirect, render, get_object_or_404 | |
|
4 | from django.contrib import messages | |||
4 |
|
5 | |||
5 | from apps.main.models import Device |
|
6 | from apps.main.models import Device | |
6 | from apps.main.views import sidebar |
|
7 | from apps.main.views import sidebar | |
7 |
|
8 | |||
8 | from .models import JARSConfiguration |
|
9 | from .models import JARSConfiguration, JARSfilter | |
9 | from .forms import JARSConfigurationForm |
|
10 | from .forms import JARSConfigurationForm, JARSfilterForm | |
10 | # Create your views here. |
|
11 | # Create your views here. | |
11 |
|
12 | |||
12 | def jars_conf(request, id_conf): |
|
13 | def jars_conf(request, id_conf): | |
@@ -17,7 +18,6 def jars_conf(request, id_conf): | |||||
17 | port=conf.device.port_address |
|
18 | port=conf.device.port_address | |
18 |
|
19 | |||
19 | kwargs = {} |
|
20 | kwargs = {} | |
20 |
|
||||
21 | kwargs['status'] = conf.device.get_status_display() |
|
21 | kwargs['status'] = conf.device.get_status_display() | |
22 |
|
22 | |||
23 |
|
23 | |||
@@ -58,10 +58,62 def jars_conf_edit(request, id_conf): | |||||
58 | ##ERRORS |
|
58 | ##ERRORS | |
59 |
|
59 | |||
60 | kwargs = {} |
|
60 | kwargs = {} | |
|
61 | ||||
|
62 | kwargs['filter_id'] = conf.filter.id | |||
61 | kwargs['id_dev'] = conf.id |
|
63 | kwargs['id_dev'] = conf.id | |
62 | kwargs['form'] = form |
|
64 | kwargs['form'] = form | |
63 | kwargs['title'] = 'Device Configuration' |
|
65 | kwargs['title'] = 'Device Configuration' | |
64 | kwargs['suptitle'] = 'Edit' |
|
66 | kwargs['suptitle'] = 'Edit' | |
65 | kwargs['button'] = 'Save' |
|
67 | kwargs['button'] = 'Save' | |
66 |
|
68 | |||
67 | return render(request, 'jars_conf_edit.html', kwargs) No newline at end of file |
|
69 | return render(request, 'jars_conf_edit.html', kwargs) | |
|
70 | ||||
|
71 | def view_filter(request, conf_id, filter_id): | |||
|
72 | ||||
|
73 | conf = get_object_or_404(JARSConfiguration, pk=conf_id) | |||
|
74 | filter = get_object_or_404(JARSfilter, pk=filter_id) | |||
|
75 | ||||
|
76 | kwargs = {} | |||
|
77 | kwargs['conf'] = conf | |||
|
78 | kwargs['filter'] = filter | |||
|
79 | kwargs['dev_conf'] = filter | |||
|
80 | kwargs['dev_conf_keys'] = ['name', 'clock', | |||
|
81 | 'mult', 'fch', | |||
|
82 | 'filter_fir', 'filter_2', | |||
|
83 | 'filter_5', 'speed'] | |||
|
84 | ||||
|
85 | kwargs['title'] = 'Filter View' | |||
|
86 | kwargs['suptitle'] = 'Details' | |||
|
87 | kwargs['button'] = 'SI' | |||
|
88 | kwargs['edit_button'] = 'Edit Filter' | |||
|
89 | kwargs['add_button'] = 'Add Filter' | |||
|
90 | ||||
|
91 | return render(request, 'jars_filter.html', kwargs) | |||
|
92 | ||||
|
93 | def edit_filter(request, conf_id, filter_id): | |||
|
94 | ||||
|
95 | conf = get_object_or_404(JARSConfiguration, pk=conf_id) | |||
|
96 | ||||
|
97 | if filter_id: | |||
|
98 | filter = get_object_or_404(JARSfilter, pk=filter_id) | |||
|
99 | ||||
|
100 | if request.method=='GET': | |||
|
101 | form = JARSfilterForm(instance=filter) | |||
|
102 | ||||
|
103 | if request.method=='POST': | |||
|
104 | #form = JARSfilterForm(request.POST) | |||
|
105 | form = JARSfilterForm(request.POST, instance=filter) | |||
|
106 | if form.is_valid(): | |||
|
107 | form.save() | |||
|
108 | messages.success(request, 'JARS Filter successfully updated') | |||
|
109 | return redirect('url_jars_filter', conf.id, filter.id) | |||
|
110 | ||||
|
111 | kwargs = {} | |||
|
112 | kwargs['form'] = form | |||
|
113 | kwargs['title'] = conf.name | |||
|
114 | kwargs['suptitle'] = 'Edit Filter' | |||
|
115 | kwargs['button'] = 'Save' | |||
|
116 | # kwargs['previous'] = conf.get_absolute_url_edit() | |||
|
117 | kwargs['dev_conf'] = conf | |||
|
118 | ||||
|
119 | return render(request, 'jars_filter_edit.html', kwargs) No newline at end of file |
General Comments 0
You need to be logged in to leave comments.
Login now