# HG changeset patch # User Benoît Allard # Date 1412859005 -7200 # Node ID b6a48669edb8bcbd714ed72963326482b5fb459d # Parent cc836f9e869ebdd0d16e56cd954da5c4d841a1d4 Don't create a branch only to have empty name diff -r cc836f9e869e -r b6a48669edb8 farol/producttree.py --- 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']: diff -r cc836f9e869e -r b6a48669edb8 farol/templates/producttree/edit_branch.j2 --- 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 %}
-{% call selectinput('type', "Type", types, branch._type) %} +{% call selectinput('type', "Type", types, _type) %}

Branch Types:

Vendor:
The name of the vendor or manufacturer that makes the product
@@ -45,10 +45,10 @@
Specification:
A specification such as a standard, best common practice, etc.
{% endcall %} -{% call textinput('name', "Name", value=branch._name, required=True) %} +{% call textinput('name', "Name", value=name, required=True) %}

Name will contain the canonical descriptor or “friendly name” of the branch.

{% endcall %} -{{ selectinput2('parent', "Path to Parent Branch", branches, branch.getParentPath()) }} +{{ selectinput2('parent', "Path to Parent Branch", branches, parentpath) }} Cancel