update tag links

This commit is contained in:
2022-01-05 22:53:42 +00:00
parent 351e0324ac
commit e7a1265666
4 changed files with 24 additions and 6 deletions

View File

@@ -179,6 +179,23 @@ class Post(models.Model):
def tag_string(self):
return self.get_tags()
@property
def three_tag_names(self):
tag_lst = []
count = 0
for t in self.tags.names():
tag_lst.append(t)
count += 1
if count > 2:
break
return tag_lst
@property
def tag_names(self):
return [t for t in self.tags.names()]
@property
def imageurl(self):
""" returns the url to the image"""

View File

@@ -113,6 +113,7 @@ def tags(request, tag=""):
"featured_post": featured_post,
"job_members": job_members,
"tags_list": None,
"tag": tag,
}
return render(request, "posts/tag.html", context)

View File

@@ -2,9 +2,9 @@
<div class="article-cover-desc">
<div class="article-cover-desc-items">
<ul class="article-cover-tags">
<li><a href="#">#fet</a></li>
<li><a href="#">#ug</a></li>
<li><a href="#">#öh</a></li>
{% for t in post.three_tag_names %}
<li><a href="{% url 'posts:posts.tags' t %}">#{{ t }}</a></li>
{% endfor %}
</ul>
<div>
<a href="{{ post.url }}"><h3 class="text-gray-50">{{ post.title | safe }}</h3></a>

View File

@@ -48,9 +48,9 @@
<section>
<div class="mb-4 flex flex-col sm:flex-col gap-2 mx-auto">
<ul class="px-4 sm:px-0 mb-2 flex flex-row justify-center gap-2 sm:gap-4 flex-wrap text-blue-700 text-sm uppercase tracking-wide sm:font-medium">
<li class="inline-block py-1 px-2 bg-blue-100 rounded-full"><a href="#">#fachschaft</a></li>
<li class="inline-block py-1 px-2 bg-blue-100 rounded-full"><a href="#">#WelcomeDay</a></li>
<li class="inline-block py-1 px-2 bg-blue-100 rounded-full"><a href="#">#Inskriptionsberatung</a></li>
{% for t in post.tag_names %}
<li class="inline-block py-1 px-2 bg-blue-100 rounded-full"><a href="{% url 'posts:posts.tags' t %}">#{{ t }}</a></li>
{% endfor %}
</ul>
<h1 class="px-4 sm:px-0 text-lg sm:text-xl lg:text-3xl text-center sm:text-left font-medium text-gray-900 font-serif tracking-wider leading-normal" style="line-height: 1.5;">{{ post.title|tags_to_url }}</h1>
<div class="mx-auto max-w-max sm:mx-0 sm:max-w-none sm:flex justify-between items-center">