diff --git a/core/models.py b/core/models.py index c581c129..2aaab6d1 100644 --- a/core/models.py +++ b/core/models.py @@ -1,5 +1,6 @@ # -*- coding: utf-8 -*- import random +import re from datetime import timedelta from typing import Iterable, Optional @@ -120,6 +121,20 @@ class Tag(TagBase): blank=False, ) + @property + def complementary_color(self): + DARK, LIGHT = '#101010', '#EFEFEF' + if not self.color: + return DARK + + + r, g, b = [int(x, 16) for x in re.match("#(..)(..)(..)", self.color).groups()] + yiq = ((r * 299) + (g * 587) + (b * 114)) // 1000 + if yiq >= 128: + return DARK + else: + return LIGHT + class Tagged(GenericTaggedItemBase): tag = models.ForeignKey( diff --git a/core/templates/core/note_list.html b/core/templates/core/note_list.html index 77fda053..7d272221 100644 --- a/core/templates/core/note_list.html +++ b/core/templates/core/note_list.html @@ -27,6 +27,7 @@ {% trans "Child" %} {% endif %} {% trans "Note" %} + {% trans "Tags" %} @@ -54,6 +55,15 @@ {{ note.child }} {% endif %} {{ note.note }} + + {% for tag in note.tags.all %} + + {{ tag.name|escape }} + + {% empty %} + - + {% endfor %} + {% empty %}