$def with (user, form, ou=None, computer=None)
$var title = _p("Assign disk profile")
$var tab: navigator
$var css = ['navigator.css']

$code:
    hierarchy = [storage(link='', caption=_("Assign disk profile"))]
    if computer:
        hierarchy += [storage(link='/navigator/computer/%s' % computer.name, caption=computer.name)]
        parent = computer.ou
        while parent:
            hierarchy.append(storage(link='/navigator/ou/%s' % parent.name, caption=parent.name))
            # Do not show more hirarchy elements than needed
            if parent in user.organizative_units:
                break
            parent = parent.parent
    elif ou:
        hierarchy += [storage(link='/navigator/ou/%s' % ou.name, caption=ou.name)]
        parent = ou.parent
        if not ou in user.organizative_units:
            while parent:
                hierarchy.append(storage(link='/navigator/ou/%s' % parent.name, caption=parent.name))
                # Do not show more hirarchy elements than needed
                if parent in user.organizative_units:
                    break
                parent = parent.parent

    hierarchy.append(storage(link='/navigator', caption=_("Root")))
    hierarchy.reverse()

$var hierarchy = hierarchy

$if ou:
    <h3>$ou.description</h3>
$else:
    <h3>$computer.name</h3>

<form method="POST" action="">
    $:form.render()
    <button>$_p("Submit")</button>
</form>

$if ou:
    <img src="/static/images/nav-ou.png"/><br/>
$elif computer:
    <div class="computer" title="$computer.description">
        <div id="compimg">
            <img src="/static/images/$(computer.get_img())-big.png"/>
        </div>
        <div id="comptext">
            <p>
            <em>$_("Name")</em>: $computer.name<br/>
            <em>$_("MAC")</em>: $computer.get_canonical_mac()<br/>
            <em>$_("IP")</em>: $computer.ip<br/>
            <em>$_("OS")</em>: $computer.os<br/>
            <em>$_("Status")</em>:
            $if computer.online:
                Online<br/>
            $else:
                Offline<br/>
            </p>
        </div>
        <p>$computer.description</p>
    </div>
    <div class="clear"></div>
