From 176324ed79df002154a5ade2da69bfc24bbbca02 Mon Sep 17 00:00:00 2001 From: FreneticScribbler Date: Mon, 6 Apr 2020 14:59:10 +0100 Subject: [PATCH] Tweak versioning templates to allow ID overrides Asset specific templates begone. Still need to bring back the ID formatting for the Rigboard. --- assets/templates/asset_detail.html | 2 +- assets/views.py | 19 +++++++++++++++++-- versioning/templates/activity_feed.html | 2 +- versioning/templates/activity_table.html | 8 ++++---- .../templates/asset_activity_table.html | 17 ----------------- .../templates/asset_version_history.html | 18 ------------------ .../templates/partials/last_edited.html | 2 +- .../templates/partials/last_edited_asset.html | 5 ----- .../{ => partials}/version_scripts.html | 0 versioning/templates/version_history.html | 8 ++++---- versioning/versioning.py | 7 +++++++ 11 files changed, 35 insertions(+), 53 deletions(-) delete mode 100644 versioning/templates/asset_activity_table.html delete mode 100644 versioning/templates/asset_version_history.html delete mode 100644 versioning/templates/partials/last_edited_asset.html rename versioning/templates/{ => partials}/version_scripts.html (100%) diff --git a/assets/templates/asset_detail.html b/assets/templates/asset_detail.html index 798ab68e..0ab8a8fe 100644 --- a/assets/templates/asset_detail.html +++ b/assets/templates/asset_detail.html @@ -30,5 +30,5 @@
{% include 'partials/asset_buttons.html' %}
-{% include 'partials/last_edited_asset.html' with target="asset_history" %} +{% include 'partials/last_edited.html' with target="asset_history" id=object.asset_id %} {% endblock %} diff --git a/assets/views.py b/assets/views.py index 9faeb468..c6ab541d 100644 --- a/assets/views.py +++ b/assets/views.py @@ -233,18 +233,33 @@ class SupplierVersionHistory(versioning.VersionHistory): class AssetVersionHistory(versioning.VersionHistory): - template_name = "asset_version_history.html" + template_name = "version_history.html" def get_object(self, **kwargs): return get_object_or_404(models.Asset, asset_id=self.kwargs['pk']) + def get_context_data(self, **kwargs): + context = super(AssetVersionHistory, self).get_context_data(**kwargs) + context['object'] = self.get_object() + context['id'] = self.get_object().asset_id + context['override'] = 'base_assets.html' + + return context + class ActivityTable(versioning.ActivityTable): model = versioning.RIGSVersion - template_name = "asset_activity_table.html" + template_name = "activity_table.html" paginate_by = 25 def get_queryset(self): versions = versioning.RIGSVersion.objects.get_for_multiple_models( [models.Asset, models.Supplier]) return versions + + def get_context_data(self, **kwargs): + context = super(ActivityTable, self).get_context_data(**kwargs) + context['override'] = 'base_assets.html' + context['title'] = 'Asset Database' + + return context diff --git a/versioning/templates/activity_feed.html b/versioning/templates/activity_feed.html index c61f9065..6e55acd4 100644 --- a/versioning/templates/activity_feed.html +++ b/versioning/templates/activity_feed.html @@ -1,5 +1,5 @@ {% block js %} -{% include 'version_scripts.html' %} +{% include 'partials/version_scripts.html' %}