Skip to content
Snippets Groups Projects
Commit eecd0e50 authored by jan.bednarik's avatar jan.bednarik
Browse files

shared: ArticleMixin upgrades

parent f89e0b30
No related branches found
No related tags found
2 merge requests!187Release,!186Uniweb články
......@@ -25,7 +25,11 @@ class SubpageMixin:
class ArticleMixin(models.Model):
"""Common fields for articles"""
"""
Common fields for articles
If you want to tag articles, add tags as `tags` field in article page model.
"""
RICH_TEXT_FEATURES = [
"h2",
......@@ -66,6 +70,18 @@ class ArticleMixin(models.Model):
class Meta:
abstract = True
@classmethod
def has_tags(cls):
try:
cls._meta.get_field("tags")
except models.FieldDoesNotExist:
return False
return True
def tag_filter_page(self):
"""Page used for filtering by tags in url like `?tag=foo`."""
return self.get_parent()
class Person(models.Model):
"""Informace o Piratovi. Slouzi prevazne jako cache informaci o osobe pro
......
......@@ -41,20 +41,15 @@
</a>
<p class="card-body-text flex-grow">{{ article.perex }}</p>
{# TODO tags #}
{% comment %}
<div class="inline-block-nogap mt-4">
<button class="btn article-card__category-button btn--grey-125 btn--condensed text-sm font-light">
<div class="btn__body ">Kategorie 1</div>
</button>
<button class="btn article-card__category-button btn--grey-125 btn--condensed text-sm font-light">
<div class="btn__body ">Kategorie 2</div>
</button>
<button class="btn article-card__category-button btn--grey-125 btn--condensed text-sm font-light">
<div class="btn__body ">Dlouhá kategorie 3</div>
</button>
</div>
{% endcomment %}
{% if article.has_tags %}
<div class="inline-block-nogap mt-4">
{% for tag in article.tags.all %}
<a href="{% pageurl article.tag_filter_page %}?tag={{ tag }}" class="btn article-card__category-button btn--grey-125 btn--condensed text-sm font-light">
<div class="btn__body ">{{ tag }}</div>
</a>
{% endfor %}
</div>
{% endif %}
</div>
</article>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment