File tree Expand file tree Collapse file tree 2 files changed +29
-0
lines changed Expand file tree Collapse file tree 2 files changed +29
-0
lines changed Original file line number Diff line number Diff line change @@ -695,6 +695,24 @@ def is_preprint_orphan(self):
695
695
def has_submitted_preprint (self ):
696
696
return self .machine_state != DefaultStates .INITIAL .value
697
697
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
+
698
716
@property
699
717
def deep_url (self ):
700
718
# Required for GUID routing
Original file line number Diff line number Diff line change @@ -257,6 +257,17 @@ def ember_app(path=None):
257
257
preprint = Preprint .load (guid_str )
258
258
if preprint and preprint ._id != guid_str :
259
259
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 )
260
271
# For all other cases, let ember app handle it
261
272
ember_app = EXTERNAL_EMBER_APPS .get ('ember_osf_web' , False ) or ember_app
262
273
break
You can’t perform that action at this time.
0 commit comments