<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
                      "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:py="http://genshi.edgewall.org/"
      xmlns:xi="http://www.w3.org/2001/XInclude">

  <xi:include href="master.html" />
  <xi:include href="lib.html" />

  <?python from pyforge.lib.security import has_project_access ?>

  <head>
    <meta content="text/html; charset=UTF-8" http-equiv="content-type" py:replace="''"/>
    <title>Project Overview for $c.project.shortname</title>

    <link rel="stylesheet" type="text/css" media="screen" href="${g.app_static('css/admin.css')}"/>
  </head>

  <body>
    <h1 class="title">Project Overview for $c.project.shortname</h1>
    <div py:if="c.project.deleted" class="notice">This project has been deleted and is not visible to non-admin users</div>
    <div py:if="not has_project_access('update')()">
      <div class="span-3 clear"><label>Name</label></div>
      <div class="span-15 last">$c.project.name</div>
      <hr class="clear clearfix" />
      <div class="span-3 clear"><label>Category</label></div>
      <div class="span-15 last">${c.project.category and c.project.category.label or 'Uncategorized'}</div>
      <hr class="clear clearfix" />
      <div class="span-3 clear"><label>Icon</label></div>
      <div class="span-15 last">
        <img py:if="c.project.icon" src="${c.project.url()}/icon"/>
        <span py:if="not c.project.icon">&nbsp;</span>
      </div>
      <hr class="clear clearfix" />
      <div class="span-3 clear"><label>Summary</label></div>
      <div class="span-15 last"><pre>$c.project.short_description</pre></div>
      <hr class="clear clearfix" />
      <div class="span-3 clear"><label>Description</label></div>
      <div class="span-15 last">${Markup(c.project.description_html)}</div>
      <hr class="clear clearfix" />
      <div class="span-3 clear"><label>Screenshots</label></div>
      <div class="span-15 last">
          <py:if test="len(c.project.get_screenshots())">
            <a py:for="ss in c.project.get_screenshots()" href="${c.project.url()}screenshot/$ss.filename"><img src="${c.project.url()}screenshot/$ss.filename/thumb" style="margin-right: 1em"/></a>
          </py:if>
          <py:if test="not len(c.project.get_screenshots())">No screenshots have been created.</py:if>
      </div>
    </div>
    <form py:if="has_project_access('update')()" method="POST" action="update" enctype="multipart/form-data">
      <div class="span-3"><label>Name:</label></div>
      <div class="editable viewing span-13 last">
        <div class="viewer">$c.project.name</div>
        <div class="editor"><input name="name" value="$c.project.name"/></div>
      </div>
      <hr class="clear clearfix" />

      <div class="span-3"><label>Shortname:</label></div>
      <div class="span-13 last fakeinput">$c.project.shortname</div>
      <hr class="clear clearfix" />

      <div class="span-3"><label>Category:</label></div>
      <div class="editable viewing span-13 last">
        <div class="viewer">${c.project.category and c.project.category.label or 'Uncategorized'}</div>
        <div class="editor">
          <select name="category">
            <option value="">Uncategorized</option>
            <py:for each="cat in categories">
            <option value="$cat._id" py:if="c.project.category and c.project.category._id == cat._id" selected="selected">$cat.label</option>
            <option value="$cat._id" py:if="not c.project.category or (c.project.category and c.project.category._id != cat._id)">$cat.label</option>
            <py:for each="subcat in cat.subcategories">
            <option value="$subcat._id" py:if="c.project.category and c.project.category._id == subcat._id" selected="selected">-- $subcat.label</option>
            <option value="$subcat._id" py:if="not c.project.category or (c.project.category and c.project.category._id != subcat._id)">-- $subcat.label</option>
            </py:for>
            </py:for>
          </select>
        </div>
      </div>
      <hr class="clear clearfix" />

      <div class="span-3"><label>Icon:</label></div>
      <div class="editable viewing span-13 last">
        <div class="viewer" py:if="c.project.icon"><img src="${c.project.url()}/icon"/></div>
        <div class="viewer" py:if="not c.project.icon">No icon has been created.</div>
        <div class="editor">${file_field('icon', 'File')}</div>
      </div>
      <div class="push-3 span-13 last" py:if="c.project.icon">
        <input type="submit" name="delete_icon" value="Delete Icon"
               class="ui-state-default ui-button ui-button-text clear clearfix"/>
      </div>
      <hr class="clear clearfix" />

      <div class="span-3"><label>Summary:</label></div>
      <div class="editable viewing span-13 last">
        <div class="viewer"><pre>$c.project.short_description</pre></div>
        <div class="editor multiline"><textarea name="short_description">$c.project.short_description</textarea></div>
      </div>
      <hr class="clear clearfix" />

      <div class="span-3"><label>Description:</label></div>
      <div class="span-13 last">${c.markdown_editor.display(name='description',value=c.project.description)}</div>
      <hr class="clear clearfix" />

      <div class="span-3"><label>Tags:</label></div>
      <div class="editable viewing span-13 last">
        <div class="viewer">${len(c.project.labels) and ', '.join(c.project.labels) or "No Tags"}</div>
        <div class="editor">${c.label_edit.display(name='labels',value=c.project.labels)}</div>
      </div>
      <hr class="clear clearfix" />

      <div class="span-3"><label>Screenshots:</label></div>
      <div class="editable viewing span-13 last">
        <div class="viewer">
          <py:if test="len(c.project.get_screenshots())">
            <a py:for="ss in c.project.get_screenshots()" href="${c.project.url()}screenshot/$ss.filename"><img src="${c.project.url()}screenshot/$ss.filename/thumb" style="margin-right: 1em"/></a>
          </py:if>
          <py:if test="not len(c.project.get_screenshots())">No screenshots have been created.</py:if>
        </div>
        <div class="editor multiline">${file_field('screenshot', 'File')}</div>
      </div>
      <hr class="clear clearfix" />

      <div class="push-3 span-15 last">
        <input type="submit" value="Save"
               class="ui-state-default ui-button ui-button-text"/>
        <input type="submit" value="Delete Project" name="delete"
               class="ui-state-default ui-button ui-button-text"
               py:if="not c.project.deleted"/>
        <input type="submit" value="Undelete Project" name="undelete"
               class="ui-state-default ui-button ui-button-text"
               py:if="c.project.deleted"/>
      </div>
    </form>
  </body>

</html>
