Skip to content

Commit

Permalink
#3594 updates the article jump link to use a distinct set of elements…
Browse files Browse the repository at this point in the history
… rather than using stages, will also reduce the number of queries.
  • Loading branch information
ajrbyers committed Mar 19, 2024
1 parent 62c24f6 commit e1b486e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
11 changes: 11 additions & 0 deletions src/submission/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -1679,6 +1679,17 @@ def get_subject_area(self):
def workflow_stages(self):
return core_models.WorkflowLog.objects.filter(article=self)

def distinct_workflow_elements(self):
workflow_element_ids = core_models.WorkflowLog.objects.filter(
article=self,
).values_list(
'element'
).distinct()

return core_models.WorkflowElement.objects.filter(
pk__in=[element_id[0] for element_id in workflow_element_ids]
)

@property
def current_workflow_element(self):
try:
Expand Down
7 changes: 3 additions & 4 deletions src/templates/admin/elements/article_jump.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,9 @@
{% if editor or section_editor %}
<div class="small expanded button-group">
<a class="button" href="{% url 'review_unassigned_article' article.pk %}">Editor Assignment</a>
{% for stage in article.workflow_stages %}

<a class="button{% if stage.element.element_name == 'review' and article.stage == 'Unassigned' %} disabled{% endif %}"
href="{% url stage.element.jump_url article.pk %}">{{ stage.element.element_name|capfirst }}</a>
{% for element in article.distinct_workflow_elements %}
<a class="button{% if element.element_name == 'review' and article.stage == 'Unassigned' %} disabled{% endif %}"
href="{% url element.jump_url article.pk %}">{{ element.element_name|capfirst }}</a>
{% endfor %}
<button class="button" type="button" data-toggle="more-dropdown">Logs, Documents and More</button>

Expand Down

0 comments on commit e1b486e

Please # to comment.