Fixed expiration mail phrasing
[flowspy] / templates / apply.html
1 {% extends "base.html" %}
2 {% load i18n %}
3
4 {% block title %}
5         {% if edit %}
6                 {% trans "Edit Rule" %} {{form.data.name}}
7         {% else %}
8                 {% trans "Create new Rule" %}
9         {% endif %}
10 {% endblock %}
11
12 {% block breadcrumbs %}:: 
13         {% if edit %}
14                 {% trans "Edit rule" %} {{form.data.name}}
15         {% else %}
16         {% trans "Create rule" %}
17         {% endif %}
18                 {% endblock %}
19 {% block extrahead %}
20 <script>
21         $(document).ready( function(){
22                 
23                 $("#id_sourceport").css('width', '100px').attr('size', '5');
24                 $("#id_port").css('width', '100px').attr('size', '5');
25                 $("#id_destinationport").css('width', '100px').attr('size', '5');
26                 $('#id_then').attr("multiple", "");
27                 $( "#id_expires" ).datepicker({ dateFormat: 'yy-mm-dd' , maxDate: '+10d', minDate: '+1d', changeMonth: false, changeYear: false }).datepicker( $.datepicker.regional[ "el" ] );
28                 $('#then_diag').dialog({
29                         height: 220,
30             width: 340,
31                         modal: true,
32                         autoOpen: false,
33                         buttons: {
34                 'Add': function() {
35                         console.log($("#add_rl_form").serialize());
36                         $.ajax({
37                         url:"{% url add-rate-limit %}", 
38                         data:$("#add_rl_form").serialize(),
39                         type: "POST",
40                         cache: false,
41                         success:function(data){
42                                         try {
43                                                 value = data.pk;
44                                                 text = data.value;
45                                                 $('#id_then').append($("<option></option>").attr("value",value).text(text));
46                                                 $('#then_diag').dialog('close');
47                                         }
48                                         catch (exception) {
49                                                 $('#then_diag').html(data);
50                                         }                                       
51                                 }
52                                 });
53                 },
54                 Cancel: function() {
55                         $('#then_diag').dialog('close');
56                 }
57         }
58                 });
59                 
60                 $('#port_diag').dialog({
61                         height: 220,
62             width: 340,
63                         modal: true,
64                         autoOpen: false,
65                         buttons: {
66                 'Add': function() {
67                         console.log($("#add_port_form").serialize());
68                         $.ajax({
69                         url:"{% url add-port %}", 
70                         data:$("#add_port_form").serialize(),
71                         type: "POST",
72                         cache: false,
73                         success:function(data){
74                                         try {
75                                                 value = data.value;
76                                                 text = data.text;
77                                                 $('#id_port').append($("<option></option>").attr("value",value).text(text));
78                                                 $('#id_destinationport').append($("<option></option>").attr("value",value).text(text));
79                                                 $('#id_sourceport').append($("<option></option>").attr("value",value).text(text));
80                                                 $('#port_diag').dialog('close');
81                                         }
82                                         catch (exception) {
83                                                 $('#port_diag').html(data);
84                                         }                                       
85                                 }
86                                 });
87                 },
88                 Cancel: function() {
89                         $('#port_diag').dialog('close');
90                 }
91         }
92                 });
93                 
94                 
95                 $("#new_then_actions").button({
96             icons: {
97                 primary: "ui-icon-plusthick"
98             },
99                         })
100                         .click(function(){
101                                 $.ajax({
102                                         url: "{% url add-rate-limit %}",
103                                         cache: false,
104                                         success: function(data){
105                                                 $("#then_diag").html(data);
106                                         }
107                                 });
108                                 $('#then_diag').dialog('open');
109                                 return false;
110                         });
111                         
112                         
113                         $(".new_port").button({
114             icons: {
115                 primary: "ui-icon-plusthick"
116             },
117                         })
118                         .click(function(){
119                                 $.ajax({
120                                         url: "{% url add-port %}",
121                                         cache: false,
122                                         success: function(data){
123                                                 $("#port_diag").html(data);
124                                         }
125                                 });
126                                 $('#port_diag').dialog('open');
127                                 return false;
128                         });
129                 });
130                 
131 </script>
132 {% endblock %}
133 {% block content %}
134 <style type="text/css">
135 th {
136         text-align: right;
137         padding-right: 0.5em;
138         vertical-align: top;
139 }
140
141 .help {
142         font-style: italic;
143
144 }
145 </style>
146 <div align="center">
147         {% if edit %}
148         <h3>{% trans "Edit rule" %}: {{form.data.name}}</h3>
149         {% else %}
150 <h3>{% trans "Apply for a new rule" %}</h3>
151 {% endif %}
152 <form method="POST">
153 {% csrf_token %}
154 {% load unescape %}
155 {% if form.non_field_errors %}
156 <p class="error">{{ form.non_field_errors|unescape}}</p>
157 {% endif %}
158
159 <fieldset {% if edit %} style="display:none;" {% endif %}>
160         <legend>{% trans "Rule Basic Info" %}</legend>
161 <table>
162 <tr><th>{{ form.name.label_tag }}</th><td>{{ form.name }}<span class="error">{{ form.name.errors|join:", " }}</span></td></tr>
163 <tr class="help"><td></td><td>A unique identifier will be added as a name_suffix</td></tr>
164 </table>
165 </fieldset>
166
167 <fieldset>
168 <legend>{% trans "Rule Match Conditions" %}</legend>
169 <table>
170 <input type="hidden" id="id_applier" name="applier" value="{{applier}}"/>
171 <tr><th>{{ form.source.label_tag }}</th><td>{{ form.source }}<span class="error">{{ form.source.errors|join:", " }}</span></td></tr>
172 <tr class="help"><td></td><td>{{ form.source.help_text }}</td></tr>
173 <tr><th>{{ form.sourceport.label_tag }}</th><td>{{ form.sourceport }}&nbsp;&nbsp;<button class="new_port">Port</button><span class="error">{{ form.sourceport.errors|join:", " }}</span></td></tr>
174 <tr class="help"><td></td><td>{{ form.sourceport.help_text }}</td></tr>
175 <tr><th>{{ form.destination.label_tag }}</th><td>{{ form.destination }}<span class="error">{{ form.destination.errors|join:", " }}</span></td></tr>
176 <tr class="help"><td></td><td>{{ form.destination.help_text }}</td></tr>
177 <tr><th>{{ form.destinationport.label_tag }}</th><td>{{ form.destinationport }}&nbsp;&nbsp;<button class="new_port">Port</button><span class="error">{{ form.destinationport.errors|join:", " }}</span></td></tr>
178 <tr class="help"><td></td><td>{{ form.destinationport.help_text }}</td></tr>
179 <tr><th>{{ form.port.label_tag }}</th><td>{{ form.port }}&nbsp;&nbsp;<button class="new_port">Port</button><span class="error">{{ form.port.errors|join:", " }}</span></td></tr>
180 <tr class="help"><td></td><td>{{ form.port.help_text }}</td></tr>
181 </table>
182 </fieldset>
183 <fieldset>
184 <legend>{% trans "Rule Actions" %}</legend>
185 <table>
186 <tr><th>{{ form.then.label_tag }}</th><td>{{ form.then }}&nbsp;&nbsp;<button id="new_then_actions">Rate-limit</button><span class="error">{{ form.then.errors|join:", " }}</span></td></tr>
187 </table>
188 </fieldset>
189 <fieldset>
190 <legend>{% trans "Expiration" %}</legend>
191 <table>
192 <tr><th>{{ form.expires.label_tag }}</th><td>{{ form.expires }}<span class="error">{{ form.expires.errors|join:", " }}</span></td></tr>
193 </table>
194 </fieldset>
195 <fieldset>
196 <legend>{% trans "Use/Comments" %}</legend>
197 {% blocktrans %}
198 <p>Give a short description of the intended use of this rule, that justifies the parameter selection above. Feel free to include any additional comments.</p>
199 {% endblocktrans %}
200 <p>{{ form.comments }}
201 {% if form.errors %}<br /><span class="error">{{ form.comments.errors|join:", " }}</span>{% endif %}
202 </p>
203 </fieldset>
204
205 <p><input type="submit" value="{% trans "Apply" %}" /></p>
206 </form>
207 </div>
208
209 <div id="then_diag" title="Add new rate-limit value">
210 </div>
211
212 <div id="port_diag" title="Add new port">
213 </div>
214
215 {% endblock %}