|
@@ -16,7 +16,7 @@ from braces.views import MultiplePermiss
|
|
|
# Application imports.
|
|
|
from .forms import ProjectForm, LocationForm, EntityForm, InterfaceForm, CommunicationForm
|
|
|
from .models import Project, Entity, Location, Interface, Communication
|
|
|
from .utils import generate_entity_iptables
|
|
|
from .utils import generate_entity_iptables, generate_project_diagram
|
|
|
|
|
|
|
|
|
class IndexView(MultiplePermissionsRequiredMixin, TemplateView):
|
|
@@ -880,3 +880,38 @@ class CommunicationDeleteView(SetHeadlin
|
|
|
"""
|
|
|
|
|
|
return "Delete communication %s" % self.object
|
|
|
|
|
|
|
|
|
@permission_required("conntrackt.view", raise_exception=True)
|
|
|
def project_diagram(request, pk):
|
|
|
"""
|
|
|
Custom view that returns response containing diagram of project
|
|
|
communications.
|
|
|
|
|
|
The diagram will include coloured entities, with directional lines
|
|
|
connecting the source and destination end entities.
|
|
|
|
|
|
The output format is SVG.
|
|
|
|
|
|
Arguments:
|
|
|
|
|
|
request - Request object.
|
|
|
|
|
|
pk - Project ID for which the diagram should be generated.
|
|
|
|
|
|
Returns:
|
|
|
|
|
|
Response object that contains the project diagram rendered as SVG.
|
|
|
"""
|
|
|
|
|
|
# Fetch the project.
|
|
|
project = get_object_or_404(Project, pk=pk)
|
|
|
|
|
|
# Generate the diagram.
|
|
|
content = generate_project_diagram(project).create_svg()
|
|
|
|
|
|
# Set the mime type.
|
|
|
response = HttpResponse(content, mimetype='image/svg+xml')
|
|
|
|
|
|
# Return the response object.
|
|
|
return response
|