Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions osf/models/preprint.py
Original file line number Diff line number Diff line change
Expand Up @@ -690,6 +690,24 @@ def is_preprint_orphan(self):
def has_submitted_preprint(self):
return self.machine_state != DefaultStates.INITIAL.value

@property
def is_pending_moderation(self):
if self.machine_state == DefaultStates.INITIAL.value:
return False

if not self.provider or not self.provider.reviews_workflow:
return False

from api.providers.workflows import PUBLIC_STATES

workflow = self.provider.reviews_workflow
public_states = PUBLIC_STATES.get(workflow, [])

if self.machine_state not in public_states:
return True

return False

@property
def deep_url(self):
# Required for GUID routing
Expand Down
11 changes: 11 additions & 0 deletions website/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,17 @@ def ember_app(path=None):
preprint = Preprint.load(guid_str)
if preprint and preprint._id != guid_str:
return redirect(f"{settings.DOMAIN}preprints/{path_values[0]}/{preprint._id}", code=302)
if preprint:
from framework.auth import Auth
auth = Auth.from_kwargs(request.args.to_dict(), {})
if not preprint.can_view(auth):
if preprint.is_pending_moderation:
renderer = OsfWebRenderer('pending_moderation.mako', trust=False)
return renderer({
'resource_type': (preprint.provider.preprint_word or 'preprint') if preprint.provider else 'preprint',
'provider_name': preprint.provider.name if preprint.provider else 'OSF',
})
raise HTTPError(http_status.HTTP_404_NOT_FOUND)
# For all other cases, let ember app handle it
ember_app = EXTERNAL_EMBER_APPS.get('ember_osf_web', False) or ember_app
break
Expand Down
37 changes: 37 additions & 0 deletions website/templates/pending_moderation.mako
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<%inherit file="base.mako"/>
<%def name="title()">Pending Moderation</%def>
<%def name="description()">This ${resource_type} is pending moderation</%def>

<%def name="content()">
<style>
/* Ensure content area has enough height so the footer sticks to the bottom */
.pending-wrapper {
min-height: calc(100vh - 180px); /* header+footer approximate height */
display: -webkit-box;
display: -ms-flexbox;
display: flex;
-webkit-box-align: center;
-ms-flex-align: center;
align-items: center;
}
</style>

<div class="pending-wrapper">
<div class="container">
<div class='row'>
<div class='col-md-12'>
<div class="text-center">
<h2 id='pending-moderation-message'>Pending Moderation</h2>
<div class="alert alert-info">
<i class="fa fa-hourglass-half"></i>
<strong>This ${resource_type} is pending moderation at ${provider_name}</strong>
<p>This ${resource_type} has been submitted for review and is not yet publicly available.
Please check back later as moderation decisions may take some time.</p>
</div>
</div>
</div>
</div>
</div>
</div>
</%def>

Loading