Skip to content

Commit

Permalink
config: allow configuration of user schema
Browse files Browse the repository at this point in the history
  • Loading branch information
rekt-hard authored and kpsherva committed Jun 6, 2023
1 parent 4dbc71a commit 52d1afd
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
5 changes: 5 additions & 0 deletions invenio_users_resources/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
"""Invenio module providing management APIs for users and roles/groups."""


from invenio_users_resources.services.schemas import UserSchema

USERS_RESOURCES_AVATAR_COLORS = [
"#e06055",
"#ff8a65",
Expand Down Expand Up @@ -39,3 +41,6 @@
"#55526f",
"#67635a",
]

USERS_RESOURCES_SERVICE_SCHEMA = UserSchema
"""Schema used by the users service."""
2 changes: 1 addition & 1 deletion invenio_users_resources/ext.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def init_config(self, app):

def init_services(self, app):
"""Initialize the services for users and user groups."""
self.users_service = UsersService(config=UsersServiceConfig)
self.users_service = UsersService(config=UsersServiceConfig.build(app))
self.groups_service = GroupsService(config=GroupsServiceConfig)

def init_resources(self, app):
Expand Down
5 changes: 3 additions & 2 deletions invenio_users_resources/services/users/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
SearchOptions,
pagination_links,
)
from invenio_records_resources.services.base.config import ConfiguratorMixin, FromConfig
from invenio_records_resources.services.records.params import QueryStrParam, SortParam
from invenio_records_resources.services.records.queryparser import (
QueryParser,
Expand Down Expand Up @@ -56,7 +57,7 @@ class UserSearchOptions(SearchOptions):
]


class UsersServiceConfig(RecordServiceConfig):
class UsersServiceConfig(RecordServiceConfig, ConfiguratorMixin):
"""Requests service configuration."""

# common configuration
Expand All @@ -68,7 +69,7 @@ class UsersServiceConfig(RecordServiceConfig):
# specific configuration
service_id = "users"
record_cls = UserAggregate
schema = UserSchema
schema = FromConfig("USERS_RESOURCES_SERVICE_SCHEMA", UserSchema)
indexer_queue_name = "users"
index_dumper = None

Expand Down

0 comments on commit 52d1afd

Please sign in to comment.