-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add logging configuration (#97)
* feat: makes characters searchable in admin view * misc: adds quotes to character name in admin view for improved readability * feat: adds logging configuration * fix: fixes unit test file name so it is discovered by test suit * chore: delete unused file
- Loading branch information
Showing
5 changed files
with
65 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,20 @@ | ||
from typing import Tuple | ||
|
||
from django.contrib import admin | ||
from django.db.models import Q, QuerySet | ||
from django.http import HttpRequest | ||
|
||
from .models import Character | ||
|
||
|
||
@admin.register(Character) | ||
class CharacterAdminView(admin.ModelAdmin): | ||
readonly_fields = ("character_name", "last_updated") | ||
list_filter = ("character_sheet_version", "account__unique_identifier") | ||
search_fields = ("data__Name__icontains", "account__unique_identifier__icontains", "account__email__icontains") | ||
|
||
def get_search_results(self, request: HttpRequest, queryset: QuerySet, search_term: str) -> Tuple[QuerySet, bool]: | ||
queryset, use_distinct = super().get_search_results(request, queryset, search_term) | ||
|
||
queryset |= self.model.objects.filter(Q(data__Name__icontains=search_term)) | ||
return queryset, use_distinct |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.