Skip to content

Commit

Permalink
make admin more readable
Browse files Browse the repository at this point in the history
  • Loading branch information
rachaelcodes committed Jun 26, 2024
1 parent d4f6b5b commit 3628025
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
13 changes: 11 additions & 2 deletions django_app/redbox_app/redbox_core/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,18 @@ class FileAdmin(admin.ModelAdmin):
date_hierarchy = "created_at"


class CitationInline(admin.StackedInline):
model = models.Citation
ordering = ("modified_at",)

extra = 1


class ChatMessageAdmin(admin.ModelAdmin):
list_display = ["chat_history", "get_user", "text", "role", "route", "created_at"]
list_display = ["text", "role", "get_user", "chat_history", "route", "created_at"]
list_filter = ["role", "route", "chat_history__users"]
date_hierarchy = "created_at"
inlines = [CitationInline]

@admin.display(ordering="chat_history__users", description="User")
def get_user(self, obj):
Expand All @@ -45,6 +53,7 @@ class ChatMessageInline(admin.StackedInline):
ordering = ("modified_at",)
readonly_fields = ["modified_at", "source_files"]
extra = 1
show_change_link = True # allows users to click through to look at Citations


class ChatHistoryAdmin(admin.ModelAdmin):
Expand Down Expand Up @@ -76,7 +85,7 @@ def export_as_csv(self, request, queryset): # noqa:ARG002


class CitationAdmin(admin.ModelAdmin):
list_display = ["chat_message", "text", "get_user", "file"]
list_display = ["text", "get_user", "chat_message", "file"]
list_filter = ["chat_message__chat_history__users"]

@admin.display(ordering="chat_message__chat_history__users", description="User")
Expand Down
2 changes: 1 addition & 1 deletion django_app/redbox_app/redbox_core/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,4 +244,4 @@ class ChatMessage(UUIDPrimaryKeyBase, TimeStampedModel):
source_files = models.ManyToManyField(File, through=Citation)

def __str__(self) -> str: # pragma: no cover
return f"{self.chat_history} - {self.text} - {self.role}"
return f"{self.text} - {self.role}"

0 comments on commit 3628025

Please sign in to comment.