|
@@ -11,13 +11,13 @@ from django.shortcuts import render_to_r
|
|
|
from django.views.generic import TemplateView, DetailView, CreateView, UpdateView, DeleteView
|
|
|
|
|
|
# Third-party application imports.
|
|
|
from braces.views import MultiplePermissionsRequiredMixin
|
|
|
|
|
|
# Application imports.
|
|
|
from .forms import EntityForm, InterfaceForm, CommunicationForm, ProjectForm
|
|
|
from .forms import ProjectForm, LocationForm, EntityForm, InterfaceForm, CommunicationForm
|
|
|
from .models import Project, Entity, Location, Interface, Communication
|
|
|
from .utils import generate_entity_iptables
|
|
|
|
|
|
|
|
|
class IndexView(MultiplePermissionsRequiredMixin, TemplateView):
|
|
|
"""
|
|
@@ -314,71 +314,45 @@ class ProjectDeleteView(MultiplePermissi
|
|
|
class LocationCreateView(MultiplePermissionsRequiredMixin, CreateView):
|
|
|
"""
|
|
|
View for creating a new location.
|
|
|
"""
|
|
|
|
|
|
model = Location
|
|
|
form_class = LocationForm
|
|
|
template_name_suffix = "_create_form"
|
|
|
|
|
|
# Required permissions.
|
|
|
permissions = {
|
|
|
"all": ("conntrackt.add_location",),
|
|
|
}
|
|
|
|
|
|
# Raise authorisation denied exception for unmet permissions.
|
|
|
raise_exception = True
|
|
|
|
|
|
success_url = reverse_lazy("index")
|
|
|
|
|
|
def get_form(self, form_class):
|
|
|
"""
|
|
|
Implements an override for the default form constructed for the create
|
|
|
view that includes some better styling of input widgets.
|
|
|
"""
|
|
|
|
|
|
form = super(LocationCreateView, self).get_form(form_class)
|
|
|
form.fields["name"].widget.attrs["class"] = "span6"
|
|
|
form.fields["name"].widget.attrs["placeholder"] = "New Location"
|
|
|
form.fields["description"].widget.attrs["class"] = "span6"
|
|
|
form.fields["description"].widget.attrs["placeholder"] = "Description for new location."
|
|
|
|
|
|
return form
|
|
|
|
|
|
|
|
|
class LocationUpdateView(MultiplePermissionsRequiredMixin, UpdateView):
|
|
|
"""
|
|
|
View for modifying an existing location.
|
|
|
"""
|
|
|
|
|
|
model = Location
|
|
|
form_class = LocationForm
|
|
|
template_name_suffix = "_update_form"
|
|
|
|
|
|
# Required permissions.
|
|
|
permissions = {
|
|
|
"all": ("conntrackt.change_location",),
|
|
|
}
|
|
|
|
|
|
# Raise authorisation denied exception for unmet permissions.
|
|
|
raise_exception = True
|
|
|
|
|
|
success_url = reverse_lazy("index")
|
|
|
|
|
|
def get_form(self, form_class):
|
|
|
"""
|
|
|
Implements an override for the default form constructed for the create
|
|
|
view that includes some better styling of input widgets.
|
|
|
"""
|
|
|
|
|
|
form = super(LocationUpdateView, self).get_form(form_class)
|
|
|
form.fields["name"].widget.attrs["class"] = "span6"
|
|
|
form.fields["name"].widget.attrs["placeholder"] = "Location name"
|
|
|
form.fields["description"].widget.attrs["class"] = "span6"
|
|
|
form.fields["description"].widget.attrs["placeholder"] = "Description for location."
|
|
|
|
|
|
return form
|
|
|
|
|
|
|
|
|
class LocationDeleteView(MultiplePermissionsRequiredMixin, DeleteView):
|
|
|
"""
|
|
|
View for deleting a location.
|
|
|
"""
|
|
|
|