Permalink
Browse files

some fixes

  • Loading branch information...
1 parent 1c76e5a commit a906490cc37486782ab0d378d4dd31ca83878f48 Stefan Foulis committed Apr 24, 2009
View
3 image_filer/models/__init__.py 100644 → 100755
@@ -73,6 +73,9 @@ class FolderRoot(object):
def _children(self):
return Folder.objects.filter(parent__isnull=True)
children = property(_children)
+ def _files(self):
+ return []
+ files = property(_files)
class Folder(models.Model):
"""
@@ -1,8 +1,19 @@
{% extends "admin/change_form.html" %}
+{% load i18n admin_modify adminmedia %}
{% block breadcrumbs %}<div class="breadcrumbs"><a href="/admin/">Home</a> › <a href="/admin/image_filer/">Image Portfolio</a>{% if original.folder %} › <a href="{% url image_filer-directory_listing-root %}">Root</a>{% for ancestor_folder in original.folder.get_ancestors %} › <a href="{% url image_filer-directory_listing ancestor_folder.id %}">{{ ancestor_folder.name }}</a>{% endfor %} › <a href="{% url image_filer-directory_listing original.folder.id %}">{{ original.folder.name }}</a>{% endif %} › {{ original }}</div>{% endblock %}
{% block coltype %}colMS{% endblock %}
+{% block object-tools %}
+{% if change %}{% if not is_popup %}
+ <ul class="object-tools">
+ <li><a href="export/">Export</a></li>
+ <li><a href="history/" class="historylink">{% trans "History" %}</a></li>
+ {% if has_absolute_url %}<li><a href="../../../r/{{ content_type_id }}/{{ object_id }}/" class="viewsitelink">{% trans "View on site" %}</a></li>{% endif%}
+ </ul>
+{% endif %}{% endif %}
+{% endblock %}
+
{% block sidebar %}
<div id="content-related">
<div id="navcontainer">
@@ -31,8 +31,6 @@
{% block content %}
<div id="content-main">
- has_edit_permission: <strong>{{permissions.has_edit_permission }}</strong> | has_read_permission: <strong>{{permissions.has_read_permission}}</strong> | has_add_children_permission: <strong>{{permissions.has_add_children_permission}}</strong>
- <br/>perms: {{ permstest }}
<ul class="object-tools">
<li><a id="newFolderButton" href="#">{% trans "New Folder" %}</a></li>
<li><a id="uploadButton" href="#" class="focus">{% trans "Upload" %}</a></li>
@@ -0,0 +1,13 @@
+{% extends "admin/image_filer/image/change_form.html" %}
+
+{% block breadcrumbs %}<div class="breadcrumbs"><a href="/admin/">Home</a> › <a href="/admin/image_filer/">Image Portfolio</a>{% if original.folder %} › <a href="{% url image_filer-directory_listing-root %}">Root</a>{% for ancestor_folder in original.folder.get_ancestors %} › <a href="{% url image_filer-directory_listing ancestor_folder.id %}">{{ ancestor_folder.name }}</a>{% endfor %} › <a href="{% url image_filer-directory_listing original.folder.id %}">{{ original.folder.name }}</a>{% endif %} › <a href="/admin/image_filer/image/{{ image.id }}/">{{ image.label }}</a> › export</div>{% endblock %}
+
+{% block coltype %}colMS{% endblock %}
+{% block content %}
+<form action="{% url image_filer-export_image image.id %}" method="post">
+ <table>
+ {{ form }}
+ </table>
+ <input type="submit" value="download image" />
+</form>
+{% endblock %}
View
26 image_filer/views.py 100644 → 100755
@@ -27,8 +27,13 @@ def _userperms(item, request):
return r
class ImagesWithMissingDataRoot(FolderRoot):
def _children(self):
- return Image.objects.filter(has_all_mandatory_data=False)
+ return []
children = property(_children)
+ def _files(self):
+ return Image.objects.filter(has_all_mandatory_data=False)
+ files = property(_files)
+
+
def directory_listing(request, folder_id=None, images_with_missing_data=False):
new_folder_form = NewFolderForm()
if images_with_missing_data:
@@ -38,7 +43,6 @@ def directory_listing(request, folder_id=None, images_with_missing_data=False):
else:
folder = Folder.objects.get(id=folder_id)
-
# Debug
upload_file_form = UploadFileForm()
@@ -48,6 +52,8 @@ def directory_listing(request, folder_id=None, images_with_missing_data=False):
for f in folder.children:
f.perms = _userperms(f, request)
folder_children.append(f)
+ for f in folder.files:
+ folder_files.append(f)
else:
for f in folder.children.all():
f.perms = _userperms(f, request)
@@ -230,10 +236,13 @@ class ImageExportForm(forms.Form):
FORMAT_CHOICES = (
('jpg', 'jpg'),
('png', 'png'),
+ ('gif', 'gif'),
+ #('tif', 'tif'),
)
format = forms.ChoiceField(choices=FORMAT_CHOICES)
crop = forms.BooleanField(required=False)
+ upscale = forms.BooleanField(required=False)
width = forms.IntegerField()
height = forms.IntegerField()
@@ -252,10 +261,21 @@ def export_image(request, image_id):
if format=='png':
mimetype='image/jpg'
pil_format = 'PNG'
+ #elif format=='tif':
+ # mimetype='image/tiff'
+ # pil_format = 'TIFF'
+ elif format=='gif':
+ mimetype='image/gif'
+ pil_format = 'GIF'
else:
mimetype='image/jpg'
pil_format = 'JPEG'
- im = resize_filter.render(im,size_x=int(form.cleaned_data['width']), size_y=int(form.cleaned_data['height']), crop=form.cleaned_data['crop'])
+ im = resize_filter.render(im,
+ size_x=int(form.cleaned_data['width']),
+ size_y=int(form.cleaned_data['height']),
+ crop=form.cleaned_data['crop'],
+ upscale=form.cleaned_data['upscale']
+ )
response = HttpResponse(mimetype='%s' % mimetype)
response['Content-Disposition'] = 'attachment; filename=exported_image.%s' % format
im.save(response, pil_format)

0 comments on commit a906490

Please sign in to comment.