@@ -54,7 +54,7 def cgs_conf(request, id_conf): | |||
|
54 | 54 | # messages.error(request, message=status) |
|
55 | 55 | |
|
56 | 56 | kwargs['dev_conf'] = conf |
|
57 |
kwargs['dev_conf_keys'] = [' |
|
|
57 | kwargs['dev_conf_keys'] = ['name', | |
|
58 | 58 | 'freq0', 'freq1', |
|
59 | 59 | 'freq2', 'freq3'] |
|
60 | 60 |
@@ -21,8 +21,6 def dds_conf(request, id_conf): | |||
|
21 | 21 | |
|
22 | 22 | kwargs['dev_conf'] = conf |
|
23 | 23 | kwargs['dev_conf_keys'] = ['name', |
|
24 | 'experiment', | |
|
25 | 'device', | |
|
26 | 24 | 'clock', |
|
27 | 25 | 'multiplier', |
|
28 | 26 | 'frequencyA_Mhz', |
@@ -22,7 +22,7 def jars_conf(request, id_conf): | |||
|
22 | 22 | |
|
23 | 23 | |
|
24 | 24 | kwargs['dev_conf'] = conf |
|
25 |
kwargs['dev_conf_keys'] = [' |
|
|
25 | kwargs['dev_conf_keys'] = ['name', | |
|
26 | 26 | 'cards_number', 'channels_number', 'channels', |
|
27 | 27 | 'rd_directory', 'raw_data_blocks', 'data_type', |
|
28 | 28 | 'acq_profiles', 'profiles_block', 'fftpoints', |
@@ -1,5 +1,5 | |||
|
1 | 1 | [ |
|
2 |
{"fields": {"name": " |
|
|
2 | {"fields": {"name": "JRO Imaging", "description": ""}, "model": "main.location", "pk": 1}, | |
|
3 | 3 | {"fields": {"name": "JASMET", "description": ""}, "model": "main.location", "pk": 2}, |
|
4 | 4 | {"fields": {"name": "SOUSY", "description": ""}, "model": "main.location", "pk": 3}, |
|
5 | 5 | {"fields": {"name": "JULIA", "description": ""}, "model": "main.location", "pk": 4}, |
@@ -32,6 +32,20 class DatepickerWidget(forms.widgets.TextInput): | |||
|
32 | 32 | html = '<div class="input-group date">'+input_html+'<span class="input-group-addon"><i class="glyphicon glyphicon-calendar"></i></span></div>' |
|
33 | 33 | return mark_safe(html) |
|
34 | 34 | |
|
35 | class DateRangepickerWidget(forms.widgets.TextInput): | |
|
36 | def render(self, name, value, attrs=None): | |
|
37 | start = attrs['start_date'] | |
|
38 | end = attrs['end_date'] | |
|
39 | html = '''<div class="col-md-5 input-group date" style="float:inherit"> | |
|
40 | <input class="form-control" id="id_start_date" name="start_date" placeholder="Start" title="" type="text" value="{}"> | |
|
41 | <span class="input-group-addon"><i class="glyphicon glyphicon-calendar"></i></span> | |
|
42 | </div> | |
|
43 | <div class="col-md-5 col-md-offset-2 input-group date" style="float:inherit"> | |
|
44 | <input class="form-control" id="id_end_date" name="end_date" placeholder="End" title="" type="text" value="{}"> | |
|
45 | <span class="input-group-addon"><i class="glyphicon glyphicon-calendar"></i></span> | |
|
46 | </div>'''.format(start, end) | |
|
47 | return mark_safe(html) | |
|
48 | ||
|
35 | 49 | class TimepickerWidget(forms.widgets.TextInput): |
|
36 | 50 | def render(self, name, value, attrs=None): |
|
37 | 51 | input_html = super(TimepickerWidget, self).render(name, value, attrs) |
@@ -132,6 +146,7 class OperationForm(forms.Form): | |||
|
132 | 146 | super(OperationForm, self).__init__(*args, **kwargs) |
|
133 | 147 | self.fields['campaign'].choices=Campaign.objects.all().order_by('-start_date').values_list('id', 'name')[:length] |
|
134 | 148 | |
|
149 | ||
|
135 | 150 | class OperationSearchForm(forms.Form): |
|
136 | 151 | # -----ALL Campaigns------ |
|
137 | 152 | campaign = forms.ChoiceField(label="Campaign") |
@@ -140,6 +155,7 class OperationSearchForm(forms.Form): | |||
|
140 | 155 | super(OperationSearchForm, self).__init__(*args, **kwargs) |
|
141 | 156 | self.fields['campaign'].choices=Campaign.objects.all().order_by('-start_date').values_list('id', 'name') |
|
142 | 157 | |
|
158 | ||
|
143 | 159 | class NewForm(forms.Form): |
|
144 | 160 | |
|
145 | 161 | create_from = forms.ChoiceField(choices=((0, '-----'), |
@@ -152,4 +168,23 class NewForm(forms.Form): | |||
|
152 | 168 | template_choices = kwargs.pop('template_choices', []) |
|
153 | 169 | super(NewForm, self).__init__(*args, **kwargs) |
|
154 | 170 | self.fields['choose_template'].choices = add_empty_choice(template_choices) |
|
171 | ||
|
172 | ||
|
173 | class FilterForm(forms.Form): | |
|
174 | ||
|
175 | def __init__(self, *args, **kwargs): | |
|
176 | extra_fields = kwargs.pop('extra_fields', []) | |
|
177 | super(FilterForm, self).__init__(*args, **kwargs) | |
|
178 | ||
|
179 | for field in extra_fields: | |
|
180 | if 'range_date' in field: | |
|
181 | self.fields[field] = forms.CharField(required=False) | |
|
182 | self.fields[field].widget = DateRangepickerWidget() | |
|
183 | if 'initial' in kwargs: | |
|
184 | self.fields[field].widget.attrs = {'start_date':kwargs['initial'].get('start_date', ''), | |
|
185 | 'end_date':kwargs['initial'].get('end_date', '')} | |
|
186 | elif 'template' in field: | |
|
187 | self.fields['template'] = forms.BooleanField(required=False) | |
|
188 | else: | |
|
189 | self.fields[field] = forms.CharField(required=False) | |
|
155 | 190 | No newline at end of file |
@@ -75,7 +75,7 class Location(models.Model): | |||
|
75 | 75 | return u'%s' % self.name |
|
76 | 76 | |
|
77 | 77 | def get_absolute_url(self): |
|
78 |
return reverse('url_ |
|
|
78 | return reverse('url_location', args=[str(self.id)]) | |
|
79 | 79 | |
|
80 | 80 | |
|
81 | 81 | class DeviceType(models.Model): |
@@ -143,10 +143,11 class Campaign(models.Model): | |||
|
143 | 143 | ordering = ('name',) |
|
144 | 144 | |
|
145 | 145 | def __unicode__(self): |
|
146 | return u'%s' % (self.name) | |
|
146 | if self.template: | |
|
147 | return u'{} (template)'.format(self.name) | |
|
148 | else: | |
|
149 | return u'{}'.format(self.name) | |
|
147 | 150 | |
|
148 | def get_absolute_url(self): | |
|
149 | return reverse('url_campaign', args=[str(self.id)]) | |
|
150 | 151 | |
|
151 | 152 | def parms_to_dict(self): |
|
152 | 153 | |
@@ -259,7 +260,7 class Experiment(models.Model): | |||
|
259 | 260 | return u'%s' % (self.name) |
|
260 | 261 | |
|
261 | 262 | @property |
|
262 | def radar(self): | |
|
263 | def radar_system(self): | |
|
263 | 264 | return self.location |
|
264 | 265 | |
|
265 | 266 | def clone(self, **kwargs): |
@@ -434,8 +435,8 class Configuration(PolymorphicModel): | |||
|
434 | 435 | |
|
435 | 436 | name = models.CharField(verbose_name="Configuration Name", max_length=40, default='') |
|
436 | 437 | |
|
437 | experiment = models.ForeignKey('Experiment', null=True, blank=True, on_delete=models.CASCADE) | |
|
438 | device = models.ForeignKey(Device, null=True, on_delete=models.CASCADE) | |
|
438 | experiment = models.ForeignKey('Experiment', verbose_name='Experiment', null=True, blank=True, on_delete=models.CASCADE) | |
|
439 | device = models.ForeignKey('Device', verbose_name='Device', null=True, on_delete=models.CASCADE) | |
|
439 | 440 | |
|
440 | 441 | type = models.PositiveSmallIntegerField(default=0, choices=CONF_TYPES) |
|
441 | 442 | |
@@ -450,8 +451,17 class Configuration(PolymorphicModel): | |||
|
450 | 451 | db_table = 'db_configurations' |
|
451 | 452 | |
|
452 | 453 | def __unicode__(self): |
|
453 | ||
|
454 |
|
|
|
454 | ||
|
455 | device = '{}:'.format(self.device.device_type.name.upper()) | |
|
456 | ||
|
457 | if 'mix' in self._meta.get_all_field_names(): | |
|
458 | if self.mix: | |
|
459 | device = '{} MIXED:'.format(self.device.device_type.name.upper()) | |
|
460 | ||
|
461 | if self.template: | |
|
462 | return u'{} {} (template)'.format(device, self.name) | |
|
463 | else: | |
|
464 | return u'{} {}'.format(device, self.name) | |
|
455 | 465 | |
|
456 | 466 | def clone(self, **kwargs): |
|
457 | 467 |
@@ -52,6 +52,7 | |||
|
52 | 52 | <li><a href="{% url 'url_add_experiment' %}">Experiment</a></li> |
|
53 | 53 | <li><a href="{% url 'url_add_dev_conf' 0%}">Device Configuration</a></li> |
|
54 | 54 | <li><a href="{% url 'url_add_device'%}">Device</a></li> |
|
55 | <li><a href="{% url 'url_add_location'%}">Radar System</a></li> | |
|
55 | 56 | </ul> |
|
56 | 57 | </li> |
|
57 | 58 | <li class=" dropdown {% block search-active %}{% endblock %}"> |
@@ -61,6 +62,7 | |||
|
61 | 62 | <li><a href="{% url 'url_experiments' %}">Experiments</a></li> |
|
62 | 63 | <li><a href="{% url 'url_dev_confs' %}">Configurations</a></li> |
|
63 | 64 | <li><a href="{% url 'url_devices' %}">Devices</a></li> |
|
65 | <li><a href="{% url 'url_locations' %}">Radar Systems</a></li> | |
|
64 | 66 | </ul> |
|
65 | 67 | </li> |
|
66 | 68 | </ul> |
@@ -2,45 +2,72 | |||
|
2 | 2 | {% load bootstrap3 %} |
|
3 | 3 | {% load static %} |
|
4 | 4 | {% load main_tags %} |
|
5 | ||
|
5 | 6 | {% block extra-head %} |
|
6 | 7 | <link href="{% static 'css/bootstrap-datetimepicker.min.css' %}" media="screen" rel="stylesheet"> |
|
7 | 8 | {% endblock %} |
|
8 | 9 | |
|
9 |
{% block |
|
|
10 | ||
|
10 | {% block search-active %}active{% endblock %} | |
|
11 | 11 | {% block content-title %}{{title}}{% endblock %} |
|
12 | 12 | {% block content-suptitle %}{{suptitle}}{% endblock %} |
|
13 | 13 | |
|
14 | 14 | {% block content %} |
|
15 | ||
|
16 | {% block content-filter %} | |
|
17 | {% if form %} | |
|
18 | <form class="form" method="get"> | |
|
19 | {% bootstrap_form form layout='horizontal' size='medium' %} | |
|
20 | <div class="pull-right"> | |
|
21 | <button type="button" class="btn btn-primary" onclick="window.location.replace('?');"><span class="glyphicon glyphicon-refresh" aria-hidden="true"></span></button> | |
|
22 | <button type="submit" class="btn btn-primary"><span class="glyphicon glyphicon-search" aria-hidden="true"></span></button> | |
|
23 | </div> | |
|
24 | </form> | |
|
25 | {% endif %} | |
|
26 | {% endblock %} | |
|
27 | <br><br> | |
|
15 | 28 | <table class="table table-hover"> |
|
16 | 29 | <tr> |
|
17 |
|
|
|
18 |
|
|
|
19 |
|
|
|
20 |
|
|
|
30 | <th>#</th> | |
|
31 | {% for key in keys %} | |
|
32 | <th>{{ key|title }}</th> | |
|
33 | {% endfor%} | |
|
21 | 34 | </tr> |
|
22 |
{% for |
|
|
23 |
|
|
|
24 |
|
|
|
25 |
|
|
|
26 |
|
|
|
27 |
|
|
|
28 |
|
|
|
35 | {% for object in objects %} | |
|
36 | <tr class="clickable-row" data-href="{{object.get_absolute_url}}"> | |
|
37 | <td>{{ forloop.counter|add:offset }}</td> | |
|
38 | {% for key in keys %} | |
|
39 | <td>{{ object|attr:key }}</td> | |
|
40 | {% endfor %} | |
|
41 | </tr> | |
|
29 | 42 | {% endfor %} |
|
30 | 43 | </table> |
|
31 | 44 | |
|
32 | {% endblock %} | |
|
45 | <div class="pagination"> | |
|
46 | <span class="step-links"> | |
|
47 | {% if objects.has_previous %} | |
|
48 | <a href="?page={{ objects.previous_page_number }}&{{q}}"><span class="glyphicon glyphicon-menu-left" aria-hidden="true"></span></a> | |
|
49 | {% endif %} | |
|
50 | <span class="current"> | |
|
51 | Page {{ objects.number }} of {{ objects.paginator.num_pages }}. | |
|
52 | </span> | |
|
53 | {% if objects.has_next %} | |
|
54 | <a href="?page={{ objects.next_page_number }}&{{q}}"><span class="glyphicon glyphicon-menu-right aria-hidden="true"></span></a> | |
|
55 | {% endif %} | |
|
56 | </span> | |
|
57 | </div> | |
|
33 | 58 | |
|
34 | {% block sidebar%} | |
|
35 | {% include "sidebar_devices.html" %} | |
|
36 | 59 | {% endblock %} |
|
37 | 60 | |
|
38 | 61 | {% block extra-js%} |
|
62 | <script src="{% static 'js/moment.min.js' %}"></script> | |
|
63 | <script src="{% static 'js/bootstrap-datetimepicker.min.js' %}"></script> | |
|
39 | 64 | <script type="text/javascript"> |
|
40 | ||
|
65 | ||
|
66 | $('.input-group.date').datetimepicker({"format": "YYYY-MM-DD"}); | |
|
67 | ||
|
41 | 68 | $(".clickable-row").click(function() { |
|
42 |
|
|
|
69 | document.location = $(this).data("href"); | |
|
43 | 70 | }); |
|
44 | 71 | |
|
45 | 72 | </script> |
|
46 | {% endblock %} No newline at end of file | |
|
73 | {% endblock %} |
@@ -33,7 +33,9 | |||
|
33 | 33 | <br> |
|
34 | 34 | |
|
35 | 35 | {% endif %} |
|
36 | ||
|
36 | <div class="clearfix"></div> | |
|
37 | <h2>Radar Systems</h2> | |
|
38 | <br> | |
|
37 | 39 | <div class="panel-group" id="accordion" role="tablist" aria-multiselectable="true" > |
|
38 | 40 | |
|
39 | 41 | {% for location in locations %} |
@@ -43,7 +45,7 | |||
|
43 | 45 | <h4 class="panel-title"> |
|
44 | 46 | |
|
45 | 47 | <a class="collapsed" role="button" data-toggle="collapse" href="#collapseTwo-{{ location.id }}" aria-expanded="false" aria-controls="collapseTwo"> |
|
46 |
{{location.name}}: Experiment |
|
|
48 | {{location.name}}: Experiments | |
|
47 | 49 | <span> |
|
48 | 50 | </span> |
|
49 | 51 | </a> |
@@ -6,6 +6,9 def attr(instance, key): | |||
|
6 | 6 | |
|
7 | 7 | display_key = "get_" + key + "_display" |
|
8 | 8 | |
|
9 | if key=='name': | |
|
10 | return '{}'.format(instance) | |
|
11 | ||
|
9 | 12 | if hasattr(instance, display_key): |
|
10 | 13 | return getattr(instance, display_key)() |
|
11 | 14 | |
@@ -35,5 +38,5 def get_verbose_field_name(instance, field_name): | |||
|
35 | 38 | Returns verbose_name for a field. |
|
36 | 39 | """ |
|
37 | 40 | if field_name=='ipp_unit': |
|
38 |
return 'I |
|
|
41 | return 'IPP [Km(Units)]' | |
|
39 | 42 | return mark_safe(instance._meta.get_field(field_name).verbose_name) No newline at end of file |
@@ -2,11 +2,14 from django.shortcuts import render, redirect, get_object_or_404, HttpResponse | |||
|
2 | 2 | from django.utils.safestring import mark_safe |
|
3 | 3 | from django.http import HttpResponseRedirect |
|
4 | 4 | from django.core.urlresolvers import reverse |
|
5 | from django.db.models import Q | |
|
6 | from django.core.paginator import Paginator, EmptyPage, PageNotAnInteger | |
|
5 | 7 | from django.contrib import messages |
|
6 | 8 | from datetime import datetime |
|
9 | import urllib | |
|
7 | 10 | |
|
8 | 11 | from .forms import CampaignForm, ExperimentForm, DeviceForm, ConfigurationForm, LocationForm, UploadFileForm, DownloadFileForm, OperationForm, NewForm |
|
9 | from .forms import OperationSearchForm | |
|
12 | from .forms import OperationSearchForm, FilterForm | |
|
10 | 13 | from apps.cgs.forms import CGSConfigurationForm |
|
11 | 14 | from apps.jars.forms import JARSConfigurationForm |
|
12 | 15 | from apps.usrp.forms import USRPConfigurationForm |
@@ -21,6 +24,7 from apps.usrp.models import USRPConfiguration | |||
|
21 | 24 | from apps.abs.models import ABSConfiguration |
|
22 | 25 | from apps.rc.models import RCConfiguration, RCLine, RCLineType |
|
23 | 26 | from apps.dds.models import DDSConfiguration |
|
27 | from django.http.request import QueryDict | |
|
24 | 28 | |
|
25 | 29 | # Create your views here. |
|
26 | 30 | |
@@ -63,18 +67,16 def index(request): | |||
|
63 | 67 | |
|
64 | 68 | def locations(request): |
|
65 | 69 | |
|
66 | locations = Location.objects.all().order_by('name') | |
|
67 | ||
|
68 | keys = ['id', 'name', 'description'] | |
|
70 | page = request.GET.get('page') | |
|
71 | order = ('name',) | |
|
72 | ||
|
73 | kwargs = get_paginator(Location, page, order) | |
|
69 | 74 | |
|
70 | kwargs = {} | |
|
71 | kwargs['location_keys'] = keys[1:] | |
|
72 | kwargs['locations'] = locations | |
|
73 | kwargs['title'] = 'Location' | |
|
75 | kwargs['keys'] = ['name', 'description'] | |
|
76 | kwargs['title'] = 'Radar System' | |
|
74 | 77 | kwargs['suptitle'] = 'List' |
|
75 | kwargs['button'] = 'New Location' | |
|
76 | 78 | |
|
77 |
return render(request, ' |
|
|
79 | return render(request, 'base_list.html', kwargs) | |
|
78 | 80 | |
|
79 | 81 | |
|
80 | 82 | def location(request, id_loc): |
@@ -105,11 +107,11 def location_new(request): | |||
|
105 | 107 | |
|
106 | 108 | kwargs = {} |
|
107 | 109 | kwargs['form'] = form |
|
108 |
kwargs['title'] = ' |
|
|
110 | kwargs['title'] = 'Radar System' | |
|
109 | 111 | kwargs['suptitle'] = 'New' |
|
110 | 112 | kwargs['button'] = 'Create' |
|
111 | 113 | |
|
112 |
return render(request, ' |
|
|
114 | return render(request, 'base_edit.html', kwargs) | |
|
113 | 115 | |
|
114 | 116 | |
|
115 | 117 | def location_edit(request, id_loc): |
@@ -132,7 +134,7 def location_edit(request, id_loc): | |||
|
132 | 134 | kwargs['suptitle'] = 'Edit' |
|
133 | 135 | kwargs['button'] = 'Update' |
|
134 | 136 | |
|
135 |
return render(request, ' |
|
|
137 | return render(request, 'base_edit.html', kwargs) | |
|
136 | 138 | |
|
137 | 139 | |
|
138 | 140 | def location_delete(request, id_loc): |
@@ -161,19 +163,15 def location_delete(request, id_loc): | |||
|
161 | 163 | |
|
162 | 164 | def devices(request): |
|
163 | 165 | |
|
164 | devices = Device.objects.all().order_by('device_type__name') | |
|
165 | ||
|
166 | # keys = ['id', 'device_type__name', 'name', 'ip_address'] | |
|
167 | keys = ['id', 'name', 'ip_address', 'port_address', 'device_type'] | |
|
168 | ||
|
169 | kwargs = {} | |
|
170 | kwargs['device_keys'] = keys[1:] | |
|
171 | kwargs['devices'] = devices#.values(*keys) | |
|
166 | page = request.GET.get('page') | |
|
167 | order = ('device_type', 'name') | |
|
168 | ||
|
169 | kwargs = get_paginator(Device, page, order) | |
|
170 | kwargs['keys'] = ['name', 'ip_address', 'port_address', 'device_type'] | |
|
172 | 171 | kwargs['title'] = 'Device' |
|
173 | 172 | kwargs['suptitle'] = 'List' |
|
174 | kwargs['button'] = 'New Device' | |
|
175 | 173 | |
|
176 |
return render(request, ' |
|
|
174 | return render(request, 'base_list.html', kwargs) | |
|
177 | 175 | |
|
178 | 176 | |
|
179 | 177 | def device(request, id_dev): |
@@ -208,7 +206,7 def device_new(request): | |||
|
208 | 206 | kwargs['suptitle'] = 'New' |
|
209 | 207 | kwargs['button'] = 'Create' |
|
210 | 208 | |
|
211 |
return render(request, ' |
|
|
209 | return render(request, 'base_edit.html', kwargs) | |
|
212 | 210 | |
|
213 | 211 | |
|
214 | 212 | def device_edit(request, id_dev): |
@@ -231,7 +229,7 def device_edit(request, id_dev): | |||
|
231 | 229 | kwargs['suptitle'] = 'Edit' |
|
232 | 230 | kwargs['button'] = 'Update' |
|
233 | 231 | |
|
234 |
return render(request, ' |
|
|
232 | return render(request, 'base_edit.html', kwargs) | |
|
235 | 233 | |
|
236 | 234 | |
|
237 | 235 | def device_delete(request, id_dev): |
@@ -260,18 +258,21 def device_delete(request, id_dev): | |||
|
260 | 258 | |
|
261 | 259 | def campaigns(request): |
|
262 | 260 | |
|
263 | campaigns = Campaign.objects.all().order_by('start_date') | |
|
264 | ||
|
265 | keys = ['id', 'name', 'start_date', 'end_date'] | |
|
261 | page = request.GET.get('page') | |
|
262 | order = ('start_date',) | |
|
263 | filters = request.GET.copy() | |
|
264 | ||
|
265 | kwargs = get_paginator(Campaign, page, order, filters) | |
|
266 | 266 | |
|
267 | kwargs = {} | |
|
268 | kwargs['campaign_keys'] = keys[1:] | |
|
269 | kwargs['campaigns'] = campaigns#.values(*keys) | |
|
267 | form = FilterForm(initial=request.GET, extra_fields=['range_date', 'tags','template']) | |
|
268 | kwargs['keys'] = ['name', 'start_date', 'end_date'] | |
|
270 | 269 | kwargs['title'] = 'Campaign' |
|
271 | 270 | kwargs['suptitle'] = 'List' |
|
272 | kwargs['button'] = 'New Campaign' | |
|
271 | kwargs['form'] = form | |
|
272 | filters.pop('page', None) | |
|
273 | kwargs['q'] = urllib.urlencode(filters) | |
|
273 | 274 | |
|
274 |
return render(request, ' |
|
|
275 | return render(request, 'base_list.html', kwargs) | |
|
275 | 276 | |
|
276 | 277 | |
|
277 | 278 | def campaign(request, id_camp): |
@@ -286,7 +287,7 def campaign(request, id_camp): | |||
|
286 | 287 | kwargs['campaign_keys'] = ['template', 'name', 'start_date', 'end_date', 'tags', 'description'] |
|
287 | 288 | |
|
288 | 289 | kwargs['experiments'] = experiments |
|
289 | kwargs['experiment_keys'] = ['name', 'radar', 'start_time', 'end_time'] | |
|
290 | kwargs['experiment_keys'] = ['name', 'radar_system', 'start_time', 'end_time'] | |
|
290 | 291 | |
|
291 | 292 | kwargs['title'] = 'Campaign' |
|
292 | 293 | kwargs['suptitle'] = 'Details' |
@@ -467,20 +468,22 def campaign_import(request, id_camp): | |||
|
467 | 468 | |
|
468 | 469 | def experiments(request): |
|
469 | 470 | |
|
470 | experiment_list = Experiment.objects.all() | |
|
471 | ||
|
472 | keys = ['id', 'name', 'start_time', 'end_time'] | |
|
473 | ||
|
474 | kwargs = {} | |
|
471 | page = request.GET.get('page') | |
|
472 | order = ('location',) | |
|
473 | filters = request.GET.copy() | |
|
474 | ||
|
475 | kwargs = get_paginator(Experiment, page, order, filters) | |
|
475 | 476 | |
|
476 | kwargs['experiment_keys'] = keys[1:] | |
|
477 | kwargs['experiments'] = experiment_list | |
|
477 | form = FilterForm(initial=request.GET, extra_fields=['tags','template']) | |
|
478 | 478 | |
|
479 | kwargs['keys'] = ['name', 'radar_system', 'start_time', 'end_time'] | |
|
479 | 480 | kwargs['title'] = 'Experiment' |
|
480 | 481 | kwargs['suptitle'] = 'List' |
|
481 |
kwargs[' |
|
|
482 | kwargs['form'] = form | |
|
483 | filters.pop('page', None) | |
|
484 | kwargs['q'] = urllib.urlencode(filters) | |
|
482 | 485 | |
|
483 |
return render(request, ' |
|
|
486 | return render(request, 'base_list.html', kwargs) | |
|
484 | 487 | |
|
485 | 488 | |
|
486 | 489 | def experiment(request, id_exp): |
@@ -491,7 +494,7 def experiment(request, id_exp): | |||
|
491 | 494 | |
|
492 | 495 | kwargs = {} |
|
493 | 496 | |
|
494 | kwargs['experiment_keys'] = ['template', 'radar', 'name', 'start_time', 'end_time'] | |
|
497 | kwargs['experiment_keys'] = ['template', 'radar_system', 'name', 'start_time', 'end_time'] | |
|
495 | 498 | kwargs['experiment'] = experiment |
|
496 | 499 | |
|
497 | 500 | kwargs['configuration_keys'] = ['name', 'device__ip_address', 'device__port_address', 'device__status'] |
@@ -532,7 +535,8 def experiment_new(request, id_camp=None): | |||
|
532 | 535 | form = NewForm() |
|
533 | 536 | |
|
534 | 537 | if request.method == 'POST': |
|
535 |
form = ExperimentForm(request.POST) |
|
|
538 | form = ExperimentForm(request.POST) | |
|
539 | print form.data | |
|
536 | 540 | if form.is_valid(): |
|
537 | 541 | experiment = form.save() |
|
538 | 542 | |
@@ -792,21 +796,26 def parse_mask(l): | |||
|
792 | 796 | values.reverse() |
|
793 | 797 | |
|
794 | 798 | return int(''.join([str(x) for x in values]), 2) |
|
795 | ||
|
799 | ||
|
796 | 800 | |
|
797 | 801 | def dev_confs(request): |
|
798 | 802 | |
|
799 | configurations = Configuration.objects.all().order_by('type', 'device__device_type', 'experiment') | |
|
800 | ||
|
801 | kwargs = {} | |
|
802 | 803 | |
|
803 | kwargs['configuration_keys'] = ['device', 'name', 'experiment', 'type', 'programmed_date'] | |
|
804 | kwargs['configurations'] = configurations | |
|
804 | page = request.GET.get('page') | |
|
805 | order = ('type', 'device__device_type', 'experiment') | |
|
806 | filters = request.GET.copy() | |
|
807 | ||
|
808 | kwargs = get_paginator(Configuration, page, order, filters) | |
|
805 | 809 | |
|
810 | form = FilterForm(initial=request.GET, extra_fields=['tags','template']) | |
|
811 | kwargs['keys'] = ['name', 'experiment', 'type', 'programmed_date'] | |
|
806 | 812 | kwargs['title'] = 'Configuration' |
|
807 | 813 | kwargs['suptitle'] = 'List' |
|
814 | kwargs['form'] = form | |
|
815 | filters.pop('page', None) | |
|
816 | kwargs['q'] = urllib.urlencode(filters) | |
|
808 | 817 | |
|
809 |
return render(request, ' |
|
|
818 | return render(request, 'base_list.html', kwargs) | |
|
810 | 819 | |
|
811 | 820 | |
|
812 | 821 | def dev_conf(request, id_conf): |
@@ -874,8 +883,7 def dev_conf_new(request, id_exp=0, id_dev=0): | |||
|
874 | 883 | if conf.device.device_type.name=='jars': |
|
875 | 884 | conf.add_parms_to_filter() |
|
876 | 885 | |
|
877 | return redirect('url_dev_conf', id_conf=conf.pk) | |
|
878 | ||
|
886 | return redirect('url_dev_conf', id_conf=conf.pk) | |
|
879 | 887 | |
|
880 | 888 | kwargs['id_exp'] = id_exp |
|
881 | 889 | kwargs['form'] = form |
@@ -1172,6 +1180,44 def sidebar(**kwargs): | |||
|
1172 | 1180 | |
|
1173 | 1181 | return side_data |
|
1174 | 1182 | |
|
1183 | def get_paginator(model, page, order, filters={}, n=10): | |
|
1184 | ||
|
1185 | kwargs = {} | |
|
1186 | query = Q() | |
|
1187 | if isinstance(filters, QueryDict): | |
|
1188 | filters = filters.dict() | |
|
1189 | [filters.pop(key) for key in filters.keys() if filters[key] in ('', ' ')] | |
|
1190 | filters.pop('page', None) | |
|
1191 | ||
|
1192 | if 'start_date' in filters: | |
|
1193 | filters['start_date__gte'] = filters.pop('start_date') | |
|
1194 | if 'end_date' in filters: | |
|
1195 | filters['start_date__lte'] = filters.pop('end_date') | |
|
1196 | if 'tags' in filters: | |
|
1197 | tags = filters.pop('tags') | |
|
1198 | if 'tags' in model._meta.get_all_field_names(): | |
|
1199 | query = query | Q(tags__icontains=tags) | |
|
1200 | if 'name' in model._meta.get_all_field_names(): | |
|
1201 | query = query | Q(name__icontains=tags) | |
|
1202 | if 'location' in model._meta.get_all_field_names(): | |
|
1203 | query = query | Q(location__name__icontains=tags) | |
|
1204 | if 'device' in model._meta.get_all_field_names(): | |
|
1205 | query = query | Q(device__name__icontains=tags) | |
|
1206 | ||
|
1207 | object_list = model.objects.filter(query, **filters).order_by(*order) | |
|
1208 | paginator = Paginator(object_list, n) | |
|
1209 | ||
|
1210 | try: | |
|
1211 | objects = paginator.page(page) | |
|
1212 | except PageNotAnInteger: | |
|
1213 | objects = paginator.page(1) | |
|
1214 | except EmptyPage: | |
|
1215 | objects = paginator.page(paginator.num_pages) | |
|
1216 | ||
|
1217 | kwargs['objects'] = objects | |
|
1218 | kwargs['offset'] = (int(page)-1)*n if page else 0 | |
|
1219 | ||
|
1220 | return kwargs | |
|
1175 | 1221 | |
|
1176 | 1222 | def operation(request, id_camp=None): |
|
1177 | 1223 |
@@ -57,8 +57,8 DAT_CMDS = { | |||
|
57 | 57 | |
|
58 | 58 | class RCConfiguration(Configuration): |
|
59 | 59 | |
|
60 |
ipp = models.FloatField(verbose_name='I |
|
|
61 |
ntx = models.PositiveIntegerField(verbose_name='Number of TX', validators=[MinValueValidator(1), MaxValueValidator( |
|
|
60 | ipp = models.FloatField(verbose_name='IPP [Km]', validators=[MinValueValidator(1), MaxValueValidator(9000)], default=300) | |
|
61 | ntx = models.PositiveIntegerField(verbose_name='Number of TX', validators=[MinValueValidator(1), MaxValueValidator(400)], default=1) | |
|
62 | 62 | clock_in = models.FloatField(verbose_name='Clock in [MHz]', validators=[MinValueValidator(1), MaxValueValidator(80)], default=1) |
|
63 | 63 | clock_divider = models.PositiveIntegerField(verbose_name='Clock divider', validators=[MinValueValidator(1), MaxValueValidator(256)], default=1) |
|
64 | 64 | clock = models.FloatField(verbose_name='Clock Master [MHz]', blank=True, default=1) |
@@ -74,14 +74,6 class RCConfiguration(Configuration): | |||
|
74 | 74 | class Meta: |
|
75 | 75 | db_table = 'rc_configurations' |
|
76 | 76 | |
|
77 | ||
|
78 | def __unicode__(self): | |
|
79 | ||
|
80 | if self.mix: | |
|
81 | return u'[RC MIXED]: {}'.format(self.name) | |
|
82 | else: | |
|
83 | return u'[RC]: {}'.format(self.name) | |
|
84 | ||
|
85 | 77 | def get_absolute_url_plot(self): |
|
86 | 78 | return reverse('url_plot_rc_pulses', args=[str(self.id)]) |
|
87 | 79 |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed |
General Comments 0
You need to be logged in to leave comments.
Login now