@@ -1,125 +1,141 | |||
|
1 | 1 | <!DOCTYPE html> |
|
2 | 2 | {% load static %} |
|
3 | 3 | <html lang="en"> |
|
4 | 4 | <head> |
|
5 | 5 | <meta charset="utf-8"> |
|
6 | 6 | <title>{% block title %}Jicamarca Integrated Radar System:::::{% endblock %}</title> |
|
7 | 7 | <meta name="description" content=""> |
|
8 | 8 | <meta name="author" content=""> |
|
9 | 9 | <meta name="viewport" content="width=device-width, initial-scale=1"> |
|
10 | 10 | {# bootstrap_css #} |
|
11 | 11 | <link href="{% static 'css/bootstrap-flatly.min.css' %}" media="all" rel="stylesheet"> |
|
12 | 12 | <style type="text/css"> |
|
13 | 13 | body {padding-top: 60px} |
|
14 | 14 | .logo {padding-top: 5px; height: 50px} |
|
15 |
.clickable-row {cursor: pointer;} |
|
|
15 | .clickable-row {cursor: pointer;} | |
|
16 | .col-no-padding { padding-left:0; } | |
|
16 | 17 | </style> |
|
17 | 18 | <!--[if lt IE 9]> |
|
18 | 19 | <script src="//html5shim.googlecode.com/svn/trunk/html5.js"></script> |
|
19 | 20 | <![endif]--> |
|
20 | 21 | {% block extra-head %} |
|
21 | 22 | {% endblock %} |
|
22 | 23 | </head> |
|
23 | 24 | |
|
24 | 25 | <body> |
|
25 | 26 | |
|
26 | 27 | {% block main_menu %} |
|
27 | 28 | <nav class="navbar navbar-default navbar-fixed-top" role="banner"> |
|
28 | 29 | <div class="container-fluid"> |
|
29 | 30 | <div class="navbar-header"> |
|
30 | 31 | <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#navigationbar"> |
|
31 | 32 | <span class="sr-only">Toggle navigation</span> |
|
32 | 33 | <span class="icon-bar"></span> |
|
33 | 34 | <span class="icon-bar"></span> |
|
34 | 35 | <span class="icon-bar"></span> |
|
35 | 36 | </button> |
|
36 | 37 | <a class="navbar-brand" href="{% url 'index' %}" style="padding-top:1px"><img class="logo" alt="JRO" src="{% static "images/logo-jro-white-trans.png" %}"></a> |
|
37 | 38 | </div> |
|
38 | 39 | <div class="collapse navbar-collapse" id="navigationbar"> |
|
39 | 40 | <ul class="nav navbar-nav"> |
|
40 |
<li class=" dropdown {% block |
|
|
41 | <li class=" dropdown {% block operation-active %}{% endblock %}"><a href="{% url 'url_operation'%}">Operation</a> | |
|
41 | 42 | </li> |
|
42 |
<li class=" dropdown {% block |
|
|
43 | <li class=" dropdown {% block conf-active %}{% endblock %}"> | |
|
44 | <a href="#" class="dropdown-toggle" data-toggle="dropdown">Configuration<span class="caret"></span></a> | |
|
45 | <ul class="dropdown-menu" role="menu"> | |
|
46 | <li><a href="#">Campaigns</a></li> | |
|
47 | <li><a href="#">Radars</a></li> | |
|
48 | <li><a href="#">Devices</a></li> | |
|
49 | </ul> | |
|
43 | 50 | </li> |
|
44 |
<li class=" dropdown {% block |
|
|
45 | </li> | |
|
46 | <li class=" dropdown {% block dev-active %}{% endblock %}"><a href="{% url 'url_devices'%}">Devices</a> | |
|
47 | </li> | |
|
48 | <li class=" dropdown {% block loc-active %}{% endblock %}"><a href="{% url 'url_locations'%}">Locations</a> | |
|
51 | <li class=" dropdown {% block test-active %}{% endblock %}"> | |
|
52 | <a href="#" class="dropdown-toggle" data-toggle="dropdown">Test<span class="caret"></span></a> | |
|
53 | <ul class="dropdown-menu" role="menu"> | |
|
54 | <li><a href="{% url 'url_experiments' %}">Experiments</a></li> | |
|
55 | <li><a href="{% url 'url_devices' %}">Devices</a></li> | |
|
56 | </ul> | |
|
49 | 57 | </li> |
|
58 | <li class=" dropdown {% block search-active %}{% endblock %}"> | |
|
59 | <a href="#" class="dropdown-toggle" data-toggle="dropdown">Search<span class="caret"></span></a> | |
|
60 | <ul class="dropdown-menu" role="menu"> | |
|
61 | <li><a href="{% url 'url_campaigns' %}">Campaigns</a></li> | |
|
62 | <li><a href="{% url 'url_experiments' %}">Experiments</a></li> | |
|
63 | <li><a href="{% url 'url_dev_confs' %}">Configurations</a></li> | |
|
64 | </ul> | |
|
65 | </li> | |
|
50 | 66 | </ul> |
|
51 | 67 | <ul class="nav navbar-nav navbar-right"> |
|
52 | 68 | <li class="nav-divider"></li> |
|
53 | 69 | {% if user.is_authenticated %} |
|
54 | 70 | <li class="dropdown"> |
|
55 | 71 | <a href="#" class="dropdown-toggle" data-toggle="dropdown">Hi {{ user.username }}<span class="caret"></span></a> |
|
56 | 72 | <ul class="dropdown-menu" role="menu"> |
|
57 | 73 | <li><a href="#">Control Panel</a></li> |
|
58 | 74 | <li><a href="{% url 'django.contrib.auth.views.logout' %}">Logout</a></li> |
|
59 | 75 | </ul> |
|
60 | 76 | </li> |
|
61 | 77 | {% else %} |
|
62 | 78 | <li><a href="{% url 'django.contrib.auth.views.login' %}?next={{request.get_full_path}}">Login</a></li> |
|
63 | 79 | {% endif %} |
|
64 | 80 | </ul> |
|
65 | 81 | </div> |
|
66 | 82 | </div> |
|
67 | 83 | </nav> |
|
68 | 84 | <div style="clear: both;"></div> |
|
69 | 85 | {% endblock %} |
|
70 | 86 | |
|
71 | 87 | <div class="container"> |
|
72 | 88 | <div id="page" class="row" style="min-height:600px"> |
|
73 | 89 | |
|
74 | 90 | <div class="col-md-3 hidden-xs hidden-sm" role="complementary"> |
|
75 | 91 | <br><br> |
|
76 | 92 | <div id="sidebar"> |
|
77 | 93 | {% block sidebar%} |
|
78 | 94 | {% endblock %} |
|
79 | 95 | </div> |
|
80 | 96 | </div> |
|
81 | 97 | |
|
82 | 98 | <div class="col-md-9 col-xs-12" role="main"> |
|
83 | 99 | <div class="page-header"> |
|
84 | 100 | <h1>{% block content-title %}{% endblock %} <small>{% block content-suptitle %}{% endblock %}</small></h1> |
|
85 | 101 | </div> |
|
86 | 102 | {% block messages %} |
|
87 | 103 | {% if messages %} |
|
88 | 104 | {% for message in messages %} |
|
89 | 105 | <div class="alert alert-{% if message.tags %}{% if 'error' in message.tags %}danger{% else %}{{ message.tags }}{% endif %}{% else %}info{% endif %} alert-dismissible" role="alert"> |
|
90 | 106 | <button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button> |
|
91 | 107 | <strong>{{message.tags|title}}!</strong> {{ message }} |
|
92 | 108 | </div> |
|
93 | 109 | {% endfor %} |
|
94 | 110 | {% endif %} |
|
95 | 111 | {% endblock %} |
|
96 | 112 | |
|
97 | 113 | {% block content %} |
|
98 | 114 | {% endblock %} |
|
99 | 115 | |
|
100 | 116 | </div> |
|
101 | 117 | |
|
102 | 118 | </div><!--/row--> |
|
103 | 119 | </div> <!-- container --> |
|
104 | 120 | |
|
105 | 121 | <div id="debug">{{debug}}</div> |
|
106 | 122 | |
|
107 | 123 | {% block footer %} |
|
108 | 124 | <footer class="footer"> |
|
109 | 125 | <div class="container"> |
|
110 | 126 | <p><hr></p> |
|
111 | 127 | <p> |
|
112 | 128 | © <a href="http://jro.igp.gob.pe">Jicamarca Radio Observatory</a> - {% now "Y" %} |
|
113 | 129 | </p> |
|
114 | 130 | </div> |
|
115 | 131 | </footer> |
|
116 | 132 | {% endblock %} |
|
117 | 133 | |
|
118 | 134 | {# bootstrap_javascript jquery=True #} |
|
119 | 135 | <script src="{% static 'js/jquery.min.js' %}"></script> |
|
120 | 136 | <script src="{% static 'js/bootstrap.min.js' %}"></script> |
|
121 | 137 | {% block extra-js %} |
|
122 | 138 | {% endblock%} |
|
123 | 139 | </body> |
|
124 | 140 | </html> |
|
125 | 141 |
@@ -1,594 +1,600 | |||
|
1 | 1 | from django.shortcuts import render, redirect, get_object_or_404, HttpResponse |
|
2 | 2 | from django.contrib import messages |
|
3 | 3 | |
|
4 | 4 | from .forms import CampaignForm, ExperimentForm, DeviceForm, ConfigurationForm, LocationForm |
|
5 | 5 | from apps.cgs.forms import CGSConfigurationForm |
|
6 | 6 | from apps.jars.forms import JARSConfigurationForm |
|
7 | 7 | from apps.usrp.forms import USRPConfigurationForm |
|
8 | 8 | from apps.abs.forms import ABSConfigurationForm |
|
9 | 9 | from apps.rc.forms import RCConfigurationForm |
|
10 | 10 | from apps.dds.forms import DDSConfigurationForm |
|
11 | 11 | |
|
12 | 12 | from .models import Campaign, Experiment, Device, Configuration, Location |
|
13 | 13 | from apps.cgs.models import CGSConfiguration |
|
14 | 14 | from apps.jars.models import JARSConfiguration |
|
15 | 15 | from apps.usrp.models import USRPConfiguration |
|
16 | 16 | from apps.abs.models import ABSConfiguration |
|
17 | 17 | from apps.rc.models import RCConfiguration |
|
18 | 18 | from apps.dds.models import DDSConfiguration |
|
19 | 19 | |
|
20 | 20 | # Create your views here. |
|
21 | 21 | |
|
22 | 22 | CONF_FORMS = { |
|
23 | 23 | 'rc': RCConfigurationForm, |
|
24 | 24 | 'dds': DDSConfigurationForm, |
|
25 | 25 | 'jars': JARSConfigurationForm, |
|
26 | 26 | 'cgs': CGSConfigurationForm, |
|
27 | 27 | 'abs': ABSConfigurationForm, |
|
28 | 28 | 'usrp': USRPConfigurationForm, |
|
29 | 29 | } |
|
30 | 30 | |
|
31 | 31 | CONF_MODELS = { |
|
32 | 32 | 'rc': RCConfiguration, |
|
33 | 33 | 'dds': DDSConfiguration, |
|
34 | 34 | 'jars': JARSConfiguration, |
|
35 | 35 | 'cgs': CGSConfiguration, |
|
36 | 36 | 'abs': ABSConfiguration, |
|
37 | 37 | 'usrp': USRPConfiguration, |
|
38 | 38 | } |
|
39 | 39 | |
|
40 | 40 | def index(request): |
|
41 | 41 | kwargs = {} |
|
42 | 42 | |
|
43 | 43 | return render(request, 'index.html', kwargs) |
|
44 | 44 | |
|
45 | 45 | def locations(request): |
|
46 | 46 | |
|
47 | 47 | locations = Location.objects.all().order_by('name') |
|
48 | 48 | |
|
49 | 49 | keys = ['id', 'name', 'description'] |
|
50 | 50 | |
|
51 | 51 | kwargs = {} |
|
52 | 52 | kwargs['location_keys'] = keys[1:] |
|
53 | 53 | kwargs['locations'] = locations |
|
54 | 54 | kwargs['title'] = 'Location' |
|
55 | 55 | kwargs['suptitle'] = 'List' |
|
56 | 56 | kwargs['button'] = 'New Location' |
|
57 | 57 | |
|
58 | 58 | return render(request, 'locations.html', kwargs) |
|
59 | 59 | |
|
60 | 60 | def location(request, id_loc): |
|
61 | 61 | |
|
62 | 62 | location = get_object_or_404(Location, pk=id_loc) |
|
63 | 63 | |
|
64 | 64 | kwargs = {} |
|
65 | 65 | kwargs['location'] = location |
|
66 | 66 | kwargs['location_keys'] = ['name', 'description'] |
|
67 | 67 | |
|
68 | 68 | kwargs['title'] = 'Location' |
|
69 | 69 | kwargs['suptitle'] = 'Details' |
|
70 | 70 | |
|
71 | 71 | return render(request, 'location.html', kwargs) |
|
72 | 72 | |
|
73 | 73 | def location_new(request): |
|
74 | 74 | |
|
75 | 75 | if request.method == 'GET': |
|
76 | 76 | form = LocationForm() |
|
77 | 77 | |
|
78 | 78 | if request.method == 'POST': |
|
79 | 79 | form = LocationForm(request.POST) |
|
80 | 80 | |
|
81 | 81 | if form.is_valid(): |
|
82 | 82 | form.save() |
|
83 | 83 | return redirect('url_locations') |
|
84 | 84 | |
|
85 | 85 | kwargs = {} |
|
86 | 86 | kwargs['form'] = form |
|
87 | 87 | kwargs['title'] = 'Location' |
|
88 | 88 | kwargs['suptitle'] = 'New' |
|
89 | 89 | kwargs['button'] = 'Create' |
|
90 | 90 | |
|
91 | 91 | return render(request, 'location_edit.html', kwargs) |
|
92 | 92 | |
|
93 | 93 | def location_edit(request, id_loc): |
|
94 | 94 | |
|
95 | 95 | location = get_object_or_404(Location, pk=id_loc) |
|
96 | 96 | |
|
97 | 97 | if request.method=='GET': |
|
98 | 98 | form = LocationForm(instance=location) |
|
99 | 99 | |
|
100 | 100 | if request.method=='POST': |
|
101 | 101 | form = LocationForm(request.POST, instance=location) |
|
102 | 102 | |
|
103 | 103 | if form.is_valid(): |
|
104 | 104 | form.save() |
|
105 | 105 | return redirect('url_locations') |
|
106 | 106 | |
|
107 | 107 | kwargs = {} |
|
108 | 108 | kwargs['form'] = form |
|
109 | 109 | kwargs['title'] = 'Location' |
|
110 | 110 | kwargs['suptitle'] = 'Edit' |
|
111 | 111 | kwargs['button'] = 'Update' |
|
112 | 112 | |
|
113 | 113 | return render(request, 'location_edit.html', kwargs) |
|
114 | 114 | |
|
115 | 115 | def location_delete(request, id_loc): |
|
116 | 116 | |
|
117 | 117 | location = get_object_or_404(Location, pk=id_loc) |
|
118 | 118 | |
|
119 | 119 | if request.method=='POST': |
|
120 | 120 | |
|
121 | 121 | if request.user.is_staff: |
|
122 | 122 | location.delete() |
|
123 | 123 | return redirect('url_locations') |
|
124 | 124 | |
|
125 | 125 | return HttpResponse("Not enough permission to delete this object") |
|
126 | 126 | |
|
127 | 127 | kwargs = {'object':location, 'loc_active':'active', |
|
128 | 128 | 'url_cancel':'url_location', 'id_item':id_loc} |
|
129 | 129 | |
|
130 | 130 | return render(request, 'item_delete.html', kwargs) |
|
131 | 131 | |
|
132 | 132 | def devices(request): |
|
133 | 133 | |
|
134 | 134 | devices = Device.objects.all().order_by('device_type__name') |
|
135 | 135 | |
|
136 | 136 | # keys = ['id', 'device_type__name', 'name', 'ip_address'] |
|
137 | 137 | keys = ['id', 'name', 'ip_address', 'port_address', 'device_type'] |
|
138 | 138 | |
|
139 | 139 | kwargs = {} |
|
140 | 140 | kwargs['device_keys'] = keys[1:] |
|
141 | 141 | kwargs['devices'] = devices#.values(*keys) |
|
142 | 142 | kwargs['title'] = 'Device' |
|
143 | 143 | kwargs['suptitle'] = 'List' |
|
144 | 144 | kwargs['button'] = 'New Device' |
|
145 | 145 | |
|
146 | 146 | return render(request, 'devices.html', kwargs) |
|
147 | 147 | |
|
148 | 148 | def device(request, id_dev): |
|
149 | 149 | |
|
150 | 150 | device = get_object_or_404(Device, pk=id_dev) |
|
151 | 151 | |
|
152 | 152 | kwargs = {} |
|
153 | 153 | kwargs['device'] = device |
|
154 | 154 | kwargs['device_keys'] = ['device_type', 'name', 'ip_address', 'port_address', 'description'] |
|
155 | 155 | |
|
156 | 156 | kwargs['title'] = 'Device' |
|
157 | 157 | kwargs['suptitle'] = 'Details' |
|
158 | 158 | |
|
159 | 159 | return render(request, 'device.html', kwargs) |
|
160 | 160 | |
|
161 | 161 | def device_new(request): |
|
162 | 162 | |
|
163 | 163 | if request.method == 'GET': |
|
164 | 164 | form = DeviceForm() |
|
165 | 165 | |
|
166 | 166 | if request.method == 'POST': |
|
167 | 167 | form = DeviceForm(request.POST) |
|
168 | 168 | |
|
169 | 169 | if form.is_valid(): |
|
170 | 170 | form.save() |
|
171 | 171 | return redirect('url_devices') |
|
172 | 172 | |
|
173 | 173 | kwargs = {} |
|
174 | 174 | kwargs['form'] = form |
|
175 | 175 | kwargs['title'] = 'Device' |
|
176 | 176 | kwargs['suptitle'] = 'New' |
|
177 | 177 | kwargs['button'] = 'Create' |
|
178 | 178 | |
|
179 | 179 | return render(request, 'device_edit.html', kwargs) |
|
180 | 180 | |
|
181 | 181 | def device_edit(request, id_dev): |
|
182 | 182 | |
|
183 | 183 | device = get_object_or_404(Device, pk=id_dev) |
|
184 | 184 | |
|
185 | 185 | if request.method=='GET': |
|
186 | 186 | form = DeviceForm(instance=device) |
|
187 | 187 | |
|
188 | 188 | if request.method=='POST': |
|
189 | 189 | form = DeviceForm(request.POST, instance=device) |
|
190 | 190 | |
|
191 | 191 | if form.is_valid(): |
|
192 | 192 | form.save() |
|
193 | 193 | return redirect('url_devices') |
|
194 | 194 | |
|
195 | 195 | kwargs = {} |
|
196 | 196 | kwargs['form'] = form |
|
197 | 197 | kwargs['title'] = 'Device' |
|
198 | 198 | kwargs['suptitle'] = 'Edit' |
|
199 | 199 | kwargs['button'] = 'Update' |
|
200 | 200 | |
|
201 | 201 | return render(request, 'device_edit.html', kwargs) |
|
202 | 202 | |
|
203 | 203 | def device_delete(request, id_dev): |
|
204 | 204 | |
|
205 | 205 | device = get_object_or_404(Device, pk=id_dev) |
|
206 | 206 | |
|
207 | 207 | if request.method=='POST': |
|
208 | 208 | |
|
209 | 209 | if request.user.is_staff: |
|
210 | 210 | device.delete() |
|
211 | 211 | return redirect('url_devices') |
|
212 | 212 | |
|
213 | 213 | return HttpResponse("Not enough permission to delete this object") |
|
214 | 214 | |
|
215 | 215 | kwargs = {'object':device, 'dev_active':'active', |
|
216 | 216 | 'url_cancel':'url_device', 'id_item':id_dev} |
|
217 | 217 | |
|
218 | 218 | return render(request, 'item_delete.html', kwargs) |
|
219 | 219 | |
|
220 | 220 | def campaigns(request): |
|
221 | 221 | |
|
222 | 222 | campaigns = Campaign.objects.all().order_by('start_date') |
|
223 | 223 | |
|
224 | 224 | keys = ['id', 'name', 'start_date', 'end_date'] |
|
225 | 225 | |
|
226 | 226 | kwargs = {} |
|
227 | 227 | kwargs['campaign_keys'] = keys[1:] |
|
228 | 228 | kwargs['campaigns'] = campaigns#.values(*keys) |
|
229 | 229 | kwargs['title'] = 'Campaign' |
|
230 | 230 | kwargs['suptitle'] = 'List' |
|
231 | 231 | kwargs['button'] = 'New Campaign' |
|
232 | 232 | |
|
233 | 233 | return render(request, 'campaigns.html', kwargs) |
|
234 | 234 | |
|
235 | 235 | def campaign(request, id_camp): |
|
236 | 236 | |
|
237 | 237 | campaign = get_object_or_404(Campaign, pk=id_camp) |
|
238 | 238 | experiments = Experiment.objects.filter(campaign=campaign) |
|
239 | 239 | |
|
240 | 240 | form = CampaignForm(instance=campaign) |
|
241 | 241 | |
|
242 | 242 | kwargs = {} |
|
243 | 243 | kwargs['campaign'] = campaign |
|
244 | 244 | kwargs['campaign_keys'] = ['name', 'start_date', 'end_date', 'tags', 'description'] |
|
245 | 245 | |
|
246 | 246 | keys = ['id', 'name', 'start_time', 'end_time'] |
|
247 | 247 | |
|
248 | 248 | kwargs['experiment_keys'] = keys[1:] |
|
249 | 249 | kwargs['experiments'] = experiments.values(*keys) |
|
250 | 250 | |
|
251 | 251 | kwargs['title'] = 'Campaign' |
|
252 | 252 | kwargs['suptitle'] = 'Details' |
|
253 | 253 | |
|
254 | 254 | kwargs['form'] = form |
|
255 | 255 | kwargs['button'] = 'Add Experiment' |
|
256 | 256 | |
|
257 | 257 | return render(request, 'campaign.html', kwargs) |
|
258 | 258 | |
|
259 | 259 | def campaign_new(request): |
|
260 | 260 | |
|
261 | 261 | if request.method == 'GET': |
|
262 | 262 | form = CampaignForm() |
|
263 | 263 | |
|
264 | 264 | if request.method == 'POST': |
|
265 | 265 | form = CampaignForm(request.POST) |
|
266 | 266 | |
|
267 | 267 | if form.is_valid(): |
|
268 | 268 | campaign = form.save() |
|
269 | 269 | return redirect('url_campaign', id_camp=campaign.id) |
|
270 | 270 | |
|
271 | 271 | kwargs = {} |
|
272 | 272 | kwargs['form'] = form |
|
273 | 273 | kwargs['title'] = 'Campaign' |
|
274 | 274 | kwargs['suptitle'] = 'New' |
|
275 | 275 | kwargs['button'] = 'Create' |
|
276 | 276 | |
|
277 | 277 | return render(request, 'campaign_edit.html', kwargs) |
|
278 | 278 | |
|
279 | 279 | def campaign_edit(request, id_camp): |
|
280 | 280 | |
|
281 | 281 | campaign = get_object_or_404(Campaign, pk=id_camp) |
|
282 | 282 | |
|
283 | 283 | if request.method=='GET': |
|
284 | 284 | form = CampaignForm(instance=campaign) |
|
285 | 285 | |
|
286 | 286 | if request.method=='POST': |
|
287 | 287 | form = CampaignForm(request.POST, instance=campaign) |
|
288 | 288 | |
|
289 | 289 | if form.is_valid(): |
|
290 | 290 | form.save() |
|
291 | 291 | return redirect('url_campaign', id_camp=id_camp) |
|
292 | 292 | |
|
293 | 293 | kwargs = {} |
|
294 | 294 | kwargs['form'] = form |
|
295 | 295 | kwargs['title'] = 'Campaign' |
|
296 | 296 | kwargs['suptitle'] = 'Edit' |
|
297 | 297 | kwargs['button'] = 'Update' |
|
298 | 298 | |
|
299 | 299 | return render(request, 'campaign_edit.html', kwargs) |
|
300 | 300 | |
|
301 | 301 | def campaign_delete(request, id_camp): |
|
302 | 302 | |
|
303 | 303 | campaign = get_object_or_404(Campaign, pk=id_camp) |
|
304 | 304 | |
|
305 | 305 | if request.method=='POST': |
|
306 | 306 | if request.user.is_staff: |
|
307 | 307 | campaign.delete() |
|
308 | 308 | return redirect('url_campaigns') |
|
309 | 309 | |
|
310 | 310 | return HttpResponse("Not enough permission to delete this object") |
|
311 | 311 | |
|
312 | 312 | kwargs = {'object':campaign, 'camp_active':'active', |
|
313 | 313 | 'url_cancel':'url_campaign', 'id_item':id_camp} |
|
314 | 314 | |
|
315 | 315 | return render(request, 'item_delete.html', kwargs) |
|
316 | 316 | |
|
317 | 317 | def experiments(request): |
|
318 | 318 | |
|
319 | 319 | experiment_list = Experiment.objects.all().order_by('campaign') |
|
320 | 320 | |
|
321 | 321 | keys = ['id', 'name', 'start_time', 'end_time', 'campaign'] |
|
322 | 322 | |
|
323 | 323 | kwargs = {} |
|
324 | 324 | |
|
325 | 325 | kwargs['experiment_keys'] = keys[1:] |
|
326 | 326 | kwargs['experiments'] = experiment_list#.values(*keys) |
|
327 | 327 | |
|
328 | 328 | kwargs['title'] = 'Experiment' |
|
329 | 329 | kwargs['suptitle'] = 'List' |
|
330 | 330 | kwargs['button'] = 'New Experiment' |
|
331 | 331 | |
|
332 | 332 | return render(request, 'experiments.html', kwargs) |
|
333 | 333 | |
|
334 | 334 | def experiment(request, id_exp): |
|
335 | 335 | |
|
336 | 336 | experiment = get_object_or_404(Experiment, pk=id_exp) |
|
337 | 337 | |
|
338 | 338 | experiments = Experiment.objects.filter(campaign=experiment.campaign) |
|
339 | 339 | configurations = Configuration.objects.filter(experiment=experiment, type=0) |
|
340 | 340 | |
|
341 | 341 | kwargs = {} |
|
342 | 342 | |
|
343 | 343 | exp_keys = ['id', 'campaign', 'name', 'start_time', 'end_time'] |
|
344 | 344 | conf_keys = ['id', 'device__name', 'device__device_type', 'device__ip_address', 'device__port_address'] |
|
345 | 345 | |
|
346 | 346 | conf_labels = ['id', 'device__name', 'device_type', 'ip_address', 'port_address'] |
|
347 | 347 | |
|
348 | 348 | kwargs['experiment_keys'] = exp_keys[1:] |
|
349 | 349 | kwargs['experiment'] = experiment |
|
350 | 350 | |
|
351 | 351 | kwargs['experiments'] = experiments.values(*exp_keys) |
|
352 | 352 | |
|
353 | 353 | kwargs['configuration_labels'] = conf_labels[1:] |
|
354 | 354 | kwargs['configuration_keys'] = conf_keys[1:] |
|
355 | 355 | kwargs['configurations'] = configurations #.values(*conf_keys) |
|
356 | 356 | |
|
357 | 357 | kwargs['title'] = 'Experiment' |
|
358 | 358 | kwargs['suptitle'] = 'Details' |
|
359 | 359 | |
|
360 | 360 | kwargs['button'] = 'Add Configuration' |
|
361 | 361 | |
|
362 | 362 | return render(request, 'experiment.html', kwargs) |
|
363 | 363 | |
|
364 | 364 | def experiment_new(request, id_camp=0): |
|
365 | 365 | |
|
366 | 366 | if request.method == 'GET': |
|
367 | 367 | form = ExperimentForm(initial={'campaign':id_camp}) |
|
368 | 368 | |
|
369 | 369 | if request.method == 'POST': |
|
370 | 370 | form = ExperimentForm(request.POST, initial={'campaign':id_camp}) |
|
371 | 371 | |
|
372 | 372 | if form.is_valid(): |
|
373 | 373 | experiment = form.save() |
|
374 | 374 | return redirect('url_experiment', id_exp=experiment.id) |
|
375 | 375 | |
|
376 | 376 | kwargs = {} |
|
377 | 377 | kwargs['form'] = form |
|
378 | 378 | kwargs['title'] = 'Experiment' |
|
379 | 379 | kwargs['suptitle'] = 'New' |
|
380 | 380 | kwargs['button'] = 'Create' |
|
381 | 381 | |
|
382 | 382 | return render(request, 'experiment_edit.html', kwargs) |
|
383 | 383 | |
|
384 | 384 | def experiment_edit(request, id_exp): |
|
385 | 385 | |
|
386 | 386 | experiment = get_object_or_404(Experiment, pk=id_exp) |
|
387 | 387 | |
|
388 | 388 | if request.method == 'GET': |
|
389 | 389 | form = ExperimentForm(instance=experiment) |
|
390 | 390 | |
|
391 | 391 | if request.method=='POST': |
|
392 | 392 | form = ExperimentForm(request.POST, instance=experiment) |
|
393 | 393 | |
|
394 | 394 | if form.is_valid(): |
|
395 | 395 | experiment = form.save() |
|
396 | 396 | return redirect('url_experiment', id_exp=experiment.id) |
|
397 | 397 | |
|
398 | 398 | kwargs = {} |
|
399 | 399 | kwargs['form'] = form |
|
400 | 400 | kwargs['title'] = 'Experiment' |
|
401 | 401 | kwargs['suptitle'] = 'Edit' |
|
402 | 402 | kwargs['button'] = 'Update' |
|
403 | 403 | |
|
404 | 404 | return render(request, 'experiment_edit.html', kwargs) |
|
405 | 405 | |
|
406 | 406 | def experiment_delete(request, id_exp): |
|
407 | 407 | |
|
408 | 408 | experiment = get_object_or_404(Experiment, pk=id_exp) |
|
409 | 409 | |
|
410 | 410 | if request.method=='POST': |
|
411 | 411 | if request.user.is_staff: |
|
412 | 412 | id_camp = experiment.campaign.id |
|
413 | 413 | experiment.delete() |
|
414 | 414 | return redirect('url_campaign', id_camp=id_camp) |
|
415 | 415 | |
|
416 | 416 | return HttpResponse("Not enough permission to delete this object") |
|
417 | 417 | |
|
418 | 418 | kwargs = {'object':experiment, 'exp_active':'active', |
|
419 | 419 | 'url_cancel':'url_experiment', 'id_item':id_exp} |
|
420 | 420 | |
|
421 | 421 | return render(request, 'item_delete.html', kwargs) |
|
422 | 422 | |
|
423 | 423 | def dev_confs(request): |
|
424 | 424 | |
|
425 | 425 | configurations = Configuration.objects.all().order_by('type', 'device__device_type', 'experiment') |
|
426 | 426 | |
|
427 | 427 | # keys = ['id', 'device__device_type__name', 'device__name', 'experiment__campaign__name', 'experiment__name'] |
|
428 | 428 | |
|
429 | 429 | keys = ['id', 'device', 'experiment', 'type', 'programmed_date'] |
|
430 | 430 | |
|
431 | 431 | kwargs = {} |
|
432 | 432 | |
|
433 | 433 | kwargs['configuration_keys'] = keys[1:] |
|
434 | 434 | kwargs['configurations'] = configurations#.values(*keys) |
|
435 | 435 | |
|
436 | 436 | kwargs['title'] = 'Configuration' |
|
437 | 437 | kwargs['suptitle'] = 'List' |
|
438 | 438 | kwargs['button'] = 'New Configuration' |
|
439 | 439 | |
|
440 | 440 | return render(request, 'dev_confs.html', kwargs) |
|
441 | 441 | |
|
442 | 442 | def dev_conf(request, id_conf): |
|
443 | 443 | |
|
444 | 444 | conf = get_object_or_404(Configuration, pk=id_conf) |
|
445 | 445 | |
|
446 | 446 | DevConfModel = CONF_MODELS[conf.device.device_type.name] |
|
447 | 447 | dev_conf = DevConfModel.objects.get(pk=id_conf) |
|
448 | 448 | |
|
449 | 449 | kwargs = {} |
|
450 | 450 | kwargs['dev_conf'] = dev_conf |
|
451 | 451 | kwargs['dev_conf_keys'] = ['experiment', 'device'] |
|
452 | 452 | |
|
453 | 453 | kwargs['title'] = 'Configuration' |
|
454 | 454 | kwargs['suptitle'] = 'Details' |
|
455 | 455 | |
|
456 | 456 | kwargs['button'] = 'Edit Configuration' |
|
457 | 457 | |
|
458 | 458 | ###### SIDEBAR ###### |
|
459 | 459 | kwargs.update(sidebar(conf)) |
|
460 | 460 | |
|
461 | 461 | return render(request, 'dev_conf.html', kwargs) |
|
462 | 462 | |
|
463 | 463 | def dev_conf_new(request, id_exp=0): |
|
464 | 464 | |
|
465 | 465 | if request.method == 'GET': |
|
466 | 466 | form = ConfigurationForm(initial={'experiment':id_exp}) |
|
467 | 467 | |
|
468 | 468 | if request.method == 'POST': |
|
469 | 469 | form = ConfigurationForm(request.POST) |
|
470 | 470 | |
|
471 | 471 | if form.is_valid(): |
|
472 | 472 | experiment = Experiment.objects.get(pk=request.POST['experiment']) |
|
473 | 473 | device = Device.objects.get(pk=request.POST['device']) |
|
474 | 474 | |
|
475 | 475 | exp_devices = Device.objects.filter(configuration__experiment=experiment, |
|
476 | 476 | configuration__type=0) |
|
477 | 477 | |
|
478 | 478 | if device.id not in exp_devices.values('id',): |
|
479 | 479 | |
|
480 | 480 | DevConfModel = CONF_MODELS[device.device_type.name] |
|
481 | 481 | conf = DevConfModel(experiment=experiment, device=device) |
|
482 | 482 | conf.save() |
|
483 | 483 | |
|
484 | 484 | return redirect('url_experiment', id_exp=experiment.id) |
|
485 | 485 | |
|
486 | 486 | kwargs = {} |
|
487 | 487 | kwargs['form'] = form |
|
488 | 488 | kwargs['title'] = 'Configuration' |
|
489 | 489 | kwargs['suptitle'] = 'New' |
|
490 | 490 | kwargs['button'] = 'Create' |
|
491 | 491 | |
|
492 | 492 | return render(request, 'dev_conf_edit.html', kwargs) |
|
493 | 493 | |
|
494 | 494 | def dev_conf_edit(request, id_conf): |
|
495 | 495 | |
|
496 | 496 | conf = get_object_or_404(Configuration, pk=id_conf) |
|
497 | 497 | |
|
498 | 498 | DevConfModel = CONF_MODELS[conf.device.device_type.name] |
|
499 | 499 | DevConfForm = CONF_FORMS[conf.device.device_type.name] |
|
500 | 500 | |
|
501 | 501 | dev_conf = DevConfModel.objects.get(pk=id_conf) |
|
502 | 502 | |
|
503 | 503 | if request.method=='GET': |
|
504 | 504 | form = DevConfForm(instance=dev_conf) |
|
505 | 505 | |
|
506 | 506 | if request.method=='POST': |
|
507 | 507 | form = DevConfForm(request.POST, instance=dev_conf) |
|
508 | 508 | |
|
509 | 509 | if form.is_valid(): |
|
510 | 510 | form.save() |
|
511 | 511 | return redirect('url_dev_conf', id_conf=id_conf) |
|
512 | 512 | |
|
513 | 513 | kwargs = {} |
|
514 | 514 | kwargs['form'] = form |
|
515 | 515 | kwargs['title'] = 'Device Configuration' |
|
516 | 516 | kwargs['suptitle'] = 'Edit' |
|
517 | 517 | kwargs['button'] = 'Update' |
|
518 | 518 | |
|
519 | 519 | ###### SIDEBAR ###### |
|
520 | 520 | kwargs.update(sidebar(conf)) |
|
521 | 521 | |
|
522 | 522 | return render(request, 'dev_conf_edit.html', kwargs) |
|
523 | 523 | |
|
524 | 524 | def dev_conf_read(request, id_conf): |
|
525 | 525 | |
|
526 | 526 | conf = get_object_or_404(Configuration, pk=id_conf) |
|
527 | 527 | |
|
528 | 528 | messages.error(request, "Read View not implemented yet") |
|
529 | 529 | |
|
530 | 530 | return redirect('url_dev_conf', id_conf=conf.id) |
|
531 | 531 | |
|
532 | 532 | def dev_conf_write(request, id_conf): |
|
533 | 533 | |
|
534 | 534 | conf = get_object_or_404(Configuration, pk=id_conf) |
|
535 | 535 | |
|
536 | 536 | messages.error(request, "Write View not implemented yet") |
|
537 | 537 | |
|
538 | 538 | return redirect('url_dev_conf', id_conf=conf.id) |
|
539 | 539 | |
|
540 | 540 | def dev_conf_import(request, id_conf): |
|
541 | 541 | |
|
542 | 542 | conf = get_object_or_404(Configuration, pk=id_conf) |
|
543 | 543 | |
|
544 | 544 | messages.error(request, "Import View not implemented yet") |
|
545 | 545 | |
|
546 | 546 | return redirect('url_dev_conf', id_conf=conf.id) |
|
547 | 547 | |
|
548 | 548 | def dev_conf_export(request, id_conf): |
|
549 | 549 | |
|
550 | 550 | conf = get_object_or_404(Configuration, pk=id_conf) |
|
551 | 551 | |
|
552 | 552 | messages.error(request, "Export View not implemented yet") |
|
553 | 553 | |
|
554 | 554 | return redirect('url_dev_conf', id_conf=conf.id) |
|
555 | 555 | |
|
556 | 556 | def dev_conf_delete(request, id_conf): |
|
557 | 557 | |
|
558 | 558 | conf = get_object_or_404(Configuration, pk=id_conf) |
|
559 | 559 | |
|
560 | 560 | if request.method=='POST': |
|
561 | 561 | if request.user.is_staff: |
|
562 | 562 | id_exp = conf.experiment.id |
|
563 | 563 | conf.delete() |
|
564 | 564 | return redirect('url_experiment', id_exp=id_exp) |
|
565 | 565 | |
|
566 | 566 | return HttpResponse("Not enough permission to delete this object") |
|
567 | 567 | |
|
568 | 568 | kwargs = {'object':conf, 'conf_active':'active', |
|
569 | 569 | 'url_cancel':'url_dev_conf', 'id_item':id_conf} |
|
570 | 570 | |
|
571 | 571 | ###### SIDEBAR ###### |
|
572 | 572 | kwargs.update(sidebar(conf)) |
|
573 | 573 | |
|
574 | 574 | return render(request, 'item_delete.html', kwargs) |
|
575 | 575 | |
|
576 | 576 | def sidebar(conf): |
|
577 | 577 | |
|
578 | 578 | experiments = Experiment.objects.filter(campaign=conf.experiment.campaign) |
|
579 | 579 | configurations = Configuration.objects.filter(experiment=conf.experiment, type=0) |
|
580 | 580 | |
|
581 | 581 | exp_keys = ['id', 'campaign', 'name', 'start_time', 'end_time'] |
|
582 | 582 | conf_keys = ['id', 'device'] |
|
583 | 583 | |
|
584 | 584 | kwargs = {} |
|
585 | 585 | |
|
586 | 586 | kwargs['dev_conf'] = conf |
|
587 | 587 | |
|
588 | 588 | kwargs['experiment_keys'] = exp_keys[1:] |
|
589 | 589 | kwargs['experiments'] = experiments.values(*exp_keys) |
|
590 | 590 | |
|
591 | 591 | kwargs['configuration_keys'] = conf_keys[1:] |
|
592 | 592 | kwargs['configurations'] = configurations #.values(*conf_keys) |
|
593 | 593 | |
|
594 | return kwargs No newline at end of file | |
|
594 | return kwargs | |
|
595 | ||
|
596 | ||
|
597 | def operation(request): | |
|
598 | pass | |
|
599 | ||
|
600 |
@@ -1,31 +1,32 | |||
|
1 | 1 | """radarsys URL Configuration |
|
2 | 2 | |
|
3 | 3 | The `urlpatterns` list routes URLs to views. For more information please see: |
|
4 | 4 | https://docs.djangoproject.com/en/1.8/topics/http/urls/ |
|
5 | 5 | Examples: |
|
6 | 6 | Function views |
|
7 | 7 | 1. Add an import: from my_app import views |
|
8 | 8 | 2. Add a URL to urlpatterns: url(r'^$', views.home, name='home') |
|
9 | 9 | Class-based views |
|
10 | 10 | 1. Add an import: from other_app.views import Home |
|
11 | 11 | 2. Add a URL to urlpatterns: url(r'^$', Home.as_view(), name='home') |
|
12 | 12 | Including another URLconf |
|
13 | 13 | 1. Add an import: from blog import urls as blog_urls |
|
14 | 14 | 2. Add a URL to urlpatterns: url(r'^blog/', include(blog_urls)) |
|
15 | 15 | """ |
|
16 | 16 | from django.conf.urls import include, url |
|
17 | 17 | from django.contrib import admin |
|
18 | 18 | |
|
19 | 19 | urlpatterns = [ |
|
20 | 20 | url(r'^$', 'apps.main.views.index', name='index'), |
|
21 | url(r'^operation/', 'apps.main.views.operation', name='url_operation'), | |
|
21 | 22 | url(r'^admin/', include(admin.site.urls)), |
|
22 | 23 | url(r'^accounts/', include('apps.accounts.urls')), |
|
23 | 24 | url(r'^', include('apps.main.urls')), |
|
24 | 25 | url(r'^rc/', include('apps.rc.urls')), |
|
25 | 26 | url(r'^dds/', include('apps.dds.urls')), |
|
26 | 27 | url(r'^cgs/', include('apps.cgs.urls')), |
|
27 | 28 | url(r'^jars/', include('apps.jars.urls')), |
|
28 | 29 | url(r'^usrp/', include('apps.usrp.urls')), |
|
29 | 30 | url(r'^abs/', include('apps.abs.urls')), |
|
30 | 31 | url(r'^misc/', include('apps.misc.urls')), |
|
31 | 32 | ] |
General Comments 0
You need to be logged in to leave comments.
Login now