From c708cd1d03040df69bf6cb94f648d9ea64ba134a Mon Sep 17 00:00:00 2001 From: PlexSheep Date: Sun, 4 Jun 2023 02:07:35 +0200 Subject: [PATCH] admin catch up --- gawa/blog/admin.py | 2 ++ .../migrations/0008_auto_20230604_0156.py | 21 +++++++++++++ gawa/start/admin.py | 10 ++++++ gawa/start/models.py | 31 +++++++++++++------ 4 files changed, 54 insertions(+), 10 deletions(-) create mode 100644 gawa/blog/migrations/0008_auto_20230604_0156.py diff --git a/gawa/blog/admin.py b/gawa/blog/admin.py index 7caa42b..7f546c2 100644 --- a/gawa/blog/admin.py +++ b/gawa/blog/admin.py @@ -8,6 +8,8 @@ class CategoryAdmin(admin.ModelAdmin): The admin model for Category """ + list_display = ["name", "slug"] + @admin.action(description=_("Regenerate searchable traits")) def regenerate(modeladmin, request, queryset): for obj in queryset: diff --git a/gawa/blog/migrations/0008_auto_20230604_0156.py b/gawa/blog/migrations/0008_auto_20230604_0156.py new file mode 100644 index 0000000..6b405bb --- /dev/null +++ b/gawa/blog/migrations/0008_auto_20230604_0156.py @@ -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'}, + ), + ] diff --git a/gawa/start/admin.py b/gawa/start/admin.py index 7cb02d1..4d3b0d6 100644 --- a/gawa/start/admin.py +++ b/gawa/start/admin.py @@ -25,3 +25,13 @@ class StaticSiteAdmin(admin.ModelAdmin): list_display = ["title_en", "subtitle_en", "title_de", "subtitle_de", "suburl"] ordering = ['title_de', 'title_en'] 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] + diff --git a/gawa/start/models.py b/gawa/start/models.py index cec0708..b4a30da 100644 --- a/gawa/start/models.py +++ b/gawa/start/models.py @@ -1,5 +1,6 @@ from django.db import models from django.db.models.options import override +from django.utils.translation import gettext as _ import logging logger = logging.getLogger(__name__) @@ -14,6 +15,10 @@ class Keyword(models.Model): def __str__(self): return f"{{<{self.__class__.__name__}>\"{self.text_en}\"}}" + class Meta: + verbose_name = _("Keyword") + verbose_name_plural = _("keywords") + class Searchable(models.Model): """ Abstract class for any model that should be searchable. @@ -49,7 +54,11 @@ class Searchable(models.Model): """ 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): """ @@ -60,13 +69,15 @@ class StaticSite(Searchable): # 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 - def regenerate_all_entries(cls): - - # 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") + class Meta: + verbose_name = _("static site") + verbose_name_plural = _("static sites")