mirror of
https://github.com/eduardogsilva/routerfleet.git
synced 2025-08-31 07:10:14 +02:00
Basic router manager CRUD
This commit is contained in:
parent
c104a12df0
commit
9129a007ee
16 changed files with 403 additions and 2 deletions
44
router_manager/forms.py
Normal file
44
router_manager/forms.py
Normal file
|
@ -0,0 +1,44 @@
|
|||
from django import forms
|
||||
from crispy_forms.helper import FormHelper
|
||||
from crispy_forms.layout import Layout, Submit, Row, Column, HTML
|
||||
from .models import Router
|
||||
|
||||
|
||||
class RouterForm(forms.ModelForm):
|
||||
class Meta:
|
||||
model = Router
|
||||
fields = ['name', 'address', 'username', 'password', 'ssh_key', 'monitoring', 'router_type', 'enabled']
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(RouterForm, self).__init__(*args, **kwargs)
|
||||
self.helper = FormHelper()
|
||||
self.helper.form_method = 'post'
|
||||
if self.instance.pk:
|
||||
delete_html = "<a href='javascript:void(0)' class='btn btn-outline-danger' data-command='delete' onclick='openCommandDialog(this)'>Delete</a>"
|
||||
else:
|
||||
delete_html = ''
|
||||
self.helper.layout = Layout(
|
||||
Row(
|
||||
Column('name', css_class='form-group col-md-6 mb-0'),
|
||||
Column('address', css_class='form-group col-md-6 mb-0'),
|
||||
css_class='form-row'
|
||||
),
|
||||
Row(
|
||||
Column('username', css_class='form-group col-md-6 mb-0'),
|
||||
Column('password', css_class='form-group col-md-6 mb-0'),
|
||||
css_class='form-row'
|
||||
),
|
||||
'ssh_key',
|
||||
|
||||
'router_type',
|
||||
'monitoring',
|
||||
'enabled',
|
||||
Row(
|
||||
Column(
|
||||
Submit('submit', 'Salvar', css_class='btn btn-success'),
|
||||
HTML(' <a class="btn btn-secondary" href="/router/list/">Back</a> '),
|
||||
HTML(delete_html),
|
||||
css_class='col-md-12'),
|
||||
css_class='form-row'
|
||||
)
|
||||
)
|
Loading…
Add table
Add a link
Reference in a new issue