admin catch up

This commit is contained in:
Christoph J. Scherr 2023-06-04 02:07:35 +02:00
parent 91667a7da9
commit c708cd1d03
Signed by: PlexSheep
GPG Key ID: 25B4ACF7D88186CC
4 changed files with 54 additions and 10 deletions

View File

@ -8,6 +8,8 @@ class CategoryAdmin(admin.ModelAdmin):
The admin model for Category The admin model for Category
""" """
list_display = ["name", "slug"]
@admin.action(description=_("Regenerate searchable traits")) @admin.action(description=_("Regenerate searchable traits"))
def regenerate(modeladmin, request, queryset): def regenerate(modeladmin, request, queryset):
for obj in queryset: for obj in queryset:

View File

@ -0,0 +1,21 @@
# Generated by Django 3.2.19 on 2023-06-03 23:56
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('blog', '0007_remove_blogpost_public'),
]
operations = [
migrations.AlterModelOptions(
name='blogpost',
options={'verbose_name': 'blog post', 'verbose_name_plural': 'blog posts'},
),
migrations.AlterModelOptions(
name='category',
options={'verbose_name': 'Category', 'verbose_name_plural': 'Categories'},
),
]

View File

@ -25,3 +25,13 @@ class StaticSiteAdmin(admin.ModelAdmin):
list_display = ["title_en", "subtitle_en", "title_de", "subtitle_de", "suburl"] list_display = ["title_en", "subtitle_en", "title_de", "subtitle_de", "suburl"]
ordering = ['title_de', 'title_en'] ordering = ['title_de', 'title_en']
actions = [regenerate] actions = [regenerate]
@admin.register(Searchable)
class SearchableAdmin(admin.ModelAdmin):
"""
Abstract Admin Interface for all Searchables
"""
list_display = ["title_en", "subtitle_en", "title_de", "subtitle_de", "suburl"]
ordering = ['title_de', 'title_en']
actions = [regenerate]

View File

@ -1,5 +1,6 @@
from django.db import models from django.db import models
from django.db.models.options import override from django.db.models.options import override
from django.utils.translation import gettext as _
import logging import logging
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
@ -14,6 +15,10 @@ class Keyword(models.Model):
def __str__(self): def __str__(self):
return f"{{<{self.__class__.__name__}>\"{self.text_en}\"}}" return f"{{<{self.__class__.__name__}>\"{self.text_en}\"}}"
class Meta:
verbose_name = _("Keyword")
verbose_name_plural = _("keywords")
class Searchable(models.Model): class Searchable(models.Model):
""" """
Abstract class for any model that should be searchable. Abstract class for any model that should be searchable.
@ -49,7 +54,11 @@ class Searchable(models.Model):
""" """
regenerate a object regenerate a object
""" """
raise NotImplementedError("This model does not implement regenerate") raise NotImplementedError(f"{self.__class__.__name__} does not implement regenerate")
class Meta:
verbose_name = _("Searchable")
verbose_name_plural = _("Searchables")
class StaticSite(Searchable): class StaticSite(Searchable):
""" """
@ -60,13 +69,15 @@ class StaticSite(Searchable):
# TODO automate scanning for SearchableView classes # TODO automate scanning for SearchableView classes
""" """
def regenerate(self):
"""
regenerate a object
"""
logger.info(f"regenerating {self.__class__.__name__} object: {self}")
logger.warning(f"{self.__class__.__name__} cannot regenerate.")
#self.save()
pass
@override class Meta:
def regenerate_all_entries(cls): verbose_name = _("static site")
verbose_name_plural = _("static sites")
# this does not actually contain all views, only those that should show
# up in the search.
# TODO automate searching for these
#all_views: list[SearchableView] = []
raise NotImplementedError("This model does not implement regenerate_all_entries")