def modify_acl(item_name): fqname = split_fqname(item_name) item = Item.create(item_name) meta = dict(item.meta) old_acl = meta.get(ACL, '') new_acl = request.form.get(fqname.fullname) is_valid = acl_validate(new_acl) if is_valid: if new_acl in ('Empty', ''): meta[ACL] = '' elif new_acl == 'None' and ACL in meta: del (meta[ACL]) else: meta[ACL] = new_acl try: item._save(meta=meta) except AccessDenied: # superuser viewed item acl report and tried to change acl but lacked admin permission flash( L_("Failed! Not authorized.<br>Item: %(item_name)s<br>ACL: %(acl_rule)s", item_name=fqname.fullname, acl_rule=old_acl), "error") return redirect(url_for('.item_acl_report')) flash( L_("Success! ACL saved.<br>Item: %(item_name)s<br>ACL: %(acl_rule)s", item_name=fqname.fullname, acl_rule=new_acl), "info") else: flash( L_("Nothing changed, invalid ACL.<br>Item: %(item_name)s<br>ACL: %(acl_rule)s", item_name=fqname.fullname, acl_rule=new_acl), "error") return redirect(url_for('.item_acl_report'))
def modify_acl(item_name): fqname = split_fqname(item_name) item = Item.create(item_name) meta = dict(item.meta) new_acl = request.form.get(fqname.fullname) is_valid = acl_validate(new_acl) if is_valid: if new_acl in ('Empty', ''): meta[ACL] = '' elif new_acl == 'None' and ACL in meta: del(meta[ACL]) else: meta[ACL] = new_acl item._save(meta=meta) flash(L_("Success! ACL saved.<br>Item: %(item_name)s<br>ACL: %(acl_rule)s", item_name=fqname.fullname, acl_rule=new_acl), "info") else: flash(L_("Nothing changed, invalid ACL.<br>Item: %(item_name)s<br>ACL: %(acl_rule)s", item_name=fqname.fullname, acl_rule=new_acl), "error") return redirect(url_for('.item_acl_report'))