Skip to content

Commit

Permalink
#2869 makes repository optional for fetching orphaned preprints.
Browse files Browse the repository at this point in the history
  • Loading branch information
ajrbyers authored and mauromsl committed May 12, 2022
1 parent 9a59bf5 commit 2ddb0e6
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 19 deletions.
23 changes: 5 additions & 18 deletions src/repository/logic.py
Original file line number Diff line number Diff line change
Expand Up @@ -370,29 +370,16 @@ def get_published_preprints(request, user_subject_pks):
return published_preprints.filter(pk__in=user_subject_pks)


def get_preprint_if_id(preprint_id, repository):
if preprint_id:
article = get_object_or_404(
models.Preprint,
pk=preprint_id,
date_submitted__isnull=True,
repository=repository,
)
else:
article = None

return article


# TODO: Update this
@cache(300)
def list_articles_without_subjects(repository):
def list_articles_without_subjects(repository=None):
preprints = models.Preprint.objects.filter(
date_submitted__isnull=False,
subject__isnull=True,
repository=repository,
)

if repository:
preprints = preprints.filter(
repository=repository,
)
return preprints


Expand Down
10 changes: 9 additions & 1 deletion src/repository/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -519,7 +519,15 @@ def repository_submit(request, preprint_id=None):
:param preprint_id: int Pk for a preprint object
:return: HttpResponse or HttpRedirect
"""
preprint = repository_logic.get_preprint_if_id(preprint_id, request.repository)
if preprint_id:
preprint = get_object_or_404(
models.Preprint,
pk=preprint_id,
date_submitted__isnull=True,
repository=request.repository,
)
else:
preprint = None

form = forms.PreprintInfo(
instance=preprint,
Expand Down

0 comments on commit 2ddb0e6

Please sign in to comment.