Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
CIRCLE
/
cloud
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
94
Merge Requests
10
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
fbaed012
authored
Jun 28, 2013
by
Őry Máté
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
network: initial host edit form
parent
e812b47d
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
69 additions
and
0 deletions
+69
-0
network/forms.py
+63
-0
network/templates/bootstrap/layout/linkbutton.html
+6
-0
No files found.
network/forms.py
View file @
fbaed012
from
django.forms
import
ModelForm
from
django.core.urlresolvers
import
reverse_lazy
from
crispy_forms.helper
import
FormHelper
from
crispy_forms.layout
import
Layout
,
Fieldset
,
Row
,
HTML
from
crispy_forms.layout
import
Div
,
ButtonHolder
,
Submit
,
BaseInput
from
firewall.models
import
Host
class
LinkButton
(
BaseInput
):
"""
Used to create a link button descriptor for the {
%
crispy
%
} template tag::
back = LinkButton('back', 'Back', reverse_lazy('index'))
.. note:: The first argument is also slugified and turned into the id for
the submit button.
"""
template
=
"bootstrap/layout/linkbutton.html"
field_classes
=
'btn'
def
__init__
(
self
,
name
,
text
,
url
,
*
args
,
**
kwargs
):
self
.
href
=
url
super
(
LinkButton
,
self
)
.
__init__
(
name
,
text
,
*
args
,
**
kwargs
)
class
HostForm
(
ModelForm
):
helper
=
FormHelper
()
helper
.
layout
=
Layout
(
Div
(
Row
(
Div
(
Fieldset
(
'Identity'
,
'hostname'
,
'reverse'
,
'mac'
,
),
Fieldset
(
'Network'
,
'vlan'
,
'ipv4'
,
'ipv6'
,
'shared_ip'
,
'pub_ipv4'
,
),
Fieldset
(
'Info'
,
'description'
,
'location'
,
'comment'
,
# 'created_at',
# 'modified_at',
# 'id'
),
css_class
=
'span8'
),
Div
(
HTML
(
'<p>hello</p>'
),
css_class
=
'span4'
),
),
ButtonHolder
(
Submit
(
'submit'
,
'Save'
),
LinkButton
(
'back'
,
'Back'
,
reverse_lazy
(
'network.host_list'
))
),
css_class
=
"form-horizontal"
))
class
Meta
:
model
=
Host
network/templates/bootstrap/layout/linkbutton.html
0 → 100644
View file @
fbaed012
<a
href=
"{{ input.href }}"
id=
"{% if input.name|wordcount > 1 %}{{ input.name|slugify }}{% else %}{{ input.name }}{% endif %}"
value=
""
class=
"{{ input.field_classes }}"
{{
input
.
flat_attrs
|
safe
}}
>
{{ input.value }}
</a>
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