Edgewall Software

TracDev/ContextRefactoring: trac_templates_attachment.html

File trac_templates_attachment.html, 4.4 KB (added by cboos, 14 months ago)

Work in progress snapshot - this illustrates the modifications needed to use the new resource and permission scheme in a template (base is source:trunk/trac/templates/attachment.html)

Line 
1<!DOCTYPE html
2    PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
3    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
4<html xmlns="http://www.w3.org/1999/xhtml"
5      xmlns:py="http://genshi.edgewall.org/"
6      xmlns:xi="http://www.w3.org/2001/XInclude">
7  <xi:include href="layout.html" />
8  <xi:include href="macros.html" />
9  <head>
10    <title>Attachment</title>
11  </head>
12
13  <body py:with="parent = attachments and attachments.new_attachment.parent or attachment.parent">
14
15    <div id="ctxtnav" class="nav">
16      <h2>Attachment Navigation</h2>
17      <ul>
18        <li class="first">
19          <a href="${chrome.links.up[0].href}">${_("Back to %(parent)s", parent=parent.name)}</a>
20        </li>
21      </ul>
22    </div>
23
24    <div py:choose="mode" id="content" class="attachment">
25      <py:when test="'new'">
26        <h1>Add Attachment to <a href="$parent.url(href)">$parent.name</a></h1>
27        <form id="attachment" method="post" enctype="multipart/form-data" action="">
28          <div class="field">
29            <label>File:<br /><input type="file" name="attachment" /></label>
30          </div>
31          <fieldset>
32            <legend>Attachment Info</legend>
33            <py:if test="authname == 'anonymous'">
34              <div class="field">
35                <label>Your email or username:<br />
36                  <input type="text" name="author" size="30" value="$author" />
37                </label>
38              </div>
39              </py:if>
40            <div class="field">
41              <label>Description of the file (optional):<br />
42                <input type="text" name="description" size="60" /></label>
43            </div>
44            <br />
45            <div class="options">
46              <label><input type="checkbox" name="replace" />
47                Replace existing attachment of the same name</label>
48            </div>
49            <br />
50          </fieldset>
51          <div class="buttons">
52            <input type="hidden" name="action" value="new" />
53            <input type="hidden" name="realm" value="$parent.realm" />
54            <input type="hidden" name="id" value="$parent.id" />
55            <input type="submit" value="Add attachment" />
56            <input type="submit" name="cancel" value="Cancel" />
57          </div>
58        </form>
59      </py:when>
60
61      <py:when test="'delete'">
62        <h1><a href="$parent.url(href)">$parent.name</a>: $attachment.model.filename</h1>
63        <p><strong>Are you sure you want to delete this attachment?</strong><br />
64          This is an irreversible operation.</p>
65        <div class="buttons">
66          <form method="post" action="">
67            <div id="delete">
68              <input type="hidden" name="action" value="delete" />
69              <input type="submit" name="cancel" value="Cancel" />
70              <input type="submit" value="Delete attachment" />
71            </div>
72          </form>
73        </div>
74      </py:when>
75
76      <py:when test="'list'">
77        <h1><a href="$parent.url(href)">$parent.name</a></h1>
78        ${list_of_attachments(attachments)}
79      </py:when>
80
81      <py:otherwise> <!--! 'render' mode -->
82        <h1><a href="$parent.url(href)">$parent.name</a>: $attachment.model.filename</h1>
83        <table id="info" summary="Description">
84          <tbody>
85            <tr>
86              <th scope="col">
87                File $attachment.model.filename, ${sizeinfo(attachment.model.size)}
88                (added by ${authorinfo(attachment.model.author)},  ${dateinfo(attachment.model.date)} ago)
89              </th>
90            </tr>
91            <tr>
92              <td class="message searchable" xml:space="preserve">
93                ${wiki_to_html(context(parent), attachment.model.description)}
94              </td>
95            </tr>
96          </tbody>
97        </table>
98
99        <div py:if="preview" id="preview" class="searchable">
100          ${preview_file(preview)}
101        </div>
102
103        <py:if test="attachment and 'ATTACHMENT_DELETE' in attachment.perm">
104          <div class="buttons">
105            <form method="get" action="">
106              <div id="delete">
107                <input type="hidden" name="action" value="delete" />
108                <input type="submit" value="${_('Delete attachment')}" />
109              </div>
110            </form>
111          </div>
112        </py:if>
113      </py:otherwise>
114
115    </div>
116  </body>
117</html>