# Path: src/bepasty/constants.py
# COMPLETE = 'complete'
# 
# FILENAME = 'filename'
# 
# LOCKED = 'locked'
# 
# Path: src/bepasty/utils/http.py
# def redirect_next_referrer(endpoint, **values):
#     return redirect(_redirect_target_url(request.form, True, endpoint, **values))
# 
# Path: src/bepasty/utils/permissions.py
# ADMIN = 'admin'
# 
# def may(permission):
#     """
#     check whether the current user has the permission <permission>
#     """
#     return permission in flaskg.permissions


import errno
from flask import current_app, render_template
from flask.views import MethodView
from werkzeug.exceptions import NotFound, Forbidden
from ..constants import COMPLETE, FILENAME, LOCKED
from ..utils.http import redirect_next_referrer
from ..utils.permissions import ADMIN, may
"""
Set metadata keys to specific values
"""





class SetKeyValueView(MethodView):
    # overwrite these in subclasses:
    REQUIRED_PERMISSION = None
    KEY = None
    NEXT_VALUE = None

    def error(self, item, error):
        return render_template('error.html', heading=item.meta[FILENAME], body=error), 409

    def response(self, name):

# Path: src/bepasty/constants.py
# COMPLETE = 'complete'
# 
# FILENAME = 'filename'
# 
# LOCKED = 'locked'
# 
# Path: src/bepasty/utils/http.py
# def redirect_next_referrer(endpoint, **values):
#     return redirect(_redirect_target_url(request.form, True, endpoint, **values))
# 
# Path: src/bepasty/utils/permissions.py
# ADMIN = 'admin'
# 
# def may(permission):
#     """
#     check whether the current user has the permission <permission>
#     """
#     return permission in flaskg.permissions


# Path: src/bepasty/views/setkv.py
import errno
from flask import current_app, render_template
from flask.views import MethodView
from werkzeug.exceptions import NotFound, Forbidden
from ..constants import COMPLETE, FILENAME, LOCKED
from ..utils.http import redirect_next_referrer
from ..utils.permissions import ADMIN, may

"""
Set metadata keys to specific values
"""





class SetKeyValueView(MethodView):
    # overwrite these in subclasses:
    REQUIRED_PERMISSION = None
    KEY = None
    NEXT_VALUE = None

    def error(self, item, error):
        return render_template('error.html', heading=item.meta[FILENAME], body=error), 409

    def response(self, name):

        return redirect_next_referrer('bepasty.display', name=name)