forked from lza_menace/suchwow
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
24 lines
521 B
24 lines
521 B
from flask import Blueprint
|
|
from arrow import get as arrow_get
|
|
|
|
from suchwow.models import Moderator
|
|
|
|
|
|
bp = Blueprint('filters', 'filters')
|
|
|
|
@bp.app_template_filter('shorten_address')
|
|
def shorten_address(a):
|
|
_p = a[0:4]
|
|
_s = a[-4:]
|
|
return f'{_p}...{_s}'
|
|
|
|
@bp.app_template_filter('humanize')
|
|
def humanize(d):
|
|
return arrow_get(d).humanize()
|
|
|
|
@bp.app_template_filter('is_moderator')
|
|
def is_moderator(s):
|
|
m = Moderator.select().where(Moderator.username == s)
|
|
if m:
|
|
return True
|
|
return False |