Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions dtool_lookup_server/base_uri_routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@
)
from flask_smorest import Blueprint

from dtool_lookup_server import (
AuthenticationError,
)
from dtool_lookup_server.sql_models import BaseURISchema, BaseURI
import dtool_lookup_server.utils_auth
from dtool_lookup_server.utils import (
Expand Down
18 changes: 8 additions & 10 deletions dtool_lookup_server/dataset_routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
from flask_smorest.pagination import PaginationParameters

from .sql_models import (
BaseURISchema,
DatasetSchema
)

Expand All @@ -29,7 +28,7 @@
ValidationError,
)
from dtool_lookup_server.schemas import (
UriSchema,
URISchema,
RegisterDatasetSchema,
SearchDatasetSchema,
SummarySchema,
Expand Down Expand Up @@ -119,7 +118,7 @@ def search_datasets(

@bp.route("/register", methods=["POST"])
@bp.arguments(RegisterDatasetSchema(partial=("created_at",)))
@bp.response(201, UriSchema)
@bp.response(201, URISchema)
@jwt_required()
def register(dataset: RegisterDatasetSchema):
"""Register a dataset. The user needs to have register permissions on the base_uri."""
Expand All @@ -144,9 +143,9 @@ def register(dataset: RegisterDatasetSchema):
# - may_search

@bp.route("/manifest", methods=["POST"])
@bp.arguments(UriSchema)
@bp.arguments(URISchema)
@jwt_required()
def manifest(query: UriSchema):
def manifest(query: URISchema):
"""Request the dataset manifest."""
username = get_jwt_identity()
if not dtool_lookup_server.utils_auth.user_exists(username):
Expand All @@ -170,9 +169,9 @@ def manifest(query: UriSchema):


@bp.route("/readme", methods=["POST"])
@bp.arguments(UriSchema)
@bp.arguments(URISchema)
@jwt_required()
def readme(query: UriSchema):
def readme(query: URISchema):
"""Request the dataset readme."""
username = get_jwt_identity()
if not dtool_lookup_server.utils_auth.user_exists(username):
Expand All @@ -196,10 +195,9 @@ def readme(query: UriSchema):


@bp.route("/annotations", methods=["POST"])
@bp.arguments(UriSchema)
@bp.response(200, Dict)
@bp.arguments(URISchema)
@jwt_required()
def annotations(query: UriSchema):
def annotations(query: URISchema):
"""Request the dataset annotations."""
username = get_jwt_identity()
if not dtool_lookup_server.utils_auth.user_exists(username):
Expand Down
13 changes: 7 additions & 6 deletions dtool_lookup_server/permission_routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,17 @@
AuthenticationError,
ValidationError
)
from dtool_lookup_server.schemas import BaseUriSchema, UriPermissionSchema
from dtool_lookup_server.schemas import URIPermissionSchema
from dtool_lookup_server.sql_models import BaseURISchema

bp = Blueprint("permissions", __name__, url_prefix="/admin/permission")


@bp.route("/info", methods=["POST"])
@bp.arguments(BaseUriSchema)
@bp.response(200, UriPermissionSchema)
@bp.arguments(BaseURISchema)
@bp.response(200, URIPermissionSchema)
@jwt_required()
def permission_info(data: BaseUriSchema):
def permission_info(data: BaseURISchema):
"""Get information about the permissions on a base URI.

The user needs to be admin.
Expand All @@ -39,9 +40,9 @@ def permission_info(data: BaseUriSchema):


@bp.route("/update_on_base_uri", methods=["POST"])
@bp.arguments(UriPermissionSchema)
@bp.arguments(URIPermissionSchema)
@jwt_required()
def update_on_base_uri(permissions: UriPermissionSchema):
def update_on_base_uri(permissions: URIPermissionSchema):
"""Update the permissions on a base URI.

The user needs to be admin.
Expand Down
8 changes: 2 additions & 6 deletions dtool_lookup_server/schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,10 @@
)


class UriSchema(Schema):
class URISchema(Schema):
uri = String()


class BaseUriSchema(Schema):
base_uri = String()


class RegisterUserSchema(Schema):
username = String()
is_admin = Boolean()
Expand Down Expand Up @@ -55,7 +51,7 @@ class RegisterDatasetSchema(Schema):
size_in_bytes = Integer()


class UriPermissionSchema(Schema):
class URIPermissionSchema(Schema):
base_uri = String()
users_with_register_permissions = List(String)
users_with_search_permissions = List(String)
Expand Down