Skip to content

Commit

Permalink
Updated context variable to parent rather than campaign. Added condit…
Browse files Browse the repository at this point in the history
…ion to check for falseness of model_class prior to checking if it is a subclass of DeploymentChildMixin in order to avoid exception.
  • Loading branch information
Edward Keeble committed Nov 15, 2023
1 parent c67af9e commit 2462543
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 14 deletions.
4 changes: 2 additions & 2 deletions app/admin_ui/templates/api_app/canonical/change_history.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@

{% block header %}
<div class="col">
{% if campaign %}
<a href="{% url 'campaign-detail' 'campaign' campaign.uuid %}">&lt; Back to {{ campaign.short_name|default:campaign.update.short_name }}</a>
{% if parent %}
<a href="{% url 'campaign-detail' 'campaign' parent.uuid %}">&lt; Back to {% firstof parent.short_name parent.update.short_name %}</a>
{% else %}
<a href="{% url 'canonical-list' view_model %}">&lt; Back to {{ object.content_type.model_class | verbose_name_plural | title }}</a>
{% endif %}
Expand Down
4 changes: 2 additions & 2 deletions app/admin_ui/templates/api_app/canonical/form_capable.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@

{% block header %}
<div class="col">
{% if campaign %}
<a href="{% url 'campaign-detail' 'campaign' campaign.uuid %}">&lt; Back to {{ campaign.short_name|default:campaign.update.short_name }}</a>
{% if parent %}
<a href="{% url 'campaign-detail' 'campaign' parent.uuid %}">&lt; Back to {% firstof parent.short_name parent.update.short_name %}</a>
{% else %}
<a href="{% url 'canonical-list' view_model %}">&lt; Back to {{ object.content_type.model_class | verbose_name_plural | title }}</a>
{% endif %}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@

{% block header %}
<div class="col">
{% if campaign %}
<a href="{% url 'campaign-detail' 'campaign' campaign.uuid %}">&lt; Back to {{ campaign.short_name|default:campaign.update.short_name }}</a>
{% if parent %}
<a href="{% url 'campaign-detail' 'campaign' parent.uuid %}">&lt; Back to {% firstof parent.short_name parent.update.short_name %}</a>
{% else %}
<a href="{% url 'change-history' view_model canonical_uuid %}">&lt; Back to {{ display_name }} History</a>
{% endif %}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@

{% block header %}
<div class="col">
{% if campaign %}
<a href="{% url 'campaign-detail' 'campaign' campaign.uuid %}">&lt; Back to {{ campaign.short_name|default:campaign.update.short_name }}</a>
{% if parent %}
<a href="{% url 'campaign-detail' 'campaign' parent.uuid %}">&lt; Back to {% firstof parent.short_name parent.update.short_name %}</a>
{% else %}
<a href="{% url 'canonical-list' view_model %}">&lt; Back to {{ display_name }}</a>
{% endif %}
Expand Down
4 changes: 2 additions & 2 deletions app/admin_ui/templates/api_app/form_capable.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@

{% block header %}
<div class="col">
{% if campaign %}
<a href="{% url 'campaign-detail' 'campaign' campaign.uuid %}">&lt; Back to {{ campaign.short_name|default:campaign.update.short_name }}</a>
{% if parent %}
<a href="{% url 'campaign-detail' 'campaign' parent.uuid %}">&lt; Back to {% firstof parent.short_name parent.update.short_name %}</a>
{% else %}
<a href="{% url 'change-list' view_model %}">&lt; Back to {{ object.content_type.model_class | verbose_name_plural | title }}</a>
{% endif %}
Expand Down
8 changes: 4 additions & 4 deletions app/admin_ui/views/v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,18 +85,18 @@ def get_context_data(self, **kwargs) -> dict[str, Any]:
model_instance = self.object

# if we have a change object with no published record
if issubclass(model_class, DeploymentChildMixin) or model_class is Deployment:
if model_class and (issubclass(model_class, DeploymentChildMixin) or model_class is Deployment):
# check if Campaign exists otherwise look up Change object of type Campaign
try:
context["campaign"] = Campaign.objects.get(uuid=change_object.update["campaign"])
context["parent"] = Campaign.objects.get(uuid=change_object.update["campaign"])
except Campaign.DoesNotExist:
context["campaign"] = Change.objects.of_type(Campaign).get(
context["parent"] = Change.objects.of_type(Campaign).get(
uuid=change_object.update["campaign"]
)
elif isinstance(model_instance, DeploymentChildMixin) or isinstance(
model_instance, Deployment
):
context["campaign"] = model_instance.campaign
context["parent"] = model_instance.campaign
return context


Expand Down

0 comments on commit 2462543

Please sign in to comment.