# Path: app/models.py
# class PatchState(DeclEnum):
#     unreviewed = "U", "Unreviewed"
#     comments = "C", "Comments"
#     accepted = "A", "Accepted"
#     rejected = "R", "Rejected"


from functools import wraps
from flask import render_template, request, url_for
from app.models import PatchState

def filterable(f):
    """Filter a query"""
    @wraps(f)
    def wrapped(*args, **kwargs):
        d = f(*args, **kwargs)

        q = d['query']

        state = request.args.get('state', None, type=str)
        if state:

# Path: app/models.py
# class PatchState(DeclEnum):
#     unreviewed = "U", "Unreviewed"
#     comments = "C", "Comments"
#     accepted = "A", "Accepted"
#     rejected = "R", "Rejected"


# Path: app/views/decorators.py
from functools import wraps
from flask import render_template, request, url_for
from app.models import PatchState


def filterable(f):
    """Filter a query"""
    @wraps(f)
    def wrapped(*args, **kwargs):
        d = f(*args, **kwargs)

        q = d['query']

        state = request.args.get('state', None, type=str)
        if state:

            q = q.filter_by(state=PatchState.from_string(state))