from flask import Blueprint
from flask_jwt_extended import jwt_required

from median.models import Unite

unit_blueprint = Blueprint('unit', __name__)


@unit_blueprint.route('/all', methods=['GET'])
@jwt_required()
def get_all():
    req = Unite.select(Unite)

    return {'data': [{'pk': item.pk, 'code': item.unite} for item in req]
            }, 200
