def __init__(self, *args, **kwargs):
super(ImageAddForm, self).__init__(*args, **kwargs)
- self.fields['file'].required = self.fields['download_url'].required = self.fields['source_url'].required = False
+ self.fields['file'].required = False
def clean_download_url(self):
return self.cleaned_data['download_url'] or None
class ReadonlyImageEditForm(ImageEditForm):
- """Form used for not editing a Book."""
+ """Form used for not editing an Image."""
def __init__(self, *args, **kwargs):
ret = super(ReadonlyImageEditForm, self).__init__(*args, **kwargs)
<th>{{ form.file.errors }} <input style="width: auto;" data-for="id_file" type="radio" name="upload_type" value="file"/> Lub {{form.file.label}}</th>
<td>{{form.file}}</td>
- </td>
+ </tr>
<tr><td></td><td><button type="submit">{% trans "Add image" %}</button></td></tr>
</tbody></table>
</form>
<div style="float: right; margin-bottom:1em;">
<a href="{{ object.file.url }}"><img style="width:400px"
- src="{% thumbnail object.file "400x" as thumb %}
+ src="{% thumbnail object.file "400x400" as thumb %}
{{ thumb.url }}
{% empty %}
{{ object.file.url }}
</a>
<br/><a href="{{ object.source_url }}">{{ object.title }}</a> by {{ object.author }},
{% if object.license_url %}<a href="{{ object.license_url }}">{% endif %}
- {{ object.license_name }}</a>
+ {{ object.license_name }}
{% if object.license_url %}</a>{% endif %}
<br/>{% trans "source" %}: {{ object.download_url }}
</div>
-{% if editable %}<form method="post">{% csrf_token %}{% endif %}
+{% if editable %}
+ <form method="post" enctype="multipart/form-data">
+ {% csrf_token %}
+ {{ form.non_field_errors }}
+{% endif %}
<table class='editable'><tbody>
{{ form.as_table }}
{% if editable %}
if request.user.has_perm('cover.change_image'):
if request.method == "POST":
- form = forms.ImageEditForm(request.POST, instance=image)
+ form = forms.ImageEditForm(request.POST, request.FILES, instance=image)
if form.is_valid():
form.save()
return HttpResponseRedirect(image.get_absolute_url())