diff --git a/RIGS/templates/RIGS/version_changes.html b/RIGS/templates/RIGS/version_changes.html
index 98abaf15..9fd57020 100644
--- a/RIGS/templates/RIGS/version_changes.html
+++ b/RIGS/templates/RIGS/version_changes.html
@@ -1,40 +1,23 @@
{% for change in version.field_changes %}
-
+
{% endfor %}
{% for itemChange in version.item_changes %}
-
+ {% endspaceless %}'>item '{% if itemChange.new %}{{ itemChange.new.name }}{% else %}{{ itemChange.old.name }}{% endif %}'
{% endfor %}
\ No newline at end of file
diff --git a/RIGS/templates/RIGS/version_changes_change.html b/RIGS/templates/RIGS/version_changes_change.html
new file mode 100644
index 00000000..19411a36
--- /dev/null
+++ b/RIGS/templates/RIGS/version_changes_change.html
@@ -0,0 +1,27 @@
+{# pass in variable "change" to this template #}
+
+{% if change.linebreaks and change.new and change.old %}
+ {% for diff in change.diff %}
+ {% if diff.type == "insert" %}
+ {{ diff.text|linebreaksbr }}
+ {% elif diff.type == "delete" %}
+ {{diff.text|linebreaksbr}}
+ {% else %}
+ {{diff.text|linebreaksbr}}
+ {% endif %}
+ {% endfor %}
+{% else %}
+ {% if change.old %}
+
+ {{change.old}}
+
+ {% endif %}
+ {% if change.new and change.old %}
+
+ {% endif %}
+ {% if change.new %}
+
+ {{change.new}}
+
+ {% endif %}
+{% endif %}
\ No newline at end of file
diff --git a/RIGS/versioning.py b/RIGS/versioning.py
index fa54e9ff..38c92936 100644
--- a/RIGS/versioning.py
+++ b/RIGS/versioning.py
@@ -17,6 +17,7 @@ from reversion.models import Version
from django.contrib.contenttypes.models import ContentType # Used to lookup the content_type
from django.core.paginator import Paginator, EmptyPage, PageNotAnInteger
from django.db.models import ForeignKey, IntegerField, EmailField, TextField
+from diff_match_patch import diff_match_patch
from RIGS import models, forms
import datetime
@@ -64,6 +65,25 @@ def model_compare(oldObj, newObj, excluded_keys=[]):
return True
return False
+ @property
+ def diff(self):
+ oldText = str(self.display_value(self._old)) or ""
+ newText = str(self.display_value(self._new)) or ""
+ dmp = diff_match_patch()
+ diffs = dmp.diff_main(oldText, newText)
+ dmp.diff_cleanupSemantic(diffs)
+
+ outputDiffs = []
+
+ for (op, data) in diffs:
+ if op == dmp.DIFF_INSERT:
+ outputDiffs.append({'type':'insert', 'text':data})
+ elif op == dmp.DIFF_DELETE:
+ outputDiffs.append({'type':'delete', 'text':data})
+ elif op == dmp.DIFF_EQUAL:
+ outputDiffs.append({'type':'equal', 'text':data})
+ return outputDiffs
+
changes = []
for thisField in theFields: