Mercurial > farol
changeset 106:4ea7966dcc99
Show where a Product is referenced in the Document.
author | Benoît Allard <benoit.allard@greenbone.net> |
---|---|
date | Tue, 14 Oct 2014 16:52:55 +0200 |
parents | 09915cbdf549 |
children | 86b843748c81 ce64f90e58c4 |
files | farol/producttree.py farol/templates/producttree/view_product.j2 |
diffstat | 2 files changed, 61 insertions(+), 16 deletions(-) [+] |
line wrap: on
line diff
--- a/farol/producttree.py Tue Oct 14 14:36:31 2014 +0200 +++ b/farol/producttree.py Tue Oct 14 16:52:55 2014 +0200 @@ -144,7 +144,9 @@ product = cvrf.getProductForID(productid) except IndexError: abort(404) - return render_template('producttree/view_product.j2', product=product, cvrf=cvrf) + return render_template('producttree/view_product.j2', + product=product, groups=[g for g in cvrf._producttree._groups if productid in g._productids], + cvrf=cvrf) @producttree.route('/product/<productid>/edit', methods=['GET', 'POST']) @document_required
--- a/farol/templates/producttree/view_product.j2 Tue Oct 14 14:36:31 2014 +0200 +++ b/farol/templates/producttree/view_product.j2 Tue Oct 14 16:52:55 2014 +0200 @@ -34,14 +34,13 @@ <div class='page-header'> <h1>{{ product._name }}{% if product._cpe %} <small>{{ product._cpe }}</small>{% endif %}</h1> </div> -{% if product.isRoot() %} - <p>This product is defined without relation to other elements</p> -{% elif product.isRelationship() %} - <p>This product is part of the following relationship:</p> + +{% if product.isRelationship() %} + <p>This product is defined by the following relationship:</p> {% set prodref = cvrf.getProductForID(product._parent._productreference) %} {% set relatesto = cvrf.getProductForID(product._parent._relatestoproductreference) %} <p><a href="{{ url_for('.view_product', productid=prodref._productid) }}">{{ prodref._name }}</a> as <em>{{ product._parent._relationtype | lower }}</em> <a href="{{ url_for('.view_product', productid=relatesto._productid) }}">{{ relatesto._name }}</a><p> -{% else %} +{% elif not product.isRoot() %} {% call panel(heading="Tree", title=3, collapsible=False) %} {% for type, name in product.getTree() %} <ul><li>{{ type }}: <em>{{ name }}</em></li> @@ -50,15 +49,59 @@ {% endcall %} {% endif %} -<div> -<p>This product belong to the following groups:</p> -<ul> -{% for group in cvrf._producttree._groups if product._productid in group._productids %} - <li>{{ group.getTitle() }}</li> -{% else %} - <li><em>None</em></li> -{% endfor %} -</ul> +{% call panel(heading="Relationships", title=3, collapsible=False) %} + <p>This product is part of the following relationships:</p> + <ul> + {% for relationship in cvrf._producttree._relationships if product._productid in (relationship._productreference, relationship._relatestoproductreference) %} + {% set prodref2 = cvrf.getProductForID(relationship._productreference) %} + {% set relatesto2 = cvrf.getProductForID(relationship._relatestoproductreference) %} + <li><a href="{{ url_for('.view_product', productid=prodref2._productid) }}">{{ prodref2._name }}</a> as <em>{{ relationship._relationtype | lower }}</em> <a href="{{ url_for('.view_product', productid=relatesto2._productid) }}">{{ relatesto2._name }}</a></li> + {% else %} + <li><em>None</em></li> + {% endfor %} + </ul> +{% endcall %} + +{% call panel(heading="Groups", title=3, collapsible=False) %} + <p>This product belong to the following groups:</p> + <ul> + {% for group in groups %} + <li>{{ group.getTitle() }}</li> + {% else %} + <li><em>None</em></li> + {% endfor %} + </ul> +{% endcall %} + +{% call panel(heading="Vulnerabilities", title="3", collapsible=False) %} + <p>The following Vulneralibities are mentionning this product:</p> + <ul> + {% for vulnerability in cvrf._vulnerabilities if ( + vulnerability.isMentioningProdId(product._productid) or + vulnerability.isMentioningGroupId(groups | map(attribute="_groupid") | list)) %} + <li> + <a href="{{ url_for('vulnerability.view', ordinal=vulnerability._ordinal) }}">{{ vulnerability.getTitle() }}</a> + {% set elements = vulnerability.mentionsProdId(product._productid) | list %} + {% for group in groups %} + {{ elements.extend(vulnerability.mentionsGroupId(group._groupid) | list) or '' }} + {% endfor %} + {% set comma = joiner(', ') %} + ( + {%- for grouper, list in elements | groupby('NAME') %}{{ comma() -}} + {{ grouper }}{% if list | length > 1 %}(x{{ list | length }}){% endif %} + {%- endfor -%} + ) + </li> + {% else %} + <li><em>None</em></li> + {% endfor %} + </ul> +{% endcall %} +<div class="pull-right"> + {% if cvrf.isProductOrphan(product._productid) %} + {{ delete_button(url_for('.del_product', productid=product._productid)) }} + {% else %} + <p class="text-danger"><small>This product cannot be deleted, as it is referenced in the document</small></p> + {% endif %} </div> -<div class="pull-right">{{ delete_button(url_for('.del_product', productid=product._productid)) }}</div> {% endblock %}