# Path: app/extensions/api/http_exceptions.py
# def abort(code, message=None, **kwargs):
#     """
#     Custom abort function used to provide extra information in the error
#     response, namely, ``status`` and ``message`` info.
#     """
#     if message is None:
#         if code in API_DEFAULT_HTTP_CODE_MESSAGES:  # pylint: disable=consider-using-get
#             message = API_DEFAULT_HTTP_CODE_MESSAGES[code]
#         else:
#             message = HTTPStatus(code).description  # pylint: disable=no-value-for-parameter
#     restplus_abort(code=code, status=code, message=message, **kwargs)


from flask_login import current_user
from flask_restplus._http import HTTPStatus
from permission import Rule as BaseRule
from app.extensions.api import abort
# encoding: utf-8
# pylint: disable=too-few-public-methods,invalid-name,abstract-method,method-hidden
"""
RESTful API Rules
-----------------------
"""



class DenyAbortMixin(object):
    """
    A helper permissions mixin raising an HTTP Error (specified in
    ``DENY_ABORT_CODE``) on deny.

    NOTE: Apply this mixin before Rule class so it can override NotImplemented
    deny method.
    """

    DENY_ABORT_HTTP_CODE = HTTPStatus.FORBIDDEN
    DENY_ABORT_MESSAGE = None

    def deny(self):
        """
        Abort HTTP request by raising HTTP error exception with a specified
        HTTP code.
        """

# Path: app/extensions/api/http_exceptions.py
# def abort(code, message=None, **kwargs):
#     """
#     Custom abort function used to provide extra information in the error
#     response, namely, ``status`` and ``message`` info.
#     """
#     if message is None:
#         if code in API_DEFAULT_HTTP_CODE_MESSAGES:  # pylint: disable=consider-using-get
#             message = API_DEFAULT_HTTP_CODE_MESSAGES[code]
#         else:
#             message = HTTPStatus(code).description  # pylint: disable=no-value-for-parameter
#     restplus_abort(code=code, status=code, message=message, **kwargs)


# Path: app/modules/users/permissions/rules.py
from flask_login import current_user
from flask_restplus._http import HTTPStatus
from permission import Rule as BaseRule
from app.extensions.api import abort

# encoding: utf-8
# pylint: disable=too-few-public-methods,invalid-name,abstract-method,method-hidden
"""
RESTful API Rules
-----------------------
"""



class DenyAbortMixin(object):
    """
    A helper permissions mixin raising an HTTP Error (specified in
    ``DENY_ABORT_CODE``) on deny.

    NOTE: Apply this mixin before Rule class so it can override NotImplemented
    deny method.
    """

    DENY_ABORT_HTTP_CODE = HTTPStatus.FORBIDDEN
    DENY_ABORT_MESSAGE = None

    def deny(self):
        """
        Abort HTTP request by raising HTTP error exception with a specified
        HTTP code.
        """

        return abort(code=self.DENY_ABORT_HTTP_CODE, message=self.DENY_ABORT_MESSAGE)