Exemplo n.º 1
0
    def validate_get(self, args):
        if not any([
                args.get("username"),
                args.get("status"),
                args.get("server"),
                args.get("id")
        ]):
            return {
                'error': [{
                    "message":
                    "an id, a server, a status, or a username must be provided"
                }]
            }

        if args.get("id") and not ModReqModel.objects(uid=args.get("id")):
            return {'error': [{"message": "invalid id"}]}

        if args.get("server") and Server.verify_fid(args.get("server")):
            return {
                'error': [{
                    "message": "the server field must be a valid fid"
                }]
            }

        if args.get("username") and not validate_username(
                args.get("username")):
            return {'error': [{"message": "invalid username"}]}
Exemplo n.º 2
0
    def validate_post(self, args):
        if args.get("username") and not validate_username(
                args.get("username")):
            return {'error': [{"message": "invalid username"}]}

        if args.get("request") and len(args.get("request")) > 1000:
            return {
                'error': [{
                    "message":
                    "the request must be below 1000 characters long"
                }]
            }

        if args.get("server") and Server.verify_fid(args.get("server")):
            return {
                'error': [{
                    "message": "the server field must be a valid fid"
                }]
            }

        if args.get("location") and len(args.get(
                "location")) > 100:  # need a better way to validate location
            # world,x,y,z,pitch,yaw is what we want
            # x, y, and z are doubles
            # pitch and yaw are floats
            # world should only be world, world_nether, or world_the_end
            return {
                'error': [{
                    "message":
                    "the location must be below 100 characters long"
                }]
            }
Exemplo n.º 3
0
def view_server_image(server_id):
    server = Server.objects(server_id=server_id).first()
    if server is None:
        abort(404)

    image = StringIO.StringIO(server.server_image.read())
    image.seek(0)
    return send_file(image, mimetype='image/png')
Exemplo n.º 4
0
def view_server_image(server_id):
    server = Server.objects(server_id=server_id).first()
    if server is None:
        abort(404)

    image = StringIO.StringIO(server.server_image.read())
    image.seek(0)
    return send_file(image, mimetype='image/png')
Exemplo n.º 5
0
    def validate_get(self, args):
        if not any([args.get("username"), args.get("status"), args.get("server"), args.get("id")]):
            return {'error': [{"message": "an id, a server, a status, or a username must be provided"}]}

        if args.get("id") and not ModReqModel.objects(uid=args.get("id")):
            return {'error': [{"message": "invalid id"}]}

        if args.get("server") and Server.verify_fid(args.get("server")):
            return {'error': [{"message": "the server field must be a valid fid"}]}

        if args.get("username") and not validate_username(args.get("username")):
            return {'error': [{"message": "invalid username"}]}
Exemplo n.º 6
0
    def validate_post(self, args):
        if args.get("note") and len(args.get("note")) > 1000:
            return {
                'error': [{
                    "message":
                    "the note must be below 1000 characters long"
                }]
            }

        if args.get("server") and Server.verify_fid(args.get("server")):
            return {
                'error': [{
                    "message": "the server field must be a valid fid"
                }]
            }
Exemplo n.º 7
0
    def validate_post(self, args):
        if args.get("username") and not validate_username(args.get("username")):
            return {'error': [{"message": "invalid username"}]}

        if args.get("request") and len(args.get("request")) > 1000:
            return {'error': [{"message": "the request must be below 1000 characters long"}]}

        if args.get("server") and Server.verify_fid(args.get("server")):
            return {'error': [{"message": "the server field must be a valid fid"}]}

        if args.get("location") and len(args.get("location")) > 100:  # need a better way to validate location
                                                                      # world,x,y,z,pitch,yaw is what we want
                                                                      # x, y, and z are doubles
                                                                      # pitch and yaw are floats
                                                                      # world should only be world, world_nether, or world_the_end
            return {'error': [{"message": "the location must be below 100 characters long"}]}
Exemplo n.º 8
0
    def validate_post(self, args):
        if args.get("note") and len(args.get("note")) > 1000:
            return {'error': [{"message": "the note must be below 1000 characters long"}]}

        if args.get("server") and Server.verify_fid(args.get("server")):
            return {'error': [{"message": "the server field must be a valid fid"}]}
Exemplo n.º 9
0
def view_servers():
    servers = Server.objects()
    return render_template('servers_view_servers.html',
                           servers=servers,
                           title="Servers")
Exemplo n.º 10
0
def view_servers():
    servers = Server.objects()
    return render_template('servers_view_servers.html', servers=servers, title="Servers")
Exemplo n.º 11
0
def inject_servers():
    return dict(servers=Server.objects())