nopaque/app/utils.py

16 lines
353 B
Python
Raw Normal View History

2021-11-30 16:22:16 +01:00
from app import hashids
from werkzeug.routing import BaseConverter
2021-12-03 14:07:03 +01:00
from .models import Permission
2021-11-30 16:22:16 +01:00
class HashidConverter(BaseConverter):
def to_python(self, value):
return hashids.decode(value)[0]
def to_url(self, value):
return hashids.encode(value)
2021-12-03 14:07:03 +01:00
def permission_context_processor():
return {'Permission': Permission}