Add Metadata_Files & customised the list page & set file_hash to read only on profile image, Metadata files
This commit is contained in:
parent
3325a6890e
commit
9611e8e51f
1 changed files with 48 additions and 4 deletions
|
@ -1,18 +1,62 @@
|
|||
from django.contrib import admin
|
||||
from django import forms
|
||||
from django.urls import reverse
|
||||
from django.utils.html import format_html
|
||||
|
||||
from .models import Submission_File, User_Profile_Images, User_Banner_Images
|
||||
from .models import Metadata_Files, Submission_File, User_Profile_Images, User_Banner_Images
|
||||
|
||||
# Register your models here.
|
||||
|
||||
class Submission_FileAdmin(admin.ModelAdmin):
|
||||
list_display = ('file_name', 'date_added', 'file_hash', 'file',)
|
||||
list_display = ('id', 'file_link', 'date_added', 'file_hash', 'file',)
|
||||
|
||||
def file_link(self, obj):
|
||||
url = reverse("admin:files_submission_file_change", args=[obj.id])
|
||||
return format_html('<a href="{}">{}</a>', url, obj.file_name)
|
||||
|
||||
file_link.short_description = 'File Name'
|
||||
|
||||
|
||||
class User_Banner_ImagesAdmin(admin.ModelAdmin):
|
||||
list_display = ('file_name', 'date_added', 'file_hash', 'file',)
|
||||
list_display = ('id', 'file_link', 'date_added', 'file_hash', 'file',)
|
||||
|
||||
def file_link(self, obj):
|
||||
url = reverse("admin:files_user_banner_images_change", args=[obj.id])
|
||||
return format_html('<a href="{}">{}</a>', url, obj.file_name)
|
||||
|
||||
file_link.short_description = 'File Name'
|
||||
|
||||
|
||||
class User_Profile_ImagesAdmin(admin.ModelAdmin):
|
||||
list_display = ('file_name', 'date_added', 'file_hash', 'file',)
|
||||
list_display = ('id', 'file_link', 'date_added', 'file_hash', 'file',)
|
||||
|
||||
def get_form(self, request, obj=None, **kwargs):
|
||||
form = super().get_form(request, obj, **kwargs)
|
||||
form.base_fields['file_hash'].widget = forms.TextInput(attrs={'readonly': True})
|
||||
return form
|
||||
|
||||
def file_link(self, obj):
|
||||
url = reverse("admin:files_user_profile_images_change", args=[obj.id])
|
||||
return format_html('<a href="{}">{}</a>', url, obj.file_name)
|
||||
|
||||
file_link.short_description = 'File Name'
|
||||
|
||||
class Metadata_FilesAdmin(admin.ModelAdmin):
|
||||
list_display = ('id', 'file_link', 'date_added', 'file_hash', 'file',)
|
||||
|
||||
def get_form(self, request, obj=None, **kwargs):
|
||||
form = super().get_form(request, obj, **kwargs)
|
||||
form.base_fields['file_hash'].widget = forms.TextInput(attrs={'readonly': True})
|
||||
return form
|
||||
|
||||
def file_link(self, obj):
|
||||
url = reverse("admin:files_metadata_files_change", args=[obj.id])
|
||||
return format_html('<a href="{}">{}</a>', url, obj.file_name)
|
||||
|
||||
file_link.short_description = 'File Name'
|
||||
|
||||
|
||||
admin.site.register(Metadata_Files, Metadata_FilesAdmin)
|
||||
admin.site.register(Submission_File, Submission_FileAdmin)
|
||||
admin.site.register(User_Banner_Images, User_Banner_ImagesAdmin)
|
||||
admin.site.register(User_Profile_Images, User_Profile_ImagesAdmin)
|
Loading…
Reference in a new issue