@@ -1,888 +1,891 | |||||
1 | from django.shortcuts import render, redirect, get_object_or_404, HttpResponse |
|
1 | from django.shortcuts import render, redirect, get_object_or_404, HttpResponse | |
2 | from django.contrib import messages |
|
2 | from django.contrib import messages | |
3 |
|
3 | |||
4 | from .forms import CampaignForm, ExperimentForm, DeviceForm, ConfigurationForm, LocationForm, UploadFileForm, DownloadFileForm, OperationForm |
|
4 | from .forms import CampaignForm, ExperimentForm, DeviceForm, ConfigurationForm, LocationForm, UploadFileForm, DownloadFileForm, OperationForm | |
5 | from .forms import OperationSearchForm |
|
5 | from .forms import OperationSearchForm | |
6 | from apps.cgs.forms import CGSConfigurationForm |
|
6 | from apps.cgs.forms import CGSConfigurationForm | |
7 | from apps.jars.forms import JARSConfigurationForm |
|
7 | from apps.jars.forms import JARSConfigurationForm | |
8 | from apps.usrp.forms import USRPConfigurationForm |
|
8 | from apps.usrp.forms import USRPConfigurationForm | |
9 | from apps.abs.forms import ABSConfigurationForm |
|
9 | from apps.abs.forms import ABSConfigurationForm | |
10 | from apps.rc.forms import RCConfigurationForm |
|
10 | from apps.rc.forms import RCConfigurationForm | |
11 | from apps.dds.forms import DDSConfigurationForm |
|
11 | from apps.dds.forms import DDSConfigurationForm | |
12 |
|
12 | |||
13 | from .models import Campaign, Experiment, Device, Configuration, Location#, RunningExperiment |
|
13 | from .models import Campaign, Experiment, Device, Configuration, Location#, RunningExperiment | |
14 | from apps.cgs.models import CGSConfiguration |
|
14 | from apps.cgs.models import CGSConfiguration | |
15 | from apps.jars.models import JARSConfiguration |
|
15 | from apps.jars.models import JARSConfiguration | |
16 | from apps.usrp.models import USRPConfiguration |
|
16 | from apps.usrp.models import USRPConfiguration | |
17 | from apps.abs.models import ABSConfiguration |
|
17 | from apps.abs.models import ABSConfiguration | |
18 | from apps.rc.models import RCConfiguration |
|
18 | from apps.rc.models import RCConfiguration | |
19 | from apps.dds.models import DDSConfiguration |
|
19 | from apps.dds.models import DDSConfiguration | |
20 |
|
20 | |||
21 | # Create your views here. |
|
21 | # Create your views here. | |
22 |
|
22 | |||
23 | CONF_FORMS = { |
|
23 | CONF_FORMS = { | |
24 | 'rc': RCConfigurationForm, |
|
24 | 'rc': RCConfigurationForm, | |
25 | 'dds': DDSConfigurationForm, |
|
25 | 'dds': DDSConfigurationForm, | |
26 | 'jars': JARSConfigurationForm, |
|
26 | 'jars': JARSConfigurationForm, | |
27 | 'cgs': CGSConfigurationForm, |
|
27 | 'cgs': CGSConfigurationForm, | |
28 | 'abs': ABSConfigurationForm, |
|
28 | 'abs': ABSConfigurationForm, | |
29 | 'usrp': USRPConfigurationForm, |
|
29 | 'usrp': USRPConfigurationForm, | |
30 | } |
|
30 | } | |
31 |
|
31 | |||
32 | CONF_MODELS = { |
|
32 | CONF_MODELS = { | |
33 | 'rc': RCConfiguration, |
|
33 | 'rc': RCConfiguration, | |
34 | 'dds': DDSConfiguration, |
|
34 | 'dds': DDSConfiguration, | |
35 | 'jars': JARSConfiguration, |
|
35 | 'jars': JARSConfiguration, | |
36 | 'cgs': CGSConfiguration, |
|
36 | 'cgs': CGSConfiguration, | |
37 | 'abs': ABSConfiguration, |
|
37 | 'abs': ABSConfiguration, | |
38 | 'usrp': USRPConfiguration, |
|
38 | 'usrp': USRPConfiguration, | |
39 | } |
|
39 | } | |
40 |
|
40 | |||
41 | def index(request): |
|
41 | def index(request): | |
42 | kwargs = {} |
|
42 | kwargs = {} | |
43 |
|
43 | |||
44 | return render(request, 'index.html', kwargs) |
|
44 | return render(request, 'index.html', kwargs) | |
45 |
|
45 | |||
46 | def locations(request): |
|
46 | def locations(request): | |
47 |
|
47 | |||
48 | locations = Location.objects.all().order_by('name') |
|
48 | locations = Location.objects.all().order_by('name') | |
49 |
|
49 | |||
50 | keys = ['id', 'name', 'description'] |
|
50 | keys = ['id', 'name', 'description'] | |
51 |
|
51 | |||
52 | kwargs = {} |
|
52 | kwargs = {} | |
53 | kwargs['location_keys'] = keys[1:] |
|
53 | kwargs['location_keys'] = keys[1:] | |
54 | kwargs['locations'] = locations |
|
54 | kwargs['locations'] = locations | |
55 | kwargs['title'] = 'Location' |
|
55 | kwargs['title'] = 'Location' | |
56 | kwargs['suptitle'] = 'List' |
|
56 | kwargs['suptitle'] = 'List' | |
57 | kwargs['button'] = 'New Location' |
|
57 | kwargs['button'] = 'New Location' | |
58 |
|
58 | |||
59 | return render(request, 'locations.html', kwargs) |
|
59 | return render(request, 'locations.html', kwargs) | |
60 |
|
60 | |||
61 | def location(request, id_loc): |
|
61 | def location(request, id_loc): | |
62 |
|
62 | |||
63 | location = get_object_or_404(Location, pk=id_loc) |
|
63 | location = get_object_or_404(Location, pk=id_loc) | |
64 |
|
64 | |||
65 | kwargs = {} |
|
65 | kwargs = {} | |
66 | kwargs['location'] = location |
|
66 | kwargs['location'] = location | |
67 | kwargs['location_keys'] = ['name', 'description'] |
|
67 | kwargs['location_keys'] = ['name', 'description'] | |
68 |
|
68 | |||
69 | kwargs['title'] = 'Location' |
|
69 | kwargs['title'] = 'Location' | |
70 | kwargs['suptitle'] = 'Details' |
|
70 | kwargs['suptitle'] = 'Details' | |
71 |
|
71 | |||
72 | return render(request, 'location.html', kwargs) |
|
72 | return render(request, 'location.html', kwargs) | |
73 |
|
73 | |||
74 | #def location_play(request, id_camp, id_loc): |
|
74 | #def location_play(request, id_camp, id_loc): | |
75 |
|
75 | |||
76 | # campaign = get_object_or_404(Campaign, pk=id_camp) |
|
76 | # campaign = get_object_or_404(Campaign, pk=id_camp) | |
77 | # print campaign |
|
77 | # print campaign | |
78 | # location = get_object_or_404(Location, pk=id_loc) |
|
78 | # location = get_object_or_404(Location, pk=id_loc) | |
79 | # experiments = Experiment.objects.filter(location__pk=location.id).filter(campaign__pk=campaign.id) |
|
79 | # experiments = Experiment.objects.filter(location__pk=location.id).filter(campaign__pk=campaign.id) | |
80 | # locations = Location.objects.filter(pk=id_loc) |
|
80 | # locations = Location.objects.filter(pk=id_loc) | |
81 |
|
81 | |||
82 | # if request.method=='GET': |
|
82 | # if request.method=='GET': | |
83 | # form = OperationForm(initial={'campaign': campaign.id}) |
|
83 | # form = OperationForm(initial={'campaign': campaign.id}) | |
84 |
|
84 | |||
85 | # kwargs = {} |
|
85 | # kwargs = {} | |
86 | #---Campaign |
|
86 | #---Campaign | |
87 | # kwargs['campaign'] = campaign |
|
87 | # kwargs['campaign'] = campaign | |
88 | # kwargs['campaign_keys'] = ['name', 'start_date', 'end_date', 'tags', 'description'] |
|
88 | # kwargs['campaign_keys'] = ['name', 'start_date', 'end_date', 'tags', 'description'] | |
89 | #---Experiment |
|
89 | #---Experiment | |
90 | # keys = ['id', 'name', 'start_time', 'end_time'] |
|
90 | # keys = ['id', 'name', 'start_time', 'end_time'] | |
91 | # kwargs['experiment_keys'] = keys[1:] |
|
91 | # kwargs['experiment_keys'] = keys[1:] | |
92 | # kwargs['experiments'] = experiments |
|
92 | # kwargs['experiments'] = experiments | |
93 | #---Radar |
|
93 | #---Radar | |
94 | # kwargs['location'] = location |
|
94 | # kwargs['location'] = location | |
95 | #---Else |
|
95 | #---Else | |
96 | # kwargs['title'] = 'Campaign' |
|
96 | # kwargs['title'] = 'Campaign' | |
97 | # kwargs['suptitle'] = campaign.name |
|
97 | # kwargs['suptitle'] = campaign.name | |
98 | # kwargs['form'] = form |
|
98 | # kwargs['form'] = form | |
99 | # kwargs['button'] = 'Search' |
|
99 | # kwargs['button'] = 'Search' | |
100 |
|
100 | |||
101 | # return render(request, 'operation_play.html', kwargs) |
|
101 | # return render(request, 'operation_play.html', kwargs) | |
102 |
|
102 | |||
103 | def location_new(request): |
|
103 | def location_new(request): | |
104 |
|
104 | |||
105 | if request.method == 'GET': |
|
105 | if request.method == 'GET': | |
106 | form = LocationForm() |
|
106 | form = LocationForm() | |
107 |
|
107 | |||
108 | if request.method == 'POST': |
|
108 | if request.method == 'POST': | |
109 | form = LocationForm(request.POST) |
|
109 | form = LocationForm(request.POST) | |
110 |
|
110 | |||
111 | if form.is_valid(): |
|
111 | if form.is_valid(): | |
112 | form.save() |
|
112 | form.save() | |
113 | return redirect('url_locations') |
|
113 | return redirect('url_locations') | |
114 |
|
114 | |||
115 | kwargs = {} |
|
115 | kwargs = {} | |
116 | kwargs['form'] = form |
|
116 | kwargs['form'] = form | |
117 | kwargs['title'] = 'Location' |
|
117 | kwargs['title'] = 'Location' | |
118 | kwargs['suptitle'] = 'New' |
|
118 | kwargs['suptitle'] = 'New' | |
119 | kwargs['button'] = 'Create' |
|
119 | kwargs['button'] = 'Create' | |
120 |
|
120 | |||
121 | return render(request, 'location_edit.html', kwargs) |
|
121 | return render(request, 'location_edit.html', kwargs) | |
122 |
|
122 | |||
123 | def location_edit(request, id_loc): |
|
123 | def location_edit(request, id_loc): | |
124 |
|
124 | |||
125 | location = get_object_or_404(Location, pk=id_loc) |
|
125 | location = get_object_or_404(Location, pk=id_loc) | |
126 |
|
126 | |||
127 | if request.method=='GET': |
|
127 | if request.method=='GET': | |
128 | form = LocationForm(instance=location) |
|
128 | form = LocationForm(instance=location) | |
129 |
|
129 | |||
130 | if request.method=='POST': |
|
130 | if request.method=='POST': | |
131 | form = LocationForm(request.POST, instance=location) |
|
131 | form = LocationForm(request.POST, instance=location) | |
132 |
|
132 | |||
133 | if form.is_valid(): |
|
133 | if form.is_valid(): | |
134 | form.save() |
|
134 | form.save() | |
135 | return redirect('url_locations') |
|
135 | return redirect('url_locations') | |
136 |
|
136 | |||
137 | kwargs = {} |
|
137 | kwargs = {} | |
138 | kwargs['form'] = form |
|
138 | kwargs['form'] = form | |
139 | kwargs['title'] = 'Location' |
|
139 | kwargs['title'] = 'Location' | |
140 | kwargs['suptitle'] = 'Edit' |
|
140 | kwargs['suptitle'] = 'Edit' | |
141 | kwargs['button'] = 'Update' |
|
141 | kwargs['button'] = 'Update' | |
142 |
|
142 | |||
143 | return render(request, 'location_edit.html', kwargs) |
|
143 | return render(request, 'location_edit.html', kwargs) | |
144 |
|
144 | |||
145 | def location_delete(request, id_loc): |
|
145 | def location_delete(request, id_loc): | |
146 |
|
146 | |||
147 | location = get_object_or_404(Location, pk=id_loc) |
|
147 | location = get_object_or_404(Location, pk=id_loc) | |
148 |
|
148 | |||
149 | if request.method=='POST': |
|
149 | if request.method=='POST': | |
150 |
|
150 | |||
151 | if request.user.is_staff: |
|
151 | if request.user.is_staff: | |
152 | location.delete() |
|
152 | location.delete() | |
153 | return redirect('url_locations') |
|
153 | return redirect('url_locations') | |
154 |
|
154 | |||
155 | return HttpResponse("Not enough permission to delete this object") |
|
155 | return HttpResponse("Not enough permission to delete this object") | |
156 |
|
156 | |||
157 | kwargs = {'object':location, 'loc_active':'active', |
|
157 | kwargs = {'object':location, 'loc_active':'active', | |
158 | 'url_cancel':'url_location', 'id_item':id_loc} |
|
158 | 'url_cancel':'url_location', 'id_item':id_loc} | |
159 |
|
159 | |||
160 | return render(request, 'item_delete.html', kwargs) |
|
160 | return render(request, 'item_delete.html', kwargs) | |
161 |
|
161 | |||
162 | def devices(request): |
|
162 | def devices(request): | |
163 |
|
163 | |||
164 | devices = Device.objects.all().order_by('device_type__name') |
|
164 | devices = Device.objects.all().order_by('device_type__name') | |
165 |
|
165 | |||
166 | # keys = ['id', 'device_type__name', 'name', 'ip_address'] |
|
166 | # keys = ['id', 'device_type__name', 'name', 'ip_address'] | |
167 | keys = ['id', 'name', 'ip_address', 'port_address', 'device_type'] |
|
167 | keys = ['id', 'name', 'ip_address', 'port_address', 'device_type'] | |
168 |
|
168 | |||
169 | kwargs = {} |
|
169 | kwargs = {} | |
170 | kwargs['device_keys'] = keys[1:] |
|
170 | kwargs['device_keys'] = keys[1:] | |
171 | kwargs['devices'] = devices#.values(*keys) |
|
171 | kwargs['devices'] = devices#.values(*keys) | |
172 | kwargs['title'] = 'Device' |
|
172 | kwargs['title'] = 'Device' | |
173 | kwargs['suptitle'] = 'List' |
|
173 | kwargs['suptitle'] = 'List' | |
174 | kwargs['button'] = 'New Device' |
|
174 | kwargs['button'] = 'New Device' | |
175 |
|
175 | |||
176 | return render(request, 'devices.html', kwargs) |
|
176 | return render(request, 'devices.html', kwargs) | |
177 |
|
177 | |||
178 | def device(request, id_dev): |
|
178 | def device(request, id_dev): | |
179 |
|
179 | |||
180 | device = get_object_or_404(Device, pk=id_dev) |
|
180 | device = get_object_or_404(Device, pk=id_dev) | |
181 |
|
181 | |||
182 | kwargs = {} |
|
182 | kwargs = {} | |
183 | kwargs['device'] = device |
|
183 | kwargs['device'] = device | |
184 | kwargs['device_keys'] = ['device_type', 'name', 'ip_address', 'port_address', 'description'] |
|
184 | kwargs['device_keys'] = ['device_type', 'name', 'ip_address', 'port_address', 'description'] | |
185 |
|
185 | |||
186 | kwargs['title'] = 'Device' |
|
186 | kwargs['title'] = 'Device' | |
187 | kwargs['suptitle'] = 'Details' |
|
187 | kwargs['suptitle'] = 'Details' | |
188 |
|
188 | |||
189 | return render(request, 'device.html', kwargs) |
|
189 | return render(request, 'device.html', kwargs) | |
190 |
|
190 | |||
191 | def device_new(request): |
|
191 | def device_new(request): | |
192 |
|
192 | |||
193 | if request.method == 'GET': |
|
193 | if request.method == 'GET': | |
194 | form = DeviceForm() |
|
194 | form = DeviceForm() | |
195 |
|
195 | |||
196 | if request.method == 'POST': |
|
196 | if request.method == 'POST': | |
197 | form = DeviceForm(request.POST) |
|
197 | form = DeviceForm(request.POST) | |
198 |
|
198 | |||
199 | if form.is_valid(): |
|
199 | if form.is_valid(): | |
200 | form.save() |
|
200 | form.save() | |
201 | return redirect('url_devices') |
|
201 | return redirect('url_devices') | |
202 |
|
202 | |||
203 | kwargs = {} |
|
203 | kwargs = {} | |
204 | kwargs['form'] = form |
|
204 | kwargs['form'] = form | |
205 | kwargs['title'] = 'Device' |
|
205 | kwargs['title'] = 'Device' | |
206 | kwargs['suptitle'] = 'New' |
|
206 | kwargs['suptitle'] = 'New' | |
207 | kwargs['button'] = 'Create' |
|
207 | kwargs['button'] = 'Create' | |
208 |
|
208 | |||
209 | return render(request, 'device_edit.html', kwargs) |
|
209 | return render(request, 'device_edit.html', kwargs) | |
210 |
|
210 | |||
211 | def device_edit(request, id_dev): |
|
211 | def device_edit(request, id_dev): | |
212 |
|
212 | |||
213 | device = get_object_or_404(Device, pk=id_dev) |
|
213 | device = get_object_or_404(Device, pk=id_dev) | |
214 |
|
214 | |||
215 | if request.method=='GET': |
|
215 | if request.method=='GET': | |
216 | form = DeviceForm(instance=device) |
|
216 | form = DeviceForm(instance=device) | |
217 |
|
217 | |||
218 | if request.method=='POST': |
|
218 | if request.method=='POST': | |
219 | form = DeviceForm(request.POST, instance=device) |
|
219 | form = DeviceForm(request.POST, instance=device) | |
220 |
|
220 | |||
221 | if form.is_valid(): |
|
221 | if form.is_valid(): | |
222 | form.save() |
|
222 | form.save() | |
223 | return redirect('url_devices') |
|
223 | return redirect('url_devices') | |
224 |
|
224 | |||
225 | kwargs = {} |
|
225 | kwargs = {} | |
226 | kwargs['form'] = form |
|
226 | kwargs['form'] = form | |
227 | kwargs['title'] = 'Device' |
|
227 | kwargs['title'] = 'Device' | |
228 | kwargs['suptitle'] = 'Edit' |
|
228 | kwargs['suptitle'] = 'Edit' | |
229 | kwargs['button'] = 'Update' |
|
229 | kwargs['button'] = 'Update' | |
230 |
|
230 | |||
231 | return render(request, 'device_edit.html', kwargs) |
|
231 | return render(request, 'device_edit.html', kwargs) | |
232 |
|
232 | |||
233 | def device_delete(request, id_dev): |
|
233 | def device_delete(request, id_dev): | |
234 |
|
234 | |||
235 | device = get_object_or_404(Device, pk=id_dev) |
|
235 | device = get_object_or_404(Device, pk=id_dev) | |
236 |
|
236 | |||
237 | if request.method=='POST': |
|
237 | if request.method=='POST': | |
238 |
|
238 | |||
239 | if request.user.is_staff: |
|
239 | if request.user.is_staff: | |
240 | device.delete() |
|
240 | device.delete() | |
241 | return redirect('url_devices') |
|
241 | return redirect('url_devices') | |
242 |
|
242 | |||
243 | return HttpResponse("Not enough permission to delete this object") |
|
243 | return HttpResponse("Not enough permission to delete this object") | |
244 |
|
244 | |||
245 | kwargs = {'object':device, 'dev_active':'active', |
|
245 | kwargs = {'object':device, 'dev_active':'active', | |
246 | 'url_cancel':'url_device', 'id_item':id_dev} |
|
246 | 'url_cancel':'url_device', 'id_item':id_dev} | |
247 |
|
247 | |||
248 | return render(request, 'item_delete.html', kwargs) |
|
248 | return render(request, 'item_delete.html', kwargs) | |
249 |
|
249 | |||
250 | def campaigns(request): |
|
250 | def campaigns(request): | |
251 |
|
251 | |||
252 | campaigns = Campaign.objects.all().order_by('start_date') |
|
252 | campaigns = Campaign.objects.all().order_by('start_date') | |
253 |
|
253 | |||
254 | keys = ['id', 'name', 'start_date', 'end_date'] |
|
254 | keys = ['id', 'name', 'start_date', 'end_date'] | |
255 |
|
255 | |||
256 | kwargs = {} |
|
256 | kwargs = {} | |
257 | kwargs['campaign_keys'] = keys[1:] |
|
257 | kwargs['campaign_keys'] = keys[1:] | |
258 | kwargs['campaigns'] = campaigns#.values(*keys) |
|
258 | kwargs['campaigns'] = campaigns#.values(*keys) | |
259 | kwargs['title'] = 'Campaign' |
|
259 | kwargs['title'] = 'Campaign' | |
260 | kwargs['suptitle'] = 'List' |
|
260 | kwargs['suptitle'] = 'List' | |
261 | kwargs['button'] = 'New Campaign' |
|
261 | kwargs['button'] = 'New Campaign' | |
262 |
|
262 | |||
263 | return render(request, 'campaigns.html', kwargs) |
|
263 | return render(request, 'campaigns.html', kwargs) | |
264 |
|
264 | |||
265 | def campaign(request, id_camp): |
|
265 | def campaign(request, id_camp): | |
266 |
|
266 | |||
267 | campaign = get_object_or_404(Campaign, pk=id_camp) |
|
267 | campaign = get_object_or_404(Campaign, pk=id_camp) | |
268 | experiments = Experiment.objects.filter(campaign=campaign) |
|
268 | experiments = Experiment.objects.filter(campaign=campaign) | |
269 |
|
269 | |||
270 | form = CampaignForm(instance=campaign) |
|
270 | form = CampaignForm(instance=campaign) | |
271 |
|
271 | |||
272 | kwargs = {} |
|
272 | kwargs = {} | |
273 | kwargs['campaign'] = campaign |
|
273 | kwargs['campaign'] = campaign | |
274 | kwargs['campaign_keys'] = ['name', 'start_date', 'end_date', 'tags', 'description'] |
|
274 | kwargs['campaign_keys'] = ['name', 'start_date', 'end_date', 'tags', 'description'] | |
275 |
|
275 | |||
276 | keys = ['id', 'name', 'start_time', 'end_time'] |
|
276 | keys = ['id', 'name', 'start_time', 'end_time'] | |
277 |
|
277 | |||
278 | kwargs['experiment_keys'] = keys[1:] |
|
278 | kwargs['experiment_keys'] = keys[1:] | |
279 | kwargs['experiments'] = experiments.values(*keys) |
|
279 | kwargs['experiments'] = experiments.values(*keys) | |
280 |
|
280 | |||
281 | kwargs['title'] = 'Campaign' |
|
281 | kwargs['title'] = 'Campaign' | |
282 | kwargs['suptitle'] = 'Details' |
|
282 | kwargs['suptitle'] = 'Details' | |
283 |
|
283 | |||
284 | kwargs['form'] = form |
|
284 | kwargs['form'] = form | |
285 | kwargs['button'] = 'Add Experiment' |
|
285 | kwargs['button'] = 'Add Experiment' | |
286 |
|
286 | |||
287 | return render(request, 'campaign.html', kwargs) |
|
287 | return render(request, 'campaign.html', kwargs) | |
288 |
|
288 | |||
289 | def campaign_new(request): |
|
289 | def campaign_new(request): | |
290 |
|
290 | |||
291 | if request.method == 'GET': |
|
291 | if request.method == 'GET': | |
292 | form = CampaignForm() |
|
292 | form = CampaignForm() | |
293 |
|
293 | |||
294 | if request.method == 'POST': |
|
294 | if request.method == 'POST': | |
295 | form = CampaignForm(request.POST) |
|
295 | form = CampaignForm(request.POST) | |
296 |
|
296 | |||
297 | if form.is_valid(): |
|
297 | if form.is_valid(): | |
298 | campaign = form.save() |
|
298 | campaign = form.save() | |
299 | return redirect('url_campaign', id_camp=campaign.id) |
|
299 | return redirect('url_campaign', id_camp=campaign.id) | |
300 |
|
300 | |||
301 | kwargs = {} |
|
301 | kwargs = {} | |
302 | kwargs['form'] = form |
|
302 | kwargs['form'] = form | |
303 | kwargs['title'] = 'Campaign' |
|
303 | kwargs['title'] = 'Campaign' | |
304 | kwargs['suptitle'] = 'New' |
|
304 | kwargs['suptitle'] = 'New' | |
305 | kwargs['button'] = 'Create' |
|
305 | kwargs['button'] = 'Create' | |
306 |
|
306 | |||
307 | return render(request, 'campaign_edit.html', kwargs) |
|
307 | return render(request, 'campaign_edit.html', kwargs) | |
308 |
|
308 | |||
309 | def campaign_edit(request, id_camp): |
|
309 | def campaign_edit(request, id_camp): | |
310 |
|
310 | |||
311 | campaign = get_object_or_404(Campaign, pk=id_camp) |
|
311 | campaign = get_object_or_404(Campaign, pk=id_camp) | |
312 |
|
312 | |||
313 | if request.method=='GET': |
|
313 | if request.method=='GET': | |
314 | form = CampaignForm(instance=campaign) |
|
314 | form = CampaignForm(instance=campaign) | |
315 |
|
315 | |||
316 | if request.method=='POST': |
|
316 | if request.method=='POST': | |
317 | form = CampaignForm(request.POST, instance=campaign) |
|
317 | form = CampaignForm(request.POST, instance=campaign) | |
318 |
|
318 | |||
319 | if form.is_valid(): |
|
319 | if form.is_valid(): | |
320 | form.save() |
|
320 | form.save() | |
321 | return redirect('url_campaign', id_camp=id_camp) |
|
321 | return redirect('url_campaign', id_camp=id_camp) | |
322 |
|
322 | |||
323 | kwargs = {} |
|
323 | kwargs = {} | |
324 | kwargs['form'] = form |
|
324 | kwargs['form'] = form | |
325 | kwargs['title'] = 'Campaign' |
|
325 | kwargs['title'] = 'Campaign' | |
326 | kwargs['suptitle'] = 'Edit' |
|
326 | kwargs['suptitle'] = 'Edit' | |
327 | kwargs['button'] = 'Update' |
|
327 | kwargs['button'] = 'Update' | |
328 |
|
328 | |||
329 | return render(request, 'campaign_edit.html', kwargs) |
|
329 | return render(request, 'campaign_edit.html', kwargs) | |
330 |
|
330 | |||
331 | def campaign_delete(request, id_camp): |
|
331 | def campaign_delete(request, id_camp): | |
332 |
|
332 | |||
333 | campaign = get_object_or_404(Campaign, pk=id_camp) |
|
333 | campaign = get_object_or_404(Campaign, pk=id_camp) | |
334 |
|
334 | |||
335 | if request.method=='POST': |
|
335 | if request.method=='POST': | |
336 | if request.user.is_staff: |
|
336 | if request.user.is_staff: | |
337 | campaign.delete() |
|
337 | campaign.delete() | |
338 | return redirect('url_campaigns') |
|
338 | return redirect('url_campaigns') | |
339 |
|
339 | |||
340 | return HttpResponse("Not enough permission to delete this object") |
|
340 | return HttpResponse("Not enough permission to delete this object") | |
341 |
|
341 | |||
342 | kwargs = {'object':campaign, 'camp_active':'active', |
|
342 | kwargs = {'object':campaign, 'camp_active':'active', | |
343 | 'url_cancel':'url_campaign', 'id_item':id_camp} |
|
343 | 'url_cancel':'url_campaign', 'id_item':id_camp} | |
344 |
|
344 | |||
345 | return render(request, 'item_delete.html', kwargs) |
|
345 | return render(request, 'item_delete.html', kwargs) | |
346 |
|
346 | |||
347 | def experiments(request): |
|
347 | def experiments(request): | |
348 |
|
348 | |||
349 | experiment_list = Experiment.objects.all().order_by('campaign') |
|
349 | experiment_list = Experiment.objects.all().order_by('campaign') | |
350 |
|
350 | |||
351 | keys = ['id', 'name', 'start_time', 'end_time', 'campaign'] |
|
351 | keys = ['id', 'name', 'start_time', 'end_time', 'campaign'] | |
352 |
|
352 | |||
353 | kwargs = {} |
|
353 | kwargs = {} | |
354 |
|
354 | |||
355 | kwargs['experiment_keys'] = keys[1:] |
|
355 | kwargs['experiment_keys'] = keys[1:] | |
356 | kwargs['experiments'] = experiment_list#.values(*keys) |
|
356 | kwargs['experiments'] = experiment_list#.values(*keys) | |
357 |
|
357 | |||
358 | kwargs['title'] = 'Experiment' |
|
358 | kwargs['title'] = 'Experiment' | |
359 | kwargs['suptitle'] = 'List' |
|
359 | kwargs['suptitle'] = 'List' | |
360 | kwargs['button'] = 'New Experiment' |
|
360 | kwargs['button'] = 'New Experiment' | |
361 |
|
361 | |||
362 | return render(request, 'experiments.html', kwargs) |
|
362 | return render(request, 'experiments.html', kwargs) | |
363 |
|
363 | |||
364 | def experiment(request, id_exp): |
|
364 | def experiment(request, id_exp): | |
365 |
|
365 | |||
366 | experiment = get_object_or_404(Experiment, pk=id_exp) |
|
366 | experiment = get_object_or_404(Experiment, pk=id_exp) | |
367 |
|
367 | |||
368 | experiments = Experiment.objects.filter(campaign=experiment.campaign) |
|
368 | experiments = Experiment.objects.filter(campaign=experiment.campaign) | |
369 | configurations = Configuration.objects.filter(experiment=experiment, type=0) |
|
369 | configurations = Configuration.objects.filter(experiment=experiment, type=0) | |
370 |
|
370 | |||
371 | kwargs = {} |
|
371 | kwargs = {} | |
372 |
|
372 | |||
373 | exp_keys = ['id', 'campaign', 'location', 'name', 'start_time', 'end_time'] |
|
373 | exp_keys = ['id', 'campaign', 'location', 'name', 'start_time', 'end_time'] | |
374 | conf_keys = ['id', 'device__name', 'device__device_type', 'device__ip_address', 'device__port_address'] |
|
374 | conf_keys = ['id', 'device__name', 'device__device_type', 'device__ip_address', 'device__port_address'] | |
375 |
|
375 | |||
376 | conf_labels = ['id', 'device__name', 'device_type', 'ip_address', 'port_address'] |
|
376 | conf_labels = ['id', 'device__name', 'device_type', 'ip_address', 'port_address'] | |
377 |
|
377 | |||
378 | kwargs['experiment_keys'] = exp_keys[1:] |
|
378 | kwargs['experiment_keys'] = exp_keys[1:] | |
379 | kwargs['experiment'] = experiment |
|
379 | kwargs['experiment'] = experiment | |
380 |
|
380 | |||
381 | kwargs['experiments'] = experiments.values(*exp_keys) |
|
381 | kwargs['experiments'] = experiments.values(*exp_keys) | |
382 |
|
382 | |||
383 | kwargs['configuration_labels'] = conf_labels[1:] |
|
383 | kwargs['configuration_labels'] = conf_labels[1:] | |
384 | kwargs['configuration_keys'] = conf_keys[1:] |
|
384 | kwargs['configuration_keys'] = conf_keys[1:] | |
385 | kwargs['configurations'] = configurations #.values(*conf_keys) |
|
385 | kwargs['configurations'] = configurations #.values(*conf_keys) | |
386 |
|
386 | |||
387 | kwargs['title'] = 'Experiment' |
|
387 | kwargs['title'] = 'Experiment' | |
388 | kwargs['suptitle'] = 'Details' |
|
388 | kwargs['suptitle'] = 'Details' | |
389 |
|
389 | |||
390 | kwargs['button'] = 'Add Configuration' |
|
390 | kwargs['button'] = 'Add Configuration' | |
391 |
|
391 | |||
392 | return render(request, 'experiment.html', kwargs) |
|
392 | return render(request, 'experiment.html', kwargs) | |
393 |
|
393 | |||
394 | def experiment_new(request, id_camp=0): |
|
394 | def experiment_new(request, id_camp=0): | |
395 |
|
395 | |||
396 | if request.method == 'GET': |
|
396 | if request.method == 'GET': | |
397 | form = ExperimentForm(initial={'campaign':id_camp}) |
|
397 | form = ExperimentForm(initial={'campaign':id_camp}) | |
398 |
|
398 | |||
399 | if request.method == 'POST': |
|
399 | if request.method == 'POST': | |
400 | form = ExperimentForm(request.POST, initial={'campaign':id_camp}) |
|
400 | form = ExperimentForm(request.POST, initial={'campaign':id_camp}) | |
401 |
|
401 | |||
402 | if form.is_valid(): |
|
402 | if form.is_valid(): | |
403 | experiment = form.save() |
|
403 | experiment = form.save() | |
404 | return redirect('url_experiment', id_exp=experiment.id) |
|
404 | return redirect('url_experiment', id_exp=experiment.id) | |
405 |
|
405 | |||
406 | kwargs = {} |
|
406 | kwargs = {} | |
407 | kwargs['form'] = form |
|
407 | kwargs['form'] = form | |
408 | kwargs['title'] = 'Experiment' |
|
408 | kwargs['title'] = 'Experiment' | |
409 | kwargs['suptitle'] = 'New' |
|
409 | kwargs['suptitle'] = 'New' | |
410 | kwargs['button'] = 'Create' |
|
410 | kwargs['button'] = 'Create' | |
411 |
|
411 | |||
412 | return render(request, 'experiment_edit.html', kwargs) |
|
412 | return render(request, 'experiment_edit.html', kwargs) | |
413 |
|
413 | |||
414 | def experiment_edit(request, id_exp): |
|
414 | def experiment_edit(request, id_exp): | |
415 |
|
415 | |||
416 | experiment = get_object_or_404(Experiment, pk=id_exp) |
|
416 | experiment = get_object_or_404(Experiment, pk=id_exp) | |
417 |
|
417 | |||
418 | if request.method == 'GET': |
|
418 | if request.method == 'GET': | |
419 | form = ExperimentForm(instance=experiment) |
|
419 | form = ExperimentForm(instance=experiment) | |
420 |
|
420 | |||
421 | if request.method=='POST': |
|
421 | if request.method=='POST': | |
422 | form = ExperimentForm(request.POST, instance=experiment) |
|
422 | form = ExperimentForm(request.POST, instance=experiment) | |
423 |
|
423 | |||
424 | if form.is_valid(): |
|
424 | if form.is_valid(): | |
425 | experiment = form.save() |
|
425 | experiment = form.save() | |
426 | return redirect('url_experiment', id_exp=experiment.id) |
|
426 | return redirect('url_experiment', id_exp=experiment.id) | |
427 |
|
427 | |||
428 | kwargs = {} |
|
428 | kwargs = {} | |
429 | kwargs['form'] = form |
|
429 | kwargs['form'] = form | |
430 | kwargs['title'] = 'Experiment' |
|
430 | kwargs['title'] = 'Experiment' | |
431 | kwargs['suptitle'] = 'Edit' |
|
431 | kwargs['suptitle'] = 'Edit' | |
432 | kwargs['button'] = 'Update' |
|
432 | kwargs['button'] = 'Update' | |
433 |
|
433 | |||
434 | return render(request, 'experiment_edit.html', kwargs) |
|
434 | return render(request, 'experiment_edit.html', kwargs) | |
435 |
|
435 | |||
436 | def experiment_delete(request, id_exp): |
|
436 | def experiment_delete(request, id_exp): | |
437 |
|
437 | |||
438 | experiment = get_object_or_404(Experiment, pk=id_exp) |
|
438 | experiment = get_object_or_404(Experiment, pk=id_exp) | |
439 |
|
439 | |||
440 | if request.method=='POST': |
|
440 | if request.method=='POST': | |
441 | if request.user.is_staff: |
|
441 | if request.user.is_staff: | |
442 | id_camp = experiment.campaign.id |
|
442 | id_camp = experiment.campaign.id | |
443 | experiment.delete() |
|
443 | experiment.delete() | |
444 | return redirect('url_campaign', id_camp=id_camp) |
|
444 | return redirect('url_campaign', id_camp=id_camp) | |
445 |
|
445 | |||
446 | return HttpResponse("Not enough permission to delete this object") |
|
446 | return HttpResponse("Not enough permission to delete this object") | |
447 |
|
447 | |||
448 | kwargs = {'object':experiment, 'exp_active':'active', |
|
448 | kwargs = {'object':experiment, 'exp_active':'active', | |
449 | 'url_cancel':'url_experiment', 'id_item':id_exp} |
|
449 | 'url_cancel':'url_experiment', 'id_item':id_exp} | |
450 |
|
450 | |||
451 | return render(request, 'item_delete.html', kwargs) |
|
451 | return render(request, 'item_delete.html', kwargs) | |
452 |
|
452 | |||
453 | def dev_confs(request): |
|
453 | def dev_confs(request): | |
454 |
|
454 | |||
455 | configurations = Configuration.objects.all().order_by('type', 'device__device_type', 'experiment') |
|
455 | configurations = Configuration.objects.all().order_by('type', 'device__device_type', 'experiment') | |
456 |
|
456 | |||
457 | # keys = ['id', 'device__device_type__name', 'device__name', 'experiment__campaign__name', 'experiment__name'] |
|
457 | # keys = ['id', 'device__device_type__name', 'device__name', 'experiment__campaign__name', 'experiment__name'] | |
458 |
|
458 | |||
459 | keys = ['id', 'device', 'experiment', 'type', 'programmed_date'] |
|
459 | keys = ['id', 'device', 'experiment', 'type', 'programmed_date'] | |
460 |
|
460 | |||
461 | kwargs = {} |
|
461 | kwargs = {} | |
462 |
|
462 | |||
463 | kwargs['configuration_keys'] = keys[1:] |
|
463 | kwargs['configuration_keys'] = keys[1:] | |
464 | kwargs['configurations'] = configurations#.values(*keys) |
|
464 | kwargs['configurations'] = configurations#.values(*keys) | |
465 |
|
465 | |||
466 | kwargs['title'] = 'Configuration' |
|
466 | kwargs['title'] = 'Configuration' | |
467 | kwargs['suptitle'] = 'List' |
|
467 | kwargs['suptitle'] = 'List' | |
468 | kwargs['button'] = 'New Configuration' |
|
468 | kwargs['button'] = 'New Configuration' | |
469 |
|
469 | |||
470 | return render(request, 'dev_confs.html', kwargs) |
|
470 | return render(request, 'dev_confs.html', kwargs) | |
471 |
|
471 | |||
472 | def dev_conf(request, id_conf): |
|
472 | def dev_conf(request, id_conf): | |
473 |
|
473 | |||
474 | conf = get_object_or_404(Configuration, pk=id_conf) |
|
474 | conf = get_object_or_404(Configuration, pk=id_conf) | |
475 |
|
475 | |||
476 | DevConfModel = CONF_MODELS[conf.device.device_type.name] |
|
476 | DevConfModel = CONF_MODELS[conf.device.device_type.name] | |
477 | dev_conf = DevConfModel.objects.get(pk=id_conf) |
|
477 | dev_conf = DevConfModel.objects.get(pk=id_conf) | |
478 |
|
478 | |||
479 | kwargs = {} |
|
479 | kwargs = {} | |
480 | kwargs['dev_conf'] = dev_conf |
|
480 | kwargs['dev_conf'] = dev_conf | |
481 | kwargs['dev_conf_keys'] = ['name', 'experiment', 'device'] |
|
481 | kwargs['dev_conf_keys'] = ['name', 'experiment', 'device'] | |
482 |
|
482 | |||
483 | kwargs['title'] = 'Configuration' |
|
483 | kwargs['title'] = 'Configuration' | |
484 | kwargs['suptitle'] = 'Details' |
|
484 | kwargs['suptitle'] = 'Details' | |
485 |
|
485 | |||
486 | kwargs['button'] = 'Edit Configuration' |
|
486 | kwargs['button'] = 'Edit Configuration' | |
487 |
|
487 | |||
488 | ###### SIDEBAR ###### |
|
488 | ###### SIDEBAR ###### | |
489 | kwargs.update(sidebar(conf)) |
|
489 | kwargs.update(sidebar(conf)) | |
490 |
|
490 | |||
491 | return render(request, 'dev_conf.html', kwargs) |
|
491 | return render(request, 'dev_conf.html', kwargs) | |
492 |
|
492 | |||
493 | def dev_conf_new(request, id_exp=0): |
|
493 | def dev_conf_new(request, id_exp=0): | |
494 |
|
494 | |||
495 | if request.method == 'GET': |
|
495 | if request.method == 'GET': | |
496 | form = ConfigurationForm(initial={'experiment':id_exp}) |
|
496 | form = ConfigurationForm(initial={'experiment':id_exp}) | |
497 |
|
497 | |||
498 | if request.method == 'POST': |
|
498 | if request.method == 'POST': | |
499 | experiment = Experiment.objects.get(pk=request.POST['experiment']) |
|
499 | experiment = Experiment.objects.get(pk=request.POST['experiment']) | |
500 | device = Device.objects.get(pk=request.POST['device']) |
|
500 | device = Device.objects.get(pk=request.POST['device']) | |
501 |
|
501 | |||
502 | DevConfForm = CONF_FORMS[device.device_type.name] |
|
502 | DevConfForm = CONF_FORMS[device.device_type.name] | |
503 |
|
503 | |||
504 | form = DevConfForm(request.POST, initial={'experiment':experiment.id}) |
|
504 | form = DevConfForm(request.POST, initial={'experiment':experiment.id}) | |
505 |
|
505 | |||
506 | if form.is_valid(): |
|
506 | if form.is_valid(): | |
507 | dev_conf = form.save() |
|
507 | dev_conf = form.save() | |
508 |
|
508 | |||
509 | return redirect('url_experiment', id_exp=experiment.id) |
|
509 | return redirect('url_experiment', id_exp=experiment.id) | |
510 |
|
510 | |||
511 | kwargs = {} |
|
511 | kwargs = {} | |
512 | kwargs['form'] = form |
|
512 | kwargs['form'] = form | |
513 | kwargs['title'] = 'Configuration' |
|
513 | kwargs['title'] = 'Configuration' | |
514 | kwargs['suptitle'] = 'New' |
|
514 | kwargs['suptitle'] = 'New' | |
515 | kwargs['button'] = 'Create' |
|
515 | kwargs['button'] = 'Create' | |
516 |
|
516 | |||
517 | return render(request, 'dev_conf_edit.html', kwargs) |
|
517 | return render(request, 'dev_conf_edit.html', kwargs) | |
518 |
|
518 | |||
519 | def dev_conf_edit(request, id_conf): |
|
519 | def dev_conf_edit(request, id_conf): | |
520 |
|
520 | |||
521 | conf = get_object_or_404(Configuration, pk=id_conf) |
|
521 | conf = get_object_or_404(Configuration, pk=id_conf) | |
522 |
|
522 | |||
523 | DevConfModel = CONF_MODELS[conf.device.device_type.name] |
|
523 | DevConfModel = CONF_MODELS[conf.device.device_type.name] | |
524 | DevConfForm = CONF_FORMS[conf.device.device_type.name] |
|
524 | DevConfForm = CONF_FORMS[conf.device.device_type.name] | |
525 |
|
525 | |||
526 | dev_conf = DevConfModel.objects.get(pk=id_conf) |
|
526 | dev_conf = DevConfModel.objects.get(pk=id_conf) | |
527 |
|
527 | |||
528 | if request.method=='GET': |
|
528 | if request.method=='GET': | |
529 | form = DevConfForm(instance=dev_conf) |
|
529 | form = DevConfForm(instance=dev_conf) | |
530 |
|
530 | |||
531 | if request.method=='POST': |
|
531 | if request.method=='POST': | |
532 | form = DevConfForm(request.POST, instance=dev_conf) |
|
532 | form = DevConfForm(request.POST, instance=dev_conf) | |
533 |
|
533 | |||
534 | if form.is_valid(): |
|
534 | if form.is_valid(): | |
535 | form.save() |
|
535 | form.save() | |
536 | return redirect('url_dev_conf', id_conf=id_conf) |
|
536 | return redirect('url_dev_conf', id_conf=id_conf) | |
537 |
|
537 | |||
538 | kwargs = {} |
|
538 | kwargs = {} | |
539 | kwargs['form'] = form |
|
539 | kwargs['form'] = form | |
540 | kwargs['title'] = 'Device Configuration' |
|
540 | kwargs['title'] = 'Device Configuration' | |
541 | kwargs['suptitle'] = 'Edit' |
|
541 | kwargs['suptitle'] = 'Edit' | |
542 | kwargs['button'] = 'Update' |
|
542 | kwargs['button'] = 'Update' | |
543 |
|
543 | |||
544 | ###### SIDEBAR ###### |
|
544 | ###### SIDEBAR ###### | |
545 | kwargs.update(sidebar(conf)) |
|
545 | kwargs.update(sidebar(conf)) | |
546 |
|
546 | |||
547 | return render(request, '%s_conf_edit.html' %conf.device.device_type.name, kwargs) |
|
547 | return render(request, '%s_conf_edit.html' %conf.device.device_type.name, kwargs) | |
548 |
|
548 | |||
549 | def dev_conf_start(request, id_conf): |
|
549 | def dev_conf_start(request, id_conf): | |
550 |
|
550 | |||
551 | conf = get_object_or_404(Configuration, pk=id_conf) |
|
551 | conf = get_object_or_404(Configuration, pk=id_conf) | |
552 |
|
552 | |||
553 | DevConfModel = CONF_MODELS[conf.device.device_type.name] |
|
553 | DevConfModel = CONF_MODELS[conf.device.device_type.name] | |
554 |
|
554 | |||
555 | conf = DevConfModel.objects.get(pk=id_conf) |
|
555 | conf = DevConfModel.objects.get(pk=id_conf) | |
556 |
|
556 | |||
557 | if conf.start_device(): |
|
557 | if conf.start_device(): | |
558 | messages.success(request, conf.message) |
|
558 | messages.success(request, conf.message) | |
559 | else: |
|
559 | else: | |
560 | messages.error(request, conf.message) |
|
560 | messages.error(request, conf.message) | |
561 |
|
561 | |||
562 | conf.status_device() |
|
562 | conf.status_device() | |
563 |
|
563 | |||
564 | return redirect(conf.get_absolute_url()) |
|
564 | return redirect(conf.get_absolute_url()) | |
565 |
|
565 | |||
566 | def dev_conf_stop(request, id_conf): |
|
566 | def dev_conf_stop(request, id_conf): | |
567 |
|
567 | |||
568 | conf = get_object_or_404(Configuration, pk=id_conf) |
|
568 | conf = get_object_or_404(Configuration, pk=id_conf) | |
569 |
|
569 | |||
570 | DevConfModel = CONF_MODELS[conf.device.device_type.name] |
|
570 | DevConfModel = CONF_MODELS[conf.device.device_type.name] | |
571 |
|
571 | |||
572 | conf = DevConfModel.objects.get(pk=id_conf) |
|
572 | conf = DevConfModel.objects.get(pk=id_conf) | |
573 |
|
573 | |||
574 | if conf.stop_device(): |
|
574 | if conf.stop_device(): | |
575 | messages.success(request, conf.message) |
|
575 | messages.success(request, conf.message) | |
576 | else: |
|
576 | else: | |
577 | messages.error(request, conf.message) |
|
577 | messages.error(request, conf.message) | |
578 |
|
578 | |||
579 | conf.status_device() |
|
579 | conf.status_device() | |
580 |
|
580 | |||
581 | return redirect(conf.get_absolute_url()) |
|
581 | return redirect(conf.get_absolute_url()) | |
582 |
|
582 | |||
583 | def dev_conf_status(request, id_conf): |
|
583 | def dev_conf_status(request, id_conf): | |
584 |
|
584 | |||
585 | conf = get_object_or_404(Configuration, pk=id_conf) |
|
585 | conf = get_object_or_404(Configuration, pk=id_conf) | |
586 |
|
586 | |||
587 | DevConfModel = CONF_MODELS[conf.device.device_type.name] |
|
587 | DevConfModel = CONF_MODELS[conf.device.device_type.name] | |
588 |
|
588 | |||
589 | conf = DevConfModel.objects.get(pk=id_conf) |
|
589 | conf = DevConfModel.objects.get(pk=id_conf) | |
590 |
|
590 | |||
591 | if conf.status_device(): |
|
591 | if conf.status_device(): | |
592 | messages.success(request, conf.message) |
|
592 | messages.success(request, conf.message) | |
593 | else: |
|
593 | else: | |
594 | messages.error(request, conf.message) |
|
594 | messages.error(request, conf.message) | |
595 |
|
595 | |||
596 | return redirect(conf.get_absolute_url()) |
|
596 | return redirect(conf.get_absolute_url()) | |
597 |
|
597 | |||
598 |
|
598 | |||
599 | def dev_conf_write(request, id_conf): |
|
599 | def dev_conf_write(request, id_conf): | |
600 |
|
600 | |||
601 | conf = get_object_or_404(Configuration, pk=id_conf) |
|
601 | conf = get_object_or_404(Configuration, pk=id_conf) | |
602 |
|
602 | |||
603 | DevConfModel = CONF_MODELS[conf.device.device_type.name] |
|
603 | DevConfModel = CONF_MODELS[conf.device.device_type.name] | |
604 |
|
604 | |||
605 | conf = DevConfModel.objects.get(pk=id_conf) |
|
605 | conf = DevConfModel.objects.get(pk=id_conf) | |
606 |
|
606 | |||
607 | answer = conf.write_device() |
|
607 | answer = conf.write_device() | |
608 | conf.status_device() |
|
608 | conf.status_device() | |
609 |
|
609 | |||
610 | if answer: |
|
610 | if answer: | |
611 | messages.success(request, conf.message) |
|
611 | messages.success(request, conf.message) | |
612 |
|
612 | |||
613 | #Creating a historical configuration |
|
613 | #Creating a historical configuration | |
614 | conf.pk = None |
|
614 | conf.pk = None | |
615 | conf.id = None |
|
615 | conf.id = None | |
616 | conf.type = 1 |
|
616 | conf.type = 1 | |
617 | conf.template = 0 |
|
617 | conf.template = 0 | |
618 | conf.save() |
|
618 | conf.save() | |
619 |
|
619 | |||
620 | #Original configuration |
|
620 | #Original configuration | |
621 | conf = DevConfModel.objects.get(pk=id_conf) |
|
621 | conf = DevConfModel.objects.get(pk=id_conf) | |
622 | else: |
|
622 | else: | |
623 | messages.error(request, conf.message) |
|
623 | messages.error(request, conf.message) | |
624 |
|
624 | |||
625 | return redirect(conf.get_absolute_url()) |
|
625 | return redirect(conf.get_absolute_url()) | |
626 |
|
626 | |||
627 | def dev_conf_read(request, id_conf): |
|
627 | def dev_conf_read(request, id_conf): | |
628 |
|
628 | |||
629 | conf = get_object_or_404(Configuration, pk=id_conf) |
|
629 | conf = get_object_or_404(Configuration, pk=id_conf) | |
630 |
|
630 | |||
631 | DevConfModel = CONF_MODELS[conf.device.device_type.name] |
|
631 | DevConfModel = CONF_MODELS[conf.device.device_type.name] | |
632 | DevConfForm = CONF_FORMS[conf.device.device_type.name] |
|
632 | DevConfForm = CONF_FORMS[conf.device.device_type.name] | |
633 |
|
633 | |||
634 | conf = DevConfModel.objects.get(pk=id_conf) |
|
634 | conf = DevConfModel.objects.get(pk=id_conf) | |
635 |
|
635 | |||
636 | if request.method=='GET': |
|
636 | if request.method=='GET': | |
637 |
|
637 | |||
638 | parms = conf.read_device() |
|
638 | parms = conf.read_device() | |
639 | conf.status_device() |
|
639 | conf.status_device() | |
640 |
|
640 | |||
641 | if not parms: |
|
641 | if not parms: | |
642 | messages.error(request, conf.message) |
|
642 | messages.error(request, conf.message) | |
643 | return redirect(conf.get_absolute_url()) |
|
643 | return redirect(conf.get_absolute_url()) | |
644 |
|
644 | |||
645 | form = DevConfForm(initial=parms, instance=conf) |
|
645 | form = DevConfForm(initial=parms, instance=conf) | |
646 |
|
646 | |||
647 | if request.method=='POST': |
|
647 | if request.method=='POST': | |
648 | form = DevConfForm(request.POST, instance=conf) |
|
648 | form = DevConfForm(request.POST, instance=conf) | |
649 |
|
649 | |||
650 | if form.is_valid(): |
|
650 | if form.is_valid(): | |
651 | form.save() |
|
651 | form.save() | |
652 | return redirect(conf.get_absolute_url()) |
|
652 | return redirect(conf.get_absolute_url()) | |
653 |
|
653 | |||
654 | messages.error(request, "Parameters could not be saved") |
|
654 | messages.error(request, "Parameters could not be saved") | |
655 |
|
655 | |||
656 | kwargs = {} |
|
656 | kwargs = {} | |
657 | kwargs['id_dev'] = conf.id |
|
657 | kwargs['id_dev'] = conf.id | |
658 | kwargs['form'] = form |
|
658 | kwargs['form'] = form | |
659 | kwargs['title'] = 'Device Configuration' |
|
659 | kwargs['title'] = 'Device Configuration' | |
660 | kwargs['suptitle'] = 'Parameters read from device' |
|
660 | kwargs['suptitle'] = 'Parameters read from device' | |
661 | kwargs['button'] = 'Save' |
|
661 | kwargs['button'] = 'Save' | |
662 |
|
662 | |||
663 | ###### SIDEBAR ###### |
|
663 | ###### SIDEBAR ###### | |
664 | kwargs.update(sidebar(conf)) |
|
664 | kwargs.update(sidebar(conf)) | |
665 |
|
665 | |||
666 | return render(request, '%s_conf_edit.html' %conf.device.device_type.name, kwargs) |
|
666 | return render(request, '%s_conf_edit.html' %conf.device.device_type.name, kwargs) | |
667 |
|
667 | |||
668 | def dev_conf_import(request, id_conf): |
|
668 | def dev_conf_import(request, id_conf): | |
669 |
|
669 | |||
670 | conf = get_object_or_404(Configuration, pk=id_conf) |
|
670 | conf = get_object_or_404(Configuration, pk=id_conf) | |
671 |
|
671 | |||
672 | DevConfModel = CONF_MODELS[conf.device.device_type.name] |
|
672 | DevConfModel = CONF_MODELS[conf.device.device_type.name] | |
673 | DevConfForm = CONF_FORMS[conf.device.device_type.name] |
|
673 | DevConfForm = CONF_FORMS[conf.device.device_type.name] | |
674 |
|
674 | |||
675 | conf = DevConfModel.objects.get(pk=id_conf) |
|
675 | conf = DevConfModel.objects.get(pk=id_conf) | |
676 |
|
676 | |||
677 | if request.method == 'GET': |
|
677 | if request.method == 'GET': | |
678 | file_form = UploadFileForm() |
|
678 | file_form = UploadFileForm() | |
679 |
|
679 | |||
680 | if request.method == 'POST': |
|
680 | if request.method == 'POST': | |
681 | file_form = UploadFileForm(request.POST, request.FILES) |
|
681 | file_form = UploadFileForm(request.POST, request.FILES) | |
682 |
|
682 | |||
683 | if file_form.is_valid(): |
|
683 | if file_form.is_valid(): | |
684 |
|
684 | |||
685 | parms = conf.import_from_file(request.FILES['file']) |
|
685 | parms = conf.import_from_file(request.FILES['file']) | |
686 |
|
686 | |||
687 | if parms: |
|
687 | if parms: | |
688 | messages.success(request, "Parameters imported from: '%s'." %request.FILES['file'].name) |
|
688 | messages.success(request, "Parameters imported from: '%s'." %request.FILES['file'].name) | |
689 | print parms |
|
689 | print parms | |
690 | form = DevConfForm(initial=parms, instance=conf) |
|
690 | form = DevConfForm(initial=parms, instance=conf) | |
691 |
|
691 | |||
692 | kwargs = {} |
|
692 | kwargs = {} | |
693 | kwargs['id_dev'] = conf.id |
|
693 | kwargs['id_dev'] = conf.id | |
694 | kwargs['form'] = form |
|
694 | kwargs['form'] = form | |
695 | kwargs['title'] = 'Device Configuration' |
|
695 | kwargs['title'] = 'Device Configuration' | |
696 | kwargs['suptitle'] = 'Parameters imported' |
|
696 | kwargs['suptitle'] = 'Parameters imported' | |
697 | kwargs['button'] = 'Save' |
|
697 | kwargs['button'] = 'Save' | |
698 | kwargs['action'] = conf.get_absolute_url_edit() |
|
698 | kwargs['action'] = conf.get_absolute_url_edit() | |
699 | kwargs['previous'] = conf.get_absolute_url() |
|
699 | kwargs['previous'] = conf.get_absolute_url() | |
700 |
|
700 | |||
701 | ###### SIDEBAR ###### |
|
701 | ###### SIDEBAR ###### | |
702 | kwargs.update(sidebar(conf)) |
|
702 | kwargs.update(sidebar(conf)) | |
703 |
|
703 | |||
704 | return render(request, '%s_conf_edit.html' %conf.device.device_type.name, kwargs) |
|
704 | return render(request, '%s_conf_edit.html' %conf.device.device_type.name, kwargs) | |
705 |
|
705 | |||
706 | messages.error(request, "Could not import parameters from file") |
|
706 | messages.error(request, "Could not import parameters from file") | |
707 |
|
707 | |||
708 | kwargs = {} |
|
708 | kwargs = {} | |
709 | kwargs['id_dev'] = conf.id |
|
709 | kwargs['id_dev'] = conf.id | |
710 | kwargs['title'] = 'Device Configuration' |
|
710 | kwargs['title'] = 'Device Configuration' | |
711 | kwargs['form'] = file_form |
|
711 | kwargs['form'] = file_form | |
712 | kwargs['suptitle'] = 'Importing file' |
|
712 | kwargs['suptitle'] = 'Importing file' | |
713 | kwargs['button'] = 'Import' |
|
713 | kwargs['button'] = 'Import' | |
714 |
|
714 | |||
715 | kwargs.update(sidebar(conf)) |
|
715 | kwargs.update(sidebar(conf)) | |
716 |
|
716 | |||
717 | return render(request, 'dev_conf_import.html', kwargs) |
|
717 | return render(request, 'dev_conf_import.html', kwargs) | |
718 |
|
718 | |||
719 | def dev_conf_export(request, id_conf): |
|
719 | def dev_conf_export(request, id_conf): | |
720 |
|
720 | |||
721 | conf = get_object_or_404(Configuration, pk=id_conf) |
|
721 | conf = get_object_or_404(Configuration, pk=id_conf) | |
722 |
|
722 | |||
723 | DevConfModel = CONF_MODELS[conf.device.device_type.name] |
|
723 | DevConfModel = CONF_MODELS[conf.device.device_type.name] | |
724 |
|
724 | |||
725 | conf = DevConfModel.objects.get(pk=id_conf) |
|
725 | conf = DevConfModel.objects.get(pk=id_conf) | |
726 |
|
726 | |||
727 | if request.method == 'GET': |
|
727 | if request.method == 'GET': | |
728 | file_form = DownloadFileForm(conf.device.device_type.name) |
|
728 | file_form = DownloadFileForm(conf.device.device_type.name) | |
729 |
|
729 | |||
730 | if request.method == 'POST': |
|
730 | if request.method == 'POST': | |
731 | file_form = DownloadFileForm(conf.device.device_type.name, request.POST) |
|
731 | file_form = DownloadFileForm(conf.device.device_type.name, request.POST) | |
732 |
|
732 | |||
733 | if file_form.is_valid(): |
|
733 | if file_form.is_valid(): | |
734 | fields = conf.export_to_file(format = file_form.cleaned_data['format']) |
|
734 | fields = conf.export_to_file(format = file_form.cleaned_data['format']) | |
735 |
|
735 | |||
736 | response = HttpResponse(content_type=fields['content_type']) |
|
736 | response = HttpResponse(content_type=fields['content_type']) | |
737 | response['Content-Disposition'] = 'attachment; filename="%s"' %fields['filename'] |
|
737 | response['Content-Disposition'] = 'attachment; filename="%s"' %fields['filename'] | |
738 | response.write(fields['content']) |
|
738 | response.write(fields['content']) | |
739 |
|
739 | |||
740 | return response |
|
740 | return response | |
741 |
|
741 | |||
742 | messages.error(request, "Could not export parameters") |
|
742 | messages.error(request, "Could not export parameters") | |
743 |
|
743 | |||
744 | kwargs = {} |
|
744 | kwargs = {} | |
745 | kwargs['id_dev'] = conf.id |
|
745 | kwargs['id_dev'] = conf.id | |
746 | kwargs['title'] = 'Device Configuration' |
|
746 | kwargs['title'] = 'Device Configuration' | |
747 | kwargs['form'] = file_form |
|
747 | kwargs['form'] = file_form | |
748 | kwargs['suptitle'] = 'Exporting file' |
|
748 | kwargs['suptitle'] = 'Exporting file' | |
749 | kwargs['button'] = 'Export' |
|
749 | kwargs['button'] = 'Export' | |
750 |
|
750 | |||
751 | return render(request, 'dev_conf_export.html', kwargs) |
|
751 | return render(request, 'dev_conf_export.html', kwargs) | |
752 |
|
752 | |||
753 | def dev_conf_delete(request, id_conf): |
|
753 | def dev_conf_delete(request, id_conf): | |
754 |
|
754 | |||
755 | conf = get_object_or_404(Configuration, pk=id_conf) |
|
755 | conf = get_object_or_404(Configuration, pk=id_conf) | |
756 |
|
756 | |||
757 | if request.method=='POST': |
|
757 | if request.method=='POST': | |
758 | if request.user.is_staff: |
|
758 | if request.user.is_staff: | |
759 | id_exp = conf.experiment.id |
|
759 | id_exp = conf.experiment.id | |
760 | conf.delete() |
|
760 | conf.delete() | |
761 | return redirect('url_experiment', id_exp=id_exp) |
|
761 | return redirect('url_experiment', id_exp=id_exp) | |
762 |
|
762 | |||
763 | return HttpResponse("Not enough permission to delete this object") |
|
763 | return HttpResponse("Not enough permission to delete this object") | |
764 |
|
764 | |||
765 | kwargs = {'object':conf, 'conf_active':'active', |
|
765 | kwargs = {'object':conf, 'conf_active':'active', | |
766 | 'url_cancel':'url_dev_conf', 'id_item':id_conf} |
|
766 | 'url_cancel':'url_dev_conf', 'id_item':id_conf} | |
767 |
|
767 | |||
768 | ###### SIDEBAR ###### |
|
768 | ###### SIDEBAR ###### | |
769 | kwargs.update(sidebar(conf)) |
|
769 | kwargs.update(sidebar(conf)) | |
770 |
|
770 | |||
771 | return render(request, 'item_delete.html', kwargs) |
|
771 | return render(request, 'item_delete.html', kwargs) | |
772 |
|
772 | |||
773 | def sidebar(conf): |
|
773 | def sidebar(conf): | |
774 |
|
774 | |||
775 | experiments = Experiment.objects.filter(campaign=conf.experiment.campaign) |
|
775 | experiments = Experiment.objects.filter(campaign=conf.experiment.campaign) | |
776 | configurations = Configuration.objects.filter(experiment=conf.experiment, type=0) |
|
776 | configurations = Configuration.objects.filter(experiment=conf.experiment, type=0) | |
777 |
|
777 | |||
778 | exp_keys = ['id', 'campaign', 'name', 'start_time', 'end_time'] |
|
778 | exp_keys = ['id', 'campaign', 'name', 'start_time', 'end_time'] | |
779 | conf_keys = ['id', 'device'] |
|
779 | conf_keys = ['id', 'device'] | |
780 |
|
780 | |||
781 | kwargs = {} |
|
781 | kwargs = {} | |
782 |
|
782 | |||
783 | kwargs['dev_conf'] = conf |
|
783 | kwargs['dev_conf'] = conf | |
784 |
|
784 | |||
785 | kwargs['experiment_keys'] = exp_keys[1:] |
|
785 | kwargs['experiment_keys'] = exp_keys[1:] | |
786 | kwargs['experiments'] = experiments.values(*exp_keys) |
|
786 | kwargs['experiments'] = experiments.values(*exp_keys) | |
787 |
|
787 | |||
788 | kwargs['configuration_keys'] = conf_keys[1:] |
|
788 | kwargs['configuration_keys'] = conf_keys[1:] | |
789 | kwargs['configurations'] = configurations #.values(*conf_keys) |
|
789 | kwargs['configurations'] = configurations #.values(*conf_keys) | |
790 |
|
790 | |||
791 | return kwargs |
|
791 | return kwargs | |
792 |
|
792 | |||
793 |
|
793 | |||
794 | def operation(request, id_camp=None): |
|
794 | def operation(request, id_camp=None): | |
795 |
|
795 | |||
796 | if not id_camp: |
|
796 | if not id_camp: | |
797 | campaigns = Campaign.objects.all().order_by('-start_date') |
|
797 | campaigns = Campaign.objects.all().order_by('-start_date') | |
798 |
|
798 | |||
799 | if not campaigns: |
|
799 | if not campaigns: | |
|
800 | kwargs['title'] = 'No Campaigns' | |||
|
801 | kwargs['suptitle'] = 'Empty' | |||
800 | return render(request, 'operation.html', {}) |
|
802 | return render(request, 'operation.html', {}) | |
801 |
|
803 | |||
802 | id_camp = campaigns[0].id |
|
804 | id_camp = campaigns[0].id | |
803 |
|
805 | |||
804 | campaign = get_object_or_404(Campaign, pk = id_camp) |
|
806 | campaign = get_object_or_404(Campaign, pk = id_camp) | |
805 |
|
807 | |||
806 | if request.method=='GET': |
|
808 | if request.method=='GET': | |
807 | form = OperationForm(initial={'campaign': campaign.id}, length = 5) |
|
809 | form = OperationForm(initial={'campaign': campaign.id}, length = 5) | |
808 |
|
810 | |||
809 | if request.method=='POST': |
|
811 | if request.method=='POST': | |
810 | form = OperationForm(request.POST, initial={'campaign':campaign.id}, length = 5) |
|
812 | form = OperationForm(request.POST, initial={'campaign':campaign.id}, length = 5) | |
811 |
|
813 | |||
812 | if form.is_valid(): |
|
814 | if form.is_valid(): | |
813 | return redirect('url_operation', id_camp=campaign.id) |
|
815 | return redirect('url_operation', id_camp=campaign.id) | |
814 | locations = Location.objects.filter(experiment__campaign__pk = campaign.id).distinct() |
|
816 | locations = Location.objects.filter(experiment__campaign__pk = campaign.id).distinct() | |
815 | experiments = Experiment.objects.filter(campaign__pk=campaign.id) |
|
817 | experiments = Experiment.objects.filter(campaign__pk=campaign.id) | |
816 | #experiments = [Experiment.objects.filter(location__pk=location.id).filter(campaign__pk=campaign.id) for location in locations] |
|
818 | #experiments = [Experiment.objects.filter(location__pk=location.id).filter(campaign__pk=campaign.id) for location in locations] | |
817 | kwargs = {} |
|
819 | kwargs = {} | |
818 | #---Campaign |
|
820 | #---Campaign | |
819 | kwargs['campaign'] = campaign |
|
821 | kwargs['campaign'] = campaign | |
820 | kwargs['campaign_keys'] = ['name', 'start_date', 'end_date', 'tags', 'description'] |
|
822 | kwargs['campaign_keys'] = ['name', 'start_date', 'end_date', 'tags', 'description'] | |
821 | #---Experiment |
|
823 | #---Experiment | |
822 | keys = ['id', 'name', 'start_time', 'end_time'] |
|
824 | keys = ['id', 'name', 'start_time', 'end_time'] | |
823 | kwargs['experiment_keys'] = keys[1:] |
|
825 | kwargs['experiment_keys'] = keys[1:] | |
824 | kwargs['experiments'] = experiments |
|
826 | kwargs['experiments'] = experiments | |
825 | #---Radar |
|
827 | #---Radar | |
826 | kwargs['locations'] = locations |
|
828 | kwargs['locations'] = locations | |
827 | #---Else |
|
829 | #---Else | |
828 | kwargs['title'] = 'Campaign' |
|
830 | kwargs['title'] = 'Campaign' | |
829 | kwargs['suptitle'] = campaign.name |
|
831 | kwargs['suptitle'] = campaign.name | |
830 | kwargs['form'] = form |
|
832 | kwargs['form'] = form | |
831 | kwargs['button'] = 'Search' |
|
833 | kwargs['button'] = 'Search' | |
832 | kwargs['details'] = True |
|
834 | kwargs['details'] = True | |
833 | kwargs['search_button'] = True |
|
835 | kwargs['search_button'] = True | |
834 |
|
836 | |||
835 | return render(request, 'operation.html', kwargs) |
|
837 | return render(request, 'operation.html', kwargs) | |
836 |
|
838 | |||
837 | def operation_search(request, id_camp=None, location_play = None): |
|
839 | def operation_search(request, id_camp=None, location_play = None): | |
838 |
|
840 | |||
839 |
|
841 | |||
840 | if not id_camp: |
|
842 | if not id_camp: | |
841 | campaigns = Campaign.objects.all().order_by('-start_date') |
|
843 | campaigns = Campaign.objects.all().order_by('-start_date') | |
842 | form = OperationSearchForm() |
|
844 | form = OperationSearchForm() | |
843 |
|
845 | |||
844 | if not campaigns: |
|
846 | if not campaigns: | |
845 | return render(request, 'operation.html', {}) |
|
847 | return render(request, 'operation.html', {}) | |
846 |
|
848 | |||
847 | id_camp = campaigns[0].id |
|
849 | id_camp = campaigns[0].id | |
848 | campaign = get_object_or_404(Campaign, pk = id_camp) |
|
850 | campaign = get_object_or_404(Campaign, pk = id_camp) | |
849 |
|
851 | |||
850 | kwargs = {} |
|
852 | kwargs = {} | |
851 | kwargs['title'] = 'All Campaigns' |
|
853 | kwargs['title'] = 'All Campaigns' | |
852 | kwargs['form'] = form |
|
854 | kwargs['form'] = form | |
|
855 | kwargs['details'] = True | |||
853 | return render(request, 'operation.html', kwargs) |
|
856 | return render(request, 'operation.html', kwargs) | |
854 |
|
857 | |||
855 | else: |
|
858 | else: | |
856 | campaign = get_object_or_404(Campaign, pk = id_camp) |
|
859 | campaign = get_object_or_404(Campaign, pk = id_camp) | |
857 | locations = Location.objects.filter(experiment__campaign__pk = campaign.id).distinct() |
|
860 | locations = Location.objects.filter(experiment__campaign__pk = campaign.id).distinct() | |
858 | experiments = Experiment.objects.filter(campaign__pk=campaign.id) |
|
861 | experiments = Experiment.objects.filter(campaign__pk=campaign.id) | |
859 | #experiments = [Experiment.objects.filter(location__pk=location.id).filter(campaign__pk=campaign.id) for location in locations] |
|
862 | #experiments = [Experiment.objects.filter(location__pk=location.id).filter(campaign__pk=campaign.id) for location in locations] | |
860 | form = OperationSearchForm(initial={'campaign': campaign.id}) |
|
863 | form = OperationSearchForm(initial={'campaign': campaign.id}) | |
861 |
|
864 | |||
862 | kwargs = {} |
|
865 | kwargs = {} | |
863 | #---Campaign |
|
866 | #---Campaign | |
864 | kwargs['campaign'] = campaign |
|
867 | kwargs['campaign'] = campaign | |
865 | kwargs['campaign_keys'] = ['name', 'start_date', 'end_date', 'tags', 'description'] |
|
868 | kwargs['campaign_keys'] = ['name', 'start_date', 'end_date', 'tags', 'description'] | |
866 | #---Experiment |
|
869 | #---Experiment | |
867 | keys = ['id', 'name', 'start_time', 'end_time'] |
|
870 | keys = ['id', 'name', 'start_time', 'end_time'] | |
868 | kwargs['experiment_keys'] = keys[1:] |
|
871 | kwargs['experiment_keys'] = keys[1:] | |
869 | kwargs['experiments'] = experiments |
|
872 | kwargs['experiments'] = experiments | |
870 | #---Radar |
|
873 | #---Radar | |
871 | kwargs['locations'] = locations |
|
874 | kwargs['locations'] = locations | |
872 | #---Else |
|
875 | #---Else | |
873 | kwargs['title'] = 'Campaign' |
|
876 | kwargs['title'] = 'Campaign' | |
874 | kwargs['suptitle'] = campaign.name |
|
877 | kwargs['suptitle'] = campaign.name | |
875 | kwargs['form'] = form |
|
878 | kwargs['form'] = form | |
876 | kwargs['button'] = 'Select' |
|
879 | kwargs['button'] = 'Select' | |
877 | kwargs['details'] = True |
|
880 | kwargs['details'] = True | |
878 | kwargs['search_button'] = False |
|
881 | kwargs['search_button'] = False | |
879 |
|
882 | |||
880 |
|
883 | |||
881 | if request.method=='POST': |
|
884 | if request.method=='POST': | |
882 | form = OperationSearchForm(request.POST, initial={'campaign':campaign.id}) |
|
885 | form = OperationSearchForm(request.POST, initial={'campaign':campaign.id}) | |
883 |
|
886 | |||
884 | if form.is_valid(): |
|
887 | if form.is_valid(): | |
885 | return redirect('operation.html', id_camp=campaign.id) |
|
888 | return redirect('operation.html', id_camp=campaign.id) | |
886 |
|
889 | |||
887 |
|
890 | |||
888 | return render(request, 'operation.html', kwargs) No newline at end of file |
|
891 | return render(request, 'operation.html', kwargs) |
General Comments 0
You need to be logged in to leave comments.
Login now