@@ -0,0 +1,95 | |||||
|
1 | {% extends "base.html" %} | |||
|
2 | {% load bootstrap3 %} | |||
|
3 | {% load static %} | |||
|
4 | {% load main_tags %} | |||
|
5 | {% block extra-head %} | |||
|
6 | <link href="{% static 'css/bootstrap-datetimepicker.min.css' %}" media="screen" rel="stylesheet"> | |||
|
7 | {% endblock %} | |||
|
8 | ||||
|
9 | {% block camp-active %}active{% endblock %} | |||
|
10 | ||||
|
11 | {% block content-title %}{{title}}{% endblock %} | |||
|
12 | {% block content-suptitle %}{{suptitle}}{% endblock %} | |||
|
13 | ||||
|
14 | {% block content %} | |||
|
15 | ||||
|
16 | <form class="form" method="post" action=""> | |||
|
17 | {% csrf_token %} | |||
|
18 | {% bootstrap_form form layout='horizontal' size='medium' %} | |||
|
19 | <div style="clear: both;"></div> | |||
|
20 | <br> | |||
|
21 | <button type="submit" class="btn btn-primary pull-right">{{button}}</button> | |||
|
22 | <br> | |||
|
23 | <br> | |||
|
24 | </form> | |||
|
25 | <br> | |||
|
26 | <br> | |||
|
27 | ||||
|
28 | <div class="panel-group" id="accordion" role="tablist" aria-multiselectable="true" > | |||
|
29 | ||||
|
30 | {% for radar in radars %} | |||
|
31 | ||||
|
32 | <div class="panel panel-default"> | |||
|
33 | <div class="panel-heading" role="tab" id="headingTwo"> | |||
|
34 | <h4 class="panel-title"> | |||
|
35 | <a class="collapsed" role="button" data-toggle="collapse" href="#collapseTwo-{{ radar.id }}" aria-expanded="false" aria-controls="collapseTwo"> | |||
|
36 | {{radar.name}}: Experiment List | |||
|
37 | </a> | |||
|
38 | </h4> | |||
|
39 | </div> | |||
|
40 | ||||
|
41 | <div id="collapseTwo-{{ radar.id }}" class="panel-collapse collapse in" role="tabpanel" aria-labelledby="headingTwo"> | |||
|
42 | <div class="panel-body"> | |||
|
43 | <table class="table table-hover"> | |||
|
44 | <tr> | |||
|
45 | ||||
|
46 | {% for header in experiment_keys %} | |||
|
47 | <th>{{ header|title }}</th> | |||
|
48 | {% endfor%} | |||
|
49 | </tr> | |||
|
50 | {% for item in experiments %} | |||
|
51 | {% for exs in item %} | |||
|
52 | <tr class="clickable-row" data-href="{% url 'url_experiment' exs.id %}" > | |||
|
53 | ||||
|
54 | {% for key in experiment_keys %} | |||
|
55 | {% if radar.name in exs.radar.name %} | |||
|
56 | <td>{{ exs|attr:key }}</td> | |||
|
57 | {% endif %} | |||
|
58 | {% endfor %} | |||
|
59 | {% endfor %} | |||
|
60 | </tr> | |||
|
61 | {% endfor %} | |||
|
62 | </table> | |||
|
63 | </div> | |||
|
64 | </div> | |||
|
65 | </div> | |||
|
66 | {% endfor %} | |||
|
67 | </div> | |||
|
68 | ||||
|
69 | {% endblock %} | |||
|
70 | ||||
|
71 | ||||
|
72 | ||||
|
73 | {% block extra-js%} | |||
|
74 | <script type="text/javascript"> | |||
|
75 | ||||
|
76 | //$("#bt_add").click(function() { | |||
|
77 | //alert("sometext"); | |||
|
78 | // document.location = "{% url 'url_operation' campaign.id %}"; | |||
|
79 | //}); | |||
|
80 | ||||
|
81 | $(".clickable-row").click(function() { | |||
|
82 | document.location = $(this).data("href"); | |||
|
83 | }); | |||
|
84 | ||||
|
85 | $(document).ready(function() { | |||
|
86 | $("#id_campaign").change(function() { | |||
|
87 | var id_camp = document.getElementById("id_campaign").value; | |||
|
88 | //alert(id_camp); | |||
|
89 | document.location = "{% url 'url_operation'%}"+String(id_camp); | |||
|
90 | }); | |||
|
91 | }); | |||
|
92 | ||||
|
93 | ||||
|
94 | </script> | |||
|
95 | {% endblock %} No newline at end of file |
@@ -1,8 +1,10 | |||||
1 | from django.contrib import admin |
|
1 | from django.contrib import admin | |
2 | from .models import Device, DeviceType, Experiment, Campaign |
|
2 | from .models import Device, DeviceType, Experiment, Campaign, Location, Radar | |
3 |
|
3 | |||
4 | # Register your models here. |
|
4 | # Register your models here. | |
5 | admin.site.register(Campaign) |
|
5 | admin.site.register(Campaign) | |
6 | admin.site.register(Experiment) |
|
6 | admin.site.register(Experiment) | |
7 | admin.site.register(Device) |
|
7 | admin.site.register(Device) | |
8 | admin.site.register(DeviceType) No newline at end of file |
|
8 | admin.site.register(DeviceType) | |
|
9 | admin.site.register(Location) | |||
|
10 | admin.site.register(Radar) No newline at end of file |
@@ -1,64 +1,74 | |||||
1 | from django import forms |
|
1 | from django import forms | |
2 | from django.utils.safestring import mark_safe |
|
2 | from django.utils.safestring import mark_safe | |
|
3 | from datetime import datetime | |||
|
4 | ||||
|
5 | from apps.main.widgets import Filtering_ComboBox_Widget, Datepicker, HTMLrender,Filtering_ComboBox_Widget2 | |||
|
6 | ||||
3 |
|
7 | |||
4 | from .models import DeviceType, Device, Experiment, Campaign, Configuration, Location |
|
8 | from .models import DeviceType, Device, Experiment, Campaign, Configuration, Location | |
5 |
|
9 | |||
6 | def add_empty_choice(choices, pos=0, label='-----'): |
|
10 | def add_empty_choice(choices, pos=0, label='-----'): | |
7 | if len(choices)>0: |
|
11 | if len(choices)>0: | |
8 | choices = list(choices) |
|
12 | choices = list(choices) | |
9 | choices.insert(0, (0, label)) |
|
13 | choices.insert(0, (0, label)) | |
10 | return choices |
|
14 | return choices | |
11 | else: |
|
15 | else: | |
12 | return [(0, label)] |
|
16 | return [(0, label)] | |
13 |
|
17 | |||
14 | class DatepickerWidget(forms.widgets.TextInput): |
|
18 | class DatepickerWidget(forms.widgets.TextInput): | |
15 | def render(self, name, value, attrs=None): |
|
19 | def render(self, name, value, attrs=None): | |
16 | input_html = super(DatepickerWidget, self).render(name, value, attrs) |
|
20 | input_html = super(DatepickerWidget, self).render(name, value, attrs) | |
17 | html = '<div class="input-group date">'+input_html+'<span class="input-group-addon"><i class="glyphicon glyphicon-calendar"></i></span></div>' |
|
21 | html = '<div class="input-group date">'+input_html+'<span class="input-group-addon"><i class="glyphicon glyphicon-calendar"></i></span></div>' | |
18 | return mark_safe(html) |
|
22 | return mark_safe(html) | |
19 |
|
23 | |||
20 | class TimepickerWidget(forms.widgets.TextInput): |
|
24 | class TimepickerWidget(forms.widgets.TextInput): | |
21 | def render(self, name, value, attrs=None): |
|
25 | def render(self, name, value, attrs=None): | |
22 | input_html = super(TimepickerWidget, self).render(name, value, attrs) |
|
26 | input_html = super(TimepickerWidget, self).render(name, value, attrs) | |
23 | html = '<div class="input-group time">'+input_html+'<span class="input-group-addon"><i class="glyphicon glyphicon-time"></i></span></div>' |
|
27 | html = '<div class="input-group time">'+input_html+'<span class="input-group-addon"><i class="glyphicon glyphicon-time"></i></span></div>' | |
24 | return mark_safe(html) |
|
28 | return mark_safe(html) | |
25 |
|
29 | |||
26 | class CampaignForm(forms.ModelForm): |
|
30 | class CampaignForm(forms.ModelForm): | |
27 | def __init__(self, *args, **kwargs): |
|
31 | def __init__(self, *args, **kwargs): | |
28 | super(CampaignForm, self).__init__(*args, **kwargs) |
|
32 | super(CampaignForm, self).__init__(*args, **kwargs) | |
29 | self.fields['start_date'].widget = DatepickerWidget(self.fields['start_date'].widget.attrs) |
|
33 | self.fields['start_date'].widget = DatepickerWidget(self.fields['start_date'].widget.attrs) | |
30 | self.fields['end_date'].widget = DatepickerWidget(self.fields['end_date'].widget.attrs) |
|
34 | self.fields['end_date'].widget = DatepickerWidget(self.fields['end_date'].widget.attrs) | |
31 |
|
35 | |||
32 | class Meta: |
|
36 | class Meta: | |
33 | model = Campaign |
|
37 | model = Campaign | |
34 | exclude = [''] |
|
38 | exclude = [''] | |
35 |
|
39 | |||
36 | class ExperimentForm(forms.ModelForm): |
|
40 | class ExperimentForm(forms.ModelForm): | |
37 | def __init__(self, *args, **kwargs): |
|
41 | def __init__(self, *args, **kwargs): | |
38 | super(ExperimentForm, self).__init__(*args, **kwargs) |
|
42 | super(ExperimentForm, self).__init__(*args, **kwargs) | |
39 | self.fields['start_time'].widget = TimepickerWidget(self.fields['start_time'].widget.attrs) |
|
43 | self.fields['start_time'].widget = TimepickerWidget(self.fields['start_time'].widget.attrs) | |
40 | self.fields['end_time'].widget = TimepickerWidget(self.fields['end_time'].widget.attrs) |
|
44 | self.fields['end_time'].widget = TimepickerWidget(self.fields['end_time'].widget.attrs) | |
41 |
|
45 | |||
42 | self.fields['campaign'].widget.attrs['readonly'] = True |
|
46 | self.fields['campaign'].widget.attrs['readonly'] = True | |
43 |
|
47 | |||
44 | class Meta: |
|
48 | class Meta: | |
45 | model = Experiment |
|
49 | model = Experiment | |
46 | exclude = [''] |
|
50 | exclude = [''] | |
47 |
|
51 | |||
48 | class LocationForm(forms.ModelForm): |
|
52 | class LocationForm(forms.ModelForm): | |
49 | class Meta: |
|
53 | class Meta: | |
50 | model = Location |
|
54 | model = Location | |
51 | exclude = [''] |
|
55 | exclude = [''] | |
52 |
|
56 | |||
53 | class DeviceForm(forms.ModelForm): |
|
57 | class DeviceForm(forms.ModelForm): | |
54 | class Meta: |
|
58 | class Meta: | |
55 | model = Device |
|
59 | model = Device | |
56 | exclude = ['status'] |
|
60 | exclude = ['status'] | |
57 |
|
61 | |||
58 | class ConfigurationForm(forms.ModelForm): |
|
62 | class ConfigurationForm(forms.ModelForm): | |
59 | class Meta: |
|
63 | class Meta: | |
60 | model = Configuration |
|
64 | model = Configuration | |
61 | exclude = ['type', 'created_date', 'programmed_date', 'parameters'] |
|
65 | exclude = ['type', 'created_date', 'programmed_date', 'parameters'] | |
62 |
|
66 | |||
63 | class DeviceTypeForm(forms.Form): |
|
67 | class DeviceTypeForm(forms.Form): | |
64 | device_type = forms.ChoiceField(choices=add_empty_choice(DeviceType.objects.all().order_by('name').values_list('id', 'name'))) |
|
68 | device_type = forms.ChoiceField(choices=add_empty_choice(DeviceType.objects.all().order_by('name').values_list('id', 'name'))) | |
|
69 | ||||
|
70 | class OperationForm(forms.Form): | |||
|
71 | today = datetime.today() | |||
|
72 | # -----Campaigns from this month------ | |||
|
73 | campaign = forms.ChoiceField(choices=Campaign.objects.filter(start_date__month=today.month).filter(start_date__year=today.year).order_by('-start_date').values_list('id', 'name'), label="Campaign") | |||
|
74 | No newline at end of file |
@@ -1,34 +1,37 | |||||
1 | from django.conf.urls import url |
|
1 | from django.conf.urls import url | |
2 |
|
2 | |||
3 | urlpatterns = ( |
|
3 | urlpatterns = ( | |
4 | url(r'^location/new/$', 'apps.main.views.location_new', name='url_add_location'), |
|
4 | url(r'^location/new/$', 'apps.main.views.location_new', name='url_add_location'), | |
5 | url(r'^location/$', 'apps.main.views.locations', name='url_locations'), |
|
5 | url(r'^location/$', 'apps.main.views.locations', name='url_locations'), | |
6 | url(r'^location/(?P<id_loc>-?\d+)/$', 'apps.main.views.location', name='url_location'), |
|
6 | url(r'^location/(?P<id_loc>-?\d+)/$', 'apps.main.views.location', name='url_location'), | |
7 | url(r'^location/(?P<id_loc>-?\d+)/edit/$', 'apps.main.views.location_edit', name='url_edit_location'), |
|
7 | url(r'^location/(?P<id_loc>-?\d+)/edit/$', 'apps.main.views.location_edit', name='url_edit_location'), | |
8 | url(r'^location/(?P<id_loc>-?\d+)/delete/$', 'apps.main.views.location_delete', name='url_delete_location'), |
|
8 | url(r'^location/(?P<id_loc>-?\d+)/delete/$', 'apps.main.views.location_delete', name='url_delete_location'), | |
9 |
|
9 | |||
10 | url(r'^device/new/$', 'apps.main.views.device_new', name='url_add_device'), |
|
10 | url(r'^device/new/$', 'apps.main.views.device_new', name='url_add_device'), | |
11 | url(r'^device/$', 'apps.main.views.devices', name='url_devices'), |
|
11 | url(r'^device/$', 'apps.main.views.devices', name='url_devices'), | |
12 | url(r'^device/(?P<id_dev>-?\d+)/$', 'apps.main.views.device', name='url_device'), |
|
12 | url(r'^device/(?P<id_dev>-?\d+)/$', 'apps.main.views.device', name='url_device'), | |
13 | url(r'^device/(?P<id_dev>-?\d+)/edit/$', 'apps.main.views.device_edit', name='url_edit_device'), |
|
13 | url(r'^device/(?P<id_dev>-?\d+)/edit/$', 'apps.main.views.device_edit', name='url_edit_device'), | |
14 | url(r'^device/(?P<id_dev>-?\d+)/delete/$', 'apps.main.views.device_delete', name='url_delete_device'), |
|
14 | url(r'^device/(?P<id_dev>-?\d+)/delete/$', 'apps.main.views.device_delete', name='url_delete_device'), | |
15 |
|
15 | |||
16 | url(r'^campaign/new/$', 'apps.main.views.campaign_new', name='url_add_campaign'), |
|
16 | url(r'^campaign/new/$', 'apps.main.views.campaign_new', name='url_add_campaign'), | |
17 | url(r'^campaign/$', 'apps.main.views.campaigns', name='url_campaigns'), |
|
17 | url(r'^campaign/$', 'apps.main.views.campaigns', name='url_campaigns'), | |
18 | url(r'^campaign/(?P<id_camp>-?\d+)/$', 'apps.main.views.campaign', name='url_campaign'), |
|
18 | url(r'^campaign/(?P<id_camp>-?\d+)/$', 'apps.main.views.campaign', name='url_campaign'), | |
19 | url(r'^campaign/(?P<id_camp>-?\d+)/edit/$', 'apps.main.views.campaign_edit', name='url_edit_campaign'), |
|
19 | url(r'^campaign/(?P<id_camp>-?\d+)/edit/$', 'apps.main.views.campaign_edit', name='url_edit_campaign'), | |
20 | url(r'^campaign/(?P<id_camp>-?\d+)/delete/$', 'apps.main.views.campaign_delete', name='url_delete_campaign'), |
|
20 | url(r'^campaign/(?P<id_camp>-?\d+)/delete/$', 'apps.main.views.campaign_delete', name='url_delete_campaign'), | |
21 |
|
21 | |||
22 | url(r'^campaign/(?P<id_camp>-?\d+)/new_experiment/$', 'apps.main.views.experiment_new', name='url_add_experiment'), |
|
22 | url(r'^campaign/(?P<id_camp>-?\d+)/new_experiment/$', 'apps.main.views.experiment_new', name='url_add_experiment'), | |
23 | url(r'^experiment/$', 'apps.main.views.experiments', name='url_experiments'), |
|
23 | url(r'^experiment/$', 'apps.main.views.experiments', name='url_experiments'), | |
24 | url(r'^experiment/(?P<id_exp>-?\d+)/$', 'apps.main.views.experiment', name='url_experiment'), |
|
24 | url(r'^experiment/(?P<id_exp>-?\d+)/$', 'apps.main.views.experiment', name='url_experiment'), | |
25 | url(r'^experiment/(?P<id_exp>-?\d+)/edit/$', 'apps.main.views.experiment_edit', name='url_edit_experiment'), |
|
25 | url(r'^experiment/(?P<id_exp>-?\d+)/edit/$', 'apps.main.views.experiment_edit', name='url_edit_experiment'), | |
26 | url(r'^experiment/(?P<id_exp>-?\d+)/delete/$', 'apps.main.views.experiment_delete', name='url_delete_experiment'), |
|
26 | url(r'^experiment/(?P<id_exp>-?\d+)/delete/$', 'apps.main.views.experiment_delete', name='url_delete_experiment'), | |
27 |
|
27 | |||
28 | url(r'^experiment/(?P<id_exp>-?\d+)/new_dev_conf/$', 'apps.main.views.dev_conf_new', name='url_add_dev_conf'), |
|
28 | url(r'^experiment/(?P<id_exp>-?\d+)/new_dev_conf/$', 'apps.main.views.dev_conf_new', name='url_add_dev_conf'), | |
29 | url(r'^dev_conf/$', 'apps.main.views.dev_confs', name='url_dev_confs'), |
|
29 | url(r'^dev_conf/$', 'apps.main.views.dev_confs', name='url_dev_confs'), | |
30 | url(r'^dev_conf/(?P<id_conf>-?\d+)/$', 'apps.main.views.dev_conf', name='url_dev_conf'), |
|
30 | url(r'^dev_conf/(?P<id_conf>-?\d+)/$', 'apps.main.views.dev_conf', name='url_dev_conf'), | |
31 | url(r'^dev_conf/(?P<id_conf>-?\d+)/edit/$', 'apps.main.views.dev_conf_edit', name='url_edit_dev_conf'), |
|
31 | url(r'^dev_conf/(?P<id_conf>-?\d+)/edit/$', 'apps.main.views.dev_conf_edit', name='url_edit_dev_conf'), | |
32 | url(r'^dev_conf/(?P<id_conf>-?\d+)/delete/$', 'apps.main.views.dev_conf_delete', name='url_delete_dev_conf'), |
|
32 | url(r'^dev_conf/(?P<id_conf>-?\d+)/delete/$', 'apps.main.views.dev_conf_delete', name='url_delete_dev_conf'), | |
33 |
|
33 | |||
|
34 | url(r'^operation/$', 'apps.main.views.operation', name='url_operation'), | |||
|
35 | url(r'^operation/(?P<id_camp>-?\d+)/$', 'apps.main.views.operation', name='url_operation'), | |||
|
36 | ||||
34 | ) |
|
37 | ) |
@@ -1,595 +1,631 | |||||
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 |
|
4 | from datetime import datetime | |
|
5 | ||||
|
6 | from .forms import CampaignForm, ExperimentForm, DeviceForm, ConfigurationForm, LocationForm, OperationForm | |||
5 | from apps.cgs.forms import CGSConfigurationForm |
|
7 | from apps.cgs.forms import CGSConfigurationForm | |
6 | from apps.jars.forms import JARSConfigurationForm |
|
8 | from apps.jars.forms import JARSConfigurationForm | |
7 | from apps.usrp.forms import USRPConfigurationForm |
|
9 | from apps.usrp.forms import USRPConfigurationForm | |
8 | from apps.abs.forms import ABSConfigurationForm |
|
10 | from apps.abs.forms import ABSConfigurationForm | |
9 | from apps.rc.forms import RCConfigurationForm |
|
11 | from apps.rc.forms import RCConfigurationForm | |
10 | from apps.dds.forms import DDSConfigurationForm |
|
12 | from apps.dds.forms import DDSConfigurationForm | |
11 |
|
13 | |||
12 | from .models import Campaign, Experiment, Device, Configuration, Location |
|
14 | from .models import Campaign, Experiment, Device, Configuration, Location, Radar | |
13 | from apps.cgs.models import CGSConfiguration |
|
15 | from apps.cgs.models import CGSConfiguration | |
14 | from apps.jars.models import JARSConfiguration |
|
16 | from apps.jars.models import JARSConfiguration | |
15 | from apps.usrp.models import USRPConfiguration |
|
17 | from apps.usrp.models import USRPConfiguration | |
16 | from apps.abs.models import ABSConfiguration |
|
18 | from apps.abs.models import ABSConfiguration | |
17 | from apps.rc.models import RCConfiguration |
|
19 | from apps.rc.models import RCConfiguration | |
18 | from apps.dds.models import DDSConfiguration |
|
20 | from apps.dds.models import DDSConfiguration | |
19 |
|
21 | |||
20 | # Create your views here. |
|
22 | # Create your views here. | |
21 |
|
23 | |||
22 | CONF_FORMS = { |
|
24 | CONF_FORMS = { | |
23 | 'rc': RCConfigurationForm, |
|
25 | 'rc': RCConfigurationForm, | |
24 | 'dds': DDSConfigurationForm, |
|
26 | 'dds': DDSConfigurationForm, | |
25 | 'jars': JARSConfigurationForm, |
|
27 | 'jars': JARSConfigurationForm, | |
26 | 'cgs': CGSConfigurationForm, |
|
28 | 'cgs': CGSConfigurationForm, | |
27 | 'abs': ABSConfigurationForm, |
|
29 | 'abs': ABSConfigurationForm, | |
28 | 'usrp': USRPConfigurationForm, |
|
30 | 'usrp': USRPConfigurationForm, | |
29 | } |
|
31 | } | |
30 |
|
32 | |||
31 | CONF_MODELS = { |
|
33 | CONF_MODELS = { | |
32 | 'rc': RCConfiguration, |
|
34 | 'rc': RCConfiguration, | |
33 | 'dds': DDSConfiguration, |
|
35 | 'dds': DDSConfiguration, | |
34 | 'jars': JARSConfiguration, |
|
36 | 'jars': JARSConfiguration, | |
35 | 'cgs': CGSConfiguration, |
|
37 | 'cgs': CGSConfiguration, | |
36 | 'abs': ABSConfiguration, |
|
38 | 'abs': ABSConfiguration, | |
37 | 'usrp': USRPConfiguration, |
|
39 | 'usrp': USRPConfiguration, | |
38 | } |
|
40 | } | |
39 |
|
41 | |||
40 | def index(request): |
|
42 | def index(request): | |
41 | kwargs = {} |
|
43 | kwargs = {} | |
42 |
|
44 | |||
43 | return render(request, 'index.html', kwargs) |
|
45 | return render(request, 'index.html', kwargs) | |
44 |
|
46 | |||
45 | def locations(request): |
|
47 | def locations(request): | |
46 |
|
48 | |||
47 | locations = Location.objects.all().order_by('name') |
|
49 | locations = Location.objects.all().order_by('name') | |
48 |
|
50 | |||
49 | keys = ['id', 'name', 'description'] |
|
51 | keys = ['id', 'name', 'description'] | |
50 |
|
52 | |||
51 | kwargs = {} |
|
53 | kwargs = {} | |
52 | kwargs['location_keys'] = keys[1:] |
|
54 | kwargs['location_keys'] = keys[1:] | |
53 | kwargs['locations'] = locations |
|
55 | kwargs['locations'] = locations | |
54 | kwargs['title'] = 'Location' |
|
56 | kwargs['title'] = 'Location' | |
55 | kwargs['suptitle'] = 'List' |
|
57 | kwargs['suptitle'] = 'List' | |
56 | kwargs['button'] = 'New Location' |
|
58 | kwargs['button'] = 'New Location' | |
57 |
|
59 | |||
58 | return render(request, 'locations.html', kwargs) |
|
60 | return render(request, 'locations.html', kwargs) | |
59 |
|
61 | |||
60 | def location(request, id_loc): |
|
62 | def location(request, id_loc): | |
61 |
|
63 | |||
62 | location = get_object_or_404(Location, pk=id_loc) |
|
64 | location = get_object_or_404(Location, pk=id_loc) | |
63 |
|
65 | |||
64 | kwargs = {} |
|
66 | kwargs = {} | |
65 | kwargs['location'] = location |
|
67 | kwargs['location'] = location | |
66 | kwargs['location_keys'] = ['name', 'description'] |
|
68 | kwargs['location_keys'] = ['name', 'description'] | |
67 |
|
69 | |||
68 | kwargs['title'] = 'Location' |
|
70 | kwargs['title'] = 'Location' | |
69 | kwargs['suptitle'] = 'Details' |
|
71 | kwargs['suptitle'] = 'Details' | |
70 |
|
72 | |||
71 | return render(request, 'location.html', kwargs) |
|
73 | return render(request, 'location.html', kwargs) | |
72 |
|
74 | |||
73 | def location_new(request): |
|
75 | def location_new(request): | |
74 |
|
76 | |||
75 | if request.method == 'GET': |
|
77 | if request.method == 'GET': | |
76 | form = LocationForm() |
|
78 | form = LocationForm() | |
77 |
|
79 | |||
78 | if request.method == 'POST': |
|
80 | if request.method == 'POST': | |
79 | form = LocationForm(request.POST) |
|
81 | form = LocationForm(request.POST) | |
80 |
|
82 | |||
81 | if form.is_valid(): |
|
83 | if form.is_valid(): | |
82 | form.save() |
|
84 | form.save() | |
83 | return redirect('url_locations') |
|
85 | return redirect('url_locations') | |
84 |
|
86 | |||
85 | kwargs = {} |
|
87 | kwargs = {} | |
86 | kwargs['form'] = form |
|
88 | kwargs['form'] = form | |
87 | kwargs['title'] = 'Location' |
|
89 | kwargs['title'] = 'Location' | |
88 | kwargs['suptitle'] = 'New' |
|
90 | kwargs['suptitle'] = 'New' | |
89 | kwargs['button'] = 'Create' |
|
91 | kwargs['button'] = 'Create' | |
90 |
|
92 | |||
91 | return render(request, 'location_edit.html', kwargs) |
|
93 | return render(request, 'location_edit.html', kwargs) | |
92 |
|
94 | |||
93 | def location_edit(request, id_loc): |
|
95 | def location_edit(request, id_loc): | |
94 |
|
96 | |||
95 | location = get_object_or_404(Location, pk=id_loc) |
|
97 | location = get_object_or_404(Location, pk=id_loc) | |
96 |
|
98 | |||
97 | if request.method=='GET': |
|
99 | if request.method=='GET': | |
98 | form = LocationForm(instance=location) |
|
100 | form = LocationForm(instance=location) | |
99 |
|
101 | |||
100 | if request.method=='POST': |
|
102 | if request.method=='POST': | |
101 | form = LocationForm(request.POST, instance=location) |
|
103 | form = LocationForm(request.POST, instance=location) | |
102 |
|
104 | |||
103 | if form.is_valid(): |
|
105 | if form.is_valid(): | |
104 | form.save() |
|
106 | form.save() | |
105 | return redirect('url_locations') |
|
107 | return redirect('url_locations') | |
106 |
|
108 | |||
107 | kwargs = {} |
|
109 | kwargs = {} | |
108 | kwargs['form'] = form |
|
110 | kwargs['form'] = form | |
109 | kwargs['title'] = 'Location' |
|
111 | kwargs['title'] = 'Location' | |
110 | kwargs['suptitle'] = 'Edit' |
|
112 | kwargs['suptitle'] = 'Edit' | |
111 | kwargs['button'] = 'Update' |
|
113 | kwargs['button'] = 'Update' | |
112 |
|
114 | |||
113 | return render(request, 'location_edit.html', kwargs) |
|
115 | return render(request, 'location_edit.html', kwargs) | |
114 |
|
116 | |||
115 | def location_delete(request, id_loc): |
|
117 | def location_delete(request, id_loc): | |
116 |
|
118 | |||
117 | location = get_object_or_404(Location, pk=id_loc) |
|
119 | location = get_object_or_404(Location, pk=id_loc) | |
118 |
|
120 | |||
119 | if request.method=='POST': |
|
121 | if request.method=='POST': | |
120 |
|
122 | |||
121 | if request.user.is_staff: |
|
123 | if request.user.is_staff: | |
122 | location.delete() |
|
124 | location.delete() | |
123 | return redirect('url_locations') |
|
125 | return redirect('url_locations') | |
124 |
|
126 | |||
125 | return HttpResponse("Not enough permission to delete this object") |
|
127 | return HttpResponse("Not enough permission to delete this object") | |
126 |
|
128 | |||
127 | kwargs = {'object':location, 'loc_active':'active', |
|
129 | kwargs = {'object':location, 'loc_active':'active', | |
128 | 'url_cancel':'url_location', 'id_item':id_loc} |
|
130 | 'url_cancel':'url_location', 'id_item':id_loc} | |
129 |
|
131 | |||
130 | return render(request, 'item_delete.html', kwargs) |
|
132 | return render(request, 'item_delete.html', kwargs) | |
131 |
|
133 | |||
132 | def devices(request): |
|
134 | def devices(request): | |
133 |
|
135 | |||
134 | devices = Device.objects.all().order_by('device_type__name') |
|
136 | devices = Device.objects.all().order_by('device_type__name') | |
135 |
|
137 | |||
136 | # keys = ['id', 'device_type__name', 'name', 'ip_address'] |
|
138 | # keys = ['id', 'device_type__name', 'name', 'ip_address'] | |
137 | keys = ['id', 'name', 'ip_address', 'port_address', 'device_type'] |
|
139 | keys = ['id', 'name', 'ip_address', 'port_address', 'device_type'] | |
138 |
|
140 | |||
139 | kwargs = {} |
|
141 | kwargs = {} | |
140 | kwargs['device_keys'] = keys[1:] |
|
142 | kwargs['device_keys'] = keys[1:] | |
141 | kwargs['devices'] = devices#.values(*keys) |
|
143 | kwargs['devices'] = devices#.values(*keys) | |
142 | kwargs['title'] = 'Device' |
|
144 | kwargs['title'] = 'Device' | |
143 | kwargs['suptitle'] = 'List' |
|
145 | kwargs['suptitle'] = 'List' | |
144 | kwargs['button'] = 'New Device' |
|
146 | kwargs['button'] = 'New Device' | |
145 |
|
147 | |||
146 | return render(request, 'devices.html', kwargs) |
|
148 | return render(request, 'devices.html', kwargs) | |
147 |
|
149 | |||
148 | def device(request, id_dev): |
|
150 | def device(request, id_dev): | |
149 |
|
151 | |||
150 | device = get_object_or_404(Device, pk=id_dev) |
|
152 | device = get_object_or_404(Device, pk=id_dev) | |
151 |
|
153 | |||
152 | kwargs = {} |
|
154 | kwargs = {} | |
153 | kwargs['device'] = device |
|
155 | kwargs['device'] = device | |
154 | kwargs['device_keys'] = ['device_type', 'name', 'ip_address', 'port_address', 'description'] |
|
156 | kwargs['device_keys'] = ['device_type', 'name', 'ip_address', 'port_address', 'description'] | |
155 |
|
157 | |||
156 | kwargs['title'] = 'Device' |
|
158 | kwargs['title'] = 'Device' | |
157 | kwargs['suptitle'] = 'Details' |
|
159 | kwargs['suptitle'] = 'Details' | |
158 |
|
160 | |||
159 | return render(request, 'device.html', kwargs) |
|
161 | return render(request, 'device.html', kwargs) | |
160 |
|
162 | |||
161 | def device_new(request): |
|
163 | def device_new(request): | |
162 |
|
164 | |||
163 | if request.method == 'GET': |
|
165 | if request.method == 'GET': | |
164 | form = DeviceForm() |
|
166 | form = DeviceForm() | |
165 |
|
167 | |||
166 | if request.method == 'POST': |
|
168 | if request.method == 'POST': | |
167 | form = DeviceForm(request.POST) |
|
169 | form = DeviceForm(request.POST) | |
168 |
|
170 | |||
169 | if form.is_valid(): |
|
171 | if form.is_valid(): | |
170 | form.save() |
|
172 | form.save() | |
171 | return redirect('url_devices') |
|
173 | return redirect('url_devices') | |
172 |
|
174 | |||
173 | kwargs = {} |
|
175 | kwargs = {} | |
174 | kwargs['form'] = form |
|
176 | kwargs['form'] = form | |
175 | kwargs['title'] = 'Device' |
|
177 | kwargs['title'] = 'Device' | |
176 | kwargs['suptitle'] = 'New' |
|
178 | kwargs['suptitle'] = 'New' | |
177 | kwargs['button'] = 'Create' |
|
179 | kwargs['button'] = 'Create' | |
178 |
|
180 | |||
179 | return render(request, 'device_edit.html', kwargs) |
|
181 | return render(request, 'device_edit.html', kwargs) | |
180 |
|
182 | |||
181 | def device_edit(request, id_dev): |
|
183 | def device_edit(request, id_dev): | |
182 |
|
184 | |||
183 | device = get_object_or_404(Device, pk=id_dev) |
|
185 | device = get_object_or_404(Device, pk=id_dev) | |
184 |
|
186 | |||
185 | if request.method=='GET': |
|
187 | if request.method=='GET': | |
186 | form = DeviceForm(instance=device) |
|
188 | form = DeviceForm(instance=device) | |
187 |
|
189 | |||
188 | if request.method=='POST': |
|
190 | if request.method=='POST': | |
189 | form = DeviceForm(request.POST, instance=device) |
|
191 | form = DeviceForm(request.POST, instance=device) | |
190 |
|
192 | |||
191 | if form.is_valid(): |
|
193 | if form.is_valid(): | |
192 | form.save() |
|
194 | form.save() | |
193 | return redirect('url_devices') |
|
195 | return redirect('url_devices') | |
194 |
|
196 | |||
195 | kwargs = {} |
|
197 | kwargs = {} | |
196 | kwargs['form'] = form |
|
198 | kwargs['form'] = form | |
197 | kwargs['title'] = 'Device' |
|
199 | kwargs['title'] = 'Device' | |
198 | kwargs['suptitle'] = 'Edit' |
|
200 | kwargs['suptitle'] = 'Edit' | |
199 | kwargs['button'] = 'Update' |
|
201 | kwargs['button'] = 'Update' | |
200 |
|
202 | |||
201 | return render(request, 'device_edit.html', kwargs) |
|
203 | return render(request, 'device_edit.html', kwargs) | |
202 |
|
204 | |||
203 | def device_delete(request, id_dev): |
|
205 | def device_delete(request, id_dev): | |
204 |
|
206 | |||
205 | device = get_object_or_404(Device, pk=id_dev) |
|
207 | device = get_object_or_404(Device, pk=id_dev) | |
206 |
|
208 | |||
207 | if request.method=='POST': |
|
209 | if request.method=='POST': | |
208 |
|
210 | |||
209 | if request.user.is_staff: |
|
211 | if request.user.is_staff: | |
210 | device.delete() |
|
212 | device.delete() | |
211 | return redirect('url_devices') |
|
213 | return redirect('url_devices') | |
212 |
|
214 | |||
213 | return HttpResponse("Not enough permission to delete this object") |
|
215 | return HttpResponse("Not enough permission to delete this object") | |
214 |
|
216 | |||
215 | kwargs = {'object':device, 'dev_active':'active', |
|
217 | kwargs = {'object':device, 'dev_active':'active', | |
216 | 'url_cancel':'url_device', 'id_item':id_dev} |
|
218 | 'url_cancel':'url_device', 'id_item':id_dev} | |
217 |
|
219 | |||
218 | return render(request, 'item_delete.html', kwargs) |
|
220 | return render(request, 'item_delete.html', kwargs) | |
219 |
|
221 | |||
220 | def campaigns(request): |
|
222 | def campaigns(request): | |
221 |
|
223 | |||
222 | campaigns = Campaign.objects.all().order_by('start_date') |
|
224 | campaigns = Campaign.objects.all().order_by('start_date') | |
223 |
|
225 | |||
224 | keys = ['id', 'name', 'start_date', 'end_date'] |
|
226 | keys = ['id', 'name', 'start_date', 'end_date'] | |
225 |
|
227 | |||
226 | kwargs = {} |
|
228 | kwargs = {} | |
227 | kwargs['campaign_keys'] = keys[1:] |
|
229 | kwargs['campaign_keys'] = keys[1:] | |
228 | kwargs['campaigns'] = campaigns#.values(*keys) |
|
230 | kwargs['campaigns'] = campaigns#.values(*keys) | |
229 | kwargs['title'] = 'Campaign' |
|
231 | kwargs['title'] = 'Campaign' | |
230 | kwargs['suptitle'] = 'List' |
|
232 | kwargs['suptitle'] = 'List' | |
231 | kwargs['button'] = 'New Campaign' |
|
233 | kwargs['button'] = 'New Campaign' | |
232 |
|
234 | |||
233 | return render(request, 'campaigns.html', kwargs) |
|
235 | return render(request, 'campaigns.html', kwargs) | |
234 |
|
236 | |||
235 | def campaign(request, id_camp): |
|
237 | def campaign(request, id_camp): | |
236 |
|
238 | |||
237 | campaign = get_object_or_404(Campaign, pk=id_camp) |
|
239 | campaign = get_object_or_404(Campaign, pk=id_camp) | |
238 | experiments = Experiment.objects.filter(campaign=campaign) |
|
240 | #experiments = Experiment.objects.filter(campaign=campaign) | |
239 |
|
||||
240 | form = CampaignForm(instance=campaign) |
|
241 | form = CampaignForm(instance=campaign) | |
241 |
|
242 | |||
242 | kwargs = {} |
|
243 | kwargs = {} | |
243 | kwargs['campaign'] = campaign |
|
244 | kwargs['campaign'] = campaign | |
244 | kwargs['campaign_keys'] = ['name', 'start_date', 'end_date', 'tags', 'description'] |
|
245 | kwargs['campaign_keys'] = ['name', 'start_date', 'end_date', 'tags', 'description'] | |
245 |
|
246 | |||
246 | keys = ['id', 'name', 'start_time', 'end_time'] |
|
247 | keys = ['id', 'name', 'start_time', 'end_time'] | |
247 |
|
248 | |||
248 | kwargs['experiment_keys'] = keys[1:] |
|
249 | kwargs['experiment_keys'] = keys[1:] | |
249 | kwargs['experiments'] = experiments.values(*keys) |
|
250 | #kwargs['experiments'] = experiments.values(*keys) | |
250 |
|
251 | |||
251 | kwargs['title'] = 'Campaign' |
|
252 | kwargs['title'] = 'Campaign' | |
252 | kwargs['suptitle'] = 'Details' |
|
253 | kwargs['suptitle'] = 'Details' | |
253 |
|
254 | |||
254 | kwargs['form'] = form |
|
255 | kwargs['form'] = form | |
255 | kwargs['button'] = 'Add Experiment' |
|
256 | kwargs['button'] = 'Add Experiment' | |
256 |
|
257 | |||
257 | return render(request, 'campaign.html', kwargs) |
|
258 | return render(request, 'campaign.html', kwargs) | |
258 |
|
259 | |||
259 | def campaign_new(request): |
|
260 | def campaign_new(request): | |
260 |
|
261 | |||
261 | if request.method == 'GET': |
|
262 | if request.method == 'GET': | |
262 | form = CampaignForm() |
|
263 | form = CampaignForm() | |
263 |
|
264 | |||
264 | if request.method == 'POST': |
|
265 | if request.method == 'POST': | |
265 | form = CampaignForm(request.POST) |
|
266 | form = CampaignForm(request.POST) | |
266 |
|
267 | |||
267 | if form.is_valid(): |
|
268 | if form.is_valid(): | |
268 | campaign = form.save() |
|
269 | campaign = form.save() | |
269 | return redirect('url_campaign', id_camp=campaign.id) |
|
270 | return redirect('url_campaign', id_camp=campaign.id) | |
270 |
|
271 | |||
271 | kwargs = {} |
|
272 | kwargs = {} | |
272 | kwargs['form'] = form |
|
273 | kwargs['form'] = form | |
273 | kwargs['title'] = 'Campaign' |
|
274 | kwargs['title'] = 'Campaign' | |
274 | kwargs['suptitle'] = 'New' |
|
275 | kwargs['suptitle'] = 'New' | |
275 | kwargs['button'] = 'Create' |
|
276 | kwargs['button'] = 'Create' | |
276 |
|
277 | |||
277 | return render(request, 'campaign_edit.html', kwargs) |
|
278 | return render(request, 'campaign_edit.html', kwargs) | |
278 |
|
279 | |||
279 | def campaign_edit(request, id_camp): |
|
280 | def campaign_edit(request, id_camp): | |
280 |
|
281 | |||
281 | campaign = get_object_or_404(Campaign, pk=id_camp) |
|
282 | campaign = get_object_or_404(Campaign, pk=id_camp) | |
282 |
|
283 | |||
283 | if request.method=='GET': |
|
284 | if request.method=='GET': | |
284 | form = CampaignForm(instance=campaign) |
|
285 | form = CampaignForm(instance=campaign) | |
285 |
|
286 | |||
286 | if request.method=='POST': |
|
287 | if request.method=='POST': | |
287 | form = CampaignForm(request.POST, instance=campaign) |
|
288 | form = CampaignForm(request.POST, instance=campaign) | |
288 |
|
289 | |||
289 | if form.is_valid(): |
|
290 | if form.is_valid(): | |
290 | form.save() |
|
291 | form.save() | |
291 | return redirect('url_campaign', id_camp=id_camp) |
|
292 | return redirect('url_campaign', id_camp=id_camp) | |
292 |
|
293 | |||
293 | kwargs = {} |
|
294 | kwargs = {} | |
294 | kwargs['form'] = form |
|
295 | kwargs['form'] = form | |
295 | kwargs['title'] = 'Campaign' |
|
296 | kwargs['title'] = 'Campaign' | |
296 | kwargs['suptitle'] = 'Edit' |
|
297 | kwargs['suptitle'] = 'Edit' | |
297 | kwargs['button'] = 'Update' |
|
298 | kwargs['button'] = 'Update' | |
298 |
|
299 | |||
299 | return render(request, 'campaign_edit.html', kwargs) |
|
300 | return render(request, 'campaign_edit.html', kwargs) | |
300 |
|
301 | |||
301 | def campaign_delete(request, id_camp): |
|
302 | def campaign_delete(request, id_camp): | |
302 |
|
303 | |||
303 | campaign = get_object_or_404(Campaign, pk=id_camp) |
|
304 | campaign = get_object_or_404(Campaign, pk=id_camp) | |
304 |
|
305 | |||
305 | if request.method=='POST': |
|
306 | if request.method=='POST': | |
306 | if request.user.is_staff: |
|
307 | if request.user.is_staff: | |
307 | campaign.delete() |
|
308 | campaign.delete() | |
308 | return redirect('url_campaigns') |
|
309 | return redirect('url_campaigns') | |
309 |
|
310 | |||
310 | return HttpResponse("Not enough permission to delete this object") |
|
311 | return HttpResponse("Not enough permission to delete this object") | |
311 |
|
312 | |||
312 | kwargs = {'object':campaign, 'camp_active':'active', |
|
313 | kwargs = {'object':campaign, 'camp_active':'active', | |
313 | 'url_cancel':'url_campaign', 'id_item':id_camp} |
|
314 | 'url_cancel':'url_campaign', 'id_item':id_camp} | |
314 |
|
315 | |||
315 | return render(request, 'item_delete.html', kwargs) |
|
316 | return render(request, 'item_delete.html', kwargs) | |
316 |
|
317 | |||
317 | def experiments(request): |
|
318 | def experiments(request): | |
318 |
|
319 | |||
319 | experiment_list = Experiment.objects.all().order_by('campaign') |
|
320 | experiment_list = Experiment.objects.all().order_by('campaign') | |
320 |
|
321 | |||
321 | keys = ['id', 'name', 'start_time', 'end_time', 'campaign'] |
|
322 | keys = ['id', 'name', 'start_time', 'end_time', 'campaign'] | |
322 |
|
323 | |||
323 | kwargs = {} |
|
324 | kwargs = {} | |
324 |
|
325 | |||
325 | kwargs['experiment_keys'] = keys[1:] |
|
326 | kwargs['experiment_keys'] = keys[1:] | |
326 | kwargs['experiments'] = experiment_list#.values(*keys) |
|
327 | kwargs['experiments'] = experiment_list#.values(*keys) | |
327 |
|
328 | |||
328 | kwargs['title'] = 'Experiment' |
|
329 | kwargs['title'] = 'Experiment' | |
329 | kwargs['suptitle'] = 'List' |
|
330 | kwargs['suptitle'] = 'List' | |
330 | kwargs['button'] = 'New Experiment' |
|
331 | kwargs['button'] = 'New Experiment' | |
331 |
|
332 | |||
332 | return render(request, 'experiments.html', kwargs) |
|
333 | return render(request, 'experiments.html', kwargs) | |
333 |
|
334 | |||
334 | def experiment(request, id_exp): |
|
335 | def experiment(request, id_exp): | |
335 |
|
336 | |||
336 | experiment = get_object_or_404(Experiment, pk=id_exp) |
|
337 | experiment = get_object_or_404(Experiment, pk=id_exp) | |
337 |
|
338 | |||
338 | experiments = Experiment.objects.filter(campaign=experiment.campaign) |
|
339 | experiments = Experiment.objects.filter(campaign=experiment.campaign) | |
339 | configurations = Configuration.objects.filter(experiment=experiment, type=0) |
|
340 | configurations = Configuration.objects.filter(experiment=experiment, type=0) | |
340 |
|
341 | |||
341 | kwargs = {} |
|
342 | kwargs = {} | |
342 |
|
343 | |||
343 | exp_keys = ['id', 'campaign', 'name', 'start_time', 'end_time'] |
|
344 | exp_keys = ['id', 'campaign', 'name', 'start_time', 'end_time'] | |
344 | conf_keys = ['id', 'device__name', 'device__device_type', 'device__ip_address', 'device__port_address'] |
|
345 | conf_keys = ['id', 'device__name', 'device__device_type', 'device__ip_address', 'device__port_address'] | |
345 |
|
346 | |||
346 | conf_labels = ['id', 'device__name', 'device_type', 'ip_address', 'port_address'] |
|
347 | conf_labels = ['id', 'device__name', 'device_type', 'ip_address', 'port_address'] | |
347 |
|
348 | |||
348 | kwargs['experiment_keys'] = exp_keys[1:] |
|
349 | kwargs['experiment_keys'] = exp_keys[1:] | |
349 | kwargs['experiment'] = experiment |
|
350 | kwargs['experiment'] = experiment | |
350 |
|
351 | |||
351 | kwargs['experiments'] = experiments.values(*exp_keys) |
|
352 | kwargs['experiments'] = experiments.values(*exp_keys) | |
352 |
|
353 | |||
353 | kwargs['configuration_labels'] = conf_labels[1:] |
|
354 | kwargs['configuration_labels'] = conf_labels[1:] | |
354 | kwargs['configuration_keys'] = conf_keys[1:] |
|
355 | kwargs['configuration_keys'] = conf_keys[1:] | |
355 | kwargs['configurations'] = configurations #.values(*conf_keys) |
|
356 | kwargs['configurations'] = configurations #.values(*conf_keys) | |
356 |
|
357 | |||
357 | kwargs['title'] = 'Experiment' |
|
358 | kwargs['title'] = 'Experiment' | |
358 | kwargs['suptitle'] = 'Details' |
|
359 | kwargs['suptitle'] = 'Details' | |
359 |
|
360 | |||
360 | kwargs['button'] = 'Add Configuration' |
|
361 | kwargs['button'] = 'Add Configuration' | |
361 |
|
362 | |||
362 | return render(request, 'experiment.html', kwargs) |
|
363 | return render(request, 'experiment.html', kwargs) | |
363 |
|
364 | |||
364 | def experiment_new(request, id_camp=0): |
|
365 | def experiment_new(request, id_camp=0): | |
365 |
|
366 | |||
366 | if request.method == 'GET': |
|
367 | if request.method == 'GET': | |
367 | form = ExperimentForm(initial={'campaign':id_camp}) |
|
368 | form = ExperimentForm(initial={'campaign':id_camp}) | |
368 |
|
369 | |||
369 | if request.method == 'POST': |
|
370 | if request.method == 'POST': | |
370 | form = ExperimentForm(request.POST, initial={'campaign':id_camp}) |
|
371 | form = ExperimentForm(request.POST, initial={'campaign':id_camp}) | |
371 |
|
372 | |||
372 | if form.is_valid(): |
|
373 | if form.is_valid(): | |
373 | experiment = form.save() |
|
374 | experiment = form.save() | |
374 | return redirect('url_experiment', id_exp=experiment.id) |
|
375 | return redirect('url_experiment', id_exp=experiment.id) | |
375 |
|
376 | |||
376 | kwargs = {} |
|
377 | kwargs = {} | |
377 | kwargs['form'] = form |
|
378 | kwargs['form'] = form | |
378 | kwargs['title'] = 'Experiment' |
|
379 | kwargs['title'] = 'Experiment' | |
379 | kwargs['suptitle'] = 'New' |
|
380 | kwargs['suptitle'] = 'New' | |
380 | kwargs['button'] = 'Create' |
|
381 | kwargs['button'] = 'Create' | |
381 |
|
382 | |||
382 | return render(request, 'experiment_edit.html', kwargs) |
|
383 | return render(request, 'experiment_edit.html', kwargs) | |
383 |
|
384 | |||
384 | def experiment_edit(request, id_exp): |
|
385 | def experiment_edit(request, id_exp): | |
385 |
|
386 | |||
386 | experiment = get_object_or_404(Experiment, pk=id_exp) |
|
387 | experiment = get_object_or_404(Experiment, pk=id_exp) | |
387 |
|
388 | |||
388 | if request.method == 'GET': |
|
389 | if request.method == 'GET': | |
389 | form = ExperimentForm(instance=experiment) |
|
390 | form = ExperimentForm(instance=experiment) | |
390 |
|
391 | |||
391 | if request.method=='POST': |
|
392 | if request.method=='POST': | |
392 | form = ExperimentForm(request.POST, instance=experiment) |
|
393 | form = ExperimentForm(request.POST, instance=experiment) | |
393 |
|
394 | |||
394 | if form.is_valid(): |
|
395 | if form.is_valid(): | |
395 | experiment = form.save() |
|
396 | experiment = form.save() | |
396 | return redirect('url_experiment', id_exp=experiment.id) |
|
397 | return redirect('url_experiment', id_exp=experiment.id) | |
397 |
|
398 | |||
398 | kwargs = {} |
|
399 | kwargs = {} | |
399 | kwargs['form'] = form |
|
400 | kwargs['form'] = form | |
400 | kwargs['title'] = 'Experiment' |
|
401 | kwargs['title'] = 'Experiment' | |
401 | kwargs['suptitle'] = 'Edit' |
|
402 | kwargs['suptitle'] = 'Edit' | |
402 | kwargs['button'] = 'Update' |
|
403 | kwargs['button'] = 'Update' | |
403 |
|
404 | |||
404 | return render(request, 'experiment_edit.html', kwargs) |
|
405 | return render(request, 'experiment_edit.html', kwargs) | |
405 |
|
406 | |||
406 | def experiment_delete(request, id_exp): |
|
407 | def experiment_delete(request, id_exp): | |
407 |
|
408 | |||
408 | experiment = get_object_or_404(Experiment, pk=id_exp) |
|
409 | experiment = get_object_or_404(Experiment, pk=id_exp) | |
409 |
|
410 | |||
410 | if request.method=='POST': |
|
411 | if request.method=='POST': | |
411 | if request.user.is_staff: |
|
412 | if request.user.is_staff: | |
412 | id_camp = experiment.campaign.id |
|
413 | id_camp = experiment.campaign.id | |
413 | experiment.delete() |
|
414 | experiment.delete() | |
414 | return redirect('url_campaign', id_camp=id_camp) |
|
415 | return redirect('url_campaign', id_camp=id_camp) | |
415 |
|
416 | |||
416 | return HttpResponse("Not enough permission to delete this object") |
|
417 | return HttpResponse("Not enough permission to delete this object") | |
417 |
|
418 | |||
418 | kwargs = {'object':experiment, 'exp_active':'active', |
|
419 | kwargs = {'object':experiment, 'exp_active':'active', | |
419 | 'url_cancel':'url_experiment', 'id_item':id_exp} |
|
420 | 'url_cancel':'url_experiment', 'id_item':id_exp} | |
420 |
|
421 | |||
421 | return render(request, 'item_delete.html', kwargs) |
|
422 | return render(request, 'item_delete.html', kwargs) | |
422 |
|
423 | |||
423 | def dev_confs(request): |
|
424 | def dev_confs(request): | |
424 |
|
425 | |||
425 | configurations = Configuration.objects.all().order_by('type', 'device__device_type', 'experiment') |
|
426 | configurations = Configuration.objects.all().order_by('type', 'device__device_type', 'experiment') | |
426 |
|
427 | |||
427 | # keys = ['id', 'device__device_type__name', 'device__name', 'experiment__campaign__name', 'experiment__name'] |
|
428 | # keys = ['id', 'device__device_type__name', 'device__name', 'experiment__campaign__name', 'experiment__name'] | |
428 |
|
429 | |||
429 | keys = ['id', 'device', 'experiment', 'type', 'programmed_date'] |
|
430 | keys = ['id', 'device', 'experiment', 'type', 'programmed_date'] | |
430 |
|
431 | |||
431 | kwargs = {} |
|
432 | kwargs = {} | |
432 |
|
433 | |||
433 | kwargs['configuration_keys'] = keys[1:] |
|
434 | kwargs['configuration_keys'] = keys[1:] | |
434 | kwargs['configurations'] = configurations#.values(*keys) |
|
435 | kwargs['configurations'] = configurations#.values(*keys) | |
435 |
|
436 | |||
436 | kwargs['title'] = 'Configuration' |
|
437 | kwargs['title'] = 'Configuration' | |
437 | kwargs['suptitle'] = 'List' |
|
438 | kwargs['suptitle'] = 'List' | |
438 | kwargs['button'] = 'New Configuration' |
|
439 | kwargs['button'] = 'New Configuration' | |
439 |
|
440 | |||
440 | return render(request, 'dev_confs.html', kwargs) |
|
441 | return render(request, 'dev_confs.html', kwargs) | |
441 |
|
442 | |||
442 | def dev_conf(request, id_conf): |
|
443 | def dev_conf(request, id_conf): | |
443 |
|
444 | |||
444 | conf = get_object_or_404(Configuration, pk=id_conf) |
|
445 | conf = get_object_or_404(Configuration, pk=id_conf) | |
445 |
|
446 | |||
446 | DevConfModel = CONF_MODELS[conf.device.device_type.name] |
|
447 | DevConfModel = CONF_MODELS[conf.device.device_type.name] | |
447 | dev_conf = DevConfModel.objects.get(pk=id_conf) |
|
448 | dev_conf = DevConfModel.objects.get(pk=id_conf) | |
448 |
|
449 | |||
449 | kwargs = {} |
|
450 | kwargs = {} | |
450 | kwargs['dev_conf'] = dev_conf |
|
451 | kwargs['dev_conf'] = dev_conf | |
451 | kwargs['dev_conf_keys'] = ['name', 'experiment', 'device'] |
|
452 | kwargs['dev_conf_keys'] = ['name', 'experiment', 'device'] | |
452 |
|
453 | |||
453 | kwargs['title'] = 'Configuration' |
|
454 | kwargs['title'] = 'Configuration' | |
454 | kwargs['suptitle'] = 'Details' |
|
455 | kwargs['suptitle'] = 'Details' | |
455 |
|
456 | |||
456 | kwargs['button'] = 'Edit Configuration' |
|
457 | kwargs['button'] = 'Edit Configuration' | |
457 |
|
458 | |||
458 | ###### SIDEBAR ###### |
|
459 | ###### SIDEBAR ###### | |
459 | kwargs.update(sidebar(conf)) |
|
460 | kwargs.update(sidebar(conf)) | |
460 |
|
461 | |||
461 | return render(request, 'dev_conf.html', kwargs) |
|
462 | return render(request, 'dev_conf.html', kwargs) | |
462 |
|
463 | |||
463 | def dev_conf_new(request, id_exp=0): |
|
464 | def dev_conf_new(request, id_exp=0): | |
464 |
|
465 | |||
465 | if request.method == 'GET': |
|
466 | if request.method == 'GET': | |
466 | form = ConfigurationForm(initial={'experiment':id_exp}) |
|
467 | form = ConfigurationForm(initial={'experiment':id_exp}) | |
467 |
|
468 | |||
468 | if request.method == 'POST': |
|
469 | if request.method == 'POST': | |
469 | experiment = Experiment.objects.get(pk=request.POST['experiment']) |
|
470 | experiment = Experiment.objects.get(pk=request.POST['experiment']) | |
470 | device = Device.objects.get(pk=request.POST['device']) |
|
471 | device = Device.objects.get(pk=request.POST['device']) | |
471 |
|
472 | |||
472 | DevConfForm = CONF_FORMS[device.device_type.name] |
|
473 | DevConfForm = CONF_FORMS[device.device_type.name] | |
473 |
|
474 | |||
474 | form = DevConfForm(request.POST, initial={'experiment':experiment.id}) |
|
475 | form = DevConfForm(request.POST, initial={'experiment':experiment.id}) | |
475 |
|
476 | |||
476 | if form.is_valid(): |
|
477 | if form.is_valid(): | |
477 | dev_conf = form.save() |
|
478 | dev_conf = form.save() | |
478 |
|
479 | |||
479 | return redirect('url_experiment', id_exp=experiment.id) |
|
480 | return redirect('url_experiment', id_exp=experiment.id) | |
480 |
|
481 | |||
481 | kwargs = {} |
|
482 | kwargs = {} | |
482 | kwargs['form'] = form |
|
483 | kwargs['form'] = form | |
483 | kwargs['title'] = 'Configuration' |
|
484 | kwargs['title'] = 'Configuration' | |
484 | kwargs['suptitle'] = 'New' |
|
485 | kwargs['suptitle'] = 'New' | |
485 | kwargs['button'] = 'Create' |
|
486 | kwargs['button'] = 'Create' | |
486 |
|
487 | |||
487 | return render(request, 'dev_conf_edit.html', kwargs) |
|
488 | return render(request, 'dev_conf_edit.html', kwargs) | |
488 |
|
489 | |||
489 | def dev_conf_edit(request, id_conf): |
|
490 | def dev_conf_edit(request, id_conf): | |
490 |
|
491 | |||
491 | conf = get_object_or_404(Configuration, pk=id_conf) |
|
492 | conf = get_object_or_404(Configuration, pk=id_conf) | |
492 |
|
493 | |||
493 | DevConfModel = CONF_MODELS[conf.device.device_type.name] |
|
494 | DevConfModel = CONF_MODELS[conf.device.device_type.name] | |
494 | DevConfForm = CONF_FORMS[conf.device.device_type.name] |
|
495 | DevConfForm = CONF_FORMS[conf.device.device_type.name] | |
495 |
|
496 | |||
496 | dev_conf = DevConfModel.objects.get(pk=id_conf) |
|
497 | dev_conf = DevConfModel.objects.get(pk=id_conf) | |
497 |
|
498 | |||
498 | if request.method=='GET': |
|
499 | if request.method=='GET': | |
499 | form = DevConfForm(instance=dev_conf) |
|
500 | form = DevConfForm(instance=dev_conf) | |
500 |
|
501 | |||
501 | if request.method=='POST': |
|
502 | if request.method=='POST': | |
502 | form = DevConfForm(request.POST, instance=dev_conf) |
|
503 | form = DevConfForm(request.POST, instance=dev_conf) | |
503 |
|
504 | |||
504 | if form.is_valid(): |
|
505 | if form.is_valid(): | |
505 | form.save() |
|
506 | form.save() | |
506 | return redirect('url_dev_conf', id_conf=id_conf) |
|
507 | return redirect('url_dev_conf', id_conf=id_conf) | |
507 |
|
508 | |||
508 | kwargs = {} |
|
509 | kwargs = {} | |
509 | kwargs['form'] = form |
|
510 | kwargs['form'] = form | |
510 | kwargs['title'] = 'Device Configuration' |
|
511 | kwargs['title'] = 'Device Configuration' | |
511 | kwargs['suptitle'] = 'Edit' |
|
512 | kwargs['suptitle'] = 'Edit' | |
512 | kwargs['button'] = 'Update' |
|
513 | kwargs['button'] = 'Update' | |
513 |
|
514 | |||
514 | ###### SIDEBAR ###### |
|
515 | ###### SIDEBAR ###### | |
515 | kwargs.update(sidebar(conf)) |
|
516 | kwargs.update(sidebar(conf)) | |
516 |
|
517 | |||
517 | return render(request, 'dev_conf_edit.html', kwargs) |
|
518 | return render(request, 'dev_conf_edit.html', kwargs) | |
518 |
|
519 | |||
519 | def dev_conf_read(request, id_conf): |
|
520 | def dev_conf_read(request, id_conf): | |
520 |
|
521 | |||
521 | conf = get_object_or_404(Configuration, pk=id_conf) |
|
522 | conf = get_object_or_404(Configuration, pk=id_conf) | |
522 |
|
523 | |||
523 | messages.error(request, "Read View not implemented yet") |
|
524 | messages.error(request, "Read View not implemented yet") | |
524 |
|
525 | |||
525 | return redirect('url_dev_conf', id_conf=conf.id) |
|
526 | return redirect('url_dev_conf', id_conf=conf.id) | |
526 |
|
527 | |||
527 | def dev_conf_write(request, id_conf): |
|
528 | def dev_conf_write(request, id_conf): | |
528 |
|
529 | |||
529 | conf = get_object_or_404(Configuration, pk=id_conf) |
|
530 | conf = get_object_or_404(Configuration, pk=id_conf) | |
530 |
|
531 | |||
531 | messages.error(request, "Write View not implemented yet") |
|
532 | messages.error(request, "Write View not implemented yet") | |
532 |
|
533 | |||
533 | return redirect('url_dev_conf', id_conf=conf.id) |
|
534 | return redirect('url_dev_conf', id_conf=conf.id) | |
534 |
|
535 | |||
535 | def dev_conf_import(request, id_conf): |
|
536 | def dev_conf_import(request, id_conf): | |
536 |
|
537 | |||
537 | conf = get_object_or_404(Configuration, pk=id_conf) |
|
538 | conf = get_object_or_404(Configuration, pk=id_conf) | |
538 |
|
539 | |||
539 | messages.error(request, "Import View not implemented yet") |
|
540 | messages.error(request, "Import View not implemented yet") | |
540 |
|
541 | |||
541 | return redirect('url_dev_conf', id_conf=conf.id) |
|
542 | return redirect('url_dev_conf', id_conf=conf.id) | |
542 |
|
543 | |||
543 | def dev_conf_export(request, id_conf): |
|
544 | def dev_conf_export(request, id_conf): | |
544 |
|
545 | |||
545 | conf = get_object_or_404(Configuration, pk=id_conf) |
|
546 | conf = get_object_or_404(Configuration, pk=id_conf) | |
546 |
|
547 | |||
547 | messages.error(request, "Export View not implemented yet") |
|
548 | messages.error(request, "Export View not implemented yet") | |
548 |
|
549 | |||
549 | return redirect('url_dev_conf', id_conf=conf.id) |
|
550 | return redirect('url_dev_conf', id_conf=conf.id) | |
550 |
|
551 | |||
551 | def dev_conf_delete(request, id_conf): |
|
552 | def dev_conf_delete(request, id_conf): | |
552 |
|
553 | |||
553 | conf = get_object_or_404(Configuration, pk=id_conf) |
|
554 | conf = get_object_or_404(Configuration, pk=id_conf) | |
554 |
|
555 | |||
555 | if request.method=='POST': |
|
556 | if request.method=='POST': | |
556 | if request.user.is_staff: |
|
557 | if request.user.is_staff: | |
557 | id_exp = conf.experiment.id |
|
558 | id_exp = conf.experiment.id | |
558 | conf.delete() |
|
559 | conf.delete() | |
559 | return redirect('url_experiment', id_exp=id_exp) |
|
560 | return redirect('url_experiment', id_exp=id_exp) | |
560 |
|
561 | |||
561 | return HttpResponse("Not enough permission to delete this object") |
|
562 | return HttpResponse("Not enough permission to delete this object") | |
562 |
|
563 | |||
563 | kwargs = {'object':conf, 'conf_active':'active', |
|
564 | kwargs = {'object':conf, 'conf_active':'active', | |
564 | 'url_cancel':'url_dev_conf', 'id_item':id_conf} |
|
565 | 'url_cancel':'url_dev_conf', 'id_item':id_conf} | |
565 |
|
566 | |||
566 | ###### SIDEBAR ###### |
|
567 | ###### SIDEBAR ###### | |
567 | kwargs.update(sidebar(conf)) |
|
568 | kwargs.update(sidebar(conf)) | |
568 |
|
569 | |||
569 | return render(request, 'item_delete.html', kwargs) |
|
570 | return render(request, 'item_delete.html', kwargs) | |
570 |
|
571 | |||
571 | def sidebar(conf): |
|
572 | def sidebar(conf): | |
572 |
|
573 | |||
573 | experiments = Experiment.objects.filter(campaign=conf.experiment.campaign) |
|
574 | experiments = Experiment.objects.filter(campaign=conf.experiment.campaign) | |
574 | configurations = Configuration.objects.filter(experiment=conf.experiment, type=0) |
|
575 | configurations = Configuration.objects.filter(experiment=conf.experiment, type=0) | |
575 |
|
576 | |||
576 | exp_keys = ['id', 'campaign', 'name', 'start_time', 'end_time'] |
|
577 | exp_keys = ['id', 'campaign', 'name', 'start_time', 'end_time'] | |
577 | conf_keys = ['id', 'device'] |
|
578 | conf_keys = ['id', 'device'] | |
578 |
|
579 | |||
579 | kwargs = {} |
|
580 | kwargs = {} | |
580 |
|
581 | |||
581 | kwargs['dev_conf'] = conf |
|
582 | kwargs['dev_conf'] = conf | |
582 |
|
583 | |||
583 | kwargs['experiment_keys'] = exp_keys[1:] |
|
584 | kwargs['experiment_keys'] = exp_keys[1:] | |
584 | kwargs['experiments'] = experiments.values(*exp_keys) |
|
585 | kwargs['experiments'] = experiments.values(*exp_keys) | |
585 |
|
586 | |||
586 | kwargs['configuration_keys'] = conf_keys[1:] |
|
587 | kwargs['configuration_keys'] = conf_keys[1:] | |
587 | kwargs['configurations'] = configurations #.values(*conf_keys) |
|
588 | kwargs['configurations'] = configurations #.values(*conf_keys) | |
588 |
|
589 | |||
589 | return kwargs |
|
590 | return kwargs | |
590 |
|
591 | |||
591 |
|
592 | |||
592 | def operation(request): |
|
593 | def operation(request, id_camp=None): | |
593 |
|
|
594 | ||
594 |
|
595 | today = datetime.today() | ||
595 |
|
596 | |||
|
597 | if id_camp==None: | |||
|
598 | id_camp = Campaign.objects.filter(start_date__month=today.month).filter(start_date__year=today.year).order_by('-start_date')[0].id | |||
|
599 | ||||
|
600 | if request.method=='GET': | |||
|
601 | campaign = get_object_or_404(Campaign, pk = id_camp) | |||
|
602 | campaigns = Campaign.objects.filter(start_date__month=today.month).filter(start_date__year=today.year).order_by('-start_date') | |||
|
603 | form = OperationForm(initial={'campaign': id_camp}) | |||
|
604 | ||||
|
605 | if request.method=='POST': | |||
|
606 | campaign = get_object_or_404(Campaign, pk=request.POST['campaign']) | |||
|
607 | #id_camp = Campaign.objects.filter(start_date__month=today.month).filter(start_date__year=today.year).order_by('-start_date')[1].id | |||
|
608 | form = OperationForm(request.POST, initial={'campaign':campaign.name}) | |||
|
609 | if form.is_valid(): | |||
|
610 | return redirect('url_operation', id_camp=campaign.id) | |||
|
611 | ||||
|
612 | radars = Radar.objects.filter(campaign = campaign) | |||
|
613 | experiments = [Experiment.objects.filter(radar=radar) for radar in radars] #zip(radars, [Experiment.objects.filter(radar=radar) for radar in radars]) | |||
|
614 | ||||
|
615 | kwargs = {} | |||
|
616 | #---Campaign | |||
|
617 | kwargs['campaign'] = campaign | |||
|
618 | kwargs['campaign_keys'] = ['name', 'start_date', 'end_date', 'tags', 'description'] | |||
|
619 | #---Experimet | |||
|
620 | keys = ['id', 'name', 'start_time', 'end_time', 'radar'] | |||
|
621 | kwargs['experiment_keys'] = keys[1:] | |||
|
622 | kwargs['experiments'] = experiments | |||
|
623 | #---Radar | |||
|
624 | kwargs['radars'] = radars | |||
|
625 | #---Else | |||
|
626 | kwargs['title'] = 'Operation' | |||
|
627 | kwargs['suptitle'] = campaign.name | |||
|
628 | kwargs['form'] = form | |||
|
629 | kwargs['button'] = '...' | |||
|
630 | ||||
|
631 | return render(request, 'operation.html', kwargs) No newline at end of file |
@@ -1,123 +1,123 | |||||
1 | """ |
|
1 | """ | |
2 | Django settings for radarsys project. |
|
2 | Django settings for radarsys project. | |
3 |
|
3 | |||
4 | Generated by 'django-admin startproject' using Django 1.8.6. |
|
4 | Generated by 'django-admin startproject' using Django 1.8.6. | |
5 |
|
5 | |||
6 | For more information on this file, see |
|
6 | For more information on this file, see | |
7 | https://docs.djangoproject.com/en/1.8/topics/settings/ |
|
7 | https://docs.djangoproject.com/en/1.8/topics/settings/ | |
8 |
|
8 | |||
9 | For the full list of settings and their values, see |
|
9 | For the full list of settings and their values, see | |
10 | https://docs.djangoproject.com/en/1.8/ref/settings/ |
|
10 | https://docs.djangoproject.com/en/1.8/ref/settings/ | |
11 | """ |
|
11 | """ | |
12 |
|
12 | |||
13 | # Build paths inside the project like this: os.path.join(BASE_DIR, ...) |
|
13 | # Build paths inside the project like this: os.path.join(BASE_DIR, ...) | |
14 | import os |
|
14 | import os | |
15 |
|
15 | |||
16 | BASE_DIR = os.path.dirname(os.path.abspath(__file__)) |
|
16 | BASE_DIR = os.path.dirname(os.path.abspath(__file__)) | |
17 |
|
17 | |||
18 | # Quick-start development settings - unsuitable for production |
|
18 | # Quick-start development settings - unsuitable for production | |
19 | # See https://docs.djangoproject.com/en/1.8/howto/deployment/checklist/ |
|
19 | # See https://docs.djangoproject.com/en/1.8/howto/deployment/checklist/ | |
20 |
|
20 | |||
21 | # SECURITY WARNING: keep the secret key used in production secret! |
|
21 | # SECURITY WARNING: keep the secret key used in production secret! | |
22 | SECRET_KEY = 'xshb$k5fc-+j16)cvyffj&9u__0q3$l!hieh#+tbzqg)*f^km0' |
|
22 | SECRET_KEY = 'xshb$k5fc-+j16)cvyffj&9u__0q3$l!hieh#+tbzqg)*f^km0' | |
23 |
|
23 | |||
24 | # SECURITY WARNING: don't run with debug turned on in production! |
|
24 | # SECURITY WARNING: don't run with debug turned on in production! | |
25 | DEBUG = True |
|
25 | DEBUG = True | |
26 |
|
26 | |||
27 | ALLOWED_HOSTS = [] |
|
27 | ALLOWED_HOSTS = [] | |
28 |
|
28 | |||
29 | # Application definition |
|
29 | # Application definition | |
30 |
|
30 | |||
31 | INSTALLED_APPS = ( |
|
31 | INSTALLED_APPS = ( | |
32 | 'django.contrib.admin', |
|
32 | 'django.contrib.admin', | |
33 | 'django.contrib.auth', |
|
33 | 'django.contrib.auth', | |
34 | 'django.contrib.contenttypes', |
|
34 | 'django.contrib.contenttypes', | |
35 | 'django.contrib.sessions', |
|
35 | 'django.contrib.sessions', | |
36 | 'django.contrib.messages', |
|
36 | 'django.contrib.messages', | |
37 | 'django.contrib.staticfiles', |
|
37 | 'django.contrib.staticfiles', | |
38 | 'bootstrap3', |
|
38 | 'bootstrap3', | |
39 | 'polymorphic', |
|
39 | 'polymorphic', | |
40 | 'apps.accounts', |
|
40 | 'apps.accounts', | |
41 | 'apps.main', |
|
41 | 'apps.main', | |
42 | 'apps.misc', |
|
42 | 'apps.misc', | |
43 | 'apps.rc', |
|
43 | 'apps.rc', | |
44 | 'apps.dds', |
|
44 | 'apps.dds', | |
45 | 'apps.cgs', |
|
45 | 'apps.cgs', | |
46 | 'apps.jars', |
|
46 | 'apps.jars', | |
47 | 'apps.usrp', |
|
47 | 'apps.usrp', | |
48 | 'apps.abs', |
|
48 | 'apps.abs', | |
49 | ) |
|
49 | ) | |
50 |
|
50 | |||
51 | MIDDLEWARE_CLASSES = ( |
|
51 | MIDDLEWARE_CLASSES = ( | |
52 | 'django.contrib.sessions.middleware.SessionMiddleware', |
|
52 | 'django.contrib.sessions.middleware.SessionMiddleware', | |
53 | 'django.middleware.common.CommonMiddleware', |
|
53 | 'django.middleware.common.CommonMiddleware', | |
54 | 'django.middleware.csrf.CsrfViewMiddleware', |
|
54 | 'django.middleware.csrf.CsrfViewMiddleware', | |
55 | 'django.contrib.auth.middleware.AuthenticationMiddleware', |
|
55 | 'django.contrib.auth.middleware.AuthenticationMiddleware', | |
56 | 'django.contrib.auth.middleware.SessionAuthenticationMiddleware', |
|
56 | 'django.contrib.auth.middleware.SessionAuthenticationMiddleware', | |
57 | 'django.contrib.messages.middleware.MessageMiddleware', |
|
57 | 'django.contrib.messages.middleware.MessageMiddleware', | |
58 | 'django.middleware.clickjacking.XFrameOptionsMiddleware', |
|
58 | 'django.middleware.clickjacking.XFrameOptionsMiddleware', | |
59 | 'django.middleware.security.SecurityMiddleware', |
|
59 | 'django.middleware.security.SecurityMiddleware', | |
60 | ) |
|
60 | ) | |
61 |
|
61 | |||
62 | ROOT_URLCONF = 'radarsys.urls' |
|
62 | ROOT_URLCONF = 'radarsys.urls' | |
63 |
|
63 | |||
64 | TEMPLATES = [ |
|
64 | TEMPLATES = [ | |
65 | { |
|
65 | { | |
66 | 'BACKEND': 'django.template.backends.django.DjangoTemplates', |
|
66 | 'BACKEND': 'django.template.backends.django.DjangoTemplates', | |
67 | 'DIRS': [os.path.join(BASE_DIR, "templates").replace('\\', '/'),], |
|
67 | 'DIRS': [os.path.join(BASE_DIR, "templates").replace('\\', '/'),], | |
68 | 'APP_DIRS': True, |
|
68 | 'APP_DIRS': True, | |
69 | 'OPTIONS': { |
|
69 | 'OPTIONS': { | |
70 | 'context_processors': [ |
|
70 | 'context_processors': [ | |
71 | 'django.template.context_processors.debug', |
|
71 | 'django.template.context_processors.debug', | |
72 | 'django.template.context_processors.request', |
|
72 | 'django.template.context_processors.request', | |
73 | 'django.contrib.auth.context_processors.auth', |
|
73 | 'django.contrib.auth.context_processors.auth', | |
74 | 'django.contrib.messages.context_processors.messages', |
|
74 | 'django.contrib.messages.context_processors.messages', | |
75 | ], |
|
75 | ], | |
76 | }, |
|
76 | }, | |
77 | }, |
|
77 | }, | |
78 | ] |
|
78 | ] | |
79 |
|
79 | |||
80 | WSGI_APPLICATION = 'radarsys.wsgi.application' |
|
80 | WSGI_APPLICATION = 'radarsys.wsgi.application' | |
81 |
|
81 | |||
82 |
|
82 | |||
83 | # Database |
|
83 | # Database | |
84 | # https://docs.djangoproject.com/en/1.8/ref/settings/#databases |
|
84 | # https://docs.djangoproject.com/en/1.8/ref/settings/#databases | |
85 |
|
85 | |||
86 | DATABASES = { |
|
86 | DATABASES = { | |
87 | 'default': { |
|
87 | 'default': { | |
88 | 'ENGINE': 'django.db.backends.mysql', |
|
88 | 'ENGINE': 'django.db.backends.mysql', | |
89 | 'NAME': 'radarsys', |
|
89 | 'NAME': 'radarsys', | |
90 | 'USER': 'developer', |
|
90 | 'USER': 'developer', | |
91 | 'PASSWORD': 'idi2015', |
|
91 | 'PASSWORD': 'idi2015', | |
92 | } |
|
92 | } | |
93 | } |
|
93 | } | |
94 |
|
94 | |||
95 |
|
95 | |||
96 | # Internationalization |
|
96 | # Internationalization | |
97 | # https://docs.djangoproject.com/en/1.8/topics/i18n/ |
|
97 | # https://docs.djangoproject.com/en/1.8/topics/i18n/ | |
98 |
|
98 | |||
99 | LANGUAGE_CODE = 'en-us' |
|
99 | LANGUAGE_CODE = 'en-us' | |
100 |
|
100 | |||
101 |
TIME_ZONE = |
|
101 | TIME_ZONE = None | |
102 |
|
102 | |||
103 | USE_I18N = True |
|
103 | USE_I18N = True | |
104 |
|
104 | |||
105 | USE_L10N = True |
|
105 | USE_L10N = True | |
106 |
|
106 | |||
107 |
USE_TZ = |
|
107 | USE_TZ = False | |
108 |
|
108 | |||
109 | # Static files (CSS, JavaScript, Images) |
|
109 | # Static files (CSS, JavaScript, Images) | |
110 | # https://docs.djangoproject.com/en/1.8/howto/static-files/ |
|
110 | # https://docs.djangoproject.com/en/1.8/howto/static-files/ | |
111 |
|
111 | |||
112 | STATIC_URL = '/static/' |
|
112 | STATIC_URL = '/static/' | |
113 | STATIC_ROOT = '/var/www/html/static/' |
|
113 | STATIC_ROOT = '/var/www/html/static/' | |
114 |
|
114 | |||
115 | STATICFILES_DIRS = ( |
|
115 | STATICFILES_DIRS = ( | |
116 | os.path.join(BASE_DIR, 'apps', 'main', 'static'), |
|
116 | os.path.join(BASE_DIR, 'apps', 'main', 'static'), | |
117 |
|
117 | |||
118 | ) |
|
118 | ) | |
119 |
|
119 | |||
120 | STATICFILES_FINDERS = ( |
|
120 | STATICFILES_FINDERS = ( | |
121 | 'django.contrib.staticfiles.finders.FileSystemFinder', |
|
121 | 'django.contrib.staticfiles.finders.FileSystemFinder', | |
122 | 'django.contrib.staticfiles.finders.AppDirectoriesFinder', |
|
122 | 'django.contrib.staticfiles.finders.AppDirectoriesFinder', | |
123 | ) |
|
123 | ) |
@@ -1,32 +1,31 | |||||
1 | """radarsys URL Configuration |
|
1 | """radarsys URL Configuration | |
2 |
|
2 | |||
3 | The `urlpatterns` list routes URLs to views. For more information please see: |
|
3 | The `urlpatterns` list routes URLs to views. For more information please see: | |
4 | https://docs.djangoproject.com/en/1.8/topics/http/urls/ |
|
4 | https://docs.djangoproject.com/en/1.8/topics/http/urls/ | |
5 | Examples: |
|
5 | Examples: | |
6 | Function views |
|
6 | Function views | |
7 | 1. Add an import: from my_app import views |
|
7 | 1. Add an import: from my_app import views | |
8 | 2. Add a URL to urlpatterns: url(r'^$', views.home, name='home') |
|
8 | 2. Add a URL to urlpatterns: url(r'^$', views.home, name='home') | |
9 | Class-based views |
|
9 | Class-based views | |
10 | 1. Add an import: from other_app.views import Home |
|
10 | 1. Add an import: from other_app.views import Home | |
11 | 2. Add a URL to urlpatterns: url(r'^$', Home.as_view(), name='home') |
|
11 | 2. Add a URL to urlpatterns: url(r'^$', Home.as_view(), name='home') | |
12 | Including another URLconf |
|
12 | Including another URLconf | |
13 | 1. Add an import: from blog import urls as blog_urls |
|
13 | 1. Add an import: from blog import urls as blog_urls | |
14 | 2. Add a URL to urlpatterns: url(r'^blog/', include(blog_urls)) |
|
14 | 2. Add a URL to urlpatterns: url(r'^blog/', include(blog_urls)) | |
15 | """ |
|
15 | """ | |
16 | from django.conf.urls import include, url |
|
16 | from django.conf.urls import include, url | |
17 | from django.contrib import admin |
|
17 | from django.contrib import admin | |
18 |
|
18 | |||
19 | urlpatterns = [ |
|
19 | urlpatterns = [ | |
20 | url(r'^$', 'apps.main.views.index', name='index'), |
|
20 | url(r'^$', 'apps.main.views.index', name='index'), | |
21 | url(r'^operation/', 'apps.main.views.operation', name='url_operation'), |
|
|||
22 | url(r'^admin/', include(admin.site.urls)), |
|
21 | url(r'^admin/', include(admin.site.urls)), | |
23 | url(r'^accounts/', include('apps.accounts.urls')), |
|
22 | url(r'^accounts/', include('apps.accounts.urls')), | |
24 | url(r'^', include('apps.main.urls')), |
|
23 | url(r'^', include('apps.main.urls')), | |
25 | url(r'^rc/', include('apps.rc.urls')), |
|
24 | url(r'^rc/', include('apps.rc.urls')), | |
26 | url(r'^dds/', include('apps.dds.urls')), |
|
25 | url(r'^dds/', include('apps.dds.urls')), | |
27 | url(r'^cgs/', include('apps.cgs.urls')), |
|
26 | url(r'^cgs/', include('apps.cgs.urls')), | |
28 | url(r'^jars/', include('apps.jars.urls')), |
|
27 | url(r'^jars/', include('apps.jars.urls')), | |
29 | url(r'^usrp/', include('apps.usrp.urls')), |
|
28 | url(r'^usrp/', include('apps.usrp.urls')), | |
30 | url(r'^abs/', include('apps.abs.urls')), |
|
29 | url(r'^abs/', include('apps.abs.urls')), | |
31 | url(r'^misc/', include('apps.misc.urls')), |
|
30 | url(r'^misc/', include('apps.misc.urls')), | |
32 | ] |
|
31 | ] |
General Comments 0
You need to be logged in to leave comments.
Login now