From 4e322f72114ebb76980e6e3b39c2c94ccc554b24 Mon Sep 17 00:00:00 2001 From: PlexSheep Date: Tue, 10 Oct 2023 12:00:31 +0200 Subject: [PATCH] remove searchable model --- gawa/blog/admin.py | 8 -- gawa/blog/migrations/0001_initial.py | 39 +-------- .../migrations/0002_alter_blogpost_slug.py | 18 ----- gawa/blog/migrations/0002_initial.py | 58 ++++++++++++++ gawa/blog/models.py | 17 +++- gawa/blog/templates/blog/index.html | 6 +- gawa/blog/views.py | 5 +- gawa/locale/de/LC_MESSAGES/django.mo | Bin 10503 -> 10181 bytes gawa/locale/de/LC_MESSAGES/django.po | 63 +++++++-------- gawa/locale/en/LC_MESSAGES/django.po | 45 +++-------- gawa/slides/migrations/__init__.py | 0 gawa/start/admin.py | 22 ------ gawa/start/migrations/0001_initial.py | 67 +--------------- gawa/start/migrations/0002_initial.py | 52 ++++++++++++ gawa/start/models.py | 74 +++--------------- gawa/start/templates/main_search_form.html | 5 -- gawa/start/templates/nav.html | 1 - gawa/start/urls.py | 1 - gawa/start/views.py | 52 ++---------- 19 files changed, 186 insertions(+), 347 deletions(-) delete mode 100644 gawa/blog/migrations/0002_alter_blogpost_slug.py create mode 100644 gawa/blog/migrations/0002_initial.py delete mode 100644 gawa/slides/migrations/__init__.py create mode 100644 gawa/start/migrations/0002_initial.py delete mode 100644 gawa/start/templates/main_search_form.html diff --git a/gawa/blog/admin.py b/gawa/blog/admin.py index fd8f9f2..34e86c1 100644 --- a/gawa/blog/admin.py +++ b/gawa/blog/admin.py @@ -12,12 +12,6 @@ class CategoryAdmin(admin.ModelAdmin): list_display = ["name", "slug"] -@admin.action(description=_("Regenerate traits")) -def regenerate(modeladmin, request, queryset): - for obj in queryset: - obj.regenerate() - - @admin.register(BlogPost) class BlogPostAdmin(admin.ModelAdmin): """ @@ -26,8 +20,6 @@ class BlogPostAdmin(admin.ModelAdmin): list_display = ["title_en", "subtitle_en", "title_de", "subtitle_de", "date", "category", "slug", "suburl", "public"] date_hierarchy = "date" ordering = ['title_de', 'title_en'] - actions = [regenerate] - change_list_template = "admin/blogpost.html" def get_urls(self): diff --git a/gawa/blog/migrations/0001_initial.py b/gawa/blog/migrations/0001_initial.py index b521008..35744bf 100644 --- a/gawa/blog/migrations/0001_initial.py +++ b/gawa/blog/migrations/0001_initial.py @@ -1,47 +1,12 @@ -# Generated by Django 3.2.21 on 2023-10-02 08:14 +# Generated by Django 4.2.6 on 2023-10-10 09:58 -import blog.models -from django.db import migrations, models -import django.db.models.deletion +from django.db import migrations class Migration(migrations.Migration): - initial = True - dependencies = [ - ('start', '0001_initial'), ] operations = [ - migrations.CreateModel( - name='Category', - fields=[ - ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), - ('name', models.CharField(max_length=50)), - ('slug', models.SlugField(unique=True)), - ], - options={ - 'verbose_name': 'Category', - 'verbose_name_plural': 'Categories', - }, - ), - migrations.CreateModel( - name='BlogPost', - fields=[ - ('searchable_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='start.searchable')), - ('body_en', models.TextField(blank=True, default='Dieser Artikel ist nicht auf deutsch verfügbar.')), - ('body_de', models.TextField(blank=True, default='This aritcle is not available in english.')), - ('thumbnail', models.ImageField(blank=True, default='img/thumbnails/default.jpg', upload_to='img/thumbnails')), - ('featured', models.BooleanField(default=False)), - ('langs', models.CharField(default="{'en': False, 'de': False}", max_length=64)), - ('slug', models.SlugField()), - ('category', models.ForeignKey(default=blog.models.Category.get_or_create_uncategorized, on_delete=django.db.models.deletion.SET_DEFAULT, to='blog.category')), - ], - options={ - 'verbose_name': 'blog post', - 'verbose_name_plural': 'blog posts', - }, - bases=('start.searchable',), - ), ] diff --git a/gawa/blog/migrations/0002_alter_blogpost_slug.py b/gawa/blog/migrations/0002_alter_blogpost_slug.py deleted file mode 100644 index d9fadbb..0000000 --- a/gawa/blog/migrations/0002_alter_blogpost_slug.py +++ /dev/null @@ -1,18 +0,0 @@ -# Generated by Django 4.2.5 on 2023-10-02 19:03 - -from django.db import migrations, models - - -class Migration(migrations.Migration): - - dependencies = [ - ('blog', '0001_initial'), - ] - - operations = [ - migrations.AlterField( - model_name='blogpost', - name='slug', - field=models.SlugField(unique=True), - ), - ] diff --git a/gawa/blog/migrations/0002_initial.py b/gawa/blog/migrations/0002_initial.py new file mode 100644 index 0000000..9c52c93 --- /dev/null +++ b/gawa/blog/migrations/0002_initial.py @@ -0,0 +1,58 @@ +# Generated by Django 4.2.6 on 2023-10-10 09:58 + +import blog.models +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + initial = True + + dependencies = [ + ('start', '0002_initial'), + ('blog', '0001_initial'), + ] + + operations = [ + migrations.CreateModel( + name='Category', + fields=[ + ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('name', models.CharField(max_length=50)), + ('slug', models.SlugField(unique=True)), + ], + options={ + 'verbose_name': 'Category', + 'verbose_name_plural': 'Categories', + }, + ), + migrations.CreateModel( + name='BlogPost', + fields=[ + ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('body_en', models.TextField(blank=True, default='Dieser Artikel ist nicht auf deutsch verfügbar.')), + ('body_de', models.TextField(blank=True, default='This aritcle is not available in english.')), + ('thumbnail', models.ImageField(blank=True, default='img/thumbnails/default.jpg', upload_to='img/thumbnails')), + ('featured', models.BooleanField(default=False)), + ('langs', models.CharField(default="{'en': False, 'de': False}", max_length=64)), + ('slug', models.SlugField(unique=True)), + ('title_de', models.CharField(default='Nicht übersetzt', max_length=50)), + ('title_en', models.CharField(default='Not translated', max_length=50)), + ('subtitle_de', models.CharField(blank=True, max_length=50)), + ('subtitle_en', models.CharField(blank=True, max_length=50)), + ('desc_de', models.TextField(blank=True, default='Keine Beschreibung', max_length=250)), + ('desc_en', models.TextField(blank=True, default='no description', max_length=250)), + ('date', models.DateTimeField(blank=True, null=True)), + ('update', models.DateTimeField(blank=True, null=True)), + ('suburl', models.CharField(blank=True, max_length=200, null=True)), + ('public', models.BooleanField(default=False)), + ('category', models.ForeignKey(default=blog.models.Category.get_or_create_uncategorized, on_delete=django.db.models.deletion.SET_DEFAULT, to='blog.category')), + ('keywords', models.ManyToManyField(blank=True, to='start.keyword')), + ], + options={ + 'verbose_name': 'blog post', + 'verbose_name_plural': 'blog posts', + }, + ), + ] diff --git a/gawa/blog/models.py b/gawa/blog/models.py index 9f218c6..99e1cd2 100644 --- a/gawa/blog/models.py +++ b/gawa/blog/models.py @@ -7,7 +7,7 @@ import markdown from bs4 import BeautifulSoup from django.db import models from django.utils.translation import gettext as _ -from start.models import Keyword, Searchable +from start.models import Keyword import logging logger = logging.getLogger(__name__) @@ -56,7 +56,7 @@ class Category(models.Model): slug="uncategorized", name="uncategorized") -class BlogPost(Searchable): +class BlogPost(models.Model): """ Should contain a blogpost """ @@ -87,6 +87,19 @@ class BlogPost(Searchable): langs = models.CharField( default=DEFAULT_LANGS.__repr__(), max_length=64) slug = models.SlugField(unique=True, blank=False) + title_de = models.CharField(max_length=50, default="Nicht übersetzt") + title_en = models.CharField(max_length=50, default="Not translated") + subtitle_de = models.CharField(max_length=50, blank=True) + subtitle_en = models.CharField(max_length=50, blank=True) + desc_de = models.TextField( + blank=True, max_length=250, unique=False, default="Keine Beschreibung") + desc_en = models.TextField( + blank=True, max_length=250, unique=False, default="no description") + date = models.DateTimeField(blank=True, null=True) + update = models.DateTimeField(blank=True, null=True) + keywords = models.ManyToManyField(Keyword, blank=True) + suburl = models.CharField(max_length=200, blank=True, null=True) + public = models.BooleanField(default=False) def save(self): # check if the slug is empty if we remove whitespaces diff --git a/gawa/blog/templates/blog/index.html b/gawa/blog/templates/blog/index.html index 534e25f..10798f6 100644 --- a/gawa/blog/templates/blog/index.html +++ b/gawa/blog/templates/blog/index.html @@ -43,14 +43,12 @@
-

{% translate "Looking for anything specific?" %}

- {% include 'main_search_form.html' %} -

+

{% translate "Browse posts" %} -

+
{% include 'blog/featured.html' %} diff --git a/gawa/blog/views.py b/gawa/blog/views.py index d48c2a8..45784d6 100644 --- a/gawa/blog/views.py +++ b/gawa/blog/views.py @@ -9,13 +9,11 @@ from django.views.generic import TemplateView, DetailView, ListView, View from django.db.models import Q from .models import BlogPost, Category, Keyword -from start.views import SearchableView - import logging logger = logging.getLogger(__name__) -class Index(TemplateView, SearchableView): +class Index(TemplateView): """ The index page of the gawa/blog app. @@ -51,7 +49,6 @@ class Browse(ListView): Scroll through a list of blog posts There should also be some kind of filter, for category and date. - Of course, Articles will also show up in the MainSearchView """ model = BlogPost diff --git a/gawa/locale/de/LC_MESSAGES/django.mo b/gawa/locale/de/LC_MESSAGES/django.mo index c929092912e4e08fa2d1debf7ef7d0e1945242f8..2325b55bb90b64a81f22b271f7f3624944eee015 100644 GIT binary patch delta 1630 zcmX}sOGs2v9LMp$Homg5GGC=RX1+=*EiH32A3d}dHnyms2x~x$2#XfIY;0rE!-_$o z62w3-B8aAMf3LbaxKIe)GAr0dv&+Tj(~?nfQ@ z5USsZyZ+F%Um}NN18pkyNlULJw-PW}=eVOw1G?6`jBeqJ*d-RJIWnky>;^T9k_B)clb`{uw6}`431w zS_2VBuqor8T%?pcx1c^(k~#7jk%RvWi5+>rO2S%qRbPmTK2a5Yn&h>uCu%gmj%6vK zqIa#=v5wI0NqlQ0bRsHsQEV0JHPjRF#8!fwi@bBNYW+|+yhxs?u0&l;Y*NFOG9|}M zS?elI=p{B1D+#@pT*5*V$$8;7@t0CUyVJWvKhwvF_DnlA9Jn!=2<`B_UUY_6nFiNFX& zznG|mmx1O7d869kQqN1i7{~!BZ`sVzr90Fa{4>x-rIZ5 zJ@?%9+|H*Xne$7FP8hNSU4cHgz-$CwF5&|@9Wv`=>$n3R3v;OPN z&M^Py4QAu4pS;m*hWW;&W-0tjH<=xVqvd94_zT<%A6;g~mKpmLqm+TKAbZ&?RP0~# z3+#8e82>LwOe?N1BL^#kC9n$Wd-cv=0)`893A_cB;QO!`e(3lKRKPD`E&Rrf{{cPxOHlh%FV80&h9TlxD+X1w z^-uxtg=H`Tb;1}_1x8>cJOH)+d8mM|LM8U5C2oc~aVOLld!Z7JK&^WOsuDxaPeNVE zIMlkQ-1sw)$6_bl_ykntU&&z57xpgX1=$Q#;901R=O9(He_#tpqlL^sESTOeeYv8J_D8Lk5I2^4wew#{==YmY!gZ!**$14x&@UeDOE&rAIfrT zK}%2tnwL%tm3jxNN=o`r3TGQpRq)QvpLaT2*oLk{ zx5{y%?pGCbmpYw9)zB44n)AptuguNP7Z#$KHP;NRbvC_b9nRK&0x!;ZdDes0q3T>+ zkwhi#%31jaRFkT_8&Gxp1L%5G(v9AZ-XRC!y4rHTOt;~*qN_EE&;mJ8\n" "Language-Team: LANGUAGE \n" @@ -19,10 +19,6 @@ msgstr "" "Plural-Forms: nplurals=2; plural=(n != 1);\n" "X-Translated-Using: django-rosetta 0.9.9\n" -#: blog/admin.py:15 start/admin.py:8 -msgid "Regenerate traits" -msgstr "Eigenschaften regenerieren" - #: blog/models.py:44 msgid "Category" msgstr "Kategorie" @@ -31,11 +27,11 @@ msgstr "Kategorie" msgid "Categories" msgstr "Kategorien" -#: blog/models.py:282 +#: blog/models.py:295 msgid "blog post" msgstr "Blog Post" -#: blog/models.py:283 +#: blog/models.py:296 msgid "blog posts" msgstr "Blog Posts" @@ -65,7 +61,6 @@ msgid "updated" msgstr "aktualisiert" #: blog/templates/blog/browse.html:47 start/forms.py:15 -#: start/templates/main_search_form.html:3 msgid "Search" msgstr "Suche" @@ -156,11 +151,7 @@ msgstr "" "\n" "Das ist mein persönlicher Blog. Ich lade hier hoch was auch immer ich möchte." -#: blog/templates/blog/index.html:46 -msgid "Looking for anything specific?" -msgstr "Suchst du nach etwas speziellem?" - -#: blog/templates/blog/index.html:51 +#: blog/templates/blog/index.html:49 msgid "Browse posts" msgstr "Posts durchsuchen" @@ -172,6 +163,10 @@ msgstr "Deutsch" msgid "English" msgstr "Englisch" +#: start/admin.py:8 +msgid "Regenerate traits" +msgstr "Eigenschaften regenerieren" + #: start/models.py:27 msgid "Keyword" msgstr "Schlüsselwort" @@ -180,27 +175,11 @@ msgstr "Schlüsselwort" msgid "keywords" msgstr "Schlüsselwörter" -#: start/models.py:72 -msgid "Searchable" -msgstr "suchbares Objekt" - -#: start/models.py:73 -msgid "Searchables" -msgstr "suchbare Objekte" - -#: start/models.py:95 -msgid "static site" -msgstr "statische Seite" - -#: start/models.py:96 -msgid "static sites" -msgstr "statische Seiten" - -#: start/models.py:165 +#: start/models.py:109 msgid "Link" msgstr "Link" -#: start/models.py:166 start/templates/nav.html:36 +#: start/models.py:110 start/templates/nav.html:36 #: start/templates/start/legalinfo.html:8 start/templates/start/links.html:5 msgid "Links" msgstr "Links" @@ -281,10 +260,6 @@ msgstr "Kontakt" msgid "Deutschland" msgstr "Deutschland" -#: start/templates/main_search_form.html:4 -msgid "Go" -msgstr "Los" - #: start/templates/nav.html:27 start/templates/nav.html:30 #: start/templates/nav.html:54 msgid "Start" @@ -544,6 +519,24 @@ msgstr "Andere" msgid "Search for" msgstr "Suche nach" +#~ msgid "Looking for anything specific?" +#~ msgstr "Suchst du nach etwas speziellem?" + +#~ msgid "Searchable" +#~ msgstr "suchbares Objekt" + +#~ msgid "Searchables" +#~ msgstr "suchbare Objekte" + +#~ msgid "static site" +#~ msgstr "statische Seite" + +#~ msgid "static sites" +#~ msgstr "statische Seiten" + +#~ msgid "Go" +#~ msgstr "Los" + #~ msgid "Email " #~ msgstr "E-Mail" diff --git a/gawa/locale/en/LC_MESSAGES/django.po b/gawa/locale/en/LC_MESSAGES/django.po index 24ea704..b3040e2 100644 --- a/gawa/locale/en/LC_MESSAGES/django.po +++ b/gawa/locale/en/LC_MESSAGES/django.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2023-10-09 23:19+0200\n" +"POT-Creation-Date: 2023-10-10 11:46+0200\n" "PO-Revision-Date: 2023-10-08 15:18+0200\n" "Last-Translator: \n" "Language-Team: \n" @@ -18,10 +18,6 @@ msgstr "" "Plural-Forms: nplurals=2; plural=(n != 1);\n" "X-Generator: Poedit 3.3.2\n" -#: blog/admin.py:15 start/admin.py:8 -msgid "Regenerate traits" -msgstr "" - #: blog/models.py:44 msgid "Category" msgstr "" @@ -30,11 +26,11 @@ msgstr "" msgid "Categories" msgstr "" -#: blog/models.py:282 +#: blog/models.py:295 msgid "blog post" msgstr "" -#: blog/models.py:283 +#: blog/models.py:296 msgid "blog posts" msgstr "" @@ -64,7 +60,6 @@ msgid "updated" msgstr "" #: blog/templates/blog/browse.html:47 start/forms.py:15 -#: start/templates/main_search_form.html:3 msgid "Search" msgstr "" @@ -144,11 +139,7 @@ msgid "" " " msgstr "" -#: blog/templates/blog/index.html:46 -msgid "Looking for anything specific?" -msgstr "" - -#: blog/templates/blog/index.html:51 +#: blog/templates/blog/index.html:49 msgid "Browse posts" msgstr "" @@ -160,6 +151,10 @@ msgstr "" msgid "English" msgstr "" +#: start/admin.py:8 +msgid "Regenerate traits" +msgstr "" + #: start/models.py:27 msgid "Keyword" msgstr "" @@ -168,27 +163,11 @@ msgstr "" msgid "keywords" msgstr "" -#: start/models.py:72 -msgid "Searchable" -msgstr "" - -#: start/models.py:73 -msgid "Searchables" -msgstr "" - -#: start/models.py:95 -msgid "static site" -msgstr "" - -#: start/models.py:96 -msgid "static sites" -msgstr "" - -#: start/models.py:165 +#: start/models.py:109 msgid "Link" msgstr "" -#: start/models.py:166 start/templates/nav.html:36 +#: start/models.py:110 start/templates/nav.html:36 #: start/templates/start/legalinfo.html:8 start/templates/start/links.html:5 msgid "Links" msgstr "" @@ -262,10 +241,6 @@ msgstr "Contact" msgid "Deutschland" msgstr "Germany" -#: start/templates/main_search_form.html:4 -msgid "Go" -msgstr "" - #: start/templates/nav.html:27 start/templates/nav.html:30 #: start/templates/nav.html:54 msgid "Start" diff --git a/gawa/slides/migrations/__init__.py b/gawa/slides/migrations/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/gawa/start/admin.py b/gawa/start/admin.py index 5865b61..a429314 100644 --- a/gawa/start/admin.py +++ b/gawa/start/admin.py @@ -19,28 +19,6 @@ class KeywordAdmin(admin.ModelAdmin): list_display = ["text_en", "text_de"] -@admin.register(StaticSite) -class StaticSiteAdmin(admin.ModelAdmin): - """ - Admin Interface for StaticSite - """ - 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] - - @admin.register(Link) class LinkAdmin(admin.ModelAdmin): """ diff --git a/gawa/start/migrations/0001_initial.py b/gawa/start/migrations/0001_initial.py index b61b82f..35744bf 100644 --- a/gawa/start/migrations/0001_initial.py +++ b/gawa/start/migrations/0001_initial.py @@ -1,75 +1,12 @@ -# Generated by Django 3.2.21 on 2023-10-02 08:14 +# Generated by Django 4.2.6 on 2023-10-10 09:58 -from django.db import migrations, models -import django.db.models.deletion +from django.db import migrations class Migration(migrations.Migration): - initial = True - dependencies = [ ] operations = [ - migrations.CreateModel( - name='Keyword', - fields=[ - ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), - ('slug', models.SlugField(unique=True)), - ('text_de', models.CharField(max_length=40)), - ('text_en', models.CharField(max_length=40)), - ], - options={ - 'verbose_name': 'Keyword', - 'verbose_name_plural': 'keywords', - }, - ), - migrations.CreateModel( - name='Searchable', - fields=[ - ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), - ('title_de', models.CharField(default='Nicht übersetzt', max_length=50)), - ('title_en', models.CharField(default='Not translated', max_length=50)), - ('subtitle_de', models.CharField(blank=True, max_length=50)), - ('subtitle_en', models.CharField(blank=True, max_length=50)), - ('desc_de', models.TextField(blank=True, default='Keine Beschreibung', max_length=250)), - ('desc_en', models.TextField(blank=True, default='no description', max_length=250)), - ('date', models.DateTimeField(blank=True, null=True)), - ('update', models.DateTimeField(blank=True, null=True)), - ('suburl', models.CharField(blank=True, max_length=200, null=True)), - ('public', models.BooleanField(default=False)), - ('keywords', models.ManyToManyField(blank=True, to='start.Keyword')), - ], - options={ - 'verbose_name': 'Searchable', - 'verbose_name_plural': 'Searchables', - }, - ), - migrations.CreateModel( - name='Link', - fields=[ - ('searchable_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, to='start.searchable')), - ('url', models.URLField(primary_key=True, serialize=False, unique=True)), - ('favicon', models.ImageField(blank=True, null=True, upload_to='img/links/favicons')), - ('status', models.BooleanField(default=False)), - ('personal', models.BooleanField(default=False)), - ], - options={ - 'verbose_name': 'Link', - 'verbose_name_plural': 'Links', - }, - bases=('start.searchable',), - ), - migrations.CreateModel( - name='StaticSite', - fields=[ - ('searchable_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='start.searchable')), - ], - options={ - 'verbose_name': 'static site', - 'verbose_name_plural': 'static sites', - }, - bases=('start.searchable',), - ), ] diff --git a/gawa/start/migrations/0002_initial.py b/gawa/start/migrations/0002_initial.py new file mode 100644 index 0000000..4cc3b2f --- /dev/null +++ b/gawa/start/migrations/0002_initial.py @@ -0,0 +1,52 @@ +# Generated by Django 4.2.6 on 2023-10-10 09:58 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + initial = True + + dependencies = [ + ('start', '0001_initial'), + ] + + operations = [ + migrations.CreateModel( + name='Keyword', + fields=[ + ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('slug', models.SlugField(unique=True)), + ('text_de', models.CharField(max_length=40)), + ('text_en', models.CharField(max_length=40)), + ], + options={ + 'verbose_name': 'Keyword', + 'verbose_name_plural': 'keywords', + }, + ), + migrations.CreateModel( + name='Link', + fields=[ + ('url', models.URLField(primary_key=True, serialize=False, unique=True)), + ('favicon', models.ImageField(blank=True, null=True, upload_to='img/links/favicons')), + ('status', models.BooleanField(default=False)), + ('personal', models.BooleanField(default=False)), + ('title_de', models.CharField(default='Nicht übersetzt', max_length=50)), + ('title_en', models.CharField(default='Not translated', max_length=50)), + ('subtitle_de', models.CharField(blank=True, max_length=50)), + ('subtitle_en', models.CharField(blank=True, max_length=50)), + ('desc_de', models.TextField(blank=True, default='Keine Beschreibung', max_length=250)), + ('desc_en', models.TextField(blank=True, default='no description', max_length=250)), + ('date', models.DateTimeField(blank=True, null=True)), + ('update', models.DateTimeField(blank=True, null=True)), + ('suburl', models.CharField(blank=True, max_length=200, null=True)), + ('public', models.BooleanField(default=False)), + ('keywords', models.ManyToManyField(blank=True, to='start.keyword')), + ], + options={ + 'verbose_name': 'Link', + 'verbose_name_plural': 'Links', + }, + ), + ] diff --git a/gawa/start/models.py b/gawa/start/models.py index b81660f..3652a09 100644 --- a/gawa/start/models.py +++ b/gawa/start/models.py @@ -27,14 +27,17 @@ class Keyword(models.Model): verbose_name = _("Keyword") verbose_name_plural = _("keywords") - -class Searchable(models.Model): +class Link(models.Model): """ - Abstract class for any model that should be searchable. - This model will be searched for by the searchbox that is in every upper part of the website. - - This class is not a real abstract class, I need to query it in the main search, so thats impossible + contains all my interesting links """ + + # the actual link + url = models.URLField(unique=True, null=False, primary_key=True) + favicon_dir: str = "img/links/favicons" + favicon = models.ImageField(blank=True, upload_to=favicon_dir, null=True) + status = models.BooleanField(default=False) + personal = models.BooleanField(default=False) title_de = models.CharField(max_length=50, default="Nicht übersetzt") title_en = models.CharField(max_length=50, default="Not translated") subtitle_de = models.CharField(max_length=50, blank=True) @@ -49,65 +52,6 @@ class Searchable(models.Model): suburl = models.CharField(max_length=200, blank=True, null=True) public = models.BooleanField(default=False) - @classmethod - def regenerate_all_entries(cls): - """ - regenerate all searchable items - """ - logger.info(f"regenerating all {Searchable.__name__} entries") - for obj in cls.objects.all(): - obj.regenerate() - - def __str__(self): - return f"{{<{self.__class__.__name__}>\"{self.title_en}\"}}" - - def regenerate(self): - """ - regenerate a object - """ - raise NotImplementedError( - f"{self.__class__.__name__} does not implement regenerate") - - class Meta: - verbose_name = _("Searchable") - verbose_name_plural = _("Searchables") - - -class StaticSite(Searchable): - """ - This model represents any static site, such as start:index, - that should show up in search. - - Every searchable view should inherit from start.views.SearchableView. - # 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 - - class Meta: - verbose_name = _("static site") - verbose_name_plural = _("static sites") - - -class Link(Searchable): - """ - contains all my interesting links - """ - - # the actual link - url = models.URLField(unique=True, null=False, primary_key=True) - favicon_dir: str = "img/links/favicons" - favicon = models.ImageField(blank=True, upload_to=favicon_dir, null=True) - status = models.BooleanField(default=False) - personal = models.BooleanField(default=False) - def __str__(self): return f"{{<{self.__class__.__name__}>\"{self.title_en}\"}}" diff --git a/gawa/start/templates/main_search_form.html b/gawa/start/templates/main_search_form.html deleted file mode 100644 index e24787b..0000000 --- a/gawa/start/templates/main_search_form.html +++ /dev/null @@ -1,5 +0,0 @@ -{% load i18n %} - diff --git a/gawa/start/templates/nav.html b/gawa/start/templates/nav.html index 1c9dd08..8de43dc 100644 --- a/gawa/start/templates/nav.html +++ b/gawa/start/templates/nav.html @@ -119,7 +119,6 @@ {% endif %} - diff --git a/gawa/start/urls.py b/gawa/start/urls.py index e0d23a9..3c26fd9 100644 --- a/gawa/start/urls.py +++ b/gawa/start/urls.py @@ -5,7 +5,6 @@ from . import views app_name: str = "start" urlpatterns = [ path("", views.Index.as_view(), name="index"), - path("search/", views.MainSearch.as_view(), name="search"), path("reporting/", views.Reporting.as_view(), name="reporting"), path("legal/", views.LegalInfo.as_view(), name="legal"), path("links/", views.Links.as_view(), name="links"), diff --git a/gawa/start/views.py b/gawa/start/views.py index 78420f4..23684ad 100644 --- a/gawa/start/views.py +++ b/gawa/start/views.py @@ -11,8 +11,7 @@ from django.views.static import loader from django.views import i18n from requests import request -from .forms import MainSearchForm -from .models import Link, Searchable +from .models import Link from abc import ABC @@ -20,30 +19,18 @@ import logging logger = logging.getLogger(__name__) -class SearchableView(View, ABC): - """ - This abstract view implements some traits of views that should show up - in the main search - """ - title: str - subtitle: str - desc: str - date: None = None - keywords: list[str] - - -class Index(TemplateView, SearchableView): +class Index(TemplateView): """ The index page of the gawa app. - Utilizes a generic view, because I will do so for all views, + Utilizes a generic view, because I will do so for all views, a regular view function would suffice. """ template_name: str = "start/index.html" -class Professional(TemplateView, SearchableView): +class Professional(TemplateView): """ Professional informations that might interest a professional employer """ @@ -51,7 +38,7 @@ class Professional(TemplateView, SearchableView): template_name: str = "start/legalinfo.html" -class Reporting(TemplateView, SearchableView): +class Reporting(TemplateView): """ Reporting Interface and information about the allowed scope of searching for security issues. @@ -59,39 +46,14 @@ class Reporting(TemplateView, SearchableView): # TODO template_name: str = "start/reporting.html" -class LegalInfo(TemplateView, SearchableView): + +class LegalInfo(TemplateView): """ Legal info that the german authorities want. """ # TODO template_name: str = "start/legalinfo.html" -class MainSearch(ListView): - """ - Search for anything. - """ - - model = Searchable - object_list = [] # this is only declaration, the view breaks without it. - template_name: str = "start/search.html" - - def get_queryset(self) -> QuerySet: - search = self.request.GET.get("search") - object_list = Searchable.objects.filter( - Q(title_de__icontains=search) | Q(title_en__icontains=search) | - Q(subtitle_de__icontains=search) | Q(subtitle_en__icontains=search) | - Q(desc_de__icontains=search) | Q(desc_en__icontains=search) | - Q(public=True) - ) - object_list = object_list.filter(public=True) - return object_list - - def get(self, request, *args, **kwargs): - form = MainSearchForm(request.GET) - if not form.is_valid(): - return render(request, "errors/bad_request.html") - return super().get(request, *args, **kwargs) - class Links(ListView): """