push
This commit is contained in:
0
app/utils/__init__.py
Normal file
0
app/utils/__init__.py
Normal file
16
app/utils/decorators.py
Normal file
16
app/utils/decorators.py
Normal file
@@ -0,0 +1,16 @@
|
||||
from functools import wraps
|
||||
from flask import abort
|
||||
from flask_login import current_user
|
||||
|
||||
|
||||
def roles_required(*roles):
|
||||
def decorator(func):
|
||||
@wraps(func)
|
||||
def wrapper(*args, **kwargs):
|
||||
if not current_user.is_authenticated:
|
||||
abort(401)
|
||||
if current_user.role not in roles:
|
||||
abort(403)
|
||||
return func(*args, **kwargs)
|
||||
return wrapper
|
||||
return decorator
|
||||
8
app/utils/formatters.py
Normal file
8
app/utils/formatters.py
Normal file
@@ -0,0 +1,8 @@
|
||||
from decimal import Decimal
|
||||
|
||||
|
||||
def pln(value):
|
||||
if value is None:
|
||||
return '0,00 zł'
|
||||
quantized = Decimal(value).quantize(Decimal('0.01'))
|
||||
return f"{quantized:,.2f} zł".replace(',', 'X').replace('.', ',').replace('X', ' ')
|
||||
Reference in New Issue
Block a user