- {% include 'partials/last_edited.html' with target="invoice_history" %}
+
+ {% include 'partials/last_edited.html' with target="invoice_history" %}
+
{% endblock %}
diff --git a/RIGS/templatetags/filters.py b/RIGS/templatetags/filters.py
index f95ff0f6..2c0af443 100644
--- a/RIGS/templatetags/filters.py
+++ b/RIGS/templatetags/filters.py
@@ -137,19 +137,6 @@ def profile_by_index(value):
else:
return ""
-#TODO More sensible returns
-@register.filter
-def get_json_element(value, element):
- try:
- return json.loads(value)[str(element)]
- except Exception as e:
- return None
-
-@register.filter
-def get_item(dictionary, key):
- if(type(dictionary) is dict):
- return dictionary.get(key)
-
@register.filter
def next(alist, current_index):
"""
diff --git a/RIGS/urls.py b/RIGS/urls.py
index a1436fae..439b8cee 100644
--- a/RIGS/urls.py
+++ b/RIGS/urls.py
@@ -115,6 +115,9 @@ urlpatterns = [
name='ec_history', kwargs={'model': models.EventChecklist}),
path('event/checklist/list', permission_required_with_403('RIGS.change_event')(hs.EventChecklistList.as_view()),
name='ec_list'),
+ # TEMPORARY
+ path('event/vehicle/
/history/', permission_required_with_403('RIGS.change_event')(versioning.VersionHistory.as_view()),
+ name='vc_history', kwargs={'model': models.EventChecklistVehicle}),
# Finance
path('invoice/', permission_required_with_403('RIGS.view_invoice')(finance.InvoiceIndex.as_view()),
diff --git a/versioning/templates/activity_feed_data.html b/versioning/templates/activity_feed_data.html
index 6f7e0fad..22f5410f 100644
--- a/versioning/templates/activity_feed_data.html
+++ b/versioning/templates/activity_feed_data.html
@@ -35,7 +35,7 @@
{% if version.changes.old == None %}
Created
{% else %}
- Changed {% include 'version_changes.html' %} in
+ Changed {% include 'partials/version_changes.html' %} in
{% endif %}
{% include 'partials/object_button.html' with object=version.changes.new %}
diff --git a/versioning/templates/version_changes.html b/versioning/templates/partials/version_changes.html
similarity index 92%
rename from versioning/templates/version_changes.html
rename to versioning/templates/partials/version_changes.html
index 541b33c0..a3a5a081 100644
--- a/versioning/templates/version_changes.html
+++ b/versioning/templates/partials/version_changes.html
@@ -1,4 +1,4 @@
-{% if version.changes.item_changes or version.changes.field_changes or version.changes.old == None %}
+{% if version.changes.anything_changed or version.changes.old == None %}
{% for change in version.changes.field_changes %}
{{ change.field.verbose_name }}
{% endfor %}
diff --git a/versioning/templates/partials/version_history_table.html b/versioning/templates/partials/version_history_table.html
index 96fe6780..f45c099e 100644
--- a/versioning/templates/partials/version_history_table.html
+++ b/versioning/templates/partials/version_history_table.html
@@ -19,7 +19,7 @@
{% if version.changes.old is None %}
{{object|to_class_name}} Created
{% else %}
- {% include 'version_changes.html' %}
+ {% include 'partials/version_changes.html' %}
{% endif %}
diff --git a/versioning/versioning.py b/versioning/versioning.py
index 93b6bd15..85f727d2 100644
--- a/versioning/versioning.py
+++ b/versioning/versioning.py
@@ -67,7 +67,6 @@ class FieldComparison(object):
class ModelComparison(object):
-
def __init__(self, old=None, new=None, version=None, excluded_keys=[]):
# recieves two objects of the same model, and compares them. Returns an array of FieldCompare objects
try:
@@ -117,29 +116,30 @@ class ModelComparison(object):
@cached_property
def item_changes(self):
# Recieves two event version objects and compares their items, returns an array of ItemCompare objects
-
item_type = ContentType.objects.get_for_model(models.EventItem)
- old_item_versions = self.version.parent.revision.version_set.filter(content_type=item_type)
- new_item_versions = self.version.revision.version_set.filter(content_type=item_type)
+ item_dict = {}
+ if hasattr(self.version, 'parent'):
+ old_item_versions = self.version.parent.revision.version_set.filter(content_type=item_type)
+ new_item_versions = self.version.revision.version_set.filter(content_type=item_type)
- comparisonParams = {'excluded_keys': ['id', 'event', 'order']}
+ comparisonParams = {'excluded_keys': ['id', 'event', 'order']}
- # Build some dicts of what we have
- item_dict = {} # build a list of items, key is the item_pk
- for version in old_item_versions: # put all the old versions in a list
- if version.field_dict["event_id"] == int(self.new.pk):
- compare = ModelComparison(old=version._object_version.object, **comparisonParams)
- item_dict[version.object_id] = compare
+ # Build some dicts of what we have
+ # build a list of items, key is the item_pk
+ for version in old_item_versions: # put all the old versions in a list
+ if version.field_dict["event_id"] == int(self.new.pk):
+ compare = ModelComparison(old=version._object_version.object, **comparisonParams)
+ item_dict[version.object_id] = compare
- for version in new_item_versions: # go through the new versions
- if version.field_dict["event_id"] == int(self.new.pk):
- try:
- compare = item_dict[version.object_id] # see if there's a matching old version
- compare.new = version._object_version.object # then add the new version to the dictionary
- except KeyError: # there's no matching old version, so add this item to the dictionary by itself
- compare = ModelComparison(new=version._object_version.object, **comparisonParams)
+ for version in new_item_versions: # go through the new versions
+ if version.field_dict["event_id"] == int(self.new.pk):
+ try:
+ compare = item_dict[version.object_id] # see if there's a matching old version
+ compare.new = version._object_version.object # then add the new version to the dictionary
+ except KeyError: # there's no matching old version, so add this item to the dictionary by itself
+ compare = ModelComparison(new=version._object_version.object, **comparisonParams)
- item_dict[version.object_id] = compare # update the dictionary with the changes
+ item_dict[version.object_id] = compare # update the dictionary with the changes
changes = []
for (_, compare) in list(item_dict.items()):