updated Admin models
This commit is contained in:
@@ -1,3 +1,49 @@
|
|||||||
from django.contrib import admin
|
from django.contrib import admin
|
||||||
|
|
||||||
# Register your models here.
|
from .models import (
|
||||||
|
Announcement,
|
||||||
|
AnnouncementComment,
|
||||||
|
AnnouncementRead,
|
||||||
|
Notification,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@admin.register(Announcement)
|
||||||
|
class AnnouncementAdmin(admin.ModelAdmin):
|
||||||
|
list_display = ('title', 'created_by', 'published', 'comment_count', 'created_at', 'updated_at')
|
||||||
|
list_filter = ('published', 'created_at')
|
||||||
|
search_fields = ('title', 'body')
|
||||||
|
|
||||||
|
@admin.display(description='Comments')
|
||||||
|
def comment_count(self, obj):
|
||||||
|
return obj.comments.count()
|
||||||
|
|
||||||
|
|
||||||
|
@admin.register(AnnouncementRead)
|
||||||
|
class AnnouncementReadAdmin(admin.ModelAdmin):
|
||||||
|
list_display = ('announcement', 'user', 'read_at')
|
||||||
|
search_fields = ('announcement__title', 'user__username')
|
||||||
|
readonly_fields = ('announcement', 'user', 'read_at')
|
||||||
|
|
||||||
|
def has_add_permission(self, request):
|
||||||
|
return False
|
||||||
|
|
||||||
|
def has_change_permission(self, request, obj=None):
|
||||||
|
return False
|
||||||
|
|
||||||
|
|
||||||
|
@admin.register(AnnouncementComment)
|
||||||
|
class AnnouncementCommentAdmin(admin.ModelAdmin):
|
||||||
|
list_display = ('announcement', 'user', 'body_preview', 'created_at')
|
||||||
|
search_fields = ('announcement__title', 'user__username', 'body')
|
||||||
|
|
||||||
|
@admin.display(description='Body')
|
||||||
|
def body_preview(self, obj):
|
||||||
|
return obj.body[:80]
|
||||||
|
|
||||||
|
|
||||||
|
@admin.register(Notification)
|
||||||
|
class NotificationAdmin(admin.ModelAdmin):
|
||||||
|
list_display = ('user', 'kind', 'project', 'actor', 'read', 'created_at')
|
||||||
|
list_filter = ('kind', 'read')
|
||||||
|
search_fields = ('user__username', 'text', 'project__title')
|
||||||
|
|||||||
@@ -1,14 +1,19 @@
|
|||||||
from django.contrib import admin
|
from django.contrib import admin
|
||||||
|
|
||||||
from .models import (
|
from .models import (
|
||||||
|
Comment,
|
||||||
FileIndex,
|
FileIndex,
|
||||||
Project,
|
Project,
|
||||||
ProjectAsset,
|
ProjectAsset,
|
||||||
ProjectContributor,
|
ProjectContributor,
|
||||||
|
ProjectDraft,
|
||||||
|
Rating,
|
||||||
Tag,
|
Tag,
|
||||||
TagCategory,
|
TagCategory,
|
||||||
TagList,
|
TagList,
|
||||||
|
TempUpload,
|
||||||
Version,
|
Version,
|
||||||
|
VersionFile,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@@ -16,29 +21,39 @@ from .models import (
|
|||||||
class FileIndexAdmin(admin.ModelAdmin):
|
class FileIndexAdmin(admin.ModelAdmin):
|
||||||
list_display = ('uuid', 'kind', 'owner', 'original_filename', 'size', 'created_at')
|
list_display = ('uuid', 'kind', 'owner', 'original_filename', 'size', 'created_at')
|
||||||
search_fields = ('uuid', 'original_filename', 'stored_path')
|
search_fields = ('uuid', 'original_filename', 'stored_path')
|
||||||
|
list_filter = ('kind',)
|
||||||
|
|
||||||
|
|
||||||
@admin.register(Project)
|
@admin.register(Project)
|
||||||
class ProjectAdmin(admin.ModelAdmin):
|
class ProjectAdmin(admin.ModelAdmin):
|
||||||
list_display = ('slug', 'title', 'category', 'owner', 'created_at', 'updated_at')
|
list_display = ('slug', 'title', 'category', 'owner', 'rating_score', 'rating_count', 'created_at', 'updated_at')
|
||||||
search_fields = ('slug', 'title', 'summary')
|
search_fields = ('slug', 'title', 'summary')
|
||||||
list_filter = ('category', 'created_at')
|
list_filter = ('category', 'created_at')
|
||||||
|
|
||||||
|
|
||||||
@admin.register(Version)
|
@admin.register(Version)
|
||||||
class VersionAdmin(admin.ModelAdmin):
|
class VersionAdmin(admin.ModelAdmin):
|
||||||
list_display = ('project', 'version_name', 'downloads', 'created_at')
|
list_display = ('project', 'version_name', 'pack_format', 'downloads', 'created_at')
|
||||||
search_fields = ('project__title', 'version_name')
|
search_fields = ('project__title', 'version_name')
|
||||||
|
|
||||||
|
|
||||||
|
@admin.register(VersionFile)
|
||||||
|
class VersionFileAdmin(admin.ModelAdmin):
|
||||||
|
list_display = ('version', 'filename', 'kind', 'created_at')
|
||||||
|
list_filter = ('kind',)
|
||||||
|
search_fields = ('version__project__title', 'version__version_name', 'file__original_filename')
|
||||||
|
|
||||||
|
|
||||||
@admin.register(ProjectAsset)
|
@admin.register(ProjectAsset)
|
||||||
class ProjectAssetAdmin(admin.ModelAdmin):
|
class ProjectAssetAdmin(admin.ModelAdmin):
|
||||||
list_display = ('project', 'caption', 'uploaded_by', 'created_at')
|
list_display = ('project', 'caption', 'uploaded_by', 'created_at')
|
||||||
|
search_fields = ('project__title', 'caption')
|
||||||
|
|
||||||
|
|
||||||
@admin.register(ProjectContributor)
|
@admin.register(ProjectContributor)
|
||||||
class ProjectContributorAdmin(admin.ModelAdmin):
|
class ProjectContributorAdmin(admin.ModelAdmin):
|
||||||
list_display = ('project', 'user', 'added_by', 'added_at')
|
list_display = ('project', 'user', 'added_by', 'added_at')
|
||||||
|
search_fields = ('project__title', 'user__username')
|
||||||
|
|
||||||
|
|
||||||
@admin.register(TagCategory)
|
@admin.register(TagCategory)
|
||||||
@@ -55,5 +70,40 @@ class TagAdmin(admin.ModelAdmin):
|
|||||||
|
|
||||||
@admin.register(TagList)
|
@admin.register(TagList)
|
||||||
class TagListAdmin(admin.ModelAdmin):
|
class TagListAdmin(admin.ModelAdmin):
|
||||||
list_display = ('project', 'tag', 'added_by', 'added_at')
|
list_display = ('project', 'tag', 'auto', 'added_by', 'added_at')
|
||||||
|
list_filter = ('auto',)
|
||||||
search_fields = ('project__title', 'tag__name')
|
search_fields = ('project__title', 'tag__name')
|
||||||
|
|
||||||
|
|
||||||
|
@admin.register(TempUpload)
|
||||||
|
class TempUploadAdmin(admin.ModelAdmin):
|
||||||
|
list_display = ('uuid', 'user', 'kind', 'status', 'draft_uuid', 'created_at')
|
||||||
|
list_filter = ('kind', 'status')
|
||||||
|
search_fields = ('user__username',)
|
||||||
|
|
||||||
|
|
||||||
|
@admin.register(ProjectDraft)
|
||||||
|
class ProjectDraftAdmin(admin.ModelAdmin):
|
||||||
|
list_display = ('uuid', 'user', 'draft_title', 'updated_at')
|
||||||
|
search_fields = ('user__username',)
|
||||||
|
|
||||||
|
@admin.display(description='Title')
|
||||||
|
def draft_title(self, obj):
|
||||||
|
return obj.data.get('title') or '(untitled)'
|
||||||
|
|
||||||
|
|
||||||
|
@admin.register(Rating)
|
||||||
|
class RatingAdmin(admin.ModelAdmin):
|
||||||
|
list_display = ('project', 'user', 'value', 'updated_at')
|
||||||
|
list_filter = ('value',)
|
||||||
|
search_fields = ('project__title', 'user__username')
|
||||||
|
|
||||||
|
|
||||||
|
@admin.register(Comment)
|
||||||
|
class CommentAdmin(admin.ModelAdmin):
|
||||||
|
list_display = ('project', 'user', 'body_preview', 'created_at')
|
||||||
|
search_fields = ('project__title', 'user__username', 'body')
|
||||||
|
|
||||||
|
@admin.display(description='Body')
|
||||||
|
def body_preview(self, obj):
|
||||||
|
return obj.body[:80]
|
||||||
|
|||||||
Reference in New Issue
Block a user