Skip to content

Commit 30e0c3d

Browse files
authored
[ENG-8655] Fix/eng 8655 (#11375)
* Add a new page for pending preprint moderation * Add template for pending moderation * Remove new flask view
1 parent 5413b85 commit 30e0c3d

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

api/preprints/views.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,10 @@ def get_preprint(self, check_object_permissions=True, ignore_404=False):
158158
or preprint.machine_state == ReviewStates.WITHDRAWN.value,
159159
)
160160
if not preprint_is_public and not user_is_contributor and not user_is_reviewer:
161+
if preprint.is_pending_moderation:
162+
raise PermissionDenied(
163+
detail='This preprint is pending moderation and is not yet publicly available.',
164+
)
161165
raise NotFound
162166

163167
return preprint

osf/models/preprint.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -695,6 +695,24 @@ def is_preprint_orphan(self):
695695
def has_submitted_preprint(self):
696696
return self.machine_state != DefaultStates.INITIAL.value
697697

698+
@property
699+
def is_pending_moderation(self):
700+
if self.machine_state == DefaultStates.INITIAL.value:
701+
return False
702+
703+
if not self.provider or not self.provider.reviews_workflow:
704+
return False
705+
706+
from api.providers.workflows import PUBLIC_STATES
707+
708+
workflow = self.provider.reviews_workflow
709+
public_states = PUBLIC_STATES.get(workflow, [])
710+
711+
if self.machine_state not in public_states:
712+
return True
713+
714+
return False
715+
698716
@property
699717
def deep_url(self):
700718
# Required for GUID routing

0 commit comments

Comments
 (0)