diff --git a/district/models.py b/district/models.py index a853eff4b430c9e38f92c9cc9bd84eb2527cc00a..2ac741319cf42be50e02ab0ecc568456df5930d7 100644 --- a/district/models.py +++ b/district/models.py @@ -106,7 +106,6 @@ class DistrictHomePage(MetadataPageMixin, Page): ### RELATIONS subpage_types = [ - "shared.Article", "shared.PeoplePage", "DistrictArticles", "DistrictContact", @@ -153,6 +152,10 @@ class DistrictArticles(SharedSubpageMixin, MetadataPageMixin, Page): settings_panels = [] + subpage_types = [ + "shared.Article", + ] + ### OTHERS class Meta: @@ -161,8 +164,7 @@ class DistrictArticles(SharedSubpageMixin, MetadataPageMixin, Page): def get_context(self, request): context = super().get_context(request) context["articles"] = Paginator( - self.get_siblings(inclusive=False).type(Article).live().specific(), - self.max_items or 5, + self.get_children().live().specific(), self.max_items or 5, ).get_page(request.GET.get("page")) return context diff --git a/district/templates/shared/article.html b/district/templates/shared/article.html index 2ba81e80bcc253124c7388bd6720f0bfff9a5e21..4b376b6000c16df1fe71c8ea350d4648e0b3522e 100644 --- a/district/templates/shared/article.html +++ b/district/templates/shared/article.html @@ -20,7 +20,7 @@ <span class="pr-2">{{ page.last_published_at|date:"SHORT_DATE_FORMAT" }}</span> <span class="pl-2" itemprop="author" itemtype="http://schema.org/Person" itemscope=""> <span itemprop="name"> - <a href="#">{{ page.author }}</a> + <a href="{{ page.author.url }}">{{ page.author }}</a> </span> </span> </div> diff --git a/shared/migrations/0009_remove_article_author.py b/shared/migrations/0009_remove_article_author.py new file mode 100644 index 0000000000000000000000000000000000000000..b2eab9f311148816dd85535606f5167ace7ebf0a --- /dev/null +++ b/shared/migrations/0009_remove_article_author.py @@ -0,0 +1,14 @@ +# Generated by Django 3.1.1 on 2020-10-14 13:13 + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ("shared", "0008_personpage_search_image"), + ] + + operations = [ + migrations.RemoveField(model_name="article", name="author",), + ] diff --git a/shared/migrations/0010_article_author.py b/shared/migrations/0010_article_author.py new file mode 100644 index 0000000000000000000000000000000000000000..d3ce43b670b99c65a2f84b0925ecbf1eae611e83 --- /dev/null +++ b/shared/migrations/0010_article_author.py @@ -0,0 +1,25 @@ +# Generated by Django 3.1.1 on 2020-10-14 13:13 + +import django.db.models.deletion +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ("shared", "0009_remove_article_author"), + ] + + operations = [ + migrations.AddField( + model_name="article", + name="author", + field=models.ForeignKey( + blank=True, + null=True, + on_delete=django.db.models.deletion.PROTECT, + to="shared.personpage", + verbose_name="Autor článku", + ), + ), + ] diff --git a/shared/models.py b/shared/models.py index d056505375c915cbd3f4d9b1cfb878c5d6c83105..065513a82422835e46333e614ea5c3f38dadb128 100644 --- a/shared/models.py +++ b/shared/models.py @@ -45,8 +45,14 @@ class Article(SharedSubpageMixin, MetadataPageMixin, Page): null=True, verbose_name="obrázek", ) - author = models.TextField("autor článku", blank=True) tags = ClusterTaggableManager(through=ArticleTag, blank=True) + author = models.ForeignKey( + "shared.PersonPage", + verbose_name="Autor článku", + on_delete=models.PROTECT, + null=True, + blank=True, + ) ### PANELS diff --git a/shared/templates/shared/article_preview.html b/shared/templates/shared/article_preview.html index 73b95c7a7e6d7079e4ffbb4b176a0e07a1688703..0a46e88aea09a64f7d1644a8e4b21766672a08a2 100644 --- a/shared/templates/shared/article_preview.html +++ b/shared/templates/shared/article_preview.html @@ -33,7 +33,7 @@ <meta itemprop="datePublished" content="{{ article.last_published_at }}" /> </span> <span class="article-card-meta__item" itemprop="author" itemtype="http://schema.org/Person" itemscope=""> - <span itemprop="name">{{ article.author }}</span> + <span itemprop="name">{{ article.author.name }}</span> </span> </div>