Skip to content

Instantly share code, notes, and snippets.

@hanleybrand
Created September 29, 2015 13:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save hanleybrand/96ab60ba75aec64c3a34 to your computer and use it in GitHub Desktop.
Save hanleybrand/96ab60ba75aec64c3a34 to your computer and use it in GitHub Desktop.
Some fixes for MDID3's storage/admin page
from django.contrib import admin
from models import Storage, Media, ProxyUrl, TrustedSubnet
class StorageAdmin(admin.ModelAdmin):
list_display = ('title', 'name', 'system', 'base', 'urlbase')
# http://stackoverflow.com/questions/9563935/removing-buttons-links-in-django-admin
def get_actions(self, request):
actions = super(admin.ModelAdmin, self).get_actions(request)
if 'delete_selected' in actions:
del actions['delete_selected']
return actions
def has_delete_permission(self, request, obj=None):
return False
class MediaAdmin(admin.ModelAdmin):
list_display = ('name', 'record', 'url', 'storage', 'mimetype', 'width', 'height', 'master')
raw_id_fields = ('record', )
search_fields = ['name', 'url']
class ProxyUrlAdmin(admin.ModelAdmin):
list_display = ('uuid', 'subnet', 'url', 'user', 'user_backend', 'last_access')
class TrustedSubnetAdmin(admin.ModelAdmin):
pass
admin.site.register(Storage, StorageAdmin)
admin.site.register(Media, MediaAdmin)
admin.site.register(ProxyUrl, ProxyUrlAdmin)
admin.site.register(TrustedSubnet, TrustedSubnetAdmin)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment