FEAT: Initial work on revision history for assets

The revision history for individual items mostly works, though it shows database ID where it should show asset ID. Recent changes feed isn't yet done.
This commit is contained in:
2019-12-13 20:19:17 +00:00
parent 7c876348d7
commit 206b54dab0
6 changed files with 44 additions and 7 deletions

View File

@@ -6,7 +6,7 @@ from django.utils.decorators import method_decorator
from django.urls import reverse
from django.db.models import Q
from assets import models, forms
from RIGS import versioning
@method_decorator(csrf_exempt, name='dispatch')
class AssetList(LoginRequiredMixin, generic.ListView):
@@ -203,3 +203,17 @@ class SupplierUpdate(generic.UpdateView):
model = models.Supplier
form_class = forms.SupplierForm
template_name = 'supplier_update.html'
class AssetVersionHistory(AssetIDUrlMixin, versioning.VersionHistory):
def get_context_data(self, **kwargs):
thisModel = self.kwargs['model']
context = super(versioning.VersionHistory, self).get_context_data(**kwargs)
queryset = models.Asset.objects.filter(asset_id=self.kwargs['pk'])
try:
# Get the single item from the filtered queryset
context['object'] = queryset.get()
except queryset.model.DoesNotExist:
raise Http404(_("No %(verbose_name)s found matching the query") %
{'verbose_name': queryset.model._meta.verbose_name})
return context