Skip to content

Commit

Permalink
Merge branch 'develop' into feature/settingsrefactor
Browse files Browse the repository at this point in the history
* develop:
  removed redundant </span>
  removed all print statements (commented out or otherwise)
  Remove an used import
  Fix: The admin now use subject location to crop the image
  • Loading branch information
stefanfoulis committed Apr 18, 2011
2 parents b1c3846 + 7d28ec3 commit a0a0b9f
Show file tree
Hide file tree
Showing 13 changed files with 8 additions and 32 deletions.
5 changes: 1 addition & 4 deletions filer/admin/clipboardadmin.py
Expand Up @@ -112,18 +112,15 @@ def ajax_upload(self, request, folder_id=None):
clipboard_item = ClipboardItem(clipboard=clipboard, file=file)
clipboard_item.save()
except Exception, e:
#print e
pass
else:
pass#print uploadform.errors
pass
except Exception, e:
#print e
pass
return render_to_response('admin/filer/tools/clipboard/clipboard_item_rows.html',
{'items': file_items },
context_instance=RequestContext(request))
def move_file_to_clipboard(self, request):
#print "move file"
if request.method == 'POST':
file_id = request.POST.get("file_id", None)
clipboard = tools.get_user_clipboard(request.user)
Expand Down
1 change: 0 additions & 1 deletion filer/admin/fileadmin.py
Expand Up @@ -45,7 +45,6 @@ def response_change(self, request, obj):
instead of the default change_list_view
'''
r = super(FileAdmin, self).response_change(request, obj)
#print r['Location']
if r['Location']:
# it was a successful save
if r['Location'] in ['../']:
Expand Down
10 changes: 2 additions & 8 deletions filer/admin/folderadmin.py
Expand Up @@ -64,8 +64,6 @@ def response_change(self, request, obj):
'''
r = super(FolderAdmin, self).response_change(request, obj)
if r['Location']:
#print r['Location']
#print obj
# it was a successful save
if r['Location'] in ['../']:
if obj.parent:
Expand Down Expand Up @@ -204,20 +202,18 @@ def filter_file(qs, terms=[]):
f.perms = userperms_for_request(f, request)
if hasattr(f, 'has_read_permission'):
if f.has_read_permission(request):
#print "%s has read permission for %s" % (request.user, f)
folder_children.append(f)
else:
pass#print "%s has NO read permission for %s" % (request.user, f)
pass
else:
folder_children.append(f)
for f in file_qs:
f.perms = userperms_for_request(f, request)
if hasattr(f, 'has_read_permission'):
if f.has_read_permission(request):
#print "%s has read permission for %s" % (request.user, f)
folder_files.append(f)
else:
pass#print "%s has NO read permission for %s" % (request.user, f)
pass
else:
folder_files.append(f)
try:
Expand All @@ -228,9 +224,7 @@ def filter_file(qs, terms=[]):
}
except:
permissions = {}
#folder_children = folder_children.sort(cmp=lambda x,y: cmp(x.name.lower(), y.name.lower()))
folder_files.sort(cmp=lambda x, y: cmp(x.label.lower(), y.label.lower()))
#import ipdb; ipdb.set_trace()
items = folder_children + folder_files
paginator = Paginator(items, FILER_PAGINATE_BY)

Expand Down
2 changes: 0 additions & 2 deletions filer/admin/permissions.py
Expand Up @@ -10,10 +10,8 @@ def has_add_permission(self, request):
def has_change_permission(self, request, obj=None):
if hasattr(obj, 'has_edit_permission'):
if obj.has_edit_permission(request):
#print "%s has edit permission for %s" % (request.user, obj)
return True
else:
#print "%s has NO edit permission for %s" % (request.user, obj)
return False
else:
return True
Expand Down
2 changes: 1 addition & 1 deletion filer/fields/file.py
Expand Up @@ -25,7 +25,7 @@ def render(self, name, value, attrs=None):
file = File.objects.get(pk=value)
related_url = file.logical_folder.get_admin_directory_listing_url_path()
except Exception,e:
print e
pass
if not related_url:
related_url = reverse('admin:filer-directory_listing-root')
params = self.url_parameters()
Expand Down
5 changes: 1 addition & 4 deletions filer/models/filemodels.py
Expand Up @@ -109,7 +109,7 @@ def save(self, *args, **kwargs):
try:
self.generate_sha1()
except Exception, e:
print e, type(3)
pass
super(File, self).save(*args, **kwargs)

@property
Expand Down Expand Up @@ -153,16 +153,13 @@ def __unicode__(self):


