@@ -0,0 +1,30 | |||
|
1 | {% extends 'base.html' %} | |
|
2 | ||
|
3 | {% block content-title %}{{title}}{% endblock %} | |
|
4 | {% block content-suptitle %}{{suptitle}}{% endblock %} | |
|
5 | ||
|
6 | {% block content %} | |
|
7 | ||
|
8 | <form action="" method="post" class="form">{% csrf_token %} | |
|
9 | {% if next %} | |
|
10 | <input name="next" type="hidden" value="{{ next }}" /> | |
|
11 | {% endif %} | |
|
12 | {% if delete_view %} | |
|
13 | {% if object_name %} | |
|
14 | <h3>Are you sure you wish to delete {{ object_name }}: {{ object }}?</h3> | |
|
15 | {% else %} | |
|
16 | <h3>Are you sure you wish to delete: {{ object }}?</h3> | |
|
17 | {% endif %} | |
|
18 | {% else %} | |
|
19 | <h4>Are you sure you wish to proceed?</h4> | |
|
20 | {% endif %} | |
|
21 | {% if message %}<h4>{{ message }}</h4>{% endif %} | |
|
22 | <br> | |
|
23 | <button class="btn btn-primary" type="submit"> | |
|
24 | <span class="glyphicon glyphicon-ok" aria-hidden="true"></span> Yes | |
|
25 | </button> | |
|
26 | <button type="button" class="btn btn-primary" onclick="{% if previous %}window.location.replace('{{ previous }}');{% else %}history.go(-1);{% endif %}"> | |
|
27 | <span class="glyphicon glyphicon-remove" aria-hidden="true"></span> No | |
|
28 | </button> | |
|
29 | </form> | |
|
30 | {% endblock %} |
@@ -0,0 +1,1 | |||
|
1 | {% extends "dev_conf_edit.html" %} No newline at end of file |
@@ -0,0 +1,82 | |||
|
1 | {% extends "dev_conf.html" %} | |
|
2 | {% load static %} | |
|
3 | {% load bootstrap3 %} | |
|
4 | {% block extra-head %} | |
|
5 | <style type="text/css"> | |
|
6 | /* show the move cursor as the user moves the mouse over the panel header.*/ | |
|
7 | .panel-default { cursor: move; } | |
|
8 | </style> | |
|
9 | {% endblock %} | |
|
10 | {% block content %} | |
|
11 | <table class="table table-bordered"> | |
|
12 | {% for key in dev_conf_keys %} | |
|
13 | <tr><th>{{key|title}}</th><td>{{dev_conf|attr:key}}</td></tr> | |
|
14 | {% endfor %} | |
|
15 | </table> | |
|
16 | <button class="btn btn-primary pull-right" style="margin-left: 10px" id="bt_send">Send</button> | |
|
17 | <button class="btn btn-primary pull-right" style="margin-left: 10px" id="bt_export">Export</button> | |
|
18 | <button class="btn btn-primary pull-right" style="margin-left: 10px" id="bt_edit">Edit</button> | |
|
19 | <br> | |
|
20 | <h2>RC Lines</h2><hr> | |
|
21 | ||
|
22 | <div class="panel-group" id="accordion" role="tablist" aria-multiselectable="true"> | |
|
23 | {% for line in rc_lines %} | |
|
24 | <div class="panel panel-default" > | |
|
25 | <div class="panel-heading" role="tab" id="headingOne"> | |
|
26 | <h4 class="panel-title"> | |
|
27 | <a role="button" data-toggle="collapse" data-parent="#accordion" href="#collapse{{line.id}}" aria-expanded="true" aria-controls="collapseOne"> | |
|
28 | CH{{line.channel}} - {{line.get_name}} | |
|
29 | </a> | |
|
30 | <button class="btn-xs btn-danger pull-right" name="bt_remove_line" value="{{line.pk}}"><span class="glyphicon glyphicon-remove" aria-hidden="true"></span></button> | |
|
31 | <button class="btn-xs btn-info pull-right" name="bt_line_down" value="{{line.pk}}"><span class="glyphicon glyphicon-arrow-down" aria-hidden="true"></span></button> | |
|
32 | <button class="btn-xs btn-info pull-right" name="bt_line_up" value="{{line.pk}}"><span class="glyphicon glyphicon-arrow-up" aria-hidden="true"></span></button> | |
|
33 | </h4> | |
|
34 | </div> | |
|
35 | <div id="collapse{{line.id}}" class="panel-collapse collapse" role="tabpanel" aria-labelledby="headingOne"> | |
|
36 | <div class="panel-body"> | |
|
37 | {% bootstrap_form line.form layout='horizontal' size='small' %} | |
|
38 | </div> | |
|
39 | </div> | |
|
40 | </div> | |
|
41 | {% endfor%} | |
|
42 | </div> | |
|
43 | <br> | |
|
44 | <div class="pull-right"> | |
|
45 | <button class="btn btn-primary" id="bt_add_line">Add Line</button> | |
|
46 | <button class="btn btn-primary" id="bt_add_line"> Edit </button> | |
|
47 | <button class="btn btn-primary" id="bt_pulses">Pulses</button> | |
|
48 | </div> | |
|
49 | {% endblock %} | |
|
50 | ||
|
51 | ||
|
52 | {% block extra-js%} | |
|
53 | ||
|
54 | <script type="text/javascript"> | |
|
55 | $(document).ready(function() { | |
|
56 | $("#bt_edit").click(function() { | |
|
57 | document.location = "{% url 'url_edit_rc_conf' dev_conf.id%}"; | |
|
58 | }); | |
|
59 | ||
|
60 | $("#bt_add_line").click(function() { | |
|
61 | document.location = "{% url 'url_add_rc_line' dev_conf.id%}"; | |
|
62 | }); | |
|
63 | ||
|
64 | $("button[name=bt_remove_line]").click(function(){ | |
|
65 | document.location = "line/"+$(this).val()+"/delete/"; | |
|
66 | }); | |
|
67 | ||
|
68 | $("button[name=bt_line_up]").click(function(){ | |
|
69 | document.location = "line/"+$(this).val()+"/up/"; | |
|
70 | }); | |
|
71 | ||
|
72 | $("button[name=bt_line_down]").click(function(){ | |
|
73 | document.location = "line/"+$(this).val()+"/down/"; | |
|
74 | }); | |
|
75 | ||
|
76 | ||
|
77 | ||
|
78 | $(".panel-group").sortable(); | |
|
79 | ||
|
80 | }); | |
|
81 | </script> | |
|
82 | {% endblock %} No newline at end of file |
@@ -0,0 +1,1 | |||
|
1 | {% extends "dev_conf_edit.html" %} No newline at end of file |
@@ -106,4 +106,7 class Configuration(PolymorphicModel): | |||
|
106 | 106 | return u'[%s - %s]: %s' % (self.experiment.campaign.name, |
|
107 | 107 | self.experiment.name, |
|
108 | 108 | self.device.name) |
|
109 | def get_absolute_url(self): | |
|
110 | from django.core.urlresolvers import reverse | |
|
111 | return reverse('url_%s_conf' % self.device.device_type.name, args=[str(self.id)]) | |
|
109 | 112 | No newline at end of file |
@@ -8,11 +8,11 | |||
|
8 | 8 | <meta name="author" content=""> |
|
9 | 9 | <meta name="viewport" content="width=device-width, initial-scale=1"> |
|
10 | 10 | {# bootstrap_css #} |
|
11 |
<link href="{% static 'css/bootstrap-flatly.min.css' %}" media=" |
|
|
11 | <link href="{% static 'css/bootstrap-flatly.min.css' %}" media="all" rel="stylesheet"> | |
|
12 | 12 | <style type="text/css"> |
|
13 | 13 | body {padding-top: 60px} |
|
14 | 14 | .logo {padding-top: 5px; height: 50px} |
|
15 |
.clickable-row {cursor: pointer;} |
|
|
15 | .clickable-row {cursor: pointer;} | |
|
16 | 16 | </style> |
|
17 | 17 | <!--[if lt IE 9]> |
|
18 | 18 | <script src="//html5shim.googlecode.com/svn/trunk/html5.js"></script> |
@@ -81,12 +81,21 | |||
|
81 | 81 | <div class="page-header"> |
|
82 | 82 | <h1>{% block content-title %}{% endblock %} <small>{% block content-suptitle %}{% endblock %}</small></h1> |
|
83 | 83 | <hr> |
|
84 |
</div> |
|
|
85 |
|
|
|
86 | {% endblock %} | |
|
84 | </div> | |
|
85 | {% block messages %} | |
|
86 | {% if messages %} | |
|
87 | {% for message in messages %} | |
|
88 | <div class="alert alert-{% if message.tags %}{% if 'error' in message.tags %}danger{% else %}{{ message.tags }}{% endif %}{% else %}info{% endif %} alert-dismissible" role="alert"> | |
|
89 | <button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button> | |
|
90 | <strong>{{message.tags|title}}!</strong> {{ message }} | |
|
91 | </div> | |
|
92 | {% endfor %} | |
|
93 | {% endif %} | |
|
94 | {% endblock %} | |
|
87 | 95 | <br> |
|
88 |
{% block |
|
|
96 | {% block content %} | |
|
89 | 97 | {% endblock %} |
|
98 | <br> | |
|
90 | 99 | </div> |
|
91 | 100 | |
|
92 | 101 | |
@@ -109,7 +118,7 | |||
|
109 | 118 | {# bootstrap_javascript jquery=True #} |
|
110 | 119 | <script src="{% static 'js/jquery.min.js' %}"></script> |
|
111 | 120 | <script src="{% static 'js/bootstrap.min.js' %}"></script> |
|
112 | ||
|
121 | <script src="{% static 'js/jquery-ui.min.js' %}"></script> | |
|
113 | 122 | {% block extra-js %} |
|
114 | 123 | {% endblock%} |
|
115 | 124 | </body> |
@@ -14,7 +14,10 | |||
|
14 | 14 | {% bootstrap_form form layout='horizontal' size='medium' %} |
|
15 | 15 | <div style="clear: both;"></div> |
|
16 | 16 | <br> |
|
17 | <button type="submit" class="btn btn-primary pull-right">{{button}}</button> | |
|
17 | <div class="pull-right"> | |
|
18 | <button type="button" class="btn btn-primary" onclick="{% if previous %}window.location.replace('{{ previous }}');{% else %}history.go(-1);{% endif %}">Cancel</button> | |
|
19 | <button type="submit" class="btn btn-primary">{{button}}</button> | |
|
20 | </div> | |
|
18 | 21 | </form> |
|
19 | 22 | {% endblock %} |
|
20 | 23 |
@@ -1,6 +1,8 | |||
|
1 | 1 | from django.contrib import admin |
|
2 | from .models import RCConfiguration | |
|
2 | from .models import RCConfiguration, RCLine, RCLineType | |
|
3 | 3 | |
|
4 | 4 | # Register your models here. |
|
5 | 5 | |
|
6 | 6 | admin.site.register(RCConfiguration) |
|
7 | admin.site.register(RCLine) | |
|
8 | admin.site.register(RCLineType) |
@@ -1,8 +1,43 | |||
|
1 | import json | |
|
2 | ||
|
1 | 3 | from django import forms |
|
2 | from .models import RCConfiguration | |
|
4 | from .models import RCConfiguration, RCLine, RCLineType | |
|
3 | 5 | |
|
4 | 6 | class RCConfigurationForm(forms.ModelForm): |
|
5 | 7 | |
|
6 | 8 | class Meta: |
|
7 | 9 | model = RCConfiguration |
|
8 | fields = ('experiment',) | |
|
10 | exclude = ('clock', 'ipp', 'ntx', 'clock_divider') | |
|
11 | ||
|
12 | ||
|
13 | class RCLineForm(forms.ModelForm): | |
|
14 | ||
|
15 | class Meta: | |
|
16 | model = RCLine | |
|
17 | fields = ('rc_configuration', 'line_type', 'channel') | |
|
18 | widgets = { | |
|
19 | 'channel': forms.HiddenInput(), | |
|
20 | } | |
|
21 | ||
|
22 | def save(self): | |
|
23 | line = super(RCLineForm, self).save() | |
|
24 | #auto add channel | |
|
25 | line.channel = RCLine.objects.filter(rc_configuration=line.rc_configuration).count()-1 | |
|
26 | #auto add position for TX, TR & CODE | |
|
27 | if line.line_type.name in ('tx', 'tr', 'code'): | |
|
28 | line.position = RCLine.objects.filter(rc_configuration=line.rc_configuration, line_type=line.line_type).count()-1 | |
|
29 | #add default params | |
|
30 | params = {} | |
|
31 | for field in json.loads(line.line_type.params): | |
|
32 | params[field['name']] = field['value'] | |
|
33 | line.params = json.dumps(params) | |
|
34 | line.save() | |
|
35 | return | |
|
36 | ||
|
37 | class RCLineViewForm(forms.Form): | |
|
38 | ||
|
39 | def __init__(self, *args, **kwargs): | |
|
40 | extra_fields = kwargs.pop('extra_fields') | |
|
41 | super(RCLineViewForm, self).__init__(*args, **kwargs) | |
|
42 | for label, value in extra_fields.items(): | |
|
43 | self.fields[label] = forms.CharField(initial=value) No newline at end of file |
@@ -1,10 +1,95 | |||
|
1 | ||
|
2 | from polymorphic import PolymorphicModel | |
|
3 | ||
|
1 | 4 | from django.db import models |
|
5 | from django.core.validators import MinValueValidator, MaxValueValidator | |
|
6 | ||
|
2 | 7 | from apps.main.models import Configuration |
|
3 | 8 | # Create your models here. |
|
4 | 9 | |
|
10 | LINE_TYPES = ( | |
|
11 | ('tr', 'Transmission/reception selector signal'), | |
|
12 | ('tx', 'A modulating signal (Transmission pulse)'), | |
|
13 | ('codes', 'BPSK modulating signal'), | |
|
14 | ('windows', 'Sample window signal'), | |
|
15 | ('sync', 'Synchronizing signal'), | |
|
16 | ('flip', 'IPP related periodic signal'), | |
|
17 | ('prog_pulses', 'Programmable pulse'), | |
|
18 | ) | |
|
19 | ||
|
20 | LINE_PARAMS = { | |
|
21 | "tr": [{"name":"time_after", "value": 0}], | |
|
22 | "tx": [{"name": "pulse_width", "value": 0},{"name":"delays", "value":""}], | |
|
23 | "codes": [{"name":"tx_ref", "value": ""},{"name":"code", "value": "", "choices":"RCLineCode"}], | |
|
24 | "windows": [{"name":"tx_ref","value":""}, {"name":"first_height", "value":0}, {"name":"number_of_samples","value":0}, {"name":"resolution","value":0}, {"name":"last_height","value":0}], | |
|
25 | "sync": [{"name": "delay", "value": 0}], | |
|
26 | "flip": [{"name":"number_of_flips", "value": 0}], | |
|
27 | "prog_pulses": [{"name": "begin", "value": 0}, {"name": "end","value": 0}], | |
|
28 | } | |
|
29 | ||
|
30 | ||
|
5 | 31 | class RCConfiguration(Configuration): |
|
6 | ||
|
32 | ||
|
33 | clock = models.FloatField(verbose_name='Clock Master (MHz)', validators=[MinValueValidator(0), MaxValueValidator(80)], blank=True, null=True) | |
|
34 | clock_divider = models.PositiveIntegerField(verbose_name='Clock divider', validators=[MinValueValidator(0), MaxValueValidator(256)], blank=True, null=True) | |
|
35 | ipp = models.PositiveIntegerField(verbose_name='Inter pulse period (Km)', default=10) | |
|
36 | ntx = models.PositiveIntegerField(verbose_name='Number of pulse of transmit', default=1) | |
|
37 | time_before = models.PositiveIntegerField(verbose_name='Number of pulse of transmit', default=0) | |
|
7 | 38 | |
|
8 | 39 | class Meta: |
|
9 | 40 | db_table = 'rc_configurations' |
|
10 | No newline at end of file | |
|
41 | ||
|
42 | def get_number_position(self): | |
|
43 | ||
|
44 | lines = RCLine.objects.filter(rc_configuration=self.rc_configuration) | |
|
45 | if lines: | |
|
46 | return max([line.position for line in lines]) | |
|
47 | ||
|
48 | class RCLineCode(models.Model): | |
|
49 | ||
|
50 | name = models.CharField(choices=LINE_TYPES, max_length=40) | |
|
51 | bits_per_code = models.PositiveIntegerField(default=0) | |
|
52 | number_of_codes = models.PositiveIntegerField(default=0) | |
|
53 | codes = models.TextField(blank=True, null=True) | |
|
54 | ||
|
55 | class Meta: | |
|
56 | db_table = 'rc_line_codes' | |
|
57 | ||
|
58 | ||
|
59 | class RCLineType(models.Model): | |
|
60 | ||
|
61 | name = models.CharField(choices=LINE_TYPES, max_length=40) | |
|
62 | description = models.TextField(blank=True, null=True) | |
|
63 | params = models.TextField(default='[]') | |
|
64 | ||
|
65 | class Meta: | |
|
66 | db_table = 'rc_line_types' | |
|
67 | ||
|
68 | def __unicode__(self): | |
|
69 | return u'%s - %s' % (self.name.upper(), self.get_name_display()) | |
|
70 | ||
|
71 | ||
|
72 | class RCLine(models.Model): | |
|
73 | ||
|
74 | rc_configuration = models.ForeignKey(RCConfiguration) | |
|
75 | line_type = models.ForeignKey(RCLineType) | |
|
76 | channel = models.PositiveIntegerField(default=0) | |
|
77 | position = models.PositiveIntegerField(default=0) | |
|
78 | params = models.TextField(default='{}') | |
|
79 | ||
|
80 | class Meta: | |
|
81 | db_table = 'rc_lines' | |
|
82 | ||
|
83 | def __unicode__(self): | |
|
84 | return u'%s - %s' % (self.rc_configuration, self.get_name()) | |
|
85 | ||
|
86 | def get_name(self): | |
|
87 | ||
|
88 | chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' | |
|
89 | ||
|
90 | if self.line_type.name in ('tx', 'code', 'tr'): | |
|
91 | return '%s%s' % (self.line_type.name.upper(), chars[self.position]) | |
|
92 | ||
|
93 | return self.line_type.name.upper() | |
|
94 | ||
|
95 |
@@ -1,6 +1,10 | |||
|
1 | 1 | from django.conf.urls import url |
|
2 | 2 | |
|
3 | 3 | urlpatterns = ( |
|
4 |
url(r'^(?P<id |
|
|
5 |
url(r'^(?P<id |
|
|
4 | url(r'^(?P<id>-?\d+)/$', 'apps.rc.views.conf', name='url_rc_conf'), | |
|
5 | url(r'^(?P<id>-?\d+)/edit/$', 'apps.rc.views.conf_edit', name='url_edit_rc_conf'), | |
|
6 | url(r'^(?P<id>-?\d+)/add_line/$', 'apps.rc.views.add_line', name='url_add_rc_line'), | |
|
7 | url(r'^(?P<conf_id>-?\d+)/line/(?P<line_id>-?\d+)/delete/$', 'apps.rc.views.remove_line', name='url_remove_rc_line'), | |
|
8 | url(r'^(?P<conf_id>-?\d+)/line/(?P<line_id>-?\d+)/up/$', 'apps.rc.views.line_up', name='url_rc_line_up'), | |
|
9 | url(r'^(?P<conf_id>-?\d+)/line/(?P<line_id>-?\d+)/down/$', 'apps.rc.views.line_down', name='url_rc_line_down'), | |
|
6 | 10 | ) |
@@ -1,3 +1,154 | |||
|
1 | from django.shortcuts import render | |
|
1 | import json | |
|
2 | ||
|
3 | from django.contrib import messages | |
|
4 | from django.shortcuts import render, redirect, get_object_or_404 | |
|
5 | ||
|
6 | from apps.main.models import Configuration, Experiment | |
|
7 | ||
|
8 | from .models import RCConfiguration, RCLine | |
|
9 | from .forms import RCConfigurationForm, RCLineForm, RCLineViewForm | |
|
10 | ||
|
11 | ||
|
12 | def conf(request, id): | |
|
13 | ||
|
14 | conf = get_object_or_404(RCConfiguration, pk=id) | |
|
15 | ||
|
16 | lines = RCLine.objects.filter(rc_configuration=conf).order_by('channel') | |
|
17 | ||
|
18 | for line in lines: | |
|
19 | line.form = RCLineViewForm(extra_fields=json.loads(line.params)) | |
|
20 | ||
|
21 | kwargs = {} | |
|
22 | kwargs['dev_conf'] = conf | |
|
23 | kwargs['rc_lines'] = lines | |
|
24 | kwargs['dev_conf_keys'] = ['clock', 'ipp', 'ntx','clock_divider'] | |
|
25 | ||
|
26 | kwargs['title'] = 'RC Configuration' | |
|
27 | kwargs['suptitle'] = 'Details' | |
|
28 | ||
|
29 | kwargs['button'] = 'Edit Configuration' | |
|
30 | ||
|
31 | ###### SIDEBAR ###### | |
|
32 | experiments = Experiment.objects.filter(campaign=conf.experiment.campaign) | |
|
33 | configurations = Configuration.objects.filter(experiment=conf.experiment) | |
|
34 | ||
|
35 | exp_keys = ['id', 'campaign', 'name', 'start_time', 'end_time'] | |
|
36 | conf_keys = ['id', 'device__name', 'device__device_type__name', 'device__ip_address'] | |
|
37 | ||
|
38 | kwargs['experiment_keys'] = exp_keys[1:] | |
|
39 | kwargs['experiments'] = experiments.values(*exp_keys) | |
|
40 | ||
|
41 | kwargs['configuration_keys'] = conf_keys[1:] | |
|
42 | kwargs['configurations'] = configurations.values(*conf_keys) | |
|
43 | ||
|
44 | return render(request, 'rc_conf.html', kwargs) | |
|
45 | ||
|
46 | ||
|
47 | def conf_edit(request, id): | |
|
48 | ||
|
49 | conf = get_object_or_404(RCConfiguration, pk=id) | |
|
50 | ||
|
51 | if request.method=='GET': | |
|
52 | form = RCConfigurationForm(instance=conf) | |
|
53 | ||
|
54 | if request.method=='POST': | |
|
55 | form = RCConfigurationForm(request.POST, instance=conf) | |
|
56 | ||
|
57 | if form.is_valid(): | |
|
58 | form.save() | |
|
59 | return redirect('url_rc_conf', id=id) | |
|
60 | ||
|
61 | kwargs = {} | |
|
62 | kwargs['form'] = form | |
|
63 | kwargs['title'] = 'Device Configuration' | |
|
64 | kwargs['suptitle'] = 'Edit' | |
|
65 | kwargs['button'] = 'Update' | |
|
66 | kwargs['previous'] = conf.get_absolute_url() | |
|
67 | return render(request, 'rc_conf_edit.html', kwargs) | |
|
68 | ||
|
69 | ||
|
70 | def add_line(request, id): | |
|
71 | ||
|
72 | conf = get_object_or_404(RCConfiguration, pk=id) | |
|
73 | ||
|
74 | if request.method=='GET': | |
|
75 | form = RCLineForm(initial={'rc_configuration':conf.id}) | |
|
76 | ||
|
77 | if request.method=='POST': | |
|
78 | form = RCLineForm(request.POST) | |
|
79 | ||
|
80 | if form.is_valid(): | |
|
81 | form.save() | |
|
82 | return redirect('url_rc_conf', id=id) | |
|
83 | ||
|
84 | kwargs = {} | |
|
85 | kwargs['form'] = form | |
|
86 | kwargs['title'] = 'RC Configuration' | |
|
87 | kwargs['suptitle'] = 'Add Line' | |
|
88 | kwargs['button'] = 'Add' | |
|
89 | kwargs['previous'] = conf.get_absolute_url() | |
|
90 | return render(request, 'rc_add_line.html', kwargs) | |
|
91 | ||
|
92 | ||
|
93 | def remove_line(request, conf_id, line_id): | |
|
94 | ||
|
95 | conf = get_object_or_404(RCConfiguration, pk=conf_id) | |
|
96 | line = get_object_or_404(RCLine, pk=line_id) | |
|
97 | ||
|
98 | if request.method == 'POST': | |
|
99 | if line: | |
|
100 | try: | |
|
101 | channel = line.channel | |
|
102 | line.delete() | |
|
103 | for ch in range(channel+1, RCLine.objects.filter(rc_configuration=conf).count()+1): | |
|
104 | l = RCLine.objects.get(rc_configuration=conf, channel=ch) | |
|
105 | l.channel = l.channel-1 | |
|
106 | l.save() | |
|
107 | messages.success(request, 'Line: "%s" has been deleted.' % line) | |
|
108 | except: | |
|
109 | messages.error(request, 'Unable to delete line: "%s".' % line) | |
|
110 | ||
|
111 | return redirect(conf.get_absolute_url()) | |
|
112 | ||
|
113 | kwargs = {} | |
|
114 | ||
|
115 | kwargs['object'] = line | |
|
116 | kwargs['delete_view'] = True | |
|
117 | kwargs['title'] = 'Confirm delete' | |
|
118 | kwargs['previous'] = conf.get_absolute_url() | |
|
119 | return render(request, 'confirm.html', kwargs) | |
|
120 | ||
|
121 | ||
|
122 | def line_up(request, conf_id, line_id): | |
|
123 | ||
|
124 | conf = get_object_or_404(RCConfiguration, pk=conf_id) | |
|
125 | line = get_object_or_404(RCLine, pk=line_id) | |
|
126 | ||
|
127 | if line: | |
|
128 | ch = line.channel | |
|
129 | if ch-1>=0: | |
|
130 | line0 = RCLine.objects.get(rc_configuration=conf, channel=ch-1) | |
|
131 | line0.channel = ch | |
|
132 | line0.save() | |
|
133 | line.channel = ch-1 | |
|
134 | line.save() | |
|
135 | ||
|
136 | return redirect(conf.get_absolute_url()) | |
|
137 | ||
|
138 | ||
|
139 | def line_down(request, conf_id, line_id): | |
|
140 | ||
|
141 | conf = get_object_or_404(RCConfiguration, pk=conf_id) | |
|
142 | line = get_object_or_404(RCLine, pk=line_id) | |
|
143 | ||
|
144 | if line: | |
|
145 | ch = line.channel | |
|
146 | if ch+1<RCLine.objects.filter(rc_configuration=conf).count(): | |
|
147 | line1 = RCLine.objects.get(rc_configuration=conf, channel=ch+1) | |
|
148 | line1.channel = ch | |
|
149 | line1.save() | |
|
150 | line.channel = ch+1 | |
|
151 | line.save() | |
|
152 | ||
|
153 | return redirect(conf.get_absolute_url()) | |
|
2 | 154 | |
|
3 | # Create your views here. |
|
1 | NO CONTENT: file was removed |
General Comments 0
You need to be logged in to leave comments.
Login now