annotate farol/templates/producttree/view_product.j2 @ 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 1feed9a3156e
rev   line source
0
4a9f23230eba Initial Release
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff changeset
1 {#
4a9f23230eba Initial Release
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff changeset
2 # Description:
4a9f23230eba Initial Release
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff changeset
3 # Web Template used in Farol Design
4a9f23230eba Initial Release
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff changeset
4 #
4a9f23230eba Initial Release
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff changeset
5 # Authors:
4a9f23230eba Initial Release
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff changeset
6 # BenoƮt Allard <benoit.allard@greenbone.net>
4a9f23230eba Initial Release
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff changeset
7 #
4a9f23230eba Initial Release
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff changeset
8 # Copyright:
4a9f23230eba Initial Release
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff changeset
9 # Copyright (C) 2014 Greenbone Networks GmbH
4a9f23230eba Initial Release
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff changeset
10 #
4a9f23230eba Initial Release
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff changeset
11 # This program is free software; you can redistribute it and/or
4a9f23230eba Initial Release
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff changeset
12 # modify it under the terms of the GNU General Public License
4a9f23230eba Initial Release
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff changeset
13 # as published by the Free Software Foundation; either version 2
4a9f23230eba Initial Release
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff changeset
14 # of the License, or (at your option) any later version.
4a9f23230eba Initial Release
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff changeset
15 #
4a9f23230eba Initial Release
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff changeset
16 # This program is distributed in the hope that it will be useful,
4a9f23230eba Initial Release
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff changeset
17 # but WITHOUT ANY WARRANTY; without even the implied warranty of
4a9f23230eba Initial Release
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff changeset
18 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
4a9f23230eba Initial Release
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff changeset
19 # GNU General Public License for more details.
4a9f23230eba Initial Release
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff changeset
20 #
4a9f23230eba Initial Release
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff changeset
21 # You should have received a copy of the GNU General Public License
4a9f23230eba Initial Release
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff changeset
22 # along with this program; if not, write to the Free Software
4a9f23230eba Initial Release
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff changeset
23 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
4a9f23230eba Initial Release
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff changeset
24 -#}
4a9f23230eba Initial Release
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff changeset
25
4a9f23230eba Initial Release
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff changeset
26 {% extends "base.j2" %}
105
09915cbdf549 Unify the add / edit / delete buttons
Benoît Allard <benoit.allard@greenbone.net>
parents: 87
diff changeset
27 {% from "macros.j2" import panel, edit_button, delete_button %}
0
4a9f23230eba Initial Release
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff changeset
28 {% block title %}{{ product._name }}{% endblock %}
4a9f23230eba Initial Release
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff changeset
29
4a9f23230eba Initial Release
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff changeset
30 {% set active = 'product' %}
4a9f23230eba Initial Release
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff changeset
31
4a9f23230eba Initial Release
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff changeset
32 {% block content %}
105
09915cbdf549 Unify the add / edit / delete buttons
Benoît Allard <benoit.allard@greenbone.net>
parents: 87
diff changeset
33 <div class="pull-right">{{ edit_button(url_for('.edit_product', productid=product._productid)) }}</div>
0
4a9f23230eba Initial Release
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff changeset
34 <div class='page-header'>
4a9f23230eba Initial Release
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff changeset
35 <h1>{{ product._name }}{% if product._cpe %} <small>{{ product._cpe }}</small>{% endif %}</h1>
4a9f23230eba Initial Release
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff changeset
36 </div>
106
4ea7966dcc99 Show where a Product is referenced in the Document.
Benoît Allard <benoit.allard@greenbone.net>
parents: 105
diff changeset
37
4ea7966dcc99 Show where a Product is referenced in the Document.
Benoît Allard <benoit.allard@greenbone.net>
parents: 105
diff changeset
38 {% if product.isRelationship() %}
4ea7966dcc99 Show where a Product is referenced in the Document.
Benoît Allard <benoit.allard@greenbone.net>
parents: 105
diff changeset
39 <p>This product is defined by the following relationship:</p>
0
4a9f23230eba Initial Release
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff changeset
40 {% set prodref = cvrf.getProductForID(product._parent._productreference) %}
4a9f23230eba Initial Release
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff changeset
41 {% set relatesto = cvrf.getProductForID(product._parent._relatestoproductreference) %}
4a9f23230eba Initial Release
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff changeset
42 <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>
106
4ea7966dcc99 Show where a Product is referenced in the Document.
Benoît Allard <benoit.allard@greenbone.net>
parents: 105
diff changeset
43 {% elif not product.isRoot() %}
0
4a9f23230eba Initial Release
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff changeset
44 {% call panel(heading="Tree", title=3, collapsible=False) %}
4a9f23230eba Initial Release
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff changeset
45 {% for type, name in product.getTree() %}
4a9f23230eba Initial Release
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff changeset
46 <ul><li>{{ type }}: <em>{{ name }}</em></li>
4a9f23230eba Initial Release
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff changeset
47 {% if loop.last %}{{ '</ul>' * loop.index }}{% endif %}
4a9f23230eba Initial Release
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff changeset
48 {% endfor %}
4a9f23230eba Initial Release
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff changeset
49 {% endcall %}
4a9f23230eba Initial Release
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff changeset
50 {% endif %}
87
e02724c84bae Add deletion of (orphaned) relationships
Benoît Allard <benoit.allard@greenbone.net>
parents: 84
diff changeset
51
106
4ea7966dcc99 Show where a Product is referenced in the Document.
Benoît Allard <benoit.allard@greenbone.net>
parents: 105
diff changeset
52 {% call panel(heading="Relationships", title=3, collapsible=False) %}
4ea7966dcc99 Show where a Product is referenced in the Document.
Benoît Allard <benoit.allard@greenbone.net>
parents: 105
diff changeset
53 <p>This product is part of the following relationships:</p>
4ea7966dcc99 Show where a Product is referenced in the Document.
Benoît Allard <benoit.allard@greenbone.net>
parents: 105
diff changeset
54 <ul>
4ea7966dcc99 Show where a Product is referenced in the Document.
Benoît Allard <benoit.allard@greenbone.net>
parents: 105
diff changeset
55 {% for relationship in cvrf._producttree._relationships if product._productid in (relationship._productreference, relationship._relatestoproductreference) %}
4ea7966dcc99 Show where a Product is referenced in the Document.
Benoît Allard <benoit.allard@greenbone.net>
parents: 105
diff changeset
56 {% set prodref2 = cvrf.getProductForID(relationship._productreference) %}
4ea7966dcc99 Show where a Product is referenced in the Document.
Benoît Allard <benoit.allard@greenbone.net>
parents: 105
diff changeset
57 {% set relatesto2 = cvrf.getProductForID(relationship._relatestoproductreference) %}
4ea7966dcc99 Show where a Product is referenced in the Document.
Benoît Allard <benoit.allard@greenbone.net>
parents: 105
diff changeset
58 <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>
4ea7966dcc99 Show where a Product is referenced in the Document.
Benoît Allard <benoit.allard@greenbone.net>
parents: 105
diff changeset
59 {% else %}
4ea7966dcc99 Show where a Product is referenced in the Document.
Benoît Allard <benoit.allard@greenbone.net>
parents: 105
diff changeset
60 <li><em>None</em></li>
4ea7966dcc99 Show where a Product is referenced in the Document.
Benoît Allard <benoit.allard@greenbone.net>
parents: 105
diff changeset
61 {% endfor %}
4ea7966dcc99 Show where a Product is referenced in the Document.
Benoît Allard <benoit.allard@greenbone.net>
parents: 105
diff changeset
62 </ul>
4ea7966dcc99 Show where a Product is referenced in the Document.
Benoît Allard <benoit.allard@greenbone.net>
parents: 105
diff changeset
63 {% endcall %}
4ea7966dcc99 Show where a Product is referenced in the Document.
Benoît Allard <benoit.allard@greenbone.net>
parents: 105
diff changeset
64
4ea7966dcc99 Show where a Product is referenced in the Document.
Benoît Allard <benoit.allard@greenbone.net>
parents: 105
diff changeset
65 {% call panel(heading="Groups", title=3, collapsible=False) %}
4ea7966dcc99 Show where a Product is referenced in the Document.
Benoît Allard <benoit.allard@greenbone.net>
parents: 105
diff changeset
66 <p>This product belong to the following groups:</p>
4ea7966dcc99 Show where a Product is referenced in the Document.
Benoît Allard <benoit.allard@greenbone.net>
parents: 105
diff changeset
67 <ul>
4ea7966dcc99 Show where a Product is referenced in the Document.
Benoît Allard <benoit.allard@greenbone.net>
parents: 105
diff changeset
68 {% for group in groups %}
4ea7966dcc99 Show where a Product is referenced in the Document.
Benoît Allard <benoit.allard@greenbone.net>
parents: 105
diff changeset
69 <li>{{ group.getTitle() }}</li>
4ea7966dcc99 Show where a Product is referenced in the Document.
Benoît Allard <benoit.allard@greenbone.net>
parents: 105
diff changeset
70 {% else %}
4ea7966dcc99 Show where a Product is referenced in the Document.
Benoît Allard <benoit.allard@greenbone.net>
parents: 105
diff changeset
71 <li><em>None</em></li>
4ea7966dcc99 Show where a Product is referenced in the Document.
Benoît Allard <benoit.allard@greenbone.net>
parents: 105
diff changeset
72 {% endfor %}
4ea7966dcc99 Show where a Product is referenced in the Document.
Benoît Allard <benoit.allard@greenbone.net>
parents: 105
diff changeset
73 </ul>
4ea7966dcc99 Show where a Product is referenced in the Document.
Benoît Allard <benoit.allard@greenbone.net>
parents: 105
diff changeset
74 {% endcall %}
4ea7966dcc99 Show where a Product is referenced in the Document.
Benoît Allard <benoit.allard@greenbone.net>
parents: 105
diff changeset
75
4ea7966dcc99 Show where a Product is referenced in the Document.
Benoît Allard <benoit.allard@greenbone.net>
parents: 105
diff changeset
76 {% call panel(heading="Vulnerabilities", title="3", collapsible=False) %}
4ea7966dcc99 Show where a Product is referenced in the Document.
Benoît Allard <benoit.allard@greenbone.net>
parents: 105
diff changeset
77 <p>The following Vulneralibities are mentionning this product:</p>
4ea7966dcc99 Show where a Product is referenced in the Document.
Benoît Allard <benoit.allard@greenbone.net>
parents: 105
diff changeset
78 <ul>
4ea7966dcc99 Show where a Product is referenced in the Document.
Benoît Allard <benoit.allard@greenbone.net>
parents: 105
diff changeset
79 {% for vulnerability in cvrf._vulnerabilities if (
4ea7966dcc99 Show where a Product is referenced in the Document.
Benoît Allard <benoit.allard@greenbone.net>
parents: 105
diff changeset
80 vulnerability.isMentioningProdId(product._productid) or
4ea7966dcc99 Show where a Product is referenced in the Document.
Benoît Allard <benoit.allard@greenbone.net>
parents: 105
diff changeset
81 vulnerability.isMentioningGroupId(groups | map(attribute="_groupid") | list)) %}
4ea7966dcc99 Show where a Product is referenced in the Document.
Benoît Allard <benoit.allard@greenbone.net>
parents: 105
diff changeset
82 <li>
4ea7966dcc99 Show where a Product is referenced in the Document.
Benoît Allard <benoit.allard@greenbone.net>
parents: 105
diff changeset
83 <a href="{{ url_for('vulnerability.view', ordinal=vulnerability._ordinal) }}">{{ vulnerability.getTitle() }}</a>
4ea7966dcc99 Show where a Product is referenced in the Document.
Benoît Allard <benoit.allard@greenbone.net>
parents: 105
diff changeset
84 {% set elements = vulnerability.mentionsProdId(product._productid) | list %}
4ea7966dcc99 Show where a Product is referenced in the Document.
Benoît Allard <benoit.allard@greenbone.net>
parents: 105
diff changeset
85 {% for group in groups %}
4ea7966dcc99 Show where a Product is referenced in the Document.
Benoît Allard <benoit.allard@greenbone.net>
parents: 105
diff changeset
86 {{ elements.extend(vulnerability.mentionsGroupId(group._groupid) | list) or '' }}
4ea7966dcc99 Show where a Product is referenced in the Document.
Benoît Allard <benoit.allard@greenbone.net>
parents: 105
diff changeset
87 {% endfor %}
4ea7966dcc99 Show where a Product is referenced in the Document.
Benoît Allard <benoit.allard@greenbone.net>
parents: 105
diff changeset
88 {% set comma = joiner(', ') %}
4ea7966dcc99 Show where a Product is referenced in the Document.
Benoît Allard <benoit.allard@greenbone.net>
parents: 105
diff changeset
89 (
4ea7966dcc99 Show where a Product is referenced in the Document.
Benoît Allard <benoit.allard@greenbone.net>
parents: 105
diff changeset
90 {%- for grouper, list in elements | groupby('NAME') %}{{ comma() -}}
4ea7966dcc99 Show where a Product is referenced in the Document.
Benoît Allard <benoit.allard@greenbone.net>
parents: 105
diff changeset
91 {{ grouper }}{% if list | length > 1 %}(x{{ list | length }}){% endif %}
4ea7966dcc99 Show where a Product is referenced in the Document.
Benoît Allard <benoit.allard@greenbone.net>
parents: 105
diff changeset
92 {%- endfor -%}
4ea7966dcc99 Show where a Product is referenced in the Document.
Benoît Allard <benoit.allard@greenbone.net>
parents: 105
diff changeset
93 )
4ea7966dcc99 Show where a Product is referenced in the Document.
Benoît Allard <benoit.allard@greenbone.net>
parents: 105
diff changeset
94 </li>
4ea7966dcc99 Show where a Product is referenced in the Document.
Benoît Allard <benoit.allard@greenbone.net>
parents: 105
diff changeset
95 {% else %}
4ea7966dcc99 Show where a Product is referenced in the Document.
Benoît Allard <benoit.allard@greenbone.net>
parents: 105
diff changeset
96 <li><em>None</em></li>
4ea7966dcc99 Show where a Product is referenced in the Document.
Benoît Allard <benoit.allard@greenbone.net>
parents: 105
diff changeset
97 {% endfor %}
4ea7966dcc99 Show where a Product is referenced in the Document.
Benoît Allard <benoit.allard@greenbone.net>
parents: 105
diff changeset
98 </ul>
4ea7966dcc99 Show where a Product is referenced in the Document.
Benoît Allard <benoit.allard@greenbone.net>
parents: 105
diff changeset
99 {% endcall %}
4ea7966dcc99 Show where a Product is referenced in the Document.
Benoît Allard <benoit.allard@greenbone.net>
parents: 105
diff changeset
100 <div class="pull-right">
4ea7966dcc99 Show where a Product is referenced in the Document.
Benoît Allard <benoit.allard@greenbone.net>
parents: 105
diff changeset
101 {% if cvrf.isProductOrphan(product._productid) %}
4ea7966dcc99 Show where a Product is referenced in the Document.
Benoît Allard <benoit.allard@greenbone.net>
parents: 105
diff changeset
102 {{ delete_button(url_for('.del_product', productid=product._productid)) }}
4ea7966dcc99 Show where a Product is referenced in the Document.
Benoît Allard <benoit.allard@greenbone.net>
parents: 105
diff changeset
103 {% else %}
4ea7966dcc99 Show where a Product is referenced in the Document.
Benoît Allard <benoit.allard@greenbone.net>
parents: 105
diff changeset
104 <p class="text-danger"><small>This product cannot be deleted, as it is referenced in the document</small></p>
4ea7966dcc99 Show where a Product is referenced in the Document.
Benoît Allard <benoit.allard@greenbone.net>
parents: 105
diff changeset
105 {% endif %}
0
4a9f23230eba Initial Release
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff changeset
106 </div>
4a9f23230eba Initial Release
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff changeset
107 {% endblock %}

http://farol.wald.intevation.org