1 {% extends "catalogue/base.html" %}
8 var radio_buttons = $('input[type=radio][name=upload_type]'),
9 image_fields = $('.upload_type input[type=text],input[type=file]');
11 var enable_image_field = function(field) {
12 field.attr('disabled', false);
14 disable_image_fields = function() {
15 image_fields.attr('disabled', true);
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);
26 disable_image_fields();
27 enable_image_field($('#id_download_url'));
33 <h1>{% trans "Add image" %}</h1>
36 <form method="post">{% csrf_token %}
37 <input type="hidden" name='form_id' value="flickr" />
38 <table class='editable'><tbody>
40 <tr><td></td><td><button type="submit">{% trans "Load from Flickr" %}</button></td></tr>
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' %}
50 <th>{{field.errors}} {{field.label}}</th>
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>
62 <tr><td></td><td><button type="submit">{% trans "Add image" %}</button></td></tr>