Skip to content

Commit 4a5b989

Browse files
Jacob Collinsegabancho
authored andcommitted
feat(administration): add user creation
1 parent 35b634d commit 4a5b989

File tree

4 files changed

+32
-5
lines changed

4 files changed

+32
-5
lines changed

LICENSE

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ Copyright (C) 2019-2021 CERN.
44
Copyright (C) 2019-2021 Northwestern University.
55
Copyright (C) 2021 TU Wien.
66
Copyright (C) 2021 Graz University of Technology.
7+
Copyright (C) 2024 Ubiquity Press.
78

89
Permission is hereby granted, free of charge, to any person obtaining a copy of
910
this software and associated documentation files (the "Software"), to deal in
Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
# -*- coding: utf-8 -*-
22
#
33
# Copyright (C) 2023-2024 CERN.
4+
# Copyright (C) 2024 Ubiquity Press.
45
#
56
# Invenio App RDM is free software; you can redistribute it and/or modify it
67
# under the terms of the MIT License; see LICENSE file for more details.
78

89
"""Invenio administration module for user resources."""
910

10-
from .users import UsersDetailView, UsersListView
11+
from .users import UsersCreateView, UsersDetailView, UsersListView
1112

12-
__all__ = ("UsersDetailView", "UsersListView")
13+
__all__ = ("UsersCreateView", "UsersDetailView", "UsersListView")

invenio_app_rdm/administration/users/users.py

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#
33
# Copyright (C) 2023-2024 CERN.
44
# Copyright (C) 2024 KTH Royal Institute of Technology.
5+
# Copyright (C) 2024 Ubiquity Press.
56
#
67
# Invenio App RDM is free software; you can redistribute it and/or modify it
78
# under the terms of the MIT License; see LICENSE file for more details.
@@ -12,6 +13,7 @@
1213

1314
from flask import current_app
1415
from invenio_administration.views.base import (
16+
AdminResourceCreateView,
1517
AdminResourceDetailView,
1618
AdminResourceListView,
1719
)
@@ -43,8 +45,13 @@
4345
"updated": {"text": _("Updated"), "order": 13, "width": 2},
4446
}
4547

48+
USERS_DEFAULT_FORM_ITEMS = {
49+
"username": {"text": _("Username"), "order": 1, "width": 2},
50+
"email": {"text": _("Email"), "order": 2, "width": 1},
51+
}
52+
4653

47-
# List of the columns displayed on the user list and user details
54+
# List of the columns displayed on the user list, user details, and user create form
4855

4956

5057
class UsersListView(AdminResourceListView):
@@ -63,7 +70,9 @@ class UsersListView(AdminResourceListView):
6370
display_search = True
6471
display_delete = False
6572
display_edit = False
66-
display_create = False
73+
display_create = True
74+
# self.name from create class
75+
create_view_name = "invenio-users-resources-create"
6776

6877
item_field_list = USERS_ITEM_LIST
6978

@@ -126,5 +135,19 @@ class UsersDetailView(AdminResourceDetailView):
126135
display_delete = False
127136
display_edit = False
128137

129-
pid_path = "username"
138+
pid_path = "id"
130139
item_field_list = USERS_ITEM_DETAIL
140+
141+
142+
class UsersCreateView(AdminResourceCreateView):
143+
"""Configuration for user create view."""
144+
145+
url = "/users/create"
146+
api_endpoint = "/users"
147+
extension_name = "invenio-users-resources"
148+
name = "invenio-users-resources-create"
149+
resource_config = "users_resource"
150+
title = _("Create user details")
151+
pid_path = "id"
152+
list_view_name = "users"
153+
form_fields = USERS_DEFAULT_FORM_ITEMS

setup.cfg

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
# Copyright (C) 2019-2022 Northwestern University.
55
# Copyright (C) 2022-2026 Graz University of Technology.
66
# Copyright (C) 2025 University of Münster.
7+
# Copyright (C) 2024 Ubiquity Press.
78
#
89
# Invenio App RDM is free software; you can redistribute it and/or modify it
910
# under the terms of the MIT License; see LICENSE file for more details.
@@ -111,6 +112,7 @@ invenio_celery.tasks =
111112
invenio_administration.views =
112113
invenio_users_resources_users_list = invenio_app_rdm.administration.users:UsersListView
113114
invenio_users_resources_users_details = invenio_app_rdm.administration.users:UsersDetailView
115+
invenio_users_resources_users_create = invenio_app_rdm.administration.users:UsersCreateView
114116
invenio_users_resources_domains_list = invenio_app_rdm.administration.domains:DomainsListView
115117
invenio_users_resources_domains_edit = invenio_app_rdm.administration.domains:DomainsEditView
116118
invenio_users_resources_domains_detail = invenio_app_rdm.administration.domains:DomainsDetailView

0 commit comments

Comments
 (0)