home · contact · privacy
Some work on tests, kinda unfinished.
[plomtask] / templates / _macros.html
1 {% macro edit_buttons() %}
2 <div class="edit_buttons">
3 <input class="btn-harmless" type="submit" name="update" value="update" />
4 <div class="btn-to-right">
5 <input class="btn-dangerous" type="submit" name="delete" value="delete" />
6 </div>
7 </div>
8 {% endmacro %}
9
10
11
12 {% macro datalist_of_titles(title, candidates, historical=false, with_comments=false) %}
13 <datalist id="{{title}}">
14 {% for candidate in candidates %}
15 <option value="{{candidate.id_}}">
16 {% if historical is true %}
17 {{candidate.title_then|e}}
18 {% else %}
19 {{candidate.title.newest|e}}
20 {% endif %}
21 {% if with_comments and candidate.comment %}
22 / {{candidate.comment}}
23 {% endif %}
24 </option>
25 {% endfor %}
26 </datalist>
27 {% endmacro %}
28
29
30
31 {% macro simple_checkbox_table(title, items, type_name, list_name, add_string="add", historical=false) %}
32 {% if items|length > 0 %}
33 <table>
34 {% for item in items %}
35 <tr>
36 <td>
37 <input type="checkbox" name="{{title}}" value="{{item.id_}}" checked />
38 </td>
39 <td>
40 <a href="{{type_name}}?id={{item.id_}}">{% if historical is true %}{{item.title_then}}{% else %}{{item.title.newest|e}}{% endif %}</a>
41 </td>
42 </tr>
43 {% endfor %}
44 </table>
45 {% endif %}
46 {{add_string}}: <input name="{{title}}" type="text" list="{{list_name}}" autocomplete="off" />
47 {% endmacro %}
48
49
50
51 {% macro history_page(item_name, item, attribute_name, attribute, as_pre=false) %}
52 <h3>{{item_name}} {{attribute_name}} history</h3>
53 <form action="{{item_name}}_{{attribute_name}}s?id={{item.id_}}" method="POST">
54 <table>
55
56 <tr>
57 <th>{{item_name}}</th>
58 <td><a href="{{item_name}}?id={{item.id_}}">{{item.title.newest|e}}</a></td>
59 </tr>
60
61
62 {% for date in attribute.history.keys() | sort(reverse=True) %}
63 <tr>
64 <td><input name="at:{{date}}" class="timestamp" value="{{date|truncate(19, True, '', 0)}}"></td>
65 <td>{% if as_pre %}<pre>{% endif %}{{attribute.history[date]}}{% if as_pre %}</pre>{% endif %}</td>
66 </tr>
67 {% endfor %}
68
69 </table>
70 <input class="btn-harmless" type="submit" name="update" value="update" />
71 </form>
72 {% endmacro %}