nkdsu.apps.vote.templatetags package¶
Submodules¶
nkdsu.apps.vote.templatetags.vote_tags module¶
- nkdsu.apps.vote.templatetags.vote_tags.votes_for(track: Track, show: Show) → QuerySet[source]¶
Return all votes applicable to to track for show.
- nkdsu.apps.vote.templatetags.vote_tags.when(date: datetime) → str[source]¶
Convert a date into an appropriately relative human-readable date.
- nkdsu.apps.vote.templatetags.vote_tags.percent(flt: float | None) → str[source]¶
Convert a float into a percentage string.
>>> percent(2.5) '250%' >>> percent(2/3) '67%' >>> percent(None) '[in flux]'
- nkdsu.apps.vote.templatetags.vote_tags.format_otp(number: int) → str[source]¶
Put non-breaking spaces into the string representation of a number every three digits (from the left).
>>> format_otp(123) '123' >>> format_otp(123456) '123 456' >>> format_otp(1234567) '123 456 7'
- nkdsu.apps.vote.templatetags.vote_tags.markdown(text: str) → SafeString[source]¶
Render markdown content as HTML.
- Warning:
Do not use with user-provided strings, or XSS attacks will immediately be possible.
- nkdsu.apps.vote.templatetags.vote_tags.eligible_for(track: Track, user: User | AnonymousUser) → bool[source]¶
- nkdsu.apps.vote.templatetags.vote_tags.url_display(url: str) → str[source]¶
Strip the scheme and unquote %-sequences in a URL, if present.
>>> url_display('https://nkd.su/path?q=s#fragment') 'nkd.su/path?q=s#fragment' >>> url_display('ftps://nkd.su/p%C3%A4th?q=s#fragment') 'nkd.su/päth?q=s#fragment' >>> url_display('not a url') 'not a url'