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