[pricelist] add user options pricelist_view
This commit is contained in:
parent
2d31cda665
commit
f5624e9a7d
|
@ -536,7 +536,6 @@ def post_pricelist_settings_min_prices(current_session):
|
||||||
return no_content()
|
return no_content()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@PriceListPlugin.blueprint.route("/users/<userid>/pricecalc_columns", methods=["GET", "PUT"])
|
@PriceListPlugin.blueprint.route("/users/<userid>/pricecalc_columns", methods=["GET", "PUT"])
|
||||||
@login_required()
|
@login_required()
|
||||||
def get_columns(userid, current_session):
|
def get_columns(userid, current_session):
|
||||||
|
@ -569,6 +568,39 @@ def get_columns(userid, current_session):
|
||||||
return no_content()
|
return no_content()
|
||||||
|
|
||||||
|
|
||||||
|
@PriceListPlugin.blueprint.route("/users/<userid>/pricelist", methods=["GET", "PUT"])
|
||||||
|
@login_required()
|
||||||
|
def get_priclist_setting(userid, current_session):
|
||||||
|
"""Get pricelistsetting of an user
|
||||||
|
|
||||||
|
Route: ``/pricelist/user/<userid>/pricelist`` | Method: ``GET`` or ``PUT``
|
||||||
|
|
||||||
|
POST-data: on ``PUT`` ``{value: boolean}``
|
||||||
|
|
||||||
|
Args:
|
||||||
|
userid: Userid identifying the user
|
||||||
|
current_session: Session sent wth Authorization Header
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
GET: JSON object containing the value as boolean or HTTP-error
|
||||||
|
PUT: HTTP-NoContent or HTTP-error
|
||||||
|
"""
|
||||||
|
|
||||||
|
if userid != current_session.user_.userid:
|
||||||
|
raise Forbidden
|
||||||
|
|
||||||
|
user = userController.get_user(userid)
|
||||||
|
if request.method == "GET":
|
||||||
|
return jsonify(user.get_attribute("pricelist_view", {"value": False}))
|
||||||
|
else:
|
||||||
|
data = request.get_json()
|
||||||
|
if not isinstance(data, dict) or not "value" in data or not isinstance(data["value"], bool):
|
||||||
|
raise BadRequest
|
||||||
|
user.set_attribute("pricelist_view", data)
|
||||||
|
userController.persist()
|
||||||
|
return no_content()
|
||||||
|
|
||||||
|
|
||||||
@PriceListPlugin.blueprint.route("/drinks/<int:identifier>/picture", methods=["POST", "GET", "DELETE"])
|
@PriceListPlugin.blueprint.route("/drinks/<int:identifier>/picture", methods=["POST", "GET", "DELETE"])
|
||||||
@login_required(permission=permissions.EDIT)
|
@login_required(permission=permissions.EDIT)
|
||||||
def set_picture(identifier, current_session):
|
def set_picture(identifier, current_session):
|
||||||
|
|
Loading…
Reference in New Issue