forked from stefanfoulis/django-image-filer
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added crude bucket manipulatin functions
- Loading branch information
Stefan Foulis
committed
Apr 23, 2009
1 parent
7dc1a97
commit b904259
Showing
15 changed files
with
172 additions
and
92 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
from django.db import models |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
from django.db import models | ||
from django.db.models import Q | ||
from datetime import datetime | ||
|
||
class FolderManager(models.Manager): | ||
def with_bad_metadata(self): | ||
return self.get_query_set().filter(has_all_mandatory_data=False) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
from image_filer.models import Bucket | ||
|
||
|
||
def empty_bucket(bucket): | ||
bucket.files.clear() | ||
|
||
def get_user_bucket(user): | ||
if user.is_authenticated(): | ||
bucket, was_bucket_created = Bucket.objects.get_or_create(user=user) | ||
return bucket | ||
|
||
def put_files_in_bucket(files, bucket): | ||
for file in files: | ||
bucket.append_file(file) | ||
return True | ||
def clone_files_from_bucket_to_folder(bucket, folder): | ||
for file in bucket.files.all(): | ||
cloned_file = file.clone() | ||
cloned_file.folder = folder | ||
cloned_file.save() | ||
|
||
def move_files_from_bucket_to_folder(bucket, folder): | ||
return move_files_to_folder(bucket.files.all(), folder) | ||
|
||
def move_files_to_folder(files, folder): | ||
for file in files: | ||
file.folder = folder | ||
file.save() | ||
return True |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{% load adminmedia %} | ||
{% load i18n %} | ||
|
||
<tr> | ||
<!-- FileIcon --> | ||
<td class="fb_icon"><img src="/media/filebrowser/img/filebrowser_type_{{ file.file_type|lower }}.gif" /></td> | ||
<td>{% if file.get_admin_thumbnail_url %}<img src="{{ file.get_admin_thumbnail_url }}" alt="{{ file.default_alt_text }}" />{% endif %}</td> | ||
<!-- Filename/Dimensions --> | ||
{% ifequal file.file_type 'Folder' %} | ||
<td><b><a href="{% url image_filer-directory_listing file.id %}">{{ file.name }}</a></b></td> | ||
{% else %} | ||
<td><b><a href="/admin/image_filer/image/{{ file.id }}/">{{ file.name }}</a></b><br /><span class="tiny">{{ file.file.width }} x {{ file.file.height }} px</span></td> | ||
{% endifequal %} | ||
<td>{{ file.owner }}</td> | ||
<td>{{ file.perms }}</td> | ||
<td></td> | ||
</tr> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
{% load adminmedia %} | ||
{% load i18n %} | ||
|
||
<tr> | ||
<!-- FileIcon --> | ||
<td>{% if file.has_all_mandatory_data %}<img alt="0" src="/media/admin/img/admin/icon-yes.gif"/>{% else %}<img alt="1" src="/media/admin/img/admin/icon-no.gif"/>{% endif %}</td> | ||
<td>{% if file.get_admin_thumbnail_url %}<img src="{{ file.get_admin_thumbnail_url }}" alt="{{ file.default_alt_text }}" />{% endif %}</td> | ||
<!-- Filename/Dimensions --> | ||
<td><b><a href="/admin/image_filer/image/{{ file.id }}/">{{ file.label }}</a></b><br /><span class="tiny">{{ file.file.width }} x {{ file.file.height }} px</span></td> | ||
<td>{{ file.owner }}</td> | ||
<td>{{ file.perms }}</td> | ||
<td>{{ request }} | ||
<form action="{% url image_filer-put_file_in_bucket %}" method="post"> | ||
<input type="hidden" name="file_id" value="{{ file.id }}" /> | ||
<input type="hidden" name="redirect_to" value="{{ current_url }}" /> | ||
<input type="submit" value="put in bucket" /> | ||
</form> | ||
</td> | ||
</tr> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.