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