update librarian
[redakcja.git] / apps / cover / templates / cover / add_image.html
1 {% extends "catalogue/base.html" %}
2 {% load i18n %}
3
4 {% block add_js %}
5     {{block.super}}
6     <script>
7         $(function() {
8             var radio_buttons = $('input[type=radio][name=upload_type]'),
9                 image_fields = $('.upload_type input[type=text],input[type=file]');
10
11             var enable_image_field = function(field) {
12                 field.attr('disabled', false);
13             },
14             disable_image_fields = function() {
15                 image_fields.attr('disabled', true);
16             }
17
18             radio_buttons.change(function() {
19                 var radio_button = $(this),
20                     related_image_field = $('#'+radio_button.attr('data-for'));
21                 disable_image_fields();
22                 enable_image_field(related_image_field);
23             });
24
25             /* initial state */
26             disable_image_fields();
27             enable_image_field($('#id_download_url'));
28         });
29     </script>
30 {% endblock %}
31
32 {% block content %}
33 <h1>{% trans "Add image" %}</h1>
34
35
36 <form method="post">{% csrf_token %}
37 <input type="hidden" name='form_id' value="flickr" />
38 <table class='editable'><tbody>
39     {{ ff.as_table }}
40     <tr><td></td><td><button type="submit">{% trans "Load from Flickr" %}</button></td></tr>
41 </tbody></table>
42 </form>
43
44 <form method="post" enctype="multipart/form-data">{% csrf_token %}
45 {{ form.non_field_errors }}
46 <table class='editable'><tbody>
47     {% for field in form %}
48         {% if field.name != 'download_url' and field.name != 'file' %}
49         <tr>
50             <th>{{field.errors}} {{field.label}}</th>
51             <td>{{field}}</td>
52         </tr>
53         {% endif %}
54     {% endfor %}
55     <tr class="upload_type">
56         <th>{{ form.download_url.errors }} <input style="width: auto;" checked data-for="id_download_url" type="radio" name="upload_type" value="url"/>{{form.download_url.label}}</th>
57         <td>{{form.download_url}}</td>
58         <th>{{ form.file.errors }} <input style="width: auto;" data-for="id_file" type="radio" name="upload_type" value="file"/> Lub {{form.file.label}}</th>
59         <td>{{form.file}}</td>
60
61     </tr>
62     <tr><td></td><td><button type="submit">{% trans "Add image" %}</button></td></tr>
63 </tbody></table>
64 </form>
65
66
67 {% endblock %}