Files
@ 079e7f2b0680
Branch filter:
Location: conntrackt/conntrackt/forms.py - annotation
079e7f2b0680
1.0 KiB
text/x-python
Noticket: Added uniqueness enforcement for IP/address across same entity (i.e. prevent the entity from having multiple interfaces with same IP address.)
7086387253d4 7086387253d4 7086387253d4 7086387253d4 7086387253d4 7086387253d4 7086387253d4 7086387253d4 7086387253d4 7086387253d4 7086387253d4 7086387253d4 7086387253d4 7086387253d4 7086387253d4 7086387253d4 7086387253d4 7086387253d4 7086387253d4 7086387253d4 7086387253d4 7086387253d4 7086387253d4 7086387253d4 7086387253d4 7086387253d4 7086387253d4 7086387253d4 7086387253d4 7086387253d4 7086387253d4 7086387253d4 | # Django imports.
from django.forms import ModelForm
from django.forms.models import inlineformset_factory
# Application imports.
from .models import Entity, Interface
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, and set-up placeholder values for text
# boxes.
self.fields["name"].widget.attrs["class"] = "span6"
self.fields["name"].widget.attrs["placeholder"] = "Entity name"
self.fields["description"].widget.attrs["class"] = "span6"
self.fields["description"].widget.attrs["placeholder"] = "Description for new entity."
self.fields["project"].widget.attrs["class"] = "span6"
self.fields["location"].widget.attrs["class"] = "span6"
|