Skip to content

Commit

Permalink
Change has_progress_draft naming and placement
Browse files Browse the repository at this point in the history
  • Loading branch information
Tammo-Feldmann committed Nov 2, 2023
1 parent 60ae854 commit 4de306a
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ <h1 class="my-5">{{ object.short_name }}</h1>

{% block actions %}
<div class="px-1 m-2">
{% if not has_progress_draft %}
{% if not has_draft_in_progress %}
<a href="{% url 'create-update' view_model object.uuid %}?back={{ request.path }}" class="btn btn-primary mx-2">
Edit
</a>
Expand Down
2 changes: 1 addition & 1 deletion app/admin_ui/templates/snippets/object_header_tabs.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
</li>
<li class="nav-item">
<a
class="nav-link {% if not has_progress_draft %} disabled {% endif %} {% if url_name == 'canonical-draft-edit' or url_name == 'create-update' %}active{% endif %}"
class="nav-link {% if not has_draft_in_progress %} disabled {% endif %} {% if url_name == 'canonical-draft-edit' or url_name == 'create-update' %}active{% endif %}"
href="{% url 'canonical-draft-edit' model=view_model canonical_uuid=canonical_uuid %}"
>
Edits
Expand Down
13 changes: 4 additions & 9 deletions app/admin_ui/templatetags/template_extras.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,23 +49,18 @@ def object_header_tabs(context, canonical_uuid: str):
"""
Reusable header for canonical object.
"""

has_published_draft = (
Change.objects.related_drafts(canonical_uuid)
.filter(status=Change.Statuses.PUBLISHED)
.exists()
)

latest_draft = Change.objects.related_drafts(canonical_uuid).order_by("status").first()

return {
"draft_status": latest_draft.get_status_display(),
"draft_status_class": get_draft_status_class(latest_draft.status),
"canonical_uuid": canonical_uuid,
"has_progress_draft": Change.objects.related_in_progress_drafts(
"has_draft_in_progress": Change.objects.related_in_progress_drafts(
uuid=canonical_uuid
).exists(),
"has_published_draft": has_published_draft,
"has_published_draft": Change.objects.related_drafts(canonical_uuid)
.filter(status=Change.Statuses.PUBLISHED)
.exists(),
"request": context.get("request"),
"view_model": context.get("view_model"),
}
2 changes: 1 addition & 1 deletion app/admin_ui/views/v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ def get_context_data(self, **kwargs):
Change.objects.get(uuid=self.kwargs[self.pk_url_kwarg]).model_name.lower()
),
"display_name": Change.objects.get(uuid=self.kwargs[self.pk_url_kwarg]).model_name,
"has_progress_draft": Change.objects.related_in_progress_drafts(
"has_draft_in_progress": Change.objects.related_in_progress_drafts(
self.kwargs[self.pk_url_kwarg]
).exists(),
}
Expand Down

0 comments on commit 4de306a

Please sign in to comment.