|
@@ -8,13 +8,13 @@ from django.contrib import messages
|
|
|
from django.core.urlresolvers import reverse, reverse_lazy
|
|
|
from django.http import HttpResponse
|
|
|
from django.shortcuts import render_to_response, get_object_or_404
|
|
|
from django.views.generic import TemplateView, DetailView, CreateView, UpdateView, DeleteView
|
|
|
|
|
|
# Third-party application imports.
|
|
|
from braces.views import MultiplePermissionsRequiredMixin
|
|
|
from braces.views import MultiplePermissionsRequiredMixin, SetHeadlineMixin
|
|
|
|
|
|
# Application imports.
|
|
|
from .forms import ProjectForm, LocationForm, EntityForm, InterfaceForm, CommunicationForm
|
|
|
from .models import Project, Entity, Location, Interface, Communication
|
|
|
from .utils import generate_entity_iptables
|
|
|
|
|
@@ -244,20 +244,21 @@ def project_iptables(request, project_id
|
|
|
response['Content-Disposition'] = 'attachment; filename="%s"' % filename
|
|
|
|
|
|
# Finally return the response object.
|
|
|
return response
|
|
|
|
|
|
|
|
|
class ProjectCreateView(MultiplePermissionsRequiredMixin, CreateView):
|
|
|
class ProjectCreateView(SetHeadlineMixin, MultiplePermissionsRequiredMixin, CreateView):
|
|
|
"""
|
|
|
View for creating a new project.
|
|
|
"""
|
|
|
|
|
|
model = Project
|
|
|
form_class = ProjectForm
|
|
|
template_name_suffix = "_create_form"
|
|
|
headline = "Add new project"
|
|
|
template_name = "conntrackt/create_form.html"
|
|
|
|
|
|
# Required permissions.
|
|
|
permissions = {
|
|
|
"all": ("conntrackt.add_project",),
|
|
|
}
|
|
|
|
|
@@ -308,20 +309,21 @@ class ProjectDeleteView(MultiplePermissi
|
|
|
|
|
|
messages.success(self.request, "Project %s has been removed." % self.get_object().name, extra_tags="alert alert-success")
|
|
|
|
|
|
return super(ProjectDeleteView, self).post(*args, **kwargs)
|
|
|
|
|
|
|
|
|
class LocationCreateView(MultiplePermissionsRequiredMixin, CreateView):
|
|
|
class LocationCreateView(SetHeadlineMixin, MultiplePermissionsRequiredMixin, CreateView):
|
|
|
"""
|
|
|
View for creating a new location.
|
|
|
"""
|
|
|
|
|
|
model = Location
|
|
|
form_class = LocationForm
|
|
|
template_name_suffix = "_create_form"
|
|
|
headline = "Add new location"
|
|
|
template_name = "conntrackt/create_form.html"
|
|
|
|
|
|
# Required permissions.
|
|
|
permissions = {
|
|
|
"all": ("conntrackt.add_location",),
|
|
|
}
|
|
|
|
|
@@ -376,20 +378,21 @@ class LocationDeleteView(MultiplePermiss
|
|
|
|
|
|
messages.success(self.request, "Location %s has been removed." % self.get_object().name, extra_tags="alert alert-success")
|
|
|
|
|
|
return super(LocationDeleteView, self).post(*args, **kwargs)
|
|
|
|
|
|
|
|
|
class EntityCreateView(MultiplePermissionsRequiredMixin, CreateView):
|
|
|
class EntityCreateView(SetHeadlineMixin, MultiplePermissionsRequiredMixin, CreateView):
|
|
|
"""
|
|
|
View for creating a new entity.
|
|
|
"""
|
|
|
|
|
|
model = Entity
|
|
|
form_class = EntityForm
|
|
|
template_name_suffix = "_create_form"
|
|
|
headline = "Add new entity"
|
|
|
template_name = "conntrackt/create_form.html"
|
|
|
|
|
|
# Required permissions.
|
|
|
permissions = {
|
|
|
"all": ("conntrackt.add_entity",),
|
|
|
}
|
|
|
|
|
@@ -487,20 +490,21 @@ class EntityDeleteView(MultiplePermissio
|
|
|
|
|
|
self.success_url = reverse("project", args=(self.get_object().project.id,))
|
|
|
|
|
|
return super(EntityDeleteView, self).delete(*args, **kwargs)
|
|
|
|
|
|
|
|
|
class InterfaceCreateView(MultiplePermissionsRequiredMixin, CreateView):
|
|
|
class InterfaceCreateView(SetHeadlineMixin, MultiplePermissionsRequiredMixin, CreateView):
|
|
|
"""
|
|
|
View for creating a new interface.
|
|
|
"""
|
|
|
|
|
|
model = Interface
|
|
|
form_class = InterfaceForm
|
|
|
template_name_suffix = "_create_form"
|
|
|
headline = "Add new interface"
|
|
|
template_name = "conntrackt/create_form.html"
|
|
|
|
|
|
# Required permissions
|
|
|
permissions = {
|
|
|
"all": ("conntrackt.add_interface",),
|
|
|
}
|
|
|
|
|
@@ -627,20 +631,21 @@ class InterfaceDeleteView(MultiplePermis
|
|
|
|
|
|
self.success_url = reverse("entity", args=(self.get_object().entity.id,))
|
|
|
|
|
|
return super(InterfaceDeleteView, self).delete(*args, **kwargs)
|
|
|
|
|
|
|
|
|
class CommunicationCreateView(MultiplePermissionsRequiredMixin, CreateView):
|
|
|
class CommunicationCreateView(SetHeadlineMixin, MultiplePermissionsRequiredMixin, CreateView):
|
|
|
"""
|
|
|
View for creating a new communication.
|
|
|
"""
|
|
|
|
|
|
model = Communication
|
|
|
form_class = CommunicationForm
|
|
|
template_name_suffix = "_create_form"
|
|
|
headline = "Add new communication"
|
|
|
template_name = "conntrackt/create_form.html"
|
|
|
|
|
|
# Required permissions
|
|
|
permissions = {
|
|
|
"all": ("conntrackt.add_communication",),
|
|
|
}
|
|
|
|