changeset 85:b6a48669edb8

Don't create a branch only to have empty name
author Benoît Allard <benoit.allard@greenbone.net>
date Thu, 09 Oct 2014 14:50:05 +0200
parents cc836f9e869e
children 2d41121ec991
files farol/producttree.py farol/templates/producttree/edit_branch.j2
diffstat 2 files changed, 9 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/farol/producttree.py	Thu Oct 09 14:26:59 2014 +0200
+++ b/farol/producttree.py	Thu Oct 09 14:50:05 2014 +0200
@@ -69,7 +69,9 @@
     except (ValueError, IndexError): abort(404)
     if request.method != 'POST':
         branches = [('', '')] + [(b.getName(), b.getPath(True)) for b in ptree.getNotTerminalBranches(branch)]
-        return render_template('producttree/edit_branch.j2', branch=branch, branches=branches, types=branch.TYPES)
+        return render_template('producttree/edit_branch.j2',
+                               _type=branch._type, name=branch._name, parentpath=branch.getParentPath(),
+                               branches=branches, types=branch.TYPES)
 
     pbranch = ptree
     if request.form['parent']:
@@ -95,7 +97,9 @@
     ptree = cvrf._producttree
     if request.method != 'POST':
         branches = [('', '')] + [(b.getName(), b.getPath(True)) for b in ptree.getNotTerminalBranches()]
-        return render_template('producttree/edit_branch.j2', branch=CVRFProductBranch('', '', ptree), action='Add', branches=branches, types=CVRFProductBranch.TYPES)
+        return render_template('producttree/edit_branch.j2',
+                               action='Add',
+                               branches=branches, types=CVRFProductBranch.TYPES)
 
     pbranch = ptree
     if request.form['parent']:
--- a/farol/templates/producttree/edit_branch.j2	Thu Oct 09 14:26:59 2014 +0200
+++ b/farol/templates/producttree/edit_branch.j2	Thu Oct 09 14:50:05 2014 +0200
@@ -30,7 +30,7 @@
 {% block content %}
 <form role="form" method="POST">
 
-{% call selectinput('type', "Type", types, branch._type) %}
+{% call selectinput('type', "Type", types, _type) %}
 <p>Branch <em>Types</em>:</p>
 <dl class="dl-horizontal">
   <dt>Vendor:</dt><dd>The name of the vendor or manufacturer that makes the product</dd>
@@ -45,10 +45,10 @@
   <dt>Specification:</dt><dd>A specification such as a standard, best common practice, etc.</dd>
 </dl>
 {% endcall %}
-{% call textinput('name', "Name", value=branch._name, required=True) %}
+{% call textinput('name', "Name", value=name, required=True) %}
 <p><em>Name</em> will contain the canonical descriptor or “friendly name” of the branch.</p>
 {% endcall %}
-{{ selectinput2('parent', "Path to Parent Branch", branches, branch.getParentPath()) }}
+{{ selectinput2('parent', "Path to Parent Branch", branches, parentpath) }}
 
 <button class="btn btn-primary" type="submit">{{ action or 'Update' }}</button>
 <a class="btn btn-danger" href="{{ url_for('.view') }}">Cancel</a>

http://farol.wald.intevation.org