Loading rpc/methods.py +85 −3 Original line number Diff line number Diff line Loading @@ -50,6 +50,22 @@ def _validate_limits(limit_from: int, limit_to: int) -> Tuple[int, int]: return limit_from, limit_to def _log_call(func): """ (Decorator) Log API call """ @_wraps(func) def wrapper(*args, **kwargs): print(args) print(kwargs) return func(*args, **kwargs) return wrapper def _require_superuser(func): """ (Decorator) Loading Loading @@ -127,6 +143,7 @@ def _user_has_permission( # ALL RPC functions receive a User instance as first argument @_log_call @_rpc_groups(["Utilities"]) def ping(user: User) -> str: """ Loading @@ -142,6 +159,7 @@ def ping(user: User) -> str: return "pong {}".format(user.username) @_log_call @_rpc_groups(["Metadatas"]) def metadatasets(user: User, project_id: int) -> List[Dict]: """ Loading Loading @@ -172,6 +190,7 @@ def metadatasets(user: User, project_id: int) -> List[Dict]: raise ServiceException(NO_SUCH_PROJECT) @_log_call @_rpc_groups(["Metadatas"]) def metadatas(user: User, metadata_set_id: int) -> List[Dict]: """ Loading Loading @@ -215,6 +234,7 @@ def metadatas(user: User, metadata_set_id: int) -> List[Dict]: return data @_log_call @_rpc_groups(["Metadatas"]) def metadata(user: User, metadata_id: int) -> Dict: """ Loading Loading @@ -244,6 +264,7 @@ def metadata(user: User, metadata_id: int) -> Dict: return serializers.metadata(metadata_instance) @_log_call @_rpc_groups(["Collections"]) def collections( user: User, Loading Loading @@ -344,6 +365,7 @@ def collections( return data @_log_call @_rpc_groups(["Collections"]) def collection(user: User, collection_id: int) -> Dict: """ Loading Loading @@ -380,6 +402,7 @@ def collection(user: User, collection_id: int) -> Dict: return serializers.collection(collection_instance, only_published=public_only) @_log_call @_rpc_groups(["Collections"]) def add_collection(user: User, title: str, parent_id: int) -> Dict: """ Loading Loading @@ -429,6 +452,7 @@ def add_collection(user: User, title: str, parent_id: int) -> Dict: return serializers.collection(collection_instance) @_log_call @_rpc_groups(["Collections"]) def add_collection_from_path(user: User, path: str, project_id: int) -> List[Dict]: """ Loading Loading @@ -513,6 +537,7 @@ def add_collection_from_path(user: User, path: str, project_id: int) -> List[Dic return hierarchy @_log_call @_rpc_groups(["Metadatas"]) def delete_metadata(user: User, metadata_id: int) -> bool: """ Loading @@ -530,6 +555,7 @@ def delete_metadata(user: User, metadata_id: int) -> bool: return False @_log_call @_rpc_groups(["Metadatas"]) def delete_metadataset( user: User, metadataset_id: int, recursive: bool = False Loading Loading @@ -568,6 +594,7 @@ def delete_metadataset( } @_log_call @_rpc_groups(["Collections"]) def delete_collection(user: User, collection_id: int, recursive: bool = False) -> Dict: """ Loading Loading @@ -613,6 +640,7 @@ def delete_collection(user: User, collection_id: int, recursive: bool = False) - return {"success": True, "status": "all good"} @_log_call @_rpc_groups(["Collections"]) def rename_collection(user: User, collection_id: int, title: str) -> bool: """ Loading @@ -630,6 +658,7 @@ def rename_collection(user: User, collection_id: int, title: str) -> bool: return True @_log_call @_rpc_groups(["Resources"]) def rename_resource(user: User, resource_id: int, title: str) -> bool: """ Loading @@ -647,6 +676,7 @@ def rename_resource(user: User, resource_id: int, title: str) -> bool: return True @_log_call @_rpc_groups(["Metadatas"]) def rename_meta(user: User, meta_id: int, title: str) -> bool: """ Loading @@ -662,6 +692,7 @@ def rename_meta(user: User, meta_id: int, title: str) -> bool: return True @_log_call @_rpc_groups(["Resources"]) def resources( user: User, Loading Loading @@ -744,6 +775,7 @@ def resources( return data @_log_call @_rpc_groups(["Resources"]) def resource(user: User, resource_id: int) -> Dict: """ Loading Loading @@ -781,6 +813,7 @@ def resource(user: User, resource_id: int) -> Dict: return serializers.resource(resource_instance) @_log_call @_rpc_groups(["Resources", "Collections"]) def add_resource_to_collection( user: User, resource_id: int, collection_id: int Loading Loading @@ -811,6 +844,7 @@ def add_resource_to_collection( raise ServiceException(NO_SUCH_RESOURCE) @_log_call @_rpc_groups(["Resources", "Collections"]) def remove_resource_from_collection( user: User, resource_id: int, collection_id: int Loading Loading @@ -844,6 +878,7 @@ def remove_resource_from_collection( return False @_log_call @_rpc_groups(["Resources"]) def delete_resource(user: User, resource_id: int) -> bool: """ Loading @@ -860,6 +895,7 @@ def delete_resource(user: User, resource_id: int) -> bool: return True @_log_call @_rpc_groups(["Search"]) def simple_search( user: User, Loading Loading @@ -952,6 +988,7 @@ def simple_search( return results @_log_call @_rpc_groups(["Search"]) def advanced_search_terms(user: User) -> List[str]: """ Loading @@ -970,6 +1007,7 @@ def advanced_search_terms(user: User) -> List[str]: return ["is", "contains", "does_not_contain"] @_log_call @_rpc_groups(["Search"]) def advanced_search( user: User, Loading Loading @@ -1170,6 +1208,7 @@ def advanced_search( return results @_log_call @_rpc_groups(["Search", "Collections", "Resources"]) def project_items( user: User, Loading @@ -1196,6 +1235,7 @@ def project_items( ) @_log_call @_rpc_groups(["Utilities"]) def upload_infos(user: User, sha256_hash: str, project_id: int) -> Dict: """ Loading Loading @@ -1235,6 +1275,7 @@ def upload_infos(user: User, sha256_hash: str, project_id: int) -> Dict: return infos @_log_call @_rpc_groups(["Utilities"]) def supported_file_types(user: User) -> List[Dict]: """ Loading @@ -1258,9 +1299,7 @@ def supported_file_types(user: User) -> List[Dict]: return ftypes supported_file_types.rpc_groups = ["Utilities"] @_log_call @_rpc_groups(["Metadatas"]) def add_metadataset(user: User, title: str, project_id: int) -> int: """ Loading @@ -1274,6 +1313,7 @@ def add_metadataset(user: User, title: str, project_id: int) -> int: return metadataset_instance.id @_log_call @_rpc_groups(["Metadatas"]) def add_metadata( user: User, title: str, metas_set_id: int, metadata_type_id: int = None Loading Loading @@ -1306,6 +1346,7 @@ def add_metadata( raise ServiceException(NO_SUCH_METADATATYPE) @_log_call @_rpc_groups(["Metadatas", "Resources"]) def remove_meta_from_resource(user: User, resource_id: int, meta_value_id: int) -> bool: """ Loading @@ -1326,6 +1367,7 @@ def remove_meta_from_resource(user: User, resource_id: int, meta_value_id: int) return False @_log_call @_rpc_groups(["Metadatas", "Resources"]) def set_metas_to_resource(user: User, resource_id: int, metas: List[dict]) -> bool: """ Loading Loading @@ -1366,6 +1408,7 @@ def set_metas_to_resource(user: User, resource_id: int, metas: List[dict]) -> bo return True @_log_call @_rpc_groups(["Metadatas", "Collections"]) def set_metas_to_collection( user: User, collection_id: int, metas: List[dict], cascade: bool = False Loading Loading @@ -1419,6 +1462,7 @@ def set_metas_to_collection( return True @_log_call @_rpc_groups(["Metadatas", "Resources"]) def add_meta_to_resource( user: User, resource_id: int, meta_id: int, meta_value: str Loading Loading @@ -1461,6 +1505,7 @@ def add_meta_to_resource( raise ServiceException(NO_SUCH_METADATA) @_log_call @_rpc_groups(["Deprecated"]) def remove_meta_from_collection( user: User, collection_id: int, meta_value_id: int Loading @@ -1482,6 +1527,7 @@ def remove_meta_from_collection( return False @_log_call @_rpc_groups(["Metadatas", "Collections"]) def remove_meta_value_from_collection( user: User, collection_id: int, meta_value_id: int Loading @@ -1492,6 +1538,7 @@ def remove_meta_value_from_collection( return remove_meta_from_collection(user, collection_id, meta_value_id) @_log_call @_rpc_groups(["Metadatas", "Collections"]) def add_meta_to_collection( user: User, collection_id: int, meta_id: int, meta_value: str, cascade: bool = False Loading Loading @@ -1544,6 +1591,7 @@ def add_meta_to_collection( raise ServiceException(NO_SUCH_METADATA) @_log_call @_rpc_groups(["Metadatas", "Collections"]) def change_collection_meta_value( user: User, meta_value_id: int, meta_value: str Loading @@ -1563,6 +1611,7 @@ def change_collection_meta_value( return False @_log_call @_rpc_groups(["Metadatas", "Resources"]) def change_resource_meta_value(user: User, meta_value_id: int, meta_value: str) -> bool: """ Loading @@ -1580,6 +1629,7 @@ def change_resource_meta_value(user: User, meta_value_id: int, meta_value: str) return False @_log_call @_rpc_groups(["Collections"]) def ancestors_from_collection( user: User, collection_id: int, include_self: bool = False Loading Loading @@ -1663,6 +1713,7 @@ def ancestors_from_collection( return breadcrumb @_log_call @_rpc_groups(["Collections", "Resources"]) def ancestors_from_resource(user: User, resource_id: int) -> List[List[dict]]: """ Loading Loading @@ -1733,6 +1784,7 @@ def ancestors_from_resource(user: User, resource_id: int) -> List[List[dict]]: return ancestors @_log_call @_rpc_groups(["Metadatas"]) def metadatatypes(user: User) -> List[dict]: """ Loading @@ -1753,6 +1805,7 @@ def metadatatypes(user: User) -> List[dict]: return types @_log_call @_rpc_groups(["Collections"]) def publish_collection(user: User, collection_id: int) -> bool: """ Loading @@ -1770,6 +1823,7 @@ def publish_collection(user: User, collection_id: int) -> bool: return True @_log_call @_rpc_groups(["Collections"]) def unpublish_collection(user: User, collection_id: int) -> bool: """ Loading @@ -1787,6 +1841,7 @@ def unpublish_collection(user: User, collection_id: int) -> bool: return True @_log_call @_rpc_groups(["Collections"]) def move_collection( user: User, child_collection_id: int, parent_collection_id: int Loading Loading @@ -1829,6 +1884,7 @@ def move_collection( return True @_log_call @_rpc_groups(["Tags"]) def set_tag( user: User, uid: str, project_id: int, label: str = None, ark: str = None Loading Loading @@ -1856,6 +1912,7 @@ def set_tag( return serializers.tag(tag_instance) @_log_call @_rpc_groups(["Tags"]) def delete_tag(user: User, uid: str) -> bool: """ Loading @@ -1872,6 +1929,7 @@ def delete_tag(user: User, uid: str) -> bool: return False @_log_call @_rpc_groups(["Tags"]) def tags(user: User, project_id: int) -> List[dict]: """ Loading Loading @@ -1904,6 +1962,7 @@ def tags(user: User, project_id: int) -> List[dict]: return tags_list @_log_call @_rpc_groups(["Tags", "Collections"]) def add_tag_to_collection(user: User, tag_uid: str, collection_id: int) -> bool: """ Loading @@ -1927,6 +1986,7 @@ def add_tag_to_collection(user: User, tag_uid: str, collection_id: int) -> bool: return False @_log_call @_rpc_groups(["Tags", "Collections"]) def remove_tag_from_collection(user: User, tag_uid: str, collection_id: int) -> bool: """ Loading @@ -1950,6 +2010,7 @@ def remove_tag_from_collection(user: User, tag_uid: str, collection_id: int) -> return False @_log_call @_rpc_groups(["Tags", "Resources"]) def add_tag_to_resource(user: User, tag_uid: str, resource_id: int) -> bool: """ Loading @@ -1973,6 +2034,7 @@ def add_tag_to_resource(user: User, tag_uid: str, resource_id: int) -> bool: return False @_log_call @_rpc_groups(["Tags", "Resources"]) def remove_tag_from_resource(user: User, tag_uid: str, resource_id: int) -> bool: """ Loading @@ -1996,6 +2058,7 @@ def remove_tag_from_resource(user: User, tag_uid: str, resource_id: int) -> bool return False @_log_call @_rpc_groups(["Collections", "Resources"]) def set_representative_resource( user: User, collection_id: int, resource_id: int = None Loading Loading @@ -2034,6 +2097,7 @@ def set_representative_resource( return False @_log_call @_rpc_groups(["Utilities", "Resources"]) def replace_file(user: User, from_resource_id: int, to_resource_id: int) -> bool: """ Loading Loading @@ -2101,6 +2165,7 @@ def replace_file(user: User, from_resource_id: int, to_resource_id: int) -> bool return False @_log_call @_rpc_groups(["Collections"]) def set_is_oai_record( user: User, collection_id: int, is_oai_record: bool = True Loading @@ -2122,6 +2187,7 @@ def set_is_oai_record( return False @_log_call @_rpc_groups(["Access"]) @_require_superuser def activate_rpc_access(user: User, user_name: str, api_key: str) -> bool: Loading @@ -2138,6 +2204,7 @@ def activate_rpc_access(user: User, user_name: str, api_key: str) -> bool: return True @_log_call @_rpc_groups(["Access"]) @_require_superuser def deactivate_rpc_access(user: User, user_name: str, api_key: str) -> bool: Loading @@ -2157,6 +2224,7 @@ def deactivate_rpc_access(user: User, user_name: str, api_key: str) -> bool: return False @_log_call @_rpc_groups(["Access"]) @_require_superuser def create_project(user: User, project_label: str, project_description: str) -> dict: Loading @@ -2171,6 +2239,7 @@ def create_project(user: User, project_label: str, project_description: str) -> return serializers.project(project) @_log_call @_rpc_groups(["Access"]) def list_permissions(user: User) -> List[Dict]: """ Loading Loading @@ -2212,6 +2281,7 @@ def list_permissions(user: User) -> List[Dict]: return data @_log_call @_rpc_groups(["Access"]) def projects_user_permissions(user: User) -> List[Dict]: """ Loading @@ -2235,6 +2305,7 @@ def projects_user_permissions(user: User) -> List[Dict]: return access_list @_log_call @_rpc_groups(["Access"]) def has_permission(user: User, project_id: int, permission: str) -> bool: """ Loading @@ -2248,6 +2319,7 @@ def has_permission(user: User, project_id: int, permission: str) -> bool: return False @_log_call @_rpc_groups(["Access"]) def list_roles(user: User, project_id: int) -> List[Dict]: """ Loading @@ -2260,6 +2332,7 @@ def list_roles(user: User, project_id: int) -> List[Dict]: return data @_log_call @_rpc_groups(["Access"]) @_require_superuser def set_role( Loading @@ -2284,6 +2357,7 @@ def set_role( return serializers.role(role) @_log_call @_require_superuser @_rpc_groups(["Access"]) def delete_role(user: User, project_id: int, role_label: str) -> bool: Loading @@ -2296,6 +2370,7 @@ def delete_role(user: User, project_id: int, role_label: str) -> bool: return True @_log_call @_rpc_groups(["Collections", "Resources"]) def move_items( user: User, Loading Loading @@ -2324,6 +2399,7 @@ def move_items( return results @_log_call @_rpc_groups(["Projects"]) def project_stats(user: User, project_id: int) -> dict: """ Loading Loading @@ -2365,6 +2441,7 @@ def project_stats(user: User, project_id: int) -> dict: raise ServiceException(NO_SUCH_PROJECT) @_log_call @_rpc_groups(["Collections", "Resources"]) def collection_stats(user: User, collection_id: int) -> dict: """ Loading Loading @@ -2393,6 +2470,7 @@ def collection_stats(user: User, collection_id: int) -> dict: } @_log_call @_rpc_groups(["Utilities", "Collections", "Resources"]) def recycle_bin(user: User, project_id: int) -> List[Dict]: """ Loading Loading @@ -2431,6 +2509,7 @@ def recycle_bin(user: User, project_id: int) -> List[Dict]: return results @_log_call @_rpc_groups(["Resources"]) def restore_resource(user: User, resource_id: int) -> bool: """ Loading @@ -2439,6 +2518,7 @@ def restore_resource(user: User, resource_id: int) -> bool: pass @_log_call @_rpc_groups(["Collections"]) def restore_collection(user: User, collection_id: int) -> bool: """ Loading @@ -2447,6 +2527,7 @@ def restore_collection(user: User, collection_id: int) -> bool: pass @_log_call @_rpc_groups(["Metadatas"]) def meta_count(user: User, metadata_id: int, collection_id: int) -> dict: """ Loading Loading @@ -2481,6 +2562,7 @@ def meta_count(user: User, metadata_id: int, collection_id: int) -> dict: return return_dict @_log_call @_rpc_groups(["Collections"]) def public_collections(user: User, project_id: int) -> List[dict]: """ Loading rpc/serializers.py +3 −3 Original line number Diff line number Diff line Loading @@ -26,7 +26,7 @@ def metadataset(metadataset_instance: models.MetadataSet) -> dict: "object_type": "metadataset", "id": metadataset_instance.id, "title": metadataset_instance.title, "project_id": metadataset_instance.project.id, "project_id": metadataset_instance.project_id, "metas_count": metadataset_instance.metadata_set.filter(expose=True).count(), } Loading @@ -36,10 +36,10 @@ def metadata(metadata_instance: models.Metadata) -> dict: "object_type": "metadata", "id": metadata_instance.id, "title": metadata_instance.title, "set_id": metadata_instance.set.id if metadata_instance.set else None, "set_id": metadata_instance.set_id, "set_title": metadata_instance.set.title, "rank": metadata_instance.rank, "project_id": metadata_instance.project.id, "project_id": metadata_instance.project_id, } Loading rpc/views.py +11 −1 Original line number Diff line number Diff line Loading @@ -44,7 +44,16 @@ def _silent_remove(file_path: str): def debug_sql(): if settings.DEBUG: print(json.dumps(connection.queries, indent=1)) print("") print("#--- Start PostgreSQL Queries ---#") print("") req_count = 0 for query in connection.queries: print("") print(" ", query["sql"]) print("") req_count = req_count + 1 print("#--- End PostgreSQL Queries ({} queries)---#".format(req_count)) def _file_hash256(file_path: str) -> str: Loading Loading @@ -157,6 +166,7 @@ def rpc(request: HttpRequest) -> HttpResponse: params.insert(0, user) # always add user to method call req_id = json_data["id"] result = methods[method](*params) debug_sql() return JsonResponse({"result": result, "error": None, "id": req_id}) except json.JSONDecodeError: return HttpResponse("Bad Request", status=400) Loading Loading
rpc/methods.py +85 −3 Original line number Diff line number Diff line Loading @@ -50,6 +50,22 @@ def _validate_limits(limit_from: int, limit_to: int) -> Tuple[int, int]: return limit_from, limit_to def _log_call(func): """ (Decorator) Log API call """ @_wraps(func) def wrapper(*args, **kwargs): print(args) print(kwargs) return func(*args, **kwargs) return wrapper def _require_superuser(func): """ (Decorator) Loading Loading @@ -127,6 +143,7 @@ def _user_has_permission( # ALL RPC functions receive a User instance as first argument @_log_call @_rpc_groups(["Utilities"]) def ping(user: User) -> str: """ Loading @@ -142,6 +159,7 @@ def ping(user: User) -> str: return "pong {}".format(user.username) @_log_call @_rpc_groups(["Metadatas"]) def metadatasets(user: User, project_id: int) -> List[Dict]: """ Loading Loading @@ -172,6 +190,7 @@ def metadatasets(user: User, project_id: int) -> List[Dict]: raise ServiceException(NO_SUCH_PROJECT) @_log_call @_rpc_groups(["Metadatas"]) def metadatas(user: User, metadata_set_id: int) -> List[Dict]: """ Loading Loading @@ -215,6 +234,7 @@ def metadatas(user: User, metadata_set_id: int) -> List[Dict]: return data @_log_call @_rpc_groups(["Metadatas"]) def metadata(user: User, metadata_id: int) -> Dict: """ Loading Loading @@ -244,6 +264,7 @@ def metadata(user: User, metadata_id: int) -> Dict: return serializers.metadata(metadata_instance) @_log_call @_rpc_groups(["Collections"]) def collections( user: User, Loading Loading @@ -344,6 +365,7 @@ def collections( return data @_log_call @_rpc_groups(["Collections"]) def collection(user: User, collection_id: int) -> Dict: """ Loading Loading @@ -380,6 +402,7 @@ def collection(user: User, collection_id: int) -> Dict: return serializers.collection(collection_instance, only_published=public_only) @_log_call @_rpc_groups(["Collections"]) def add_collection(user: User, title: str, parent_id: int) -> Dict: """ Loading Loading @@ -429,6 +452,7 @@ def add_collection(user: User, title: str, parent_id: int) -> Dict: return serializers.collection(collection_instance) @_log_call @_rpc_groups(["Collections"]) def add_collection_from_path(user: User, path: str, project_id: int) -> List[Dict]: """ Loading Loading @@ -513,6 +537,7 @@ def add_collection_from_path(user: User, path: str, project_id: int) -> List[Dic return hierarchy @_log_call @_rpc_groups(["Metadatas"]) def delete_metadata(user: User, metadata_id: int) -> bool: """ Loading @@ -530,6 +555,7 @@ def delete_metadata(user: User, metadata_id: int) -> bool: return False @_log_call @_rpc_groups(["Metadatas"]) def delete_metadataset( user: User, metadataset_id: int, recursive: bool = False Loading Loading @@ -568,6 +594,7 @@ def delete_metadataset( } @_log_call @_rpc_groups(["Collections"]) def delete_collection(user: User, collection_id: int, recursive: bool = False) -> Dict: """ Loading Loading @@ -613,6 +640,7 @@ def delete_collection(user: User, collection_id: int, recursive: bool = False) - return {"success": True, "status": "all good"} @_log_call @_rpc_groups(["Collections"]) def rename_collection(user: User, collection_id: int, title: str) -> bool: """ Loading @@ -630,6 +658,7 @@ def rename_collection(user: User, collection_id: int, title: str) -> bool: return True @_log_call @_rpc_groups(["Resources"]) def rename_resource(user: User, resource_id: int, title: str) -> bool: """ Loading @@ -647,6 +676,7 @@ def rename_resource(user: User, resource_id: int, title: str) -> bool: return True @_log_call @_rpc_groups(["Metadatas"]) def rename_meta(user: User, meta_id: int, title: str) -> bool: """ Loading @@ -662,6 +692,7 @@ def rename_meta(user: User, meta_id: int, title: str) -> bool: return True @_log_call @_rpc_groups(["Resources"]) def resources( user: User, Loading Loading @@ -744,6 +775,7 @@ def resources( return data @_log_call @_rpc_groups(["Resources"]) def resource(user: User, resource_id: int) -> Dict: """ Loading Loading @@ -781,6 +813,7 @@ def resource(user: User, resource_id: int) -> Dict: return serializers.resource(resource_instance) @_log_call @_rpc_groups(["Resources", "Collections"]) def add_resource_to_collection( user: User, resource_id: int, collection_id: int Loading Loading @@ -811,6 +844,7 @@ def add_resource_to_collection( raise ServiceException(NO_SUCH_RESOURCE) @_log_call @_rpc_groups(["Resources", "Collections"]) def remove_resource_from_collection( user: User, resource_id: int, collection_id: int Loading Loading @@ -844,6 +878,7 @@ def remove_resource_from_collection( return False @_log_call @_rpc_groups(["Resources"]) def delete_resource(user: User, resource_id: int) -> bool: """ Loading @@ -860,6 +895,7 @@ def delete_resource(user: User, resource_id: int) -> bool: return True @_log_call @_rpc_groups(["Search"]) def simple_search( user: User, Loading Loading @@ -952,6 +988,7 @@ def simple_search( return results @_log_call @_rpc_groups(["Search"]) def advanced_search_terms(user: User) -> List[str]: """ Loading @@ -970,6 +1007,7 @@ def advanced_search_terms(user: User) -> List[str]: return ["is", "contains", "does_not_contain"] @_log_call @_rpc_groups(["Search"]) def advanced_search( user: User, Loading Loading @@ -1170,6 +1208,7 @@ def advanced_search( return results @_log_call @_rpc_groups(["Search", "Collections", "Resources"]) def project_items( user: User, Loading @@ -1196,6 +1235,7 @@ def project_items( ) @_log_call @_rpc_groups(["Utilities"]) def upload_infos(user: User, sha256_hash: str, project_id: int) -> Dict: """ Loading Loading @@ -1235,6 +1275,7 @@ def upload_infos(user: User, sha256_hash: str, project_id: int) -> Dict: return infos @_log_call @_rpc_groups(["Utilities"]) def supported_file_types(user: User) -> List[Dict]: """ Loading @@ -1258,9 +1299,7 @@ def supported_file_types(user: User) -> List[Dict]: return ftypes supported_file_types.rpc_groups = ["Utilities"] @_log_call @_rpc_groups(["Metadatas"]) def add_metadataset(user: User, title: str, project_id: int) -> int: """ Loading @@ -1274,6 +1313,7 @@ def add_metadataset(user: User, title: str, project_id: int) -> int: return metadataset_instance.id @_log_call @_rpc_groups(["Metadatas"]) def add_metadata( user: User, title: str, metas_set_id: int, metadata_type_id: int = None Loading Loading @@ -1306,6 +1346,7 @@ def add_metadata( raise ServiceException(NO_SUCH_METADATATYPE) @_log_call @_rpc_groups(["Metadatas", "Resources"]) def remove_meta_from_resource(user: User, resource_id: int, meta_value_id: int) -> bool: """ Loading @@ -1326,6 +1367,7 @@ def remove_meta_from_resource(user: User, resource_id: int, meta_value_id: int) return False @_log_call @_rpc_groups(["Metadatas", "Resources"]) def set_metas_to_resource(user: User, resource_id: int, metas: List[dict]) -> bool: """ Loading Loading @@ -1366,6 +1408,7 @@ def set_metas_to_resource(user: User, resource_id: int, metas: List[dict]) -> bo return True @_log_call @_rpc_groups(["Metadatas", "Collections"]) def set_metas_to_collection( user: User, collection_id: int, metas: List[dict], cascade: bool = False Loading Loading @@ -1419,6 +1462,7 @@ def set_metas_to_collection( return True @_log_call @_rpc_groups(["Metadatas", "Resources"]) def add_meta_to_resource( user: User, resource_id: int, meta_id: int, meta_value: str Loading Loading @@ -1461,6 +1505,7 @@ def add_meta_to_resource( raise ServiceException(NO_SUCH_METADATA) @_log_call @_rpc_groups(["Deprecated"]) def remove_meta_from_collection( user: User, collection_id: int, meta_value_id: int Loading @@ -1482,6 +1527,7 @@ def remove_meta_from_collection( return False @_log_call @_rpc_groups(["Metadatas", "Collections"]) def remove_meta_value_from_collection( user: User, collection_id: int, meta_value_id: int Loading @@ -1492,6 +1538,7 @@ def remove_meta_value_from_collection( return remove_meta_from_collection(user, collection_id, meta_value_id) @_log_call @_rpc_groups(["Metadatas", "Collections"]) def add_meta_to_collection( user: User, collection_id: int, meta_id: int, meta_value: str, cascade: bool = False Loading Loading @@ -1544,6 +1591,7 @@ def add_meta_to_collection( raise ServiceException(NO_SUCH_METADATA) @_log_call @_rpc_groups(["Metadatas", "Collections"]) def change_collection_meta_value( user: User, meta_value_id: int, meta_value: str Loading @@ -1563,6 +1611,7 @@ def change_collection_meta_value( return False @_log_call @_rpc_groups(["Metadatas", "Resources"]) def change_resource_meta_value(user: User, meta_value_id: int, meta_value: str) -> bool: """ Loading @@ -1580,6 +1629,7 @@ def change_resource_meta_value(user: User, meta_value_id: int, meta_value: str) return False @_log_call @_rpc_groups(["Collections"]) def ancestors_from_collection( user: User, collection_id: int, include_self: bool = False Loading Loading @@ -1663,6 +1713,7 @@ def ancestors_from_collection( return breadcrumb @_log_call @_rpc_groups(["Collections", "Resources"]) def ancestors_from_resource(user: User, resource_id: int) -> List[List[dict]]: """ Loading Loading @@ -1733,6 +1784,7 @@ def ancestors_from_resource(user: User, resource_id: int) -> List[List[dict]]: return ancestors @_log_call @_rpc_groups(["Metadatas"]) def metadatatypes(user: User) -> List[dict]: """ Loading @@ -1753,6 +1805,7 @@ def metadatatypes(user: User) -> List[dict]: return types @_log_call @_rpc_groups(["Collections"]) def publish_collection(user: User, collection_id: int) -> bool: """ Loading @@ -1770,6 +1823,7 @@ def publish_collection(user: User, collection_id: int) -> bool: return True @_log_call @_rpc_groups(["Collections"]) def unpublish_collection(user: User, collection_id: int) -> bool: """ Loading @@ -1787,6 +1841,7 @@ def unpublish_collection(user: User, collection_id: int) -> bool: return True @_log_call @_rpc_groups(["Collections"]) def move_collection( user: User, child_collection_id: int, parent_collection_id: int Loading Loading @@ -1829,6 +1884,7 @@ def move_collection( return True @_log_call @_rpc_groups(["Tags"]) def set_tag( user: User, uid: str, project_id: int, label: str = None, ark: str = None Loading Loading @@ -1856,6 +1912,7 @@ def set_tag( return serializers.tag(tag_instance) @_log_call @_rpc_groups(["Tags"]) def delete_tag(user: User, uid: str) -> bool: """ Loading @@ -1872,6 +1929,7 @@ def delete_tag(user: User, uid: str) -> bool: return False @_log_call @_rpc_groups(["Tags"]) def tags(user: User, project_id: int) -> List[dict]: """ Loading Loading @@ -1904,6 +1962,7 @@ def tags(user: User, project_id: int) -> List[dict]: return tags_list @_log_call @_rpc_groups(["Tags", "Collections"]) def add_tag_to_collection(user: User, tag_uid: str, collection_id: int) -> bool: """ Loading @@ -1927,6 +1986,7 @@ def add_tag_to_collection(user: User, tag_uid: str, collection_id: int) -> bool: return False @_log_call @_rpc_groups(["Tags", "Collections"]) def remove_tag_from_collection(user: User, tag_uid: str, collection_id: int) -> bool: """ Loading @@ -1950,6 +2010,7 @@ def remove_tag_from_collection(user: User, tag_uid: str, collection_id: int) -> return False @_log_call @_rpc_groups(["Tags", "Resources"]) def add_tag_to_resource(user: User, tag_uid: str, resource_id: int) -> bool: """ Loading @@ -1973,6 +2034,7 @@ def add_tag_to_resource(user: User, tag_uid: str, resource_id: int) -> bool: return False @_log_call @_rpc_groups(["Tags", "Resources"]) def remove_tag_from_resource(user: User, tag_uid: str, resource_id: int) -> bool: """ Loading @@ -1996,6 +2058,7 @@ def remove_tag_from_resource(user: User, tag_uid: str, resource_id: int) -> bool return False @_log_call @_rpc_groups(["Collections", "Resources"]) def set_representative_resource( user: User, collection_id: int, resource_id: int = None Loading Loading @@ -2034,6 +2097,7 @@ def set_representative_resource( return False @_log_call @_rpc_groups(["Utilities", "Resources"]) def replace_file(user: User, from_resource_id: int, to_resource_id: int) -> bool: """ Loading Loading @@ -2101,6 +2165,7 @@ def replace_file(user: User, from_resource_id: int, to_resource_id: int) -> bool return False @_log_call @_rpc_groups(["Collections"]) def set_is_oai_record( user: User, collection_id: int, is_oai_record: bool = True Loading @@ -2122,6 +2187,7 @@ def set_is_oai_record( return False @_log_call @_rpc_groups(["Access"]) @_require_superuser def activate_rpc_access(user: User, user_name: str, api_key: str) -> bool: Loading @@ -2138,6 +2204,7 @@ def activate_rpc_access(user: User, user_name: str, api_key: str) -> bool: return True @_log_call @_rpc_groups(["Access"]) @_require_superuser def deactivate_rpc_access(user: User, user_name: str, api_key: str) -> bool: Loading @@ -2157,6 +2224,7 @@ def deactivate_rpc_access(user: User, user_name: str, api_key: str) -> bool: return False @_log_call @_rpc_groups(["Access"]) @_require_superuser def create_project(user: User, project_label: str, project_description: str) -> dict: Loading @@ -2171,6 +2239,7 @@ def create_project(user: User, project_label: str, project_description: str) -> return serializers.project(project) @_log_call @_rpc_groups(["Access"]) def list_permissions(user: User) -> List[Dict]: """ Loading Loading @@ -2212,6 +2281,7 @@ def list_permissions(user: User) -> List[Dict]: return data @_log_call @_rpc_groups(["Access"]) def projects_user_permissions(user: User) -> List[Dict]: """ Loading @@ -2235,6 +2305,7 @@ def projects_user_permissions(user: User) -> List[Dict]: return access_list @_log_call @_rpc_groups(["Access"]) def has_permission(user: User, project_id: int, permission: str) -> bool: """ Loading @@ -2248,6 +2319,7 @@ def has_permission(user: User, project_id: int, permission: str) -> bool: return False @_log_call @_rpc_groups(["Access"]) def list_roles(user: User, project_id: int) -> List[Dict]: """ Loading @@ -2260,6 +2332,7 @@ def list_roles(user: User, project_id: int) -> List[Dict]: return data @_log_call @_rpc_groups(["Access"]) @_require_superuser def set_role( Loading @@ -2284,6 +2357,7 @@ def set_role( return serializers.role(role) @_log_call @_require_superuser @_rpc_groups(["Access"]) def delete_role(user: User, project_id: int, role_label: str) -> bool: Loading @@ -2296,6 +2370,7 @@ def delete_role(user: User, project_id: int, role_label: str) -> bool: return True @_log_call @_rpc_groups(["Collections", "Resources"]) def move_items( user: User, Loading Loading @@ -2324,6 +2399,7 @@ def move_items( return results @_log_call @_rpc_groups(["Projects"]) def project_stats(user: User, project_id: int) -> dict: """ Loading Loading @@ -2365,6 +2441,7 @@ def project_stats(user: User, project_id: int) -> dict: raise ServiceException(NO_SUCH_PROJECT) @_log_call @_rpc_groups(["Collections", "Resources"]) def collection_stats(user: User, collection_id: int) -> dict: """ Loading Loading @@ -2393,6 +2470,7 @@ def collection_stats(user: User, collection_id: int) -> dict: } @_log_call @_rpc_groups(["Utilities", "Collections", "Resources"]) def recycle_bin(user: User, project_id: int) -> List[Dict]: """ Loading Loading @@ -2431,6 +2509,7 @@ def recycle_bin(user: User, project_id: int) -> List[Dict]: return results @_log_call @_rpc_groups(["Resources"]) def restore_resource(user: User, resource_id: int) -> bool: """ Loading @@ -2439,6 +2518,7 @@ def restore_resource(user: User, resource_id: int) -> bool: pass @_log_call @_rpc_groups(["Collections"]) def restore_collection(user: User, collection_id: int) -> bool: """ Loading @@ -2447,6 +2527,7 @@ def restore_collection(user: User, collection_id: int) -> bool: pass @_log_call @_rpc_groups(["Metadatas"]) def meta_count(user: User, metadata_id: int, collection_id: int) -> dict: """ Loading Loading @@ -2481,6 +2562,7 @@ def meta_count(user: User, metadata_id: int, collection_id: int) -> dict: return return_dict @_log_call @_rpc_groups(["Collections"]) def public_collections(user: User, project_id: int) -> List[dict]: """ Loading
rpc/serializers.py +3 −3 Original line number Diff line number Diff line Loading @@ -26,7 +26,7 @@ def metadataset(metadataset_instance: models.MetadataSet) -> dict: "object_type": "metadataset", "id": metadataset_instance.id, "title": metadataset_instance.title, "project_id": metadataset_instance.project.id, "project_id": metadataset_instance.project_id, "metas_count": metadataset_instance.metadata_set.filter(expose=True).count(), } Loading @@ -36,10 +36,10 @@ def metadata(metadata_instance: models.Metadata) -> dict: "object_type": "metadata", "id": metadata_instance.id, "title": metadata_instance.title, "set_id": metadata_instance.set.id if metadata_instance.set else None, "set_id": metadata_instance.set_id, "set_title": metadata_instance.set.title, "rank": metadata_instance.rank, "project_id": metadata_instance.project.id, "project_id": metadata_instance.project_id, } Loading
rpc/views.py +11 −1 Original line number Diff line number Diff line Loading @@ -44,7 +44,16 @@ def _silent_remove(file_path: str): def debug_sql(): if settings.DEBUG: print(json.dumps(connection.queries, indent=1)) print("") print("#--- Start PostgreSQL Queries ---#") print("") req_count = 0 for query in connection.queries: print("") print(" ", query["sql"]) print("") req_count = req_count + 1 print("#--- End PostgreSQL Queries ({} queries)---#".format(req_count)) def _file_hash256(file_path: str) -> str: Loading Loading @@ -157,6 +166,7 @@ def rpc(request: HttpRequest) -> HttpResponse: params.insert(0, user) # always add user to method call req_id = json_data["id"] result = methods[method](*params) debug_sql() return JsonResponse({"result": result, "error": None, "id": req_id}) except json.JSONDecodeError: return HttpResponse("Bad Request", status=400) Loading