revamp-file-discover #33
|
@ -0,0 +1,18 @@
|
||||||
|
# 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),
|
||||||
|
),
|
||||||
|
]
|
|
@ -76,7 +76,7 @@ class BlogPost(Searchable):
|
||||||
body_de = models.TextField(blank=True,
|
body_de = models.TextField(blank=True,
|
||||||
default="""This aritcle is not available in english.""")
|
default="""This aritcle is not available in english.""")
|
||||||
category = models.ForeignKey(
|
category = models.ForeignKey(
|
||||||
Category, on_delete=models.SET_DEFAULT, null=False,
|
Category, on_delete=models.SET_DEFAULT, blank=False,
|
||||||
default=Category.get_or_create_uncategorized)
|
default=Category.get_or_create_uncategorized)
|
||||||
thumbnail = models.ImageField(
|
thumbnail = models.ImageField(
|
||||||
blank=True,
|
blank=True,
|
||||||
|
@ -85,7 +85,15 @@ class BlogPost(Searchable):
|
||||||
featured = models.BooleanField(default=False)
|
featured = models.BooleanField(default=False)
|
||||||
langs = models.CharField(
|
langs = models.CharField(
|
||||||
default=DEFAULT_LANGS.__repr__(), max_length=64)
|
default=DEFAULT_LANGS.__repr__(), max_length=64)
|
||||||
slug = models.SlugField()
|
slug = models.SlugField(unique=True, blank=False)
|
||||||
|
|
||||||
|
def save(self):
|
||||||
|
# check if the slug is empty if we remove whitespaces
|
||||||
|
if len(self.slug.strip()) == 0:
|
||||||
|
logger.error(
|
||||||
|
f"trying to save '{self.__class__}' with empty slug: {self}")
|
||||||
|
raise ValueError(f"trying to save '{self.__class__}' with empty slug: {self}")
|
||||||
|
super().save()
|
||||||
|
|
||||||
def regenerate(self):
|
def regenerate(self):
|
||||||
"""
|
"""
|
||||||
|
@ -239,7 +247,9 @@ class BlogPost(Searchable):
|
||||||
try:
|
try:
|
||||||
matches = re.match(regex, file[0])
|
matches = re.match(regex, file[0])
|
||||||
if matches is None:
|
if matches is None:
|
||||||
|
# file is not a toml / meta file
|
||||||
files.remove(file)
|
files.remove(file)
|
||||||
|
continue
|
||||||
else:
|
else:
|
||||||
current_lang = matches.group(1)
|
current_lang = matches.group(1)
|
||||||
file[1] = matches.group(1)
|
file[1] = matches.group(1)
|
||||||
|
|
|
@ -75,7 +75,7 @@ class Searchable(models.Model):
|
||||||
|
|
||||||
class StaticSite(Searchable):
|
class StaticSite(Searchable):
|
||||||
"""
|
"""
|
||||||
This model represents any static site, such as start:index,
|
This model represents any static site, such as start:index,
|
||||||
that should show up in search.
|
that should show up in search.
|
||||||
|
|
||||||
Every searchable view should inherit from start.views.SearchableView.
|
Every searchable view should inherit from start.views.SearchableView.
|
||||||
|
|
Loading…
Reference in New Issue