@@ -3,10 +3,7 | |||
|
3 | 3 | WSGIScriptAlias / /usr/local/radarsys/radarsys/wsgi.py |
|
4 | 4 | WSGIPythonPath /usr/local/radarsys/:/usr/local/virtuals/radarsys/lib/python2.7/site-packages |
|
5 | 5 | |
|
6 |
Alias /static/ / |
|
|
7 | <Directory /usr/local/radarsys/apps/main/static> | |
|
8 | Require all granted | |
|
9 | </Directory> | |
|
6 | Alias /static/ /var/www/html/static/ | |
|
10 | 7 | |
|
11 | 8 | <Directory /usr/local/radarsys/> |
|
12 | 9 | <Files wsgi.py> |
@@ -15,5 +12,3 Alias /static/ /usr/local/radarsys/apps/main/static/ | |||
|
15 | 12 | #Allow from all |
|
16 | 13 | </Files> |
|
17 | 14 | </Directory> |
|
No newline at end of file | ||
|
18 | ||
|
19 |
@@ -3,7 +3,7 from apps.main.models import Device | |||
|
3 | 3 | from .models import CGSConfiguration |
|
4 | 4 | |
|
5 | 5 | class CGSConfigurationForm(forms.ModelForm): |
|
6 | #freq0.widget = te | |
|
6 | ||
|
7 | 7 | def __init__(self, *args, **kwargs): |
|
8 | 8 | #request = kwargs.pop('request') |
|
9 | 9 | super(CGSConfigurationForm, self).__init__(*args, **kwargs) |
@@ -13,10 +13,11 class CGSConfigurationForm(forms.ModelForm): | |||
|
13 | 13 | if instance and instance.pk: |
|
14 | 14 | |
|
15 | 15 | devices = Device.objects.filter(device_type__name='cgs') |
|
16 | items = devices.values('id', 'name', 'device_type__name', 'ip_address') | |
|
17 | 16 | |
|
18 | self.fields['experiment'].widget.attrs['readonly'] = True | |
|
19 | self.fields['device'].widget.choices = [(item['id'], '[%s]: %s | %s' % (item['device_type__name'], item['name'], item['ip_address'])) for item in items] | |
|
17 | if instance.experiment: | |
|
18 | self.fields['experiment'].widget.attrs['disabled'] = 'disabled' | |
|
19 | ||
|
20 | self.fields['device'].widget.choices = [(device.id, device) for device in devices] | |
|
20 | 21 | |
|
21 | 22 | def clean(self): |
|
22 | 23 | return |
@@ -24,9 +25,8 class CGSConfigurationForm(forms.ModelForm): | |||
|
24 | 25 | |
|
25 | 26 | class Meta: |
|
26 | 27 | model = CGSConfiguration |
|
27 | #exclude = ('freqs', 'clk_in', 'mult','div',) | |
|
28 | # exclude = ('freqs',) | |
|
29 | fields = ('experiment', 'device', 'freq0', 'freq1', 'freq2', 'freq3') | |
|
28 | exclude = ('type', 'parameters', 'status') | |
|
29 | #fields = ('experiment', 'device', 'freq0', 'freq1', 'freq2', 'freq3') | |
|
30 | 30 | |
|
31 | 31 | |
|
32 | 32 | class UploadFileForm(forms.Form): |
@@ -15,8 +15,6 class CGSConfiguration(Configuration): | |||
|
15 | 15 | freq1 = models.IntegerField(verbose_name='Frequency 1',validators=[MinValueValidator(0), MaxValueValidator(450e6)], blank=True, null=True) |
|
16 | 16 | freq2 = models.IntegerField(verbose_name='Frequency 2',validators=[MinValueValidator(0), MaxValueValidator(450e6)], blank=True, null=True) |
|
17 | 17 | freq3 = models.IntegerField(verbose_name='Frequency 3',validators=[MinValueValidator(0), MaxValueValidator(450e6)], blank=True, null=True) |
|
18 | #jfreqs = JSONField(default={"frequencies":[{"f0":freq0,"f1":freq1,"f2":freq2,"f3":freq3}]}, blank=True) | |
|
19 | ||
|
20 | 18 | |
|
21 | 19 | def verify_frequencies(self): |
|
22 | 20 |
@@ -66,7 +66,7 def cgs_conf(request, id_conf): | |||
|
66 | 66 | kwargs['no_play'] = True |
|
67 | 67 | |
|
68 | 68 | ###### SIDEBAR ###### |
|
69 | kwargs.update(sidebar(conf)) | |
|
69 | kwargs.update(sidebar(conf=conf)) | |
|
70 | 70 | |
|
71 | 71 | return render(request, 'cgs_conf.html', kwargs) |
|
72 | 72 | |
@@ -101,10 +101,6 def cgs_conf_edit(request, id_conf): | |||
|
101 | 101 | kwargs['suptitle'] = 'Edit' |
|
102 | 102 | kwargs['button'] = 'Save' |
|
103 | 103 | |
|
104 | ||
|
105 | ###### SIDEBAR ###### | |
|
106 | kwargs.update(sidebar(conf)) | |
|
107 | ||
|
108 | 104 | return render(request, 'cgs_conf_edit.html', kwargs) |
|
109 | 105 | # |
|
110 | 106 | # def cgs_conf_write(request, id_conf): |
@@ -16,10 +16,8 class DDSConfigurationForm(forms.ModelForm): | |||
|
16 | 16 | |
|
17 | 17 | devices = Device.objects.filter(device_type__name='dds') |
|
18 | 18 | |
|
19 | self.fields['experiment'].widget.attrs['readonly'] = True | |
|
20 | ||
|
21 | if instance.experiment is not None: | |
|
22 | self.fields['experiment'].widget.choices = [(instance.experiment.id, instance.experiment)] | |
|
19 | if instance.experiment: | |
|
20 | self.fields['experiment'].widget.attrs['disabled'] = 'disabled' | |
|
23 | 21 | |
|
24 | 22 | self.fields['device'].widget.choices = [(device.id, device) for device in devices] |
|
25 | 23 |
@@ -42,7 +42,7 def dds_conf(request, id_conf): | |||
|
42 | 42 | kwargs['button'] = 'Edit Configuration' |
|
43 | 43 | |
|
44 | 44 | ###### SIDEBAR ###### |
|
45 | kwargs.update(sidebar(conf)) | |
|
45 | kwargs.update(sidebar(conf=conf)) | |
|
46 | 46 | |
|
47 | 47 | return render(request, 'dds_conf.html', kwargs) |
|
48 | 48 | |
@@ -73,9 +73,6 def dds_conf_edit(request, id_conf): | |||
|
73 | 73 | kwargs['suptitle'] = 'Edit' |
|
74 | 74 | kwargs['button'] = 'Save' |
|
75 | 75 | |
|
76 | ###### SIDEBAR ###### | |
|
77 | kwargs.update(sidebar(conf)) | |
|
78 | ||
|
79 | 76 | return render(request, 'dds_conf_edit.html', kwargs) |
|
80 | 77 | |
|
81 | 78 | # def dds_conf_import(request, id_conf): |
@@ -1,7 +1,8 | |||
|
1 | 1 | [ |
|
2 |
{"fields": {"name": " |
|
|
2 | {"fields": {"name": "MAIN RADAR", "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 | {"fields": {"name": "JULIA", "description": ""}, "model": "main.location", "pk": 4}, | |
|
5 | 6 | {"fields": {"name": "rc", "description": ""}, "model": "main.devicetype", "pk": 1}, |
|
6 | 7 | {"fields": {"name": "dds", "description": ""}, "model": "main.devicetype", "pk": 2}, |
|
7 | 8 | {"fields": {"name": "cgs", "description": ""}, "model": "main.devicetype", "pk": 3}, |
@@ -39,10 +39,16 class TimepickerWidget(forms.widgets.TextInput): | |||
|
39 | 39 | return mark_safe(html) |
|
40 | 40 | |
|
41 | 41 | class CampaignForm(forms.ModelForm): |
|
42 | ||
|
43 | experiments = forms.ModelMultipleChoiceField(widget=forms.CheckboxSelectMultiple(), | |
|
44 | queryset=Experiment.objects.filter(template=True), | |
|
45 | required=False) | |
|
46 | ||
|
42 | 47 | def __init__(self, *args, **kwargs): |
|
43 | 48 | super(CampaignForm, self).__init__(*args, **kwargs) |
|
44 | 49 | self.fields['start_date'].widget = DatepickerWidget(self.fields['start_date'].widget.attrs) |
|
45 | 50 | self.fields['end_date'].widget = DatepickerWidget(self.fields['end_date'].widget.attrs) |
|
51 | self.fields['description'].widget.attrs = {'rows': 2} | |
|
46 | 52 | |
|
47 | 53 | class Meta: |
|
48 | 54 | model = Campaign |
@@ -55,8 +61,6 class ExperimentForm(forms.ModelForm): | |||
|
55 | 61 | self.fields['start_time'].widget = TimepickerWidget(self.fields['start_time'].widget.attrs) |
|
56 | 62 | self.fields['end_time'].widget = TimepickerWidget(self.fields['end_time'].widget.attrs) |
|
57 | 63 | |
|
58 | self.fields['campaign'].widget.attrs['readonly'] = True | |
|
59 | ||
|
60 | 64 | class Meta: |
|
61 | 65 | model = Experiment |
|
62 | 66 | exclude = [''] |
@@ -72,6 +76,13 class DeviceForm(forms.ModelForm): | |||
|
72 | 76 | exclude = ['status'] |
|
73 | 77 | |
|
74 | 78 | class ConfigurationForm(forms.ModelForm): |
|
79 | ||
|
80 | def __init__(self, *args, **kwargs): | |
|
81 | super(ConfigurationForm, self).__init__(*args, **kwargs) | |
|
82 | ||
|
83 | if 'initial' in kwargs and 'experiment' in kwargs['initial'] and kwargs['initial']['experiment'] not in (0, '0'): | |
|
84 | self.fields['experiment'].widget.attrs['disabled'] = 'disabled' | |
|
85 | ||
|
75 | 86 | class Meta: |
|
76 | 87 | model = Configuration |
|
77 | 88 | exclude = ['type', 'created_date', 'programmed_date', 'parameters'] |
@@ -125,3 +136,16 class OperationSearchForm(forms.Form): | |||
|
125 | 136 | super(OperationSearchForm, self).__init__(*args, **kwargs) |
|
126 | 137 | self.fields['campaign'].choices=Campaign.objects.all().order_by('-start_date').values_list('id', 'name') |
|
127 | 138 | |
|
139 | class NewForm(forms.Form): | |
|
140 | ||
|
141 | create_from = forms.ChoiceField(choices=((0, '-----'), | |
|
142 | (1, 'Empty (blank)'), | |
|
143 | (2, 'Template'))) | |
|
144 | choose_template = forms.ChoiceField() | |
|
145 | ||
|
146 | def __init__(self, *args, **kwargs): | |
|
147 | ||
|
148 | template_choices = kwargs.pop('template_choices', []) | |
|
149 | super(NewForm, self).__init__(*args, **kwargs) | |
|
150 | self.fields['choose_template'].choices = add_empty_choice(template_choices) | |
|
151 | No newline at end of file |
@@ -1,3 +1,6 | |||
|
1 | ||
|
2 | from datetime import datetime | |
|
3 | ||
|
1 | 4 | from django.db import models |
|
2 | 5 | from polymorphic import PolymorphicModel |
|
3 | 6 | |
@@ -104,33 +107,20 class Device(models.Model): | |||
|
104 | 107 | class Campaign(models.Model): |
|
105 | 108 | |
|
106 | 109 | template = models.BooleanField(default=False) |
|
107 | ||
|
108 | name = models.CharField(max_length=40, unique=True) | |
|
109 | experiment = models.ManyToManyField('Experiment') | |
|
110 | ||
|
110 | name = models.CharField(max_length=60, unique=True) | |
|
111 | 111 | start_date = models.DateTimeField(blank=True, null=True) |
|
112 | 112 | end_date = models.DateTimeField(blank=True, null=True) |
|
113 | 113 | tags = models.CharField(max_length=40) |
|
114 | 114 | description = models.TextField(blank=True, null=True) |
|
115 | experiments = models.ManyToManyField('Experiment', blank=True) | |
|
115 | 116 | |
|
116 | 117 | class Meta: |
|
117 | 118 | db_table = 'db_campaigns' |
|
119 | ordering = ('name',) | |
|
118 | 120 | |
|
119 | 121 | def __unicode__(self): |
|
120 | 122 | return u'%s' % (self.name) |
|
121 | 123 | |
|
122 | # class Radar(models.Model): | |
|
123 | # | |
|
124 | # # name = models.CharField(max_length = 30) | |
|
125 | # experiment = models.ForeignKey('Experiment', on_delete=models.CASCADE) | |
|
126 | # location = models.OneToOneField('Location', on_delete=models.CASCADE) | |
|
127 | # status = models.PositiveSmallIntegerField(default=0, choices=RADAR_STATES) | |
|
128 | # | |
|
129 | # class Meta: | |
|
130 | # db_table = 'db_radar' | |
|
131 | # | |
|
132 | # def __unicode__(self): | |
|
133 | # return u'%s' % self.location | |
|
134 | 124 | |
|
135 | 125 | class RunningExperiment(models.Model): |
|
136 | 126 | radar = models.OneToOneField('Location', on_delete=models.CASCADE) |
@@ -141,21 +131,34 class RunningExperiment(models.Model): | |||
|
141 | 131 | class Experiment(models.Model): |
|
142 | 132 | |
|
143 | 133 | template = models.BooleanField(default=False) |
|
144 | ||
|
145 | #campaign = models.ForeignKey('Campaign', null=True, blank=True, on_delete=models.CASCADE) | |
|
146 | 134 | location = models.ForeignKey('Location', null=True, blank=True, on_delete=models.CASCADE) |
|
147 | ||
|
148 | name = models.CharField(max_length=40, default='') | |
|
135 | name = models.CharField(max_length=40, default='', unique=True) | |
|
136 | location = models.ForeignKey('Location', null=True, blank=True, on_delete=models.CASCADE) | |
|
149 | 137 | start_time = models.TimeField(default='00:00:00') |
|
150 | 138 | end_time = models.TimeField(default='23:59:59') |
|
151 | 139 | status = models.PositiveSmallIntegerField(default=0, choices=EXP_STATES) |
|
152 | 140 | |
|
153 | 141 | class Meta: |
|
154 | 142 | db_table = 'db_experiments' |
|
143 | ordering = ('name',) | |
|
155 | 144 | |
|
156 | 145 | def __unicode__(self): |
|
157 | 146 | return u'%s' % (self.name) |
|
158 | 147 | |
|
148 | def clone(self, **kwargs): | |
|
149 | ||
|
150 | confs = Configuration.objects.filter(experiment=self, type=0) | |
|
151 | self.pk = None | |
|
152 | self.name = '{} [{:%Y/%m/%d}]'.format(self.name, datetime.now()) | |
|
153 | for attr, value in kwargs.items(): | |
|
154 | setattr(self, attr, value) | |
|
155 | ||
|
156 | self.save() | |
|
157 | ||
|
158 | for conf in confs: | |
|
159 | conf.clone(experiment=self, template=False) | |
|
160 | ||
|
161 | return self | |
|
159 | 162 | |
|
160 | 163 | def get_status(self): |
|
161 | 164 | configurations = Configuration.objects.filter(experiment=self) |
@@ -198,6 +201,7 class Experiment(models.Model): | |||
|
198 | 201 | |
|
199 | 202 | return color |
|
200 | 203 | |
|
204 | ||
|
201 | 205 | class Configuration(PolymorphicModel): |
|
202 | 206 | |
|
203 | 207 | template = models.BooleanField(default=False) |
@@ -228,7 +232,16 class Configuration(PolymorphicModel): | |||
|
228 | 232 | else: |
|
229 | 233 | return u'%s' % self.device.name |
|
230 | 234 | |
|
235 | def clone(self, **kwargs): | |
|
236 | ||
|
237 | self.pk = None | |
|
238 | self.id = None | |
|
239 | for attr, value in kwargs.items(): | |
|
240 | setattr(self, attr, value) | |
|
241 | ||
|
242 | self.save() | |
|
231 | 243 | |
|
244 | return self | |
|
232 | 245 | |
|
233 | 246 | def parms_to_dict(self): |
|
234 | 247 |
@@ -14,6 +14,10 | |||
|
14 | 14 | .logo {padding-top: 5px; height: 50px} |
|
15 | 15 | .clickable-row {cursor: pointer;} |
|
16 | 16 |
.col-no-padding { padding-left:0; |
|
17 | .gi-2x{font-size: 2em;} | |
|
18 | .gi-3x{font-size: 3em;} | |
|
19 | .gi-4x{font-size: 4em;} | |
|
20 | .gi-5x{font-size: 5em;} | |
|
17 | 21 | </style> |
|
18 | 22 | <!--[if lt IE 9]> |
|
19 | 23 | <script src="//html5shim.googlecode.com/svn/trunk/html5.js"></script> |
@@ -41,21 +45,13 | |||
|
41 | 45 | <ul class="nav navbar-nav"> |
|
42 | 46 | <li class=" dropdown {% block operation-active %}{% endblock %}"><a href="{% url 'url_operation'%}">Operation</a> |
|
43 | 47 | </li> |
|
44 |
<li class=" dropdown {% block |
|
|
48 | <li class=" dropdown {% block new-active %}{% endblock %}"> | |
|
45 | 49 | <a href="#" class="dropdown-toggle" data-toggle="dropdown">New<span class="caret"></span></a> |
|
46 | 50 | <ul class="dropdown-menu" role="menu"> |
|
47 | 51 | <li><a href="{% url 'url_add_campaign' %}">Campaign</a></li> |
|
48 |
<li><a href="{% url 'url_add_experiment' |
|
|
52 | <li><a href="{% url 'url_add_experiment' %}">Experiment</a></li> | |
|
49 | 53 | <li><a href="{% url 'url_add_dev_conf' 0%}">Device Configuration</a></li> |
|
50 |
<li><a href="{% url 'url_add_device'%}"> |
|
|
51 | ||
|
52 | </ul> | |
|
53 | </li> | |
|
54 | <li class=" dropdown {% block test-active %}{% endblock %}"> | |
|
55 | <a href="#" class="dropdown-toggle" data-toggle="dropdown">Test<span class="caret"></span></a> | |
|
56 | <ul class="dropdown-menu" role="menu"> | |
|
57 | <li><a href="{% url 'url_experiments' %}">Experiments</a></li> | |
|
58 | <li><a href="{% url 'url_devices' %}">Devices</a></li> | |
|
54 | <li><a href="{% url 'url_add_device'%}">Device</a></li> | |
|
59 | 55 | </ul> |
|
60 | 56 | </li> |
|
61 | 57 | <li class=" dropdown {% block search-active %}{% endblock %}"> |
@@ -64,6 +60,7 | |||
|
64 | 60 | <li><a href="{% url 'url_campaigns' %}">Campaigns</a></li> |
|
65 | 61 | <li><a href="{% url 'url_experiments' %}">Experiments</a></li> |
|
66 | 62 | <li><a href="{% url 'url_dev_confs' %}">Configurations</a></li> |
|
63 | <li><a href="{% url 'url_devices' %}">Devices</a></li> | |
|
67 | 64 | </ul> |
|
68 | 65 | </li> |
|
69 | 66 | </ul> |
@@ -53,7 +53,6 | |||
|
53 | 53 | </tr> |
|
54 | 54 | {% endfor %} |
|
55 | 55 | </table> |
|
56 | <button class="btn btn-primary pull-right" id="bt_add">{{button}}</button> | |
|
57 | 56 | </div> |
|
58 | 57 | </div> |
|
59 | 58 | </div> |
@@ -75,9 +74,5 | |||
|
75 | 74 | document.location = "{% url 'url_edit_campaign' campaign.id%}"; |
|
76 | 75 | }); |
|
77 | 76 | |
|
78 | $("#bt_add").click(function() { | |
|
79 | document.location = "{% url 'url_add_experiment' campaign.id%}"; | |
|
80 | }); | |
|
81 | ||
|
82 | 77 | </script> |
|
83 | 78 | {% endblock %} No newline at end of file |
@@ -16,8 +16,10 | |||
|
16 | 16 | {% csrf_token %} |
|
17 | 17 | {% bootstrap_form form layout='horizontal' size='medium' %} |
|
18 | 18 | <div style="clear: both;"></div> |
|
19 | {% if button %} | |
|
19 | 20 | <br> |
|
20 | 21 | <button type="submit" class="btn btn-primary pull-right">{{button}}</button> |
|
22 | {% endif %} | |
|
21 | 23 | </form> |
|
22 | 24 | {% endblock %} |
|
23 | 25 | |
@@ -32,5 +34,21 | |||
|
32 | 34 | |
|
33 | 35 | $('.input-group.date').datetimepicker({"format": "YYYY-MM-DD HH:mm"}); |
|
34 | 36 | |
|
37 | $('#id_create_from').change(function() { | |
|
38 | var url = "{% url 'url_add_campaign' %}"; | |
|
39 | if ($(this).val()=="2"){ | |
|
40 | document.location = url+"?template=0"; | |
|
41 | }else if ($(this).val()=="1"){ | |
|
42 | document.location = url+"?blank=0"; | |
|
43 | }else{ | |
|
44 | document.location = url; | |
|
45 | } | |
|
46 | }); | |
|
47 | ||
|
48 | $('#id_choose_template').change(function() { | |
|
49 | var url = "{% url 'url_add_campaign' %}"; | |
|
50 | document.location = url+"?template="+$(this).val(); | |
|
51 | }); | |
|
52 | ||
|
35 | 53 | </script> |
|
36 | 54 | {% endblock %} No newline at end of file |
@@ -28,7 +28,7 | |||
|
28 | 28 | </tr> |
|
29 | 29 | {% endfor %} |
|
30 | 30 | </table> |
|
31 | <button class="btn btn-primary pull-right" id="bt_add">{{button}}</button> | |
|
31 | ||
|
32 | 32 | {% endblock %} |
|
33 | 33 | |
|
34 | 34 | {% block sidebar%} |
@@ -38,10 +38,6 | |||
|
38 | 38 | {% block extra-js%} |
|
39 | 39 | <script type="text/javascript"> |
|
40 | 40 |
|
|
41 | $("#bt_add").click(function() { | |
|
42 | document.location = "{% url 'url_add_campaign' %}"; | |
|
43 | }); | |
|
44 | ||
|
45 | 41 | $(".clickable-row").click(function() { |
|
46 | 42 | document.location = $(this).data("href"); |
|
47 | 43 |
|
@@ -3,7 +3,7 | |||
|
3 | 3 | {% load static %} |
|
4 | 4 | {% load main_tags %} |
|
5 | 5 | |
|
6 |
{% block |
|
|
6 | {% block search-active %}active{% endblock %} | |
|
7 | 7 | |
|
8 | 8 | {% block content-title %}{{title}}{% endblock %} |
|
9 | 9 | {% block content-suptitle %}{{suptitle}}{% endblock %} |
@@ -12,7 +12,7 | |||
|
12 | 12 | |
|
13 | 13 | {% block menu-actions %} |
|
14 | 14 | <span class=" dropdown pull-right"> |
|
15 |
<a href="#" class="dropdown-toggle" data-toggle="dropdown"><span class="glyphicon glyphicon-menu-hamburger" aria-hidden="true"></span></a> |
|
|
15 | <a href="#" class="dropdown-toggle" data-toggle="dropdown"><span class="glyphicon glyphicon-menu-hamburger gi-2x" aria-hidden="true"></span></a> | |
|
16 | 16 | <ul class="dropdown-menu" role="menu"> |
|
17 | 17 | <li><a href="{{ dev_conf.get_absolute_url_edit }}"><span class="glyphicon glyphicon-pencil" aria-hidden="true"></span> Edit</a></li> |
|
18 | 18 | <li><a href="{{ dev_conf.get_absolute_url_import }}"><span class="glyphicon glyphicon-import" aria-hidden="true"></span> Import </a></li> |
@@ -37,10 +37,12 | |||
|
37 | 37 | {% endblock %} |
|
38 | 38 | |
|
39 | 39 | {% block extra-js%} |
|
40 | {% if id_exp %} | |
|
40 | 41 | <script type="text/javascript"> |
|
41 | 42 | $("#id_device").change(function() { |
|
42 | 43 | var url = "{% url 'url_add_dev_conf' id_exp %}"; |
|
43 | 44 | document.location = url+ $(this).val() + "/"; |
|
44 | 45 | }); |
|
45 | 46 |
|
|
47 | {% endif %} | |
|
46 | 48 | {% endblock %} No newline at end of file |
@@ -28,7 +28,6 | |||
|
28 | 28 | </tr> |
|
29 | 29 | {% endfor %} |
|
30 | 30 | </table> |
|
31 | <button class="btn btn-primary pull-right" id="bt_add">{{button}}</button> | |
|
32 | 31 | {% endblock %} |
|
33 | 32 | |
|
34 | 33 | {% block sidebar%} |
@@ -38,10 +37,6 | |||
|
38 | 37 | {% block extra-js%} |
|
39 | 38 | <script type="text/javascript"> |
|
40 | 39 | |
|
41 | $("#bt_add").click(function() { | |
|
42 | document.location = "{% url 'url_add_dev_conf' 0%}"; | |
|
43 | }); | |
|
44 | ||
|
45 | 40 | $(".clickable-row").click(function() { |
|
46 | 41 | document.location = $(this).data("href"); |
|
47 | 42 |
|
@@ -25,7 +25,7 | |||
|
25 | 25 | </tr> |
|
26 | 26 | {% endfor %} |
|
27 | 27 | </table> |
|
28 | <button class="btn btn-primary pull-right" id="bt_add">{{button}}</button> | |
|
28 | ||
|
29 | 29 | {% endblock %} |
|
30 | 30 | |
|
31 | 31 | {% block sidebar%} |
@@ -35,10 +35,6 | |||
|
35 | 35 | {% block extra-js%} |
|
36 | 36 | <script type="text/javascript"> |
|
37 | 37 |
|
|
38 | $("#bt_add").click(function() { | |
|
39 | document.location = "{% url 'url_add_device' %}"; | |
|
40 | }); | |
|
41 | ||
|
42 | 38 | $(".clickable-row").click(function() { |
|
43 | 39 | document.location = $(this).data("href"); |
|
44 | 40 |
|
|
1 | NO CONTENT: modified file |
@@ -17,7 +17,44 | |||
|
17 | 17 | {% bootstrap_form form layout='horizontal' size='medium' %} |
|
18 | 18 | <div style="clear: both;"></div> |
|
19 | 19 | <br> |
|
20 | {% if configurations %} | |
|
21 | <div class="panel-group" id="accordion" role="tablist" aria-multiselectable="true"> | |
|
22 | <div class="panel panel-default"> | |
|
23 | <div class="panel-heading" role="tab" id="headingTwo"> | |
|
24 | <h4 class="panel-title"> | |
|
25 | <a class="collapsed" role="button" data-toggle="collapse" data-parent="#accordion" href="#collapseTwo" aria-expanded="false" aria-controls="collapseThree"> | |
|
26 | Device Configurations | |
|
27 | </a> | |
|
28 | </h4> | |
|
29 | </div> | |
|
30 | <div id="collapseTwo" class="panel-collapse collapse in" role="tabpanel" aria-labelledby="headingTwo"> | |
|
31 | <div class="panel-body"> | |
|
32 | <table class="table table-hover"> | |
|
33 | <tr> | |
|
34 | <th>#</th> | |
|
35 | {% for key in configuration_keys %} | |
|
36 | <th>{{ key|title }}</th> | |
|
37 | {% endfor%} | |
|
38 | </tr> | |
|
39 | {% for item in configurations %} | |
|
40 | <tr class="clickable-row" data-href="{{item.get_absolute_url}}"> | |
|
41 | <td>{{ forloop.counter }}</td> | |
|
42 | {% for key in configuration_keys %} | |
|
43 | <td>{{ item|value:key }}</td> | |
|
44 | {% endfor %} | |
|
45 | </tr> | |
|
46 | {% endfor %} | |
|
47 | </table> | |
|
48 | </div> | |
|
49 | </div> | |
|
50 | </div> | |
|
51 | </div> | |
|
52 | {% endif %} | |
|
53 | ||
|
54 | {% if button %} | |
|
55 | <br> | |
|
20 | 56 | <button type="submit" class="btn btn-primary pull-right">{{button}}</button> |
|
57 | {% endif %} | |
|
21 | 58 | </form> |
|
22 | 59 | {% endblock %} |
|
23 | 60 | |
@@ -29,10 +66,28 | |||
|
29 | 66 | <script src="{% static 'js/moment.min.js' %}"></script> |
|
30 | 67 | <script src="{% static 'js/bootstrap-datetimepicker.min.js' %}"></script> |
|
31 | 68 | <script type="text/javascript"> |
|
69 | ||
|
32 | 70 | $('.input-group.time').datetimepicker({ |
|
33 | 71 | format: 'HH:mm:ss', |
|
34 | 72 | pickDate: false, |
|
35 | 73 | pickSeconds: true |
|
36 | 74 | }); |
|
75 | ||
|
76 | $('#id_create_from').change(function() { | |
|
77 | var url = "{% url 'url_add_experiment' %}"; | |
|
78 | if ($(this).val()=="2"){ | |
|
79 | document.location = url+"?template=0"; | |
|
80 | }else if ($(this).val()=="1"){ | |
|
81 | document.location = url+"?blank=0"; | |
|
82 | }else{ | |
|
83 | document.location = url; | |
|
84 | } | |
|
85 | }); | |
|
86 | ||
|
87 | $('#id_choose_template').change(function() { | |
|
88 | var url = "{% url 'url_add_experiment' %}"; | |
|
89 | document.location = url+"?template="+$(this).val(); | |
|
90 | }); | |
|
91 | ||
|
37 | 92 | </script> |
|
38 | 93 | {% endblock %} No newline at end of file |
@@ -28,7 +28,6 | |||
|
28 | 28 | </tr> |
|
29 | 29 | {% endfor %} |
|
30 | 30 | </table> |
|
31 | <button class="btn btn-primary pull-right" id="bt_add">{{button}}</button> | |
|
32 | 31 | {% endblock %} |
|
33 | 32 | |
|
34 | 33 | {% block sidebar%} |
@@ -42,9 +41,5 | |||
|
42 | 41 | document.location = $(this).data("href"); |
|
43 | 42 | }); |
|
44 | 43 | |
|
45 | $("#bt_add").click(function() { | |
|
46 | document.location = "{% url 'url_add_experiment' 0 %}"; | |
|
47 | }); | |
|
48 | ||
|
49 | 44 | </script> |
|
50 | 45 | {% endblock %} No newline at end of file |
@@ -1,3 +1,4 | |||
|
1 | ||
|
1 | 2 | {% if campaign %} |
|
2 | 3 | <div class="panel panel-default"> |
|
3 | 4 | <div class="panel-heading"> |
@@ -7,97 +8,30 | |||
|
7 | 8 | <a href="{% url 'url_campaign' campaign.id %}" class="list-group-item active" >{{ campaign.name }}</a> |
|
8 | 9 | </div> |
|
9 | 10 | </div> |
|
10 | ||
|
11 | {% if experiments %} | |
|
12 | <div class="panel panel-default"> | |
|
13 | <div class="panel-heading"> | |
|
14 | <h4>Experiments</h4> | |
|
15 | </div> | |
|
16 | <div class="list-group"> | |
|
17 | {% for item in experiments %} | |
|
18 | <a href="{% url 'url_experiment' item.id %}" class="list-group-item {{item.active}}">{{item.name}}</a> | |
|
19 | {% endfor %} | |
|
20 | </div> | |
|
21 | </div> | |
|
22 | {% endif %} | |
|
23 | 11 | {% endif %} |
|
24 | 12 | |
|
25 | 13 | {% if experiment %} |
|
26 | 14 | <div class="panel panel-default"> |
|
27 | 15 | <div class="panel-heading"> |
|
28 | <h4>Campaign</h4> | |
|
29 | </div> | |
|
30 | <div class="list-group"> | |
|
31 | <a href="{% url 'url_campaign' experiment.campaign.id %}" class="list-group-item active" >{{ experiment.campaign.name }}</a> | |
|
32 | </div> | |
|
33 | </div> | |
|
34 | ||
|
35 | {% if experiments %} | |
|
36 | <div class="panel panel-default"> | |
|
37 | <div class="panel-heading"> | |
|
38 | 16 | <h4>Experiments</h4> |
|
39 | 17 | </div> |
|
40 | 18 | <div class="list-group"> |
|
41 | {% for item in experiments %} | |
|
19 | {% for item in side_experiments %} | |
|
42 | 20 | <a href="{% url 'url_experiment' item.id %}" class="list-group-item {%if item.id == experiment.id%}active{%endif%}">{{item.name}}</a> |
|
43 | 21 | {% endfor %} |
|
44 | 22 | </div> |
|
45 | 23 | </div> |
|
46 | 24 | {% endif %} |
|
47 | 25 | |
|
48 | {% if configurations %} | |
|
49 | <div class="panel panel-default"> | |
|
50 | <div class="panel-heading"> | |
|
51 | <h4>Device Configurations</h4> | |
|
52 | </div> | |
|
53 | <div class="list-group"> | |
|
54 | {% for item in configurations %} | |
|
55 | <a href="{{item.get_absolute_url}}" class="list-group-item {{item.active}}">{{item.device.name}}</a> | |
|
56 | {% endfor %} | |
|
57 | </div> | |
|
58 | </div> | |
|
59 | {% endif %} | |
|
60 | ||
|
61 | {% endif %} | |
|
62 | ||
|
63 | 26 | {% if dev_conf %} |
|
64 | ||
|
65 | {% if campaign %} | |
|
66 | <div class="panel panel-default"> | |
|
67 | <div class="panel-heading"> | |
|
68 | <h4>Campaign</h4> | |
|
69 | </div> | |
|
70 | <div class="list-group"> | |
|
71 | <a href="{% url 'url_campaign' dev_conf.experiment.campaign.id %}" class="list-group-item active" >{{ dev_conf.experiment.campaign.name }}</a> | |
|
72 | </div> | |
|
73 | </div> | |
|
74 | {% endif %} | |
|
75 | ||
|
76 | {% if experiments %} | |
|
77 | <div class="panel panel-default"> | |
|
78 | <div class="panel-heading"> | |
|
79 | <h4>Experiments</h4> | |
|
80 | </div> | |
|
81 | <div class="list-group"> | |
|
82 | {% for item in experiments %} | |
|
83 | <a href="{% url 'url_experiment' item.id %}" class="list-group-item {%if item.id == dev_conf.experiment.id%}active{%endif%}">{{item.name}}</a> | |
|
84 | {% endfor %} | |
|
85 | </div> | |
|
86 | </div> | |
|
87 | {% endif %} | |
|
88 | ||
|
89 | {% if configurations %} | |
|
90 | 27 | <div class="panel panel-default"> |
|
91 | 28 | <div class="panel-heading"> |
|
92 | 29 | <h4>Device Configurations</h4> |
|
93 | 30 | </div> |
|
94 | 31 | <div class="list-group"> |
|
95 | {% for item in configurations %} | |
|
32 | {% for item in side_configurations %} | |
|
96 | 33 | <a href="{{item.get_absolute_url}}" class="list-group-item {%if item.id == dev_conf.id%}active{%endif%}">{{item.device.name}}</a> |
|
97 | 34 | {% endfor %} |
|
98 | 35 | </div> |
|
99 | 36 | </div> |
|
100 | 37 | {% endif %} |
|
101 | ||
|
102 | ||
|
103 | {% endif %} |
@@ -25,7 +25,6 def value(instance, key): | |||
|
25 | 25 | for my_key in key.split("__"): |
|
26 | 26 | item = attr(item, my_key) |
|
27 | 27 | |
|
28 | print item | |
|
29 | 28 | return item |
|
30 | 29 | |
|
31 | 30 | @register.simple_tag |
@@ -19,7 +19,7 urlpatterns = ( | |||
|
19 | 19 | url(r'^campaign/(?P<id_camp>-?\d+)/edit/$', 'apps.main.views.campaign_edit', name='url_edit_campaign'), |
|
20 | 20 | url(r'^campaign/(?P<id_camp>-?\d+)/delete/$', 'apps.main.views.campaign_delete', name='url_delete_campaign'), |
|
21 | 21 | |
|
22 |
url(r'^ |
|
|
22 | url(r'^experiment/new/$', 'apps.main.views.experiment_new', name='url_add_experiment'), | |
|
23 | 23 | url(r'^experiment/$', 'apps.main.views.experiments', name='url_experiments'), |
|
24 | 24 | url(r'^experiment/(?P<id_exp>-?\d+)/$', 'apps.main.views.experiment', name='url_experiment'), |
|
25 | 25 | url(r'^experiment/(?P<id_exp>-?\d+)/edit/$', 'apps.main.views.experiment_edit', name='url_edit_experiment'), |
@@ -3,7 +3,7 from django.http import HttpResponseRedirect | |||
|
3 | 3 | from django.core.urlresolvers import reverse |
|
4 | 4 | from django.contrib import messages |
|
5 | 5 | |
|
6 | from .forms import CampaignForm, ExperimentForm, DeviceForm, ConfigurationForm, LocationForm, UploadFileForm, DownloadFileForm, OperationForm | |
|
6 | from .forms import CampaignForm, ExperimentForm, DeviceForm, ConfigurationForm, LocationForm, UploadFileForm, DownloadFileForm, OperationForm, NewForm | |
|
7 | 7 | from .forms import OperationSearchForm |
|
8 | 8 | from apps.cgs.forms import CGSConfigurationForm |
|
9 | 9 | from apps.jars.forms import JARSConfigurationForm |
@@ -290,21 +290,50 def campaign(request, id_camp): | |||
|
290 | 290 | |
|
291 | 291 | def campaign_new(request): |
|
292 | 292 | |
|
293 | kwargs = {} | |
|
294 | ||
|
293 | 295 | if request.method == 'GET': |
|
296 | ||
|
297 | if 'template' in request.GET: | |
|
298 | if request.GET['template']=='0': | |
|
299 | form = NewForm(initial={'create_from':2}, | |
|
300 | template_choices=Campaign.objects.filter(template=True).values_list('id', 'name')) | |
|
301 | else: | |
|
302 | kwargs['button'] = 'Create' | |
|
303 | kwargs['experiments'] = Configuration.objects.filter(experiment=request.GET['template']) | |
|
304 | kwargs['experiment_keys'] = ['name', 'start_time', 'end_time'] | |
|
305 | form = CampaignForm(instance=Campaign.objects.get(pk=request.GET['template']), | |
|
306 | initial={'template':False}) | |
|
307 | elif 'blank' in request.GET: | |
|
308 | kwargs['button'] = 'Create' | |
|
294 | 309 | form = CampaignForm() |
|
310 | else: | |
|
311 | form = NewForm() | |
|
295 | 312 | |
|
296 | 313 | if request.method == 'POST': |
|
297 | form = CampaignForm(request.POST) | |
|
314 | kwargs['button'] = 'Create' | |
|
315 | post = request.POST.copy() | |
|
316 | experiments = [] | |
|
317 | ||
|
318 | for id_exp in post.getlist('experiments'): | |
|
319 | exp = Experiment.objects.get(pk=id_exp) | |
|
320 | new_exp = exp.clone(template=False) | |
|
321 | experiments.append(new_exp) | |
|
322 | ||
|
323 | post.setlist('experiments', []) | |
|
324 | ||
|
325 | form = CampaignForm(post) | |
|
298 | 326 | |
|
299 | 327 | if form.is_valid(): |
|
300 | 328 | campaign = form.save() |
|
329 | for exp in experiments: | |
|
330 | campaign.experiments.add(exp) | |
|
331 | campaign.save() | |
|
301 | 332 | return redirect('url_campaign', id_camp=campaign.id) |
|
302 | 333 | |
|
303 | kwargs = {} | |
|
304 | 334 | kwargs['form'] = form |
|
305 | 335 | kwargs['title'] = 'Campaign' |
|
306 | 336 | kwargs['suptitle'] = 'New' |
|
307 | kwargs['button'] = 'Create' | |
|
308 | 337 | |
|
309 | 338 | return render(request, 'campaign_edit.html', kwargs) |
|
310 | 339 | |
@@ -336,7 +365,13 def campaign_delete(request, id_camp): | |||
|
336 | 365 | |
|
337 | 366 | if request.method=='POST': |
|
338 | 367 | if request.user.is_staff: |
|
368 | ||
|
369 | for exp in campaign.experiments.all(): | |
|
370 | for conf in Configuration.objects.filter(experiment=exp): | |
|
371 | conf.delete() | |
|
372 | exp.delete() | |
|
339 | 373 | campaign.delete() |
|
374 | ||
|
340 | 375 | return redirect('url_campaigns') |
|
341 | 376 | |
|
342 | 377 | return HttpResponse("Not enough permission to delete this object") |
@@ -348,14 +383,14 def campaign_delete(request, id_camp): | |||
|
348 | 383 | |
|
349 | 384 | def experiments(request): |
|
350 | 385 | |
|
351 |
experiment_list = Experiment.objects.all() |
|
|
386 | experiment_list = Experiment.objects.all() | |
|
352 | 387 | |
|
353 |
keys = ['id', 'name', 'start_time', 'end_time' |
|
|
388 | keys = ['id', 'name', 'start_time', 'end_time'] | |
|
354 | 389 | |
|
355 | 390 | kwargs = {} |
|
356 | 391 | |
|
357 | 392 | kwargs['experiment_keys'] = keys[1:] |
|
358 |
kwargs['experiments'] = experiment_list |
|
|
393 | kwargs['experiments'] = experiment_list | |
|
359 | 394 | |
|
360 | 395 | kwargs['title'] = 'Experiment' |
|
361 | 396 | kwargs['suptitle'] = 'List' |
@@ -367,12 +402,11 def experiment(request, id_exp): | |||
|
367 | 402 | |
|
368 | 403 | experiment = get_object_or_404(Experiment, pk=id_exp) |
|
369 | 404 | |
|
370 | experiments = Experiment.objects.filter(campaign=experiment.campaign) | |
|
371 | 405 | configurations = Configuration.objects.filter(experiment=experiment, type=0) |
|
372 | 406 | |
|
373 | 407 | kwargs = {} |
|
374 | 408 | |
|
375 |
exp_keys = ['id |
|
|
409 | exp_keys = ['id', 'location', 'name', 'start_time', 'end_time'] | |
|
376 | 410 | conf_keys = ['id', 'device__name', 'device__device_type', 'device__ip_address', 'device__port_address'] |
|
377 | 411 | |
|
378 | 412 | conf_labels = ['id', 'device__name', 'device_type', 'ip_address', 'port_address'] |
@@ -380,8 +414,6 def experiment(request, id_exp): | |||
|
380 | 414 | kwargs['experiment_keys'] = exp_keys[1:] |
|
381 | 415 | kwargs['experiment'] = experiment |
|
382 | 416 | |
|
383 | kwargs['experiments'] = experiments.values(*exp_keys) | |
|
384 | ||
|
385 | 417 | kwargs['configuration_labels'] = conf_labels[1:] |
|
386 | 418 | kwargs['configuration_keys'] = conf_keys[1:] |
|
387 | 419 | kwargs['configurations'] = configurations #.values(*conf_keys) |
@@ -391,25 +423,48 def experiment(request, id_exp): | |||
|
391 | 423 | |
|
392 | 424 | kwargs['button'] = 'Add Configuration' |
|
393 | 425 | |
|
426 | ###### SIDEBAR ###### | |
|
427 | kwargs.update(sidebar(experiment=experiment)) | |
|
428 | ||
|
394 | 429 | return render(request, 'experiment.html', kwargs) |
|
395 | 430 | |
|
431 | ||
|
396 | 432 | def experiment_new(request, id_camp=None): |
|
397 | 433 | |
|
434 | kwargs = {} | |
|
435 | ||
|
398 | 436 | if request.method == 'GET': |
|
399 | form = ExperimentForm(initial={'campaign':id_camp}) | |
|
437 | if 'template' in request.GET: | |
|
438 | if request.GET['template']=='0': | |
|
439 | form = NewForm(initial={'create_from':2}, | |
|
440 | template_choices=Experiment.objects.filter(template=True).values_list('id', 'name')) | |
|
441 | else: | |
|
442 | kwargs['button'] = 'Create' | |
|
443 | kwargs['configurations'] = Configuration.objects.filter(experiment=request.GET['template']) | |
|
444 | kwargs['configuration_keys'] = ['name', 'device__name', 'device__ip_address', 'device__port_address'] | |
|
445 | form = ExperimentForm(instance=Experiment.objects.get(pk=request.GET['template']), | |
|
446 | initial={'template':False}) | |
|
447 | elif 'blank' in request.GET: | |
|
448 | kwargs['button'] = 'Create' | |
|
449 | form = ExperimentForm() | |
|
450 | else: | |
|
451 | form = NewForm() | |
|
400 | 452 | |
|
401 | 453 | if request.method == 'POST': |
|
402 |
form = ExperimentForm(request.POST |
|
|
403 | ||
|
454 | form = ExperimentForm(request.POST) | |
|
404 | 455 | if form.is_valid(): |
|
405 | 456 | experiment = form.save() |
|
457 | ||
|
458 | if 'template' in request.GET: | |
|
459 | configurations = Configuration.objects.filter(experiment=request.GET['template'], type=0) | |
|
460 | for conf in configurations: | |
|
461 | conf.clone(experiment=experiment, template=False) | |
|
462 | ||
|
406 | 463 | return redirect('url_experiment', id_exp=experiment.id) |
|
407 | 464 | |
|
408 | kwargs = {} | |
|
409 | 465 | kwargs['form'] = form |
|
410 | 466 | kwargs['title'] = 'Experiment' |
|
411 | 467 | kwargs['suptitle'] = 'New' |
|
412 | kwargs['button'] = 'Create' | |
|
413 | 468 | |
|
414 | 469 | return render(request, 'experiment_edit.html', kwargs) |
|
415 | 470 | |
@@ -441,9 +496,8 def experiment_delete(request, id_exp): | |||
|
441 | 496 | |
|
442 | 497 | if request.method=='POST': |
|
443 | 498 | if request.user.is_staff: |
|
444 | id_camp = experiment.campaign.id | |
|
445 | 499 | experiment.delete() |
|
446 |
return redirect('url_ |
|
|
500 | return redirect('url_experiments') | |
|
447 | 501 | |
|
448 | 502 | return HttpResponse("Not enough permission to delete this object") |
|
449 | 503 | |
@@ -482,7 +536,7 def dev_conf_new(request, id_exp=0, id_dev=0): | |||
|
482 | 536 | |
|
483 | 537 | initial = {} |
|
484 | 538 | |
|
485 |
if id_exp |
|
|
539 | if id_exp<>0: | |
|
486 | 540 | initial['experiment'] = id_exp |
|
487 | 541 | |
|
488 | 542 | if id_dev<>0: |
@@ -544,7 +598,7 def dev_conf_edit(request, id_conf): | |||
|
544 | 598 | kwargs['button'] = 'Update' |
|
545 | 599 | |
|
546 | 600 | ###### SIDEBAR ###### |
|
547 | kwargs.update(sidebar(conf)) | |
|
601 | kwargs.update(sidebar(conf=conf)) | |
|
548 | 602 | |
|
549 | 603 | return render(request, '%s_conf_edit.html' %conf.device.device_type.name, kwargs) |
|
550 | 604 | |
@@ -613,11 +667,7 def dev_conf_write(request, id_conf): | |||
|
613 | 667 | messages.success(request, conf.message) |
|
614 | 668 | |
|
615 | 669 | #Creating a historical configuration |
|
616 | conf.pk = None | |
|
617 | conf.id = None | |
|
618 | conf.type = 1 | |
|
619 | conf.template = 0 | |
|
620 | conf.save() | |
|
670 | conf.clone(type=0, template=False) | |
|
621 | 671 | |
|
622 | 672 | #Original configuration |
|
623 | 673 | conf = DevConfModel.objects.get(pk=id_conf) |
@@ -663,7 +713,7 def dev_conf_read(request, id_conf): | |||
|
663 | 713 | kwargs['button'] = 'Save' |
|
664 | 714 | |
|
665 | 715 | ###### SIDEBAR ###### |
|
666 | kwargs.update(sidebar(conf)) | |
|
716 | kwargs.update(sidebar(conf=conf)) | |
|
667 | 717 | |
|
668 | 718 | return render(request, '%s_conf_edit.html' %conf.device.device_type.name, kwargs) |
|
669 | 719 | |
@@ -673,7 +723,6 def dev_conf_import(request, id_conf): | |||
|
673 | 723 | |
|
674 | 724 | DevConfModel = CONF_MODELS[conf.device.device_type.name] |
|
675 | 725 | DevConfForm = CONF_FORMS[conf.device.device_type.name] |
|
676 | ||
|
677 | 726 | conf = DevConfModel.objects.get(pk=id_conf) |
|
678 | 727 | |
|
679 | 728 | if request.method == 'GET': |
@@ -688,7 +737,6 def dev_conf_import(request, id_conf): | |||
|
688 | 737 | |
|
689 | 738 | if parms: |
|
690 | 739 | messages.success(request, "Parameters imported from: '%s'." %request.FILES['file'].name) |
|
691 | print parms | |
|
692 | 740 | form = DevConfForm(initial=parms, instance=conf) |
|
693 | 741 | |
|
694 | 742 | kwargs = {} |
@@ -701,7 +749,7 def dev_conf_import(request, id_conf): | |||
|
701 | 749 | kwargs['previous'] = conf.get_absolute_url() |
|
702 | 750 | |
|
703 | 751 | ###### SIDEBAR ###### |
|
704 | kwargs.update(sidebar(conf)) | |
|
752 | kwargs.update(sidebar(conf=conf)) | |
|
705 | 753 | |
|
706 | 754 | return render(request, '%s_conf_edit.html' % conf.device.device_type.name, kwargs) |
|
707 | 755 | |
@@ -714,7 +762,7 def dev_conf_import(request, id_conf): | |||
|
714 | 762 | kwargs['suptitle'] = 'Importing file' |
|
715 | 763 | kwargs['button'] = 'Import' |
|
716 | 764 | |
|
717 | kwargs.update(sidebar(conf)) | |
|
765 | kwargs.update(sidebar(conf=conf)) | |
|
718 | 766 | |
|
719 | 767 | return render(request, 'dev_conf_import.html', kwargs) |
|
720 | 768 | |
@@ -767,26 +815,32 def dev_conf_delete(request, id_conf): | |||
|
767 | 815 | kwargs = {'object':conf, 'conf_active':'active', |
|
768 | 816 | 'url_cancel':'url_dev_conf', 'id_item':id_conf} |
|
769 | 817 | |
|
770 | ###### SIDEBAR ###### | |
|
771 | kwargs.update(sidebar(conf)) | |
|
772 | ||
|
773 | 818 | return render(request, 'item_delete.html', kwargs) |
|
774 | 819 | |
|
775 | def sidebar(conf): | |
|
776 | 820 | |
|
777 | kwargs = {} | |
|
821 | def sidebar(**kwargs): | |
|
778 | 822 | |
|
779 | if conf.experiment: | |
|
780 | experiments = Experiment.objects.filter(campaign=conf.experiment.campaign) | |
|
781 | configurations = Configuration.objects.filter(experiment=conf.experiment, type=0) | |
|
782 | exp_keys = ['id', 'campaign', 'name', 'start_time', 'end_time'] | |
|
783 | kwargs['experiment_keys'] = exp_keys[1:] | |
|
784 | kwargs['experiments'] = experiments.values(*exp_keys) | |
|
785 | conf_keys = ['id', 'device'] | |
|
786 | kwargs['configuration_keys'] = conf_keys[1:] | |
|
787 | kwargs['configurations'] = configurations #.values(*conf_keys) | |
|
823 | side_data = {} | |
|
788 | 824 | |
|
789 | return kwargs | |
|
825 | conf = kwargs.get('conf', None) | |
|
826 | experiment = kwargs.get('experiment', None) | |
|
827 | ||
|
828 | if not experiment: | |
|
829 | experiment = conf.experiment | |
|
830 | ||
|
831 | if experiment: | |
|
832 | side_data['experiment'] = experiment | |
|
833 | campaign = experiment.campaign_set.all() | |
|
834 | if campaign: | |
|
835 | side_data['campaign'] = campaign[0] | |
|
836 | experiments = campaign[0].experiments.all() | |
|
837 | else: | |
|
838 | experiments = [experiment] | |
|
839 | configurations = experiment.configuration_set.filter(type=0) | |
|
840 | side_data['side_experiments'] = experiments | |
|
841 | side_data['side_configurations'] = configurations | |
|
842 | ||
|
843 | return side_data | |
|
790 | 844 | |
|
791 | 845 | |
|
792 | 846 | def operation(request, id_camp=None): |
@@ -904,3 +958,4 def radar_stop(request, id_camp, id_radar): | |||
|
904 | 958 | return HttpResponseRedirect(reverse('url_operation_search', args=[id_camp])) |
|
905 | 959 | else: |
|
906 | 960 | return HttpResponseRedirect(reverse('url_operation', args=[id_camp])) |
|
961 |
@@ -64,8 +64,8 class RCConfigurationForm(forms.ModelForm): | |||
|
64 | 64 | |
|
65 | 65 | devices = Device.objects.filter(device_type__name='rc') |
|
66 | 66 | if instance.experiment: |
|
67 |
self.fields['experiment'].widget.attrs[' |
|
|
68 | self.fields['experiment'].widget.choices = [(instance.experiment.id, instance.experiment)] | |
|
67 | self.fields['experiment'].widget.attrs['disabled'] = 'disabled' | |
|
68 | #self.fields['experiment'].widget.choices = [(instance.experiment.id, instance.experiment)] | |
|
69 | 69 | self.fields['device'].widget.choices = [(device.id, device) for device in devices] |
|
70 | 70 | self.fields['ipp'].widget = KmUnitHzWidget(attrs={'km2unit':instance.km2unit}) |
|
71 | 71 | self.fields['clock'].widget.attrs['readonly'] = True |
@@ -73,6 +73,8 class RCConfigurationForm(forms.ModelForm): | |||
|
73 | 73 | self.fields['time_before'].label = mark_safe(self.fields['time_before'].label) |
|
74 | 74 | self.fields['time_after'].label = mark_safe(self.fields['time_after'].label) |
|
75 | 75 | |
|
76 | if 'initial' in kwargs and 'experiment' in kwargs['initial'] and kwargs['initial']['experiment'] not in (0, '0'): | |
|
77 | self.fields['experiment'].widget.attrs['disabled'] = 'disabled' | |
|
76 | 78 | |
|
77 | 79 | class Meta: |
|
78 | 80 | model = RCConfiguration |
@@ -90,6 +90,20 class RCConfiguration(Configuration): | |||
|
90 | 90 | return 20./3*(self.clock_in/self.clock_divider) |
|
91 | 91 | |
|
92 | 92 | |
|
93 | def clone(self, **kwargs): | |
|
94 | ||
|
95 | lines = self.get_lines() | |
|
96 | self.pk = None | |
|
97 | self.id = None | |
|
98 | for attr, value in kwargs.items(): | |
|
99 | setattr(self, attr, value) | |
|
100 | self.save() | |
|
101 | ||
|
102 | for line in lines: | |
|
103 | line.clone(rc_configuration=self) | |
|
104 | ||
|
105 | return self | |
|
106 | ||
|
93 | 107 | def get_lines(self, type=None): |
|
94 | 108 | ''' |
|
95 | 109 | Retrieve configuration lines |
@@ -304,6 +318,10 class RCConfiguration(Configuration): | |||
|
304 | 318 | line.save() |
|
305 | 319 | |
|
306 | 320 | |
|
321 | def status_device(self): | |
|
322 | ||
|
323 | return 0 | |
|
324 | ||
|
307 | 325 | class RCLineCode(models.Model): |
|
308 | 326 | |
|
309 | 327 | name = models.CharField(max_length=40) |
@@ -333,7 +351,7 class RCLineType(models.Model): | |||
|
333 | 351 | |
|
334 | 352 | class RCLine(models.Model): |
|
335 | 353 | |
|
336 | rc_configuration = models.ForeignKey(RCConfiguration) | |
|
354 | rc_configuration = models.ForeignKey(RCConfiguration, on_delete=models.CASCADE) | |
|
337 | 355 | line_type = models.ForeignKey(RCLineType) |
|
338 | 356 | channel = models.PositiveIntegerField(default=0) |
|
339 | 357 | position = models.PositiveIntegerField(default=0) |
@@ -348,6 +366,17 class RCLine(models.Model): | |||
|
348 | 366 | if self.rc_configuration: |
|
349 | 367 | return u'%s - %s' % (self.rc_configuration, self.get_name()) |
|
350 | 368 | |
|
369 | def clone(self, **kwargs): | |
|
370 | ||
|
371 | self.pk = None | |
|
372 | ||
|
373 | for attr, value in kwargs.items(): | |
|
374 | setattr(self, attr, value) | |
|
375 | ||
|
376 | self.save() | |
|
377 | ||
|
378 | return self | |
|
379 | ||
|
351 | 380 | def get_name(self): |
|
352 | 381 | |
|
353 | 382 | chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' |
@@ -36,7 +36,7 def conf(request, conf_id): | |||
|
36 | 36 | |
|
37 | 37 | kwargs['button'] = 'Edit Configuration' |
|
38 | 38 | ###### SIDEBAR ###### |
|
39 | kwargs.update(sidebar(conf)) | |
|
39 | kwargs.update(sidebar(conf=conf)) | |
|
40 | 40 | |
|
41 | 41 | return render(request, 'rc_conf.html', kwargs) |
|
42 | 42 | |
@@ -140,8 +140,6 def conf_edit(request, conf_id): | |||
|
140 | 140 | kwargs['button'] = 'Update' |
|
141 | 141 | kwargs['previous'] = conf.get_absolute_url() |
|
142 | 142 | |
|
143 | kwargs.update(sidebar(conf)) | |
|
144 | ||
|
145 | 143 | return render(request, 'rc_conf_edit.html', kwargs) |
|
146 | 144 | |
|
147 | 145 | |
@@ -183,8 +181,6 def add_line(request, conf_id, line_type_id=None, code_id=None): | |||
|
183 | 181 | kwargs['dev_conf'] = conf |
|
184 | 182 | kwargs['line_type'] = line_type |
|
185 | 183 | |
|
186 | kwargs.update(sidebar(conf)) | |
|
187 | ||
|
188 | 184 | return render(request, 'rc_add_line.html', kwargs) |
|
189 | 185 | |
|
190 | 186 | def edit_codes(request, conf_id, line_id, code_id=None): |
General Comments 0
You need to be logged in to leave comments.
Login now