Skip to content

Commit 89c35cf

Browse files
committed
Add a new page for pending preprint moderation
1 parent 104db68 commit 89c35cf

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

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

website/routes.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,17 @@ def ember_app(path=None):
257257
preprint = Preprint.load(guid_str)
258258
if preprint and preprint._id != guid_str:
259259
return redirect(f"{settings.DOMAIN}preprints/{path_values[0]}/{preprint._id}", code=302)
260+
if preprint:
261+
from framework.auth import Auth
262+
auth = Auth.from_kwargs(request.args.to_dict(), {})
263+
if not preprint.can_view(auth):
264+
if getattr(preprint, 'is_pending_moderation', True):
265+
renderer = OsfWebRenderer('pending_moderation.mako', trust=False)
266+
return renderer({
267+
'resource_type': (preprint.provider.preprint_word or 'preprint') if preprint.provider else 'preprint',
268+
'provider_name': preprint.provider.name if preprint.provider else 'OSF',
269+
})
270+
raise HTTPError(http_status.HTTP_404_NOT_FOUND)
260271
# For all other cases, let ember app handle it
261272
ember_app = EXTERNAL_EMBER_APPS.get('ember_osf_web', False) or ember_app
262273
break

0 commit comments

Comments
 (0)