Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
F
flowspy
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
itminedu
flowspy
Commits
052c14aa
Commit
052c14aa
authored
Dec 07, 2011
by
Leonidas Poulopoulos
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implemented expiration date selection with client and strict server validation
parent
20ff5bd4
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
19 additions
and
25 deletions
+19
-25
flowspec/forms.py
flowspec/forms.py
+11
-1
flowspec/models.py
flowspec/models.py
+1
-1
flowspec/views.py
flowspec/views.py
+0
-23
templates/apply.html
templates/apply.html
+7
-0
No files found.
flowspec/forms.py
View file @
052c14aa
...
...
@@ -7,7 +7,8 @@ from flowspy.flowspec.models import *
from
ipaddr
import
*
from
django.core.urlresolvers
import
reverse
from
django.contrib.auth.models
import
User
from
django.db.models
import
Avg
,
Max
,
Min
,
Count
import
datetime
class
RouteForm
(
forms
.
ModelForm
):
...
...
@@ -40,6 +41,15 @@ class RouteForm(forms.ModelForm):
return
self
.
cleaned_data
[
"destination"
]
except
Exception
:
raise
forms
.
ValidationError
(
'Invalid network address format'
)
def
clean_expires
(
self
):
date
=
self
.
cleaned_data
[
'expires'
]
if
date
:
range_days
=
(
date
-
datetime
.
date
.
today
()).
days
if
range_days
>
0
and
range_days
<
11
:
return
self
.
cleaned_data
[
"expires"
]
else
:
raise
forms
.
ValidationError
(
'Invalid date range'
)
def
clean
(
self
):
name
=
self
.
cleaned_data
.
get
(
'name'
,
None
)
...
...
flowspec/models.py
View file @
052c14aa
...
...
@@ -97,7 +97,7 @@ class Route(models.Model):
status
=
models
.
CharField
(
max_length
=
20
,
choices
=
ROUTE_STATES
,
blank
=
True
,
null
=
True
,
verbose_name
=
"Status"
,
default
=
"PENDING"
)
# is_online = models.BooleanField(default=False)
# is_active = models.BooleanField(default=False)
expires
=
models
.
DateField
(
default
=
days_offset
,
blank
=
True
,
null
=
True
,
)
expires
=
models
.
DateField
(
default
=
days_offset
)
response
=
models
.
CharField
(
max_length
=
512
,
blank
=
True
,
null
=
True
)
comments
=
models
.
TextField
(
null
=
True
,
blank
=
True
,
verbose_name
=
"Comments"
)
...
...
flowspec/views.py
View file @
052c14aa
...
...
@@ -90,29 +90,6 @@ def add_route(request):
return
render_to_response
(
'apply.html'
,
{
'form'
:
form
,
'applier'
:
applier
},
context_instance
=
RequestContext
(
request
))
@
login_required
@
never_cache
def
add_then
(
request
):
applier
=
request
.
user
.
pk
if
request
.
method
==
"GET"
:
form
=
RouteForm
()
return
render_to_response
(
'apply.html'
,
{
'form'
:
form
,
'applier'
:
applier
},
context_instance
=
RequestContext
(
request
))
else
:
form
=
RouteForm
(
request
.
POST
)
if
form
.
is_valid
():
route
=
form
.
save
(
commit
=
False
)
route
.
applier
=
request
.
user
route
.
expires
=
days_offset
()
route
.
save
()
form
.
save_m2m
()
route
.
commit_add
()
return
HttpResponseRedirect
(
reverse
(
"group-routes"
))
else
:
return
render_to_response
(
'apply.html'
,
{
'form'
:
form
,
'applier'
:
applier
},
context_instance
=
RequestContext
(
request
))
@
login_required
@
never_cache
def
edit_route
(
request
,
route_slug
):
...
...
templates/apply.html
View file @
052c14aa
...
...
@@ -24,6 +24,7 @@
$
(
"
#id_port
"
).
css
(
'
width
'
,
'
100px
'
).
attr
(
'
size
'
,
'
5
'
);
$
(
"
#id_destinationport
"
).
css
(
'
width
'
,
'
100px
'
).
attr
(
'
size
'
,
'
5
'
);
$
(
'
#id_then
'
).
attr
(
"
multiple
"
,
""
);
$
(
"
#id_expires
"
).
datepicker
({
dateFormat
:
'
yy-mm-dd
'
,
maxDate
:
'
+10d
'
,
minDate
:
'
+1d
'
,
changeMonth
:
false
,
changeYear
:
false
}).
datepicker
(
$
.
datepicker
.
regional
[
"
el
"
]
);
$
(
'
#then_diag
'
).
dialog
({
height
:
220
,
width
:
340
,
...
...
@@ -186,6 +187,12 @@ th {
</table>
</fieldset>
<fieldset>
<legend>
{% trans "Expiration" %}
</legend>
<table>
<tr><th>
{{ form.expires.label_tag }}
</th><td>
{{ form.expires }}
<span
class=
"error"
>
{{ form.expires.errors|join:", " }}
</span></td></tr>
</table>
</fieldset>
<fieldset>
<legend>
{% trans "Use/Comments" %}
</legend>
{% blocktrans %}
<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>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment