Files
@ 744593ed423d
Branch filter:
Location: conntrackt/conntrackt/forms.py - annotation
744593ed423d
2.5 KiB
text/x-python
CONNT-6: Implemented editing of communications from within the application. Cleaned-up the entity details template to have better looks.
7086387253d4 7086387253d4 7086387253d4 7086387253d4 7086387253d4 744593ed423d 7086387253d4 7086387253d4 7086387253d4 7086387253d4 7086387253d4 7086387253d4 7086387253d4 7086387253d4 7086387253d4 7086387253d4 7086387253d4 7086387253d4 7086387253d4 7086387253d4 7086387253d4 7086387253d4 7086387253d4 7086387253d4 2a0c8cb4797c 2a0c8cb4797c 2a0c8cb4797c 2a0c8cb4797c 2a0c8cb4797c 7086387253d4 2a0c8cb4797c 2a0c8cb4797c 2a0c8cb4797c 2a0c8cb4797c 2a0c8cb4797c 2a0c8cb4797c 2a0c8cb4797c 2a0c8cb4797c 2a0c8cb4797c 2a0c8cb4797c 2a0c8cb4797c 2a0c8cb4797c 2a0c8cb4797c 2a0c8cb4797c 2a0c8cb4797c 2a0c8cb4797c 2a0c8cb4797c 2a0c8cb4797c 2a0c8cb4797c 2a0c8cb4797c 2a0c8cb4797c 2a0c8cb4797c 2a0c8cb4797c 2a0c8cb4797c 2a0c8cb4797c 2a0c8cb4797c 2a0c8cb4797c 2a0c8cb4797c 744593ed423d 744593ed423d 744593ed423d 744593ed423d 744593ed423d 744593ed423d 744593ed423d 744593ed423d 744593ed423d 744593ed423d 744593ed423d 744593ed423d 744593ed423d 744593ed423d 744593ed423d 744593ed423d 744593ed423d 744593ed423d 744593ed423d 744593ed423d 744593ed423d 744593ed423d 744593ed423d 744593ed423d 744593ed423d | # Django imports.
from django.forms import ModelForm
from django.forms.models import inlineformset_factory
# Application imports.
from .models import Entity, Interface, Communication
class EntityForm(ModelForm):
"""
Implements a custom model form for entities with some styling changes.
"""
class Meta:
model = Entity
def __init__(self, *args, **kwargs):
"""
Initialises the form instance. Sets-up some bootstrap CSS classes for
widgets.
"""
super(EntityForm, self).__init__(*args, **kwargs)
# Update the widgets to be wider.
for field_name, field in self.fields.iteritems():
field.widget.attrs["class"] = "span6"
# Set-up some placeholders.
self.fields["name"].widget.attrs["placeholder"] = "Entity name"
self.fields["description"].widget.attrs["placeholder"] = "Entity description"
class InterfaceForm(ModelForm):
"""
Implements a custom model form for interfaces with some styling changes.
"""
class Meta:
model = Interface
def __init__(self, *args, **kwargs):
"""
Initialises the form instance. Sets-up some bootstrap CSS classes for
widgets.
"""
super(InterfaceForm, self).__init__(*args, **kwargs)
# Update the widgets to be wider.
for field_name, field in self.fields.iteritems():
field.widget.attrs["class"] = "span6"
# Set-up some placeholders.
self.fields["name"].widget.attrs["placeholder"] = "Interface name"
self.fields["description"].widget.attrs["placeholder"] = "Interface description"
self.fields["address"].widget.attrs["placeholder"] = "IP address of interface"
self.fields["netmask"].widget.attrs["placeholder"] = "IP address netmask"
class CommunicationForm(ModelForm):
"""
Implements a custom model form for communications with some styling changes.
"""
class Meta:
model = Communication
def __init__(self, *args, **kwargs):
"""
Initialises the form instance. Sets-up some bootstrap CSS classes for
widgets.
"""
super(CommunicationForm, self).__init__(*args, **kwargs)
# Update the widgets to be wider.
for field_name, field in self.fields.iteritems():
field.widget.attrs["class"] = "span6"
# Set-up some placeholders.
self.fields["port"].widget.attrs["placeholder"] = "Port used for communication"
self.fields["description"].widget.attrs["placeholder"] = "Communication description"
|