Pavel "LEdoian" Turinsky
2 years ago
3 changed files with 18 additions and 1 deletions
@ -0,0 +1,15 @@ |
|||||
|
from django import template |
||||
|
register = template.Library() |
||||
|
|
||||
|
from functools import cache |
||||
|
import seminar.models as m |
||||
|
|
||||
|
@register.filter |
||||
|
@cache |
||||
|
def barva_reseni(r: m.Reseni): |
||||
|
"""Vrátí nějakou barvu pro daný problém, ve tvaru '#RRGGBB' |
||||
|
|
||||
|
Efektivně hešujeme do barev.""" |
||||
|
|
||||
|
#TODO: ne všechny barvy jsou dobře rozlišitelné a vidět… |
||||
|
return f'#{hash(str(r.id)) & 0xffffff:06x}' |
Loading…
Reference in new issue