def crop(request, project_id=None, stack_ids=None, x_min=None, x_max=None, y_min=None, y_max=None, z_min=None, z_max=None, zoom_level=None, logged_in_user=None): """ Crops out the specified region of the stack. The region is expected to be given in terms of real world units (e.g. nm). """ # Make sure tmp dir exists and is writable if not os.path.exists( settings.TMP_DIR ) or not os.access( settings.TMP_DIR, os.W_OK ): json_message = "Please make sure your temporary folder (TMP_DIR in settings.py) exists and is writable." err_response = json_error_response( err_message ) err_response['Connection'] = 'close' return err_response # Make a list out of the stack ids string_list = stack_ids.split(",") stack_ids = [int( x ) for x in string_list] # Crate a new cropping job job = CropJob(logged_in_user, project_id, stack_ids, x_min, x_max, y_min, y_max, z_min, z_max, zoom_level) # Parameter check errors = sanity_check( job ) if len(errors) > 0: err_message = "Some problems with the cropping parameters were found: " for n, e in enumerate( errors ): if n == 0: err_message += str( n+1 ) + ". " + e else: err_message += ", " + str( n+1 ) + ". " + e err_response = json_error_response( err_message ) err_response['Connection'] = 'close' return err_response result = start_asynch_process( job ) return result
def decorated_with_catmaid_can_edit_project(request, *args, **kwargs): u = valid_catmaid_login(request) if not u: return json_error_response(request.get_full_path()+" is not accessible unless you are logged in") p = Project(pk=kwargs['project_id']) if u in p.users.all(): kwargs['logged_in_user'] = u return f(request, *args, **kwargs) else: return json_error_response("The user '%s' may not edit project %d" % (u.longname, kwargs['project_id']))
def decorated_with_catmaid_can_edit_project(request, *args, **kwargs): u = valid_catmaid_login(request) if not u: return json_error_response( request.get_full_path() + " is not accessible unless you are logged in") p = Project(pk=kwargs['project_id']) if u in p.users.all(): kwargs['logged_in_user'] = u return f(request, *args, **kwargs) else: return json_error_response( "The user '%s' may not edit project %d" % (u.longname, kwargs['project_id']))