Skip to content

Commit

Permalink
ui: Require records community
Browse files Browse the repository at this point in the history
  • Loading branch information
Samk13 committed May 15, 2023
1 parent 342c9b0 commit 84dc8c6
Showing 1 changed file with 25 additions and 16 deletions.
41 changes: 25 additions & 16 deletions invenio_app_rdm/records_ui/views/deposits.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# Copyright (C) 2019-2021 CERN.
# Copyright (C) 2019-2021 Northwestern University.
# Copyright (C) 2021 TU Wien.
# Copyright (C) 2022 KTH Royal Institute of Technology
# Copyright (C) 2022-2023 KTH Royal Institute of Technology.
# Copyright (C) 2023 Graz University of Technology.
#
# Invenio App RDM is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -356,19 +356,24 @@ def new_record():
@pass_draft_community
def deposit_create(community=None):
"""Create a new deposit."""
permissions = get_record_permissions(
[
"manage_files",
"manage_record_access",
]
)
# Can't check "publish" permission as draft is not a record with an id yet.
permissions["can_publish_with_community_only"] = current_app.config.get(
"RDM_ENSURE_RECORD_COMMUNITY_EXISTS", False
)
return render_template(
current_app.config["APP_RDM_DEPOSIT_FORM_TEMPLATE"],
forms_config=get_form_config(createUrl="/api/records"),
searchbar_config=dict(searchUrl=get_search_url()),
record=new_record(),
files=dict(default_preview=None, entries=[], links={}),
preselectedCommunity=community,
permissions=get_record_permissions(
[
"manage_files",
"manage_record_access",
]
),
permissions=permissions,
)


Expand All @@ -380,19 +385,23 @@ def deposit_edit(pid_value, draft=None, draft_files=None):
files_dict = None if draft_files is None else draft_files.to_dict()
ui_serializer = UIJSONSerializer()
record = ui_serializer.dump_obj(draft.to_dict())

permissions = draft.has_permissions_to(
[
"new_version",
"delete_draft",
"manage_files",
"manage_record_access",
"publish",
]
)
permissions["can_publish_with_community_only"] = current_app.config.get(
"RDM_ENSURE_RECORD_COMMUNITY_EXISTS", False
)
return render_template(
current_app.config["APP_RDM_DEPOSIT_FORM_TEMPLATE"],
forms_config=get_form_config(apiUrl=f"/api/records/{pid_value}/draft"),
record=record,
files=files_dict,
searchbar_config=dict(searchUrl=get_search_url()),
permissions=draft.has_permissions_to(
[
"new_version",
"delete_draft",
"manage_files",
"manage_record_access",
]
),
permissions=permissions,
)

0 comments on commit 84dc8c6

Please sign in to comment.