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"}]}
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" }] }
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')
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"}]}
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" }] }
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"}]}
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"}]}
def view_servers(): servers = Server.objects() return render_template('servers_view_servers.html', servers=servers, title="Servers")
def inject_servers(): return dict(servers=Server.objects())