13
13
from django.utils.translation import ugettext_lazy as _
14
14
from models import Image
17
def delete_with_file(modeladmin, request, queryset):
19
storage = obj.image.storage
20
storage.delete(obj.image)
22
delete_with_file.short_description = 'Delete Image including File'
25
16
class ImageAdmin(admin.ModelAdmin):
26
readonly_fields = ('content_object', 'content_type', 'object_id')
27
list_display = ('__unicode__', 'date_submitted', 'content_type', 'user')
17
list_display = ( '__unicode__', 'date_submitted', 'content_type', 'user')
28
18
list_filter = ('date_submitted',)
29
19
date_hierarchy = 'date_submitted'
30
20
search_fields = ('image', 'user__username')
31
actions = [delete_with_file]
33
(None, {'fields': ('image', 'name', 'date_submitted', 'revision')}),
34
(_('Uploaded by:'), {'fields': ('user',)}),
35
(_('Content object:'), {
36
'fields': (('content_type', 'content_object'), 'object_id')}),
22
(None, {'fields': ( ('image', 'name'), 'date_submitted', 'url','revision')}),
23
(_('Upload data:'), { 'fields': ( 'user', 'editor_ip')}),
24
(_('Content object:'), { 'fields': ( 'content_type', 'object_id')}),
39
27
admin.site.register(Image, ImageAdmin)