Changeset - b02e16dc7708
[Not reviewed]
default
0 2 0
Branko Majic (branko) - 10 years ago 2013-11-09 14:02:29
branko@majic.rs
CONNT-17: Added tabelarised representation of communications to the project details page with colour-coding.
2 files changed with 27 insertions and 0 deletions:
0 comments (0 inline, 0 general)
conntrackt/templates/conntrackt/project_detail.html
Show inline comments
 
@@ -29,21 +29,45 @@
 
    {% html_link "Get Iptables" 'project_iptables' project.id class="btn btn-primary" %}
 
  </div>
 
</div>
 
<hr>
 
{% if location_entities %}
 
<div class="row">
 
  {% for location, entities in location_entities %}
 
  <div class="span4">
 
    <div class="well">{% include "conntrackt/location_widget.html" with location=location entities=entities %}</div>
 
  </div>
 
  {% endfor %}
 
</div>
 

	
 
{% if communications %}
 
<div class="row">
 
  <div class="span12">
 
    <h2>Communications</h2>
 
    <table class="table table-hover table-condensed table-striped">
 
      <thead>
 
        <tr><th>From</th><th>To</th><th>Protocol</th><th>Port</th></tr>
 
      </thead>
 
      <tbody>
 
      {% for communication in communications %}
 
        <tr>
 
          <td><span class="badge" style="background-color: {{ communication.source_color }};">O</span> {{ communication.source }}</td>
 
          <td><span class="badge" style="background-color: {{ communication.destination_color }};">O</span> {{ communication.destination }}</td>
 
          <td>{{ communication.protocol }}</td>
 
          <td>{{ communication.port }}</td>
 
        </tr>
 
      {% endfor %}
 
      </tbody>
 
    </table>
 
  </div>
 
</div>
 
{% endif %}
 

	
 
<div class="row">
 
  <div class="span12">
 
    <h2>Communications diagram</h2>
 
    <img src="{% url "project_diagram" project.id %}" width="100%">
 
  </div>
 
</div>
 
{% endif %}
 
{% endblock %}
 

	
conntrackt/views.py
Show inline comments
 
@@ -168,24 +168,27 @@ class ProjectView(MultiplePermissionsReq
 
        # Set-up an array that will contaion (location, entities) tuples.
 
        location_entities = []
 

	
 
        # Add the (location, entities) tuple for each location that has entities
 
        # belonging to the related project.
 
        for location in Location.objects.filter(entity__project=self.object).distinct().order_by("name"):
 
            entities = Entity.objects.filter(project=self.object, location=location)
 
            location_entities.append((location, entities))
 

	
 
        # Add the (location, entities) tuples to context.
 
        context['location_entities'] = location_entities
 

	
 
        # Add all project communications to context.
 
        context['communications'] = self.object.get_project_communications_summary()
 

	
 
        # Finally return the context.
 
        return context
 

	
 

	
 
class EntityView(MultiplePermissionsRequiredMixin, DetailView):
 
    """
 
    Custom view for presenting entity information.
 
    """
 

	
 
    # Optimise the query to fetch the related data from reverse relationships.
 
    queryset = Entity.objects.all()
 
    queryset = queryset.prefetch_related('interface_set__destination_set__source__entity')
0 comments (0 inline, 0 general)