def subtype(self):
#print "get subtype"
if not self._file_type_plugin_name:
r = self
else:
try:
r = getattr(self, self._file_type_plugin_name.lower())
except Exception, e:
#print e
r = self
#print u"get subtype: %s %s" % (r, self._file_type_plugin_name)
return r
def get_admin_url_path(self):
return urlresolvers.reverse('admin:filer_file_change', args=(self.id,))
Expand Down
3 changes: 2 additions & 1 deletion filer/models/imagemodels.py
Expand Up @@ -4,7 +4,6 @@
from django.core import urlresolvers
from django.db import models
from django.utils.translation import ugettext_lazy as _
from easy_thumbnails.files import Thumbnailer
from filer import settings as filer_settings
from filer.models.filemodels import File
from filer.utils.filer_easy_thumbnails import FilerThumbnailer
Expand Down Expand Up @@ -129,6 +128,7 @@ def icons(self):
'size':(int(size),int(size)),
'crop': True,
'upscale':True,
'subject_location': self.subject_location,
}
thumb = self.file.get_thumbnail(thumbnail_options)
_icons[size] = thumb.url
Expand All @@ -143,6 +143,7 @@ def thumbnails(self):
_thumbnails = {}
for name, opts in Image.DEFAULT_THUMBNAILS.items():
try:
opts.update({'subject_location': self.subject_location})
thumb = self.file.get_thumbnail(opts)
_thumbnails[name] = thumb.url
except:
Expand Down
1 change: 0 additions & 1 deletion filer/models/tools.py
Expand Up @@ -26,7 +26,6 @@ def move_files_from_clipboard_to_folder(clipboard, folder):

def move_files_to_folder(files, folder):
for file in files:
#print "moving %s (%s) to %s" % (file, type(file), folder)
file.folder = folder
file.save()
return True
2 changes: 1 addition & 1 deletion filer/templates/admin/filer/folder/directory_table.html
Expand Up @@ -37,7 +37,7 @@
<td>
<a style="display: block; float: right;" class="changelink" href="{{ file.get_admin_url_path }}{% if is_popup %}?_popup=1{% endif %}" title="{% blocktrans with file.label as item_label %}Change '{{ item_label }}' details{% endblocktrans %}">{% trans "Change" %}</a>
<div><b><a href="{{ file.get_admin_url_path }}{% if is_popup %}?_popup=1{% endif %}" title="{% blocktrans with file.label as item_label %}Change '{{ item_label }}' details{% endblocktrans %}">{{ file.label }}</a></b><span class="tiny"> ({{ file.size|filesize:"auto1000long" }})</span></div>
{% ifequal file.file_type "Image" %}<div>{{ file.width }} x {{ file.height }} px </span></div>{% endifequal %}
{% ifequal file.file_type "Image" %}<div>{{ file.width }} x {{ file.height }} px </div>{% endifequal %}
{% if file.owner %}<div>{% trans "Owner" %}: {{ file.owner }}</div>{% endif %}
{# {% if file.has_all_mandatory_data %}<div><img alt="0" src="{{ ADMIN_MEDIA_PREFIX }}admin/img/admin/icon-yes.gif" /> {% trans "has all mandatory metadata" %}</div>{% else %}<div><img alt="1" src="{{ ADMIN_MEDIA_PREFIX }}img/admin/icon-no.gif"/> {% trans "missing metadata!" %}</div>{% endif %} #}
</td>
Expand Down
1 change: 0 additions & 1 deletion filer/thumbnail_processors.py
Expand Up @@ -25,7 +25,6 @@ def normalize_subject_location(subject_location):
try:
return ( int(subject_location[0]), int(subject_location[1]) )
except (TypeError, ValueError), e:
print e, type(e)
pass
return False
#new signature: im, size, crop=False, upscale=False, **kwargs
Expand Down
3 changes: 0 additions & 3 deletions filer/utils/files.py
Expand Up @@ -9,17 +9,14 @@ def generic_handle_file(file, original_filename):
Handels a file, regardless if a package or a single file and returns
a list of files. can recursively unpack packages.
"""
#print "entering generic_handle_file(file=%s, original_filename=%s)" % (file, original_filename)
files = []
filetype = os.path.splitext(original_filename)[1].lower()
#print filetype
if filetype=='.zip':
unpacked_files = unzip(file)
for ufile, ufilename in unpacked_files:
files += generic_handle_file(ufile, ufilename)
else:
files.append( (file,original_filename) )
#print "result of generic_handle_file: ", files
return files


Expand Down
2 changes: 0 additions & 2 deletions filer/utils/zip.py
Expand Up @@ -16,9 +16,7 @@ def unzip(file):
if bad_file:
raise Exception('"%s" in the .zip archive is corrupt.' % bad_file)
infolist = zip.infolist()
# print infolist
for zipinfo in infolist:
# print "handling %s" % zipinfo.filename
if zipinfo.filename.startswith('__'): # do not process meta files
continue
thefile = SimpleUploadedFile(name=zipinfo.filename, content=zip.read(zipinfo))
Expand Down
3 changes: 0 additions & 3 deletions filer/views.py
Expand Up @@ -79,10 +79,8 @@ def make_folder(request, folder_id=None):
new_folder.parent = folder
new_folder.owner = request.user
new_folder.save()
#print u"Saving folder %s as child of %s" % (new_folder, folder)
return HttpResponse('<script type="text/javascript">opener.dismissPopupAndReload(window);</script>')
else:
#print u"New Folder GET, parent %s" % folder
new_folder_form = NewFolderForm()
return render_to_response('admin/filer/folder/new_folder_form.html', {
'new_folder_form': new_folder_form,
Expand All @@ -92,7 +90,6 @@ def make_folder(request, folder_id=None):
class UploadFileForm(forms.ModelForm):
class Meta:
model = Image
#fields = ('file',)


@login_required
Expand Down

0 comments on commit a0a0b9f

Please sign in to comment.