Skip to content

Commit

Permalink
Fix retrieving documents/galleys in manage_issue
Browse files Browse the repository at this point in the history
  • Loading branch information
yakky committed Aug 17, 2024
1 parent 1934062 commit 61fe597
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import core.model_utils
from django.conf import settings
from django.db import migrations, models
import django.utils.timezone


class Migration(migrations.Migration):
Expand Down Expand Up @@ -173,4 +174,13 @@ class Migration(migrations.Migration):
blank=True, default="", help_text="Short name or codde", max_length=300
),
),
migrations.AlterField(
model_name="issue",
name="date",
field=models.DateTimeField(
default=django.utils.timezone.now,
help_text="Date after which the issue if visible to the public (this does not affect the article's visibility).",
verbose_name="Publication date",
),
),
]
6 changes: 5 additions & 1 deletion src/journal/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -672,7 +672,11 @@ class Issue(AbstractLastModifiedModel):
"Autogenerated cache of the display format of an issue title"
),
)
date = models.DateTimeField(default=timezone.now)
date = models.DateTimeField(
default=timezone.now,
verbose_name=gettext("Publication date"),
help_text=gettext("Date after which the issue if visible to the public (this does not affect the article's visibility)."),
)
order = models.IntegerField(default=0)
issue_type = models.ForeignKey(
"journal.IssueType", blank=False, null=True, on_delete=models.SET_NULL)
Expand Down
14 changes: 9 additions & 5 deletions src/journal/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -1317,6 +1317,8 @@ def manage_issues(request, issue_id=None, event=None):
from core.logic import resize_and_crop
issue_list = models.Issue.objects.filter(journal=request.journal)

galleys = []
documents = []
if issue_id:
issue = get_object_or_404(models.Issue, pk=issue_id)
form = issue_forms.NewIssue(instance=issue, journal=issue.journal)
Expand Down Expand Up @@ -1386,18 +1388,20 @@ def manage_issues(request, issue_id=None, event=None):
modal = 'issue'

template = 'journal/manage/issues.html'
try:
galleys = [issue.galley.file]
except IssueGalley.DoesNotExist:
galleys = []
if issue:
try:
galleys = [issue.galley.file]
except IssueGalley.DoesNotExist:
pass
documents = list(issue.documents.all())
context = {
'issues': issue_list if not issue else [issue],
'issue': issue,
'form': form,
'modal': modal,
'galley_form': galley_form,
'galleys': galleys,
'documents': list(issue.documents.all()),
'documents': documents,
'articles': issue.get_sorted_articles(published_only=False) if issue else None,
'sort_form': sort_form,
}
Expand Down
2 changes: 1 addition & 1 deletion src/submission/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ def __init__(self, *args, **kwargs):
license_queryset = license_queryset.filter(
available_for_submission=self.FILTER_PUBLIC_FIELDS,
)
if article.primary_issue and article.primary_issue.allowed_sections:
if article.primary_issue and article.primary_issue.allowed_sections.exists():
section_queryset = section_queryset.filter(
pk__in=article.primary_issue.allowed_sections.values_list('pk', flat=True),
)
Expand Down
5 changes: 2 additions & 3 deletions src/templates/admin/elements/issue/galleys.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,10 @@ <h2>{{ title }}</h2>
<td>{{ file.original_filename|truncatechars:40 }}</td>
<td>{{ object_name|title }}</td>
{% if object_mode == "galley" %}
<td><a href="{% url 'journal_issue_download_galley' issue.pk file.galley.pk %}"><i class="fa fa-download">&nbsp;</i></a>
<td><a href="{% url 'journal_issue_download_galley' issue.pk file.galley.pk %}"><i class="fa fa-download">&nbsp;</i></a></td>
{% else %}
<td><a href="{% url 'journal_issue_download_document' issue.pk file.pk %}"><i class="fa fa-download">&nbsp;</i></a>
<td><a href="{% url 'journal_issue_download_document' issue.pk file.pk %}"><i class="fa fa-download">&nbsp;</i></a></td>
{% endif %}
</td>
{% if object_mode == "galley" %}
<td><a data-open="uploadbox"><i class="fa fa-cloud-upload">&nbsp;</i></a></td>
{% endif %}
Expand Down

0 comments on commit 61fe597

Please sign in to comment.