diff farol/templates/document/view.j2 @ 7:8f41bb7f4681

Move the Document management routines to a document Blueprint
author Benoît Allard <benoit.allard@greenbone.net>
date Thu, 25 Sep 2014 17:03:35 +0200
parents farol/templates/doc.j2@4a9f23230eba
children 79b76911444e
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/farol/templates/document/view.j2	Thu Sep 25 17:03:35 2014 +0200
@@ -0,0 +1,206 @@
+{#
+# Description:
+# Web Template used in Farol Design
+#
+# Authors:
+# BenoƮt Allard <benoit.allard@greenbone.net>
+#
+# Copyright:
+# Copyright (C) 2014 Greenbone Networks GmbH
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+-#}
+
+{% extends "base.j2" %}
+{% from "macros.j2" import panel, label_value %}
+{% block title %}Document{% endblock %}
+
+{% set active='document' %}
+
+{% block content %}
+<div class='clearfix page-header'>
+  <h1>{{ cvrf._title }} <small>({{ cvrf._type }})</small></h1>
+  <a class="pull-right" href="{{ url_for('.edit_title') }}">edit title</a>
+</div>
+{% call panel(heading="Publisher", title=3, collapsible=False) %}
+  <a class="pull-right" href="{{ url_for('.edit_publisher') }}">edit</a>
+  <div class="form-horizontal">
+    {% for label, value in [("Type", cvrf._publisher._type),
+                            ("VendorID", cvrf._publisher._vendorid or ''),
+                            ("Contact Details", (cvrf._publisher._contact or '') | replace('\n', '<br>')),
+                            ("Issuing Authority", (cvrf._publisher._authority or '') | replace('\n', '<br>'))] %}
+      {{ label_value(label, value, right=8) }} {# 8: so that we reserve place for the floating 'edit'#}
+    {% endfor %}
+  </div>
+{% endcall %}
+{% call panel(heading="Document Tracking", title=3, collapsible=False) %}
+  <a class="pull-right" href="{{ url_for('.edit_tracking') }}">edit</a>
+  <div class="form-horizontal">
+    {% for label, value in [("Identification", cvrf._tracking._identification),
+                            ("Status", cvrf._tracking._status),
+                            ("Version", cvrf._tracking._version | join('.'))] %}
+      {{ label_value(label, value, right=8) }}
+    {% endfor %}
+  </div>
+  {% call panel(heading="Revision History (%d)" % cvrf._tracking._history | length, title=4) %}
+    {% for revision in cvrf._tracking._history %}
+      {% call panel() %}
+        <div class="form-horizontal">
+          <a class="pull-right" href="{{ url_for('.edit_revision', index=loop.index0) }}">edit revision</a>
+          {{ label_value('Number', revision._number | join('.'), right=8) }}
+          {{ label_value('Date', revision._date) }}
+          {{ label_value('Description', revision._description) }}
+        </div>
+      {% endcall %}
+    {% endfor %}
+    <a class="pull-right" href="{{ url_for('.add_revision') }}">add revision</a>
+  {% endcall %}
+  <div class="form-horizontal">
+    {% for label, value in [("Initial Release Date", cvrf._tracking._initialDate),
+                            ("Current Release Date", cvrf._tracking._currentDate)] %}
+      {{ label_value(label, value) }}
+    {% endfor %}
+  </div>
+  {% if cvrf._tracking._generator %}
+    {% call panel(heading="Generator", title=4, collapsible=False) %}
+      <div class="form-horizontal">
+        {% if cvrf._tracking._generator._engine %}{{ label_value('Engine', cvrf._tracking._generator._engine) }}{% endif %}
+        {% if cvrf._tracking._generator._date %}{{ label_value('Date', cvrf._tracking._generator._date) }}{% endif %}
+      </div>
+    {% endcall %}
+  {% endif %}
+{% endcall %}
+{% call panel(heading="Distribution", title=3, collapsible=False) %}
+  <a class="pull-right" href="{{ url_for('.edit_distribution') }}">edit</a>
+  <p>{{ (cvrf._distribution or '') | replace('\n', '<br>') }}</p>
+{% endcall %}
+{% call panel(heading="Aggregate Severity", title=3, collapsible=False) %}
+  <div class="form-horizontal">
+  <a class="pull-right" href="{{ url_for('.edit_severity') }}">edit</a>
+  {% if cvrf._aggregateseverity %}
+    {{ label_value('Namespace', (cvrf._aggregateseverity._namespace or '') | urlize, right=8) }}
+    {{ label_value('Severity', cvrf._aggregateseverity._severity) }}
+  {% endif %}
+  </div>
+{% endcall %}
+<div class="clearfix">
+  <div class="col-sm-4">
+    {% call panel(type="success", heading="Notes (%d)" % cvrf._notes | length , title=3) %}
+    <ul>
+    {% for note in cvrf._notes %}
+      <li><a href="{{ url_for('.view_note', ordinal=note._ordinal) }}">{{ note.getTitle() }}</a></li>
+    {% endfor %}
+    </ul>
+    <a class="pull-right" href="{{ url_for('.add_note') }}">add</a>
+    {% endcall %}
+  </div>
+  <div class="col-sm-4">
+    {% call panel(type="warning", heading="References (%d)" % cvrf._references | length, title=3) %}
+    <ul>
+    {% for reference in cvrf._references %}
+      <li><a href="{{ reference._url }}" target="_blank">{{ reference._description }}{% if reference._type %} ({{ reference._type }}){% endif %}</a> (<a href="{{ url_for('.edit_reference', index=loop.index0) }}">edit</a>)</li>
+    {% endfor %}
+    </ul>
+    <a class="pull-right" href="{{ url_for('.add_reference') }}">add</a>
+    {% endcall %}
+  </div>
+  <div class="col-sm-4">
+    {% call panel(type="info", heading="Acknowledgments (%d)" % cvrf._acknowledgments | length, title=3) %}
+    <ul>
+    {% for ack in cvrf._acknowledgments %}
+      <li><a href="{{ url_for('.view_acknowledgment', index=loop.index0) }}">{{ ack.getTitle() }}</a></li>
+    {% endfor %}
+    </ul>
+    <a class="pull-right" href="{{ url_for('.add_acknowledgment') }}">add</a>
+    {% endcall %}
+  </div>
+</div>
+
+
+<div class="clearfix">
+  <div class="col-md-6">
+    {% call panel(type="danger", heading="Product Tree", title=3) %}
+      {% if cvrf._producttree %}
+        {% call panel(heading="Branches (%d)" % cvrf._producttree._branches | length, title=4, extended=True) %}
+          {% for branch in cvrf._producttree._branches recursive %}
+            {% call panel() %}
+              <p>{{ branch._type}}: <em>{{ branch._name }}</em> (<a href="{{ url_for('producttree.edit_branch', path=branch.getPath() | join('/')) }}">edit</a>)</p>
+              {% if branch._product %}
+                <strong><a href="{{ url_for('producttree.view_product', productid=branch._product._productid) }}">{{ branch._product._name }}</a></strong> (<a href="{{ url_for('producttree.edit_product', productid=branch._product._productid) }}">edit</a>)
+              {% else %}
+                {{ loop(branch._childs) }}
+              {% endif %}
+              {% if branch.isOrphaned() %}
+                <p class="text-danger">This branch is <em>orphaned</em>. A <a href="{{ url_for('producttree.add_product') }}">product</a> or a new <a href="{{ url_for('producttree.add_branch') }}">branch</a> should be created as child of this one.</p>
+              {% endif %}
+            {% endcall %}
+          {% endfor %}
+          <a href="{{ url_for('producttree.add_branch') }}" class="pull-right">add branch</a>
+        {% endcall %}
+        {% call panel(heading="Products (%d)" % cvrf._producttree.nbProducts(), title=4) %}
+          {% for product in cvrf._producttree._products if product._parent is sameas cvrf._producttree %}
+            <p><strong><a href="{{ url_for('producttree.view_product', productid=product._productid) }}">{{ product._name }}</a></strong> (<a href="{{ url_for('producttree.edit_product', productid=product._productid) }}">edit</a>)</p>
+          {% endfor %}
+          <a href="{{ url_for('producttree.add_product') }}" class="pull-right">add product</a>
+        {% endcall %}
+        {% call panel(heading="Relationships (%d)" % cvrf._producttree._relationships | length, title=4) %}
+          {% for relationship in cvrf._producttree._relationships %}
+            {% call panel() %}
+              <p><em>{{ cvrf.getProductForID(relationship._productreference)._name }}</em> as {{ relationship._relationtype | lower }} <em>{{ cvrf.getProductForID(relationship._relatestoproductreference)._name }}</em> (<a href="{{ url_for('producttree.edit_relationship', index=loop.index0) }}">edit</a>)</p>
+              {% if relationship._product %}<p><strong><a href="{{ url_for('producttree.view_product', productid=relationship._product._productid) }}">{{ relationship._product._name }}</a></strong> (<a href="{{ url_for('producttree.edit_product', productid=relationship._product._productid) }}">edit</a>)</p>{% endif %}
+              {% if relationship.isOrphaned() %}
+                <p class="text-danger">This relationship is <em>orphaned</em>. A product should be <a href="{{ url_for('producttree.add_product') }}">created</a> as child of this one.</p>
+              {% endif %}
+            {% endcall %}
+          {% endfor %}
+          <a href="{{ url_for('producttree.add_relationship') }}" class="pull-right">add</a>
+        {% endcall %}
+        {% call panel(heading="Groups (%d)" % cvrf._producttree._groups | length, title=4) %}
+          {% for group in cvrf._producttree._groups %}
+            {% call panel() %}
+              <a href="{{ url_for('producttree.edit_group', groupid=group._groupid) }}" class="pull-right">edit</a>
+              <ul>
+                {% for productid in group._productids %}
+                  {% with product = cvrf.getProductForID(productid) %}
+                    <li><a href="{{ url_for('producttree.view_product', productid=product._productid) }}">{{ product._name }}</a></li>
+                  {% endwith %}
+                {% endfor %}
+              </ul>
+              {% if group._description %}<p class="small">{{ group._description }}</p>{% endif %}
+            {% endcall %}
+          {% endfor %}
+          <a href="{{ url_for('producttree.add_group') }}" class="pull-right">add</a>
+        {% endcall %}
+      {% else %}
+        <em>No Product tree present</em>
+        <form action="{{ url_for('producttree.create') }}" method="POST" name="createProdTree">
+          <a href="#" onclick="createProdTree.submit()" class="pull-right">create</a>
+        </form>
+      {% endif %}
+    {% endcall %}
+  </div>
+
+  <div class="col-md-6">
+    {% call panel(type="primary", heading="Vulnerabilities (%d)" % cvrf._vulnerabilities | length, title=3) %}
+    <ul>
+      {% for vulnerability in cvrf._vulnerabilities %}
+        <li><a href="{{ url_for('vulnerability.view', ordinal=vulnerability._ordinal) }}">{{ vulnerability.getTitle() }}</a></li>
+      {% endfor %}
+    </ul>
+    <a href="{{ url_for('vulnerability.add') }}" class="pull-right">add</a>
+    {% endcall %}
+  </div>
+</div>
+{% endblock %}

http://farol.wald.intevation.org