##// END OF EJS Templates
Tag colors
neko259 -
r1338:cfd49604 default
parent child Browse files
Show More
@@ -1,3 +1,4 b''
1 import hashlib
1 from django.template.loader import render_to_string
2 from django.template.loader import render_to_string
2 from django.db import models
3 from django.db import models
3 from django.db.models import Count
4 from django.db.models import Count
@@ -106,4 +107,11 b' class Tag(models.Model, Viewable):'
106
107
107 def get_related_tags(self):
108 def get_related_tags(self):
108 return set(Tag.objects.filter(thread_tags__in=self.get_threads()).exclude(
109 return set(Tag.objects.filter(thread_tags__in=self.get_threads()).exclude(
109 id=self.id).order_by('?')[:RELATED_TAGS_COUNT])
110 id=self.id).order_by('?')[:RELATED_TAGS_COUNT])
111
112 @cached_result()
113 def get_color(self):
114 """
115 Gets color hashed from the tag name.
116 """
117 return hashlib.md5(self.name.encode()).hexdigest()[:6]
@@ -37,7 +37,7 b''
37 {% endfor %}
37 {% endfor %}
38
38
39 {% if tag %}
39 {% if tag %}
40 <div class="tag_info">
40 <div class="tag_info" style="border-bottom: solid .5ex #{{ tag.get_color }}">
41 {% if random_image_post %}
41 {% if random_image_post %}
42 <div class="tag-image">
42 <div class="tag-image">
43 {% with image=random_image_post.images.first %}
43 {% with image=random_image_post.images.first %}
General Comments 0
You need to be logged in to leave comments. Login now