Example #1
0
def put_self(dbsrv=dbsrv, current_user=current_user):
    try:
        args = request.get_json()
        group_id = args.get('group_id')
        action = args.get('action')
    except:
        raise err.JSONParseError("JSON Parsing Failed.")
    if action == "resign":
        dbsrv.set_admin(current_user.id, group_id, False)
    return jsonify(success)
Example #2
0
def put_user(user_id, dbsrv=dbsrv):
    """A PUT request to users will update some combination of
    name, email, and admin status."""
    try:
        args = request.get_json()
        name = args.get('name')
        email = args.get('email')
        admin = args.get('admin')
        # this is only needed if we are changing admin status
        group_id = args.get('group_id')
    except:
        raise err.JSONParseError("JSON Parsing Failed.")

    if name is not None or email is not None:
        dbsrv.change_user(user_id,
                          name=name,
                          email=email)
    if admin is not None and group_id is not None:
        dbsrv.set_admin(user_id, group_id, bool(admin))
    return make_response("", 200)
Example #3
0
 def test_succeeds_normally(self):
     dbsrv.set_admin(2, 1, True)
     assert self.will.member[0].admin is True