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 8, 2023
1 parent 1af8f9d commit 5e37aba
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 10 deletions.
19 changes: 12 additions & 7 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_restricted"] = 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 Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// Copyright (C) 2020-2022 Northwestern University.
// Copyright (C) 2021-2022 Graz University of Technology.
// Copyright (C) 2022-2023 KTH Royal Institute of Technology.
// Copyright (C) 2023 KTH Royal Institute of Technology.
//
// Invenio App RDM is free software; you can redistribute it and/or modify it
// under the terms of the MIT License; see LICENSE file for more details.
Expand Down Expand Up @@ -115,12 +116,22 @@ export class RDMDepositForm extends Component {
/>
</Overridable>

<Overridable id="InvenioAppRdm.Deposit.CommunityHeader.container">
<CommunityHeader imagePlaceholderLink="/static/images/square-placeholder.png" />
</Overridable>
{!permissions?.can_publish_restricted && (
<Overridable id="InvenioAppRdm.Deposit.CommunityHeader.container">
<CommunityHeader imagePlaceholderLink="/static/images/square-placeholder.png" />
</Overridable>
)}
<Container id="rdm-deposit-form" className="rel-mt-1">
<Grid className="mt-25">
<Grid.Column mobile={16} tablet={16} computer={11}>
{/* Active when config "RDM_ENSURE_RECORD_COMMUNITY_EXISTS" = True */}
{permissions?.can_publish_restricted && (
<Overridable id="InvenioAppRdm.Deposit.CommunityHeaderRestricted.container">
<AccordionField active label={i18next.t("Community")}>
<CommunityHeader imagePlaceholderLink="/static/images/square-placeholder.png" />
</AccordionField>
</Overridable>
)}
<Overridable
id="InvenioAppRdm.Deposit.AccordionFieldFiles.container"
record={record}
Expand Down

0 comments on commit 5e37aba

Please sign in to comment.