# Path: core/validation/validation.py
# class TSValidationError(Exception):
# def recursive_merge(container, container_override):
# def recursive_replace(container, replace_function):
# def _replace_function_sanitize_objectify_json(container):
# def sanitize_objectify_json(json_in):
# def _replace_function_stringify_objectid_json(container):
# def stringify_objectid_cursor(cursor_in):
# def _replace_function_stringify_objectid_list(container):
# def stringify_objectid_list(list_in):
# def validate_json_list(collection, list_in):
# def validate_request(collection, json_in):
# def update_password_salt_user_list(collection, list_in):
# def update_password_salt_user_json(json_in):
# def get_password_salt(password_in):
# 
# Path: core/config.py

# 
# Path: core/validation/jsonschemafix.py



import yaml, cherrypy, types, jsonschema, logging
from core.validation.validation import TSValidationError, recursive_replace, ObjectId
from core.config import restrictions_schema, conf_approval_flow
from jsonschema.exceptions import SchemaError
from core.validation.jsonschemafix import validator
        
    # Get projection permissions
    try:
        projections_restrictions = cherrypy.session['_ts_user']['restrictions'][collection]['get']['projections']
    except (KeyError, TypeError):
        projections_restrictions = None

    # If there are no restrictions, check if is set to True
    if not criteria_restrictions and not projections_restrictions:
        # If collection.get is not set to True, the access is denied
        try:
            get_permissions = cherrypy.session['_ts_user']['restrictions'][collection]['get']
        except (KeyError, TypeError):
            get_permissions = None        
            
        if get_permissions != True:
            raise TSValidationError("Access to 'get.%s' is restricted for current user" % (collection))
        
        # Else, returns as allowed
        else:
            return
    
    # Validate projections and sort
    if projections_restrictions:
        restricted_field = next((p for p in projection if p in projections_restrictions), None)
        
        if not restricted_field:
            restricted_field = next((p for p in sort if p in projections_restrictions), None)
            
        if restricted_field:

# Path: core/validation/validation.py
# class TSValidationError(Exception):
# def recursive_merge(container, container_override):
# def recursive_replace(container, replace_function):
# def _replace_function_sanitize_objectify_json(container):
# def sanitize_objectify_json(json_in):
# def _replace_function_stringify_objectid_json(container):
# def stringify_objectid_cursor(cursor_in):
# def _replace_function_stringify_objectid_list(container):
# def stringify_objectid_list(list_in):
# def validate_json_list(collection, list_in):
# def validate_request(collection, json_in):
# def update_password_salt_user_list(collection, list_in):
# def update_password_salt_user_json(json_in):
# def get_password_salt(password_in):
# 
# Path: core/config.py

# 
# Path: core/validation/jsonschemafix.py



# Path: core/validation/permissions.py
import yaml, cherrypy, types, jsonschema, logging
from core.validation.validation import TSValidationError, recursive_replace, ObjectId
from core.config import restrictions_schema, conf_approval_flow
from jsonschema.exceptions import SchemaError
from core.validation.jsonschemafix import validator

        
    # Get projection permissions
    try:
        projections_restrictions = cherrypy.session['_ts_user']['restrictions'][collection]['get']['projections']
    except (KeyError, TypeError):
        projections_restrictions = None

    # If there are no restrictions, check if is set to True
    if not criteria_restrictions and not projections_restrictions:
        # If collection.get is not set to True, the access is denied
        try:
            get_permissions = cherrypy.session['_ts_user']['restrictions'][collection]['get']
        except (KeyError, TypeError):
            get_permissions = None        
            
        if get_permissions != True:
            raise TSValidationError("Access to 'get.%s' is restricted for current user" % (collection))
        
        # Else, returns as allowed
        else:
            return
    
    # Validate projections and sort
    if projections_restrictions:
        restricted_field = next((p for p in projection if p in projections_restrictions), None)
        
        if not restricted_field:
            restricted_field = next((p for p in sort if p in projections_restrictions), None)
            
        if restricted_field:

            raise TSValidationError("Field 'get.%s.%s' is restricted for current user" % (collection, restricted_field))