~widelands-dev/widelands-website/django_staticfiles

« back to all changes in this revision

Viewing changes to wlimages/admin.py

  • Committer: Holger Rapp
  • Date: 2016-08-08 10:06:42 UTC
  • mto: This revision was merged to the branch mainline in revision 419.
  • Revision ID: sirver@gmx.de-20160808100642-z62vwqitxoyl5fh4
Added the apt-get update script I run every 30 days.

Show diffs side-by-side

added added

removed removed

Lines of Context:
13
13
from django.utils.translation import ugettext_lazy as _
14
14
from models import Image
15
15
 
16
 
 
17
 
def delete_with_file(modeladmin, request, queryset):
18
 
    for obj in queryset:
19
 
        storage = obj.image.storage
20
 
        storage.delete(obj.image)
21
 
        obj.delete()
22
 
delete_with_file.short_description = 'Delete Image including File'
23
 
 
24
 
 
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]
32
21
    fieldsets = (
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')}),
37
25
    )
38
26
 
39
27
admin.site.register(Image, ImageAdmin)