mirror of
https://github.com/nottinghamtec/PyRIGS.git
synced 2026-03-04 11:08:24 +00:00
Merge branch 'version_history_diff', second time lucky
This commit is contained in:
@@ -11,6 +11,7 @@ fonts_dir = "fonts"
|
|||||||
|
|
||||||
# You can select your preferred output style here (can be overridden via the command line):
|
# You can select your preferred output style here (can be overridden via the command line):
|
||||||
# output_style = :expanded or :nested or :compact or :compressed
|
# output_style = :expanded or :nested or :compact or :compressed
|
||||||
|
output_style = :compressed
|
||||||
|
|
||||||
# To enable relative paths to assets via compass helper functions. Uncomment:
|
# To enable relative paths to assets via compass helper functions. Uncomment:
|
||||||
# relative_assets = true
|
# relative_assets = true
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -75,6 +75,16 @@ textarea {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
del {
|
||||||
|
background-color: #f2dede;
|
||||||
|
border-radius: 3px;
|
||||||
|
}
|
||||||
|
|
||||||
|
ins {
|
||||||
|
background-color: #dff0d8;
|
||||||
|
border-radius: 3px;
|
||||||
|
}
|
||||||
|
|
||||||
.loading-animation {
|
.loading-animation {
|
||||||
position: relative;
|
position: relative;
|
||||||
margin: 30px auto 0;
|
margin: 30px auto 0;
|
||||||
|
|||||||
@@ -1,40 +1,21 @@
|
|||||||
{% for change in version.field_changes %}
|
{% for change in version.field_changes %}
|
||||||
|
|
||||||
<button title="Changes to {{ change.field.verbose_name }}" type="button" class="btn btn-default btn-xs" data-container="body" data-html="true" data-trigger='hover' data-toggle="popover" data-content='
|
<button title="Changes to {{ change.field.verbose_name }}" type="button" class="btn btn-default btn-xs" data-container="body" data-html="true" data-trigger='hover' data-toggle="popover" data-content='{% spaceless %}
|
||||||
|
{% include "RIGS/version_changes_change.html" %}
|
||||||
{% if change.new %}
|
{% endspaceless %}'>{{ change.field.verbose_name }}</button>
|
||||||
<div class="alert alert-success {% if change.long %}overflow-ellipsis{% endif %}">
|
|
||||||
{% if change.linebreaks %}
|
|
||||||
{{change.new|linebreaksbr}}
|
|
||||||
{% else %}
|
|
||||||
{{change.new}}
|
|
||||||
{% endif %}
|
|
||||||
</div>
|
|
||||||
{% endif %}
|
|
||||||
|
|
||||||
{% if change.old %}
|
|
||||||
<div class="alert alert-danger {% if change.long %}overflow-ellipsis{% endif %}">
|
|
||||||
{% if change.linebreaks %}
|
|
||||||
{{change.old|linebreaksbr}}
|
|
||||||
{% else %}
|
|
||||||
{{change.old}}
|
|
||||||
{% endif %}
|
|
||||||
</div>
|
|
||||||
{% endif %}
|
|
||||||
|
|
||||||
'>{{ change.field.verbose_name }}</button>
|
|
||||||
|
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|
||||||
{% for itemChange in version.item_changes %}
|
{% for itemChange in version.item_changes %}
|
||||||
<button title="Changes to item '{% if itemChange.new %}{{ itemChange.new.name }}{% else %}{{ itemChange.old.name }}{% endif %}'" type="button" class="btn btn-default btn-xs" data-container="body" data-html="true" data-trigger='hover' data-toggle="popover" data-content='
|
<button title="Changes to item '{% if itemChange.new %}{{ itemChange.new.name }}{% else %}{{ itemChange.old.name }}{% endif %}'" type="button" class="btn btn-default btn-xs" data-container="body" data-html="true" data-trigger='hover' data-toggle="popover" data-content='{% spaceless %}
|
||||||
|
<ul class="list-group">
|
||||||
{% for change in itemChange.changes %}
|
{% for change in itemChange.changes %}
|
||||||
<h4>{{ change.field.verbose_name }}</h4>
|
<li class="list-group-item">
|
||||||
|
<h4 class="list-group-item-heading">{{ change.field.verbose_name }}</h4>
|
||||||
{% if change.new %}<div class="alert alert-success">{{change.new|linebreaksbr}}</div>{% endif %}
|
{% include "RIGS/version_changes_change.html" %}
|
||||||
{% if change.old %}<div class="alert alert-danger">{{change.old|linebreaksbr}}</div>{% endif %}
|
</li>
|
||||||
|
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
</ul>
|
||||||
|
|
||||||
'>item '{% if itemChange.new %}{{ itemChange.new.name }}{% else %}{{ itemChange.old.name }}{% endif %}'</button>
|
{% endspaceless %}'>item '{% if itemChange.new %}{{ itemChange.new.name }}{% else %}{{ itemChange.old.name }}{% endif %}'</button>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
26
RIGS/templates/RIGS/version_changes_change.html
Normal file
26
RIGS/templates/RIGS/version_changes_change.html
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
{# 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" %}
|
||||||
|
<ins>{{ diff.text|linebreaksbr }}</ins>
|
||||||
|
{% elif diff.type == "delete" %}
|
||||||
|
<del>{{diff.text|linebreaksbr}}</del>
|
||||||
|
{% else %}
|
||||||
|
<span>{{diff.text|linebreaksbr}}</span>
|
||||||
|
{% endif %}
|
||||||
|
{% endfor %}
|
||||||
|
{% else %}
|
||||||
|
{% if change.old %}
|
||||||
|
<del {% if change.long %}class="overflow-ellipsis"{% endif %}>
|
||||||
|
{{change.old}}
|
||||||
|
</del>
|
||||||
|
{% endif %}
|
||||||
|
{% if change.new and change.old %}
|
||||||
|
<br/>
|
||||||
|
{% endif %}
|
||||||
|
{% if change.new %}
|
||||||
|
<ins {% if change.long %}class="overflow-ellipsis"{% endif %}>
|
||||||
|
{{change.new}}
|
||||||
|
</ins>
|
||||||
|
{% endif %}
|
||||||
|
{% endif %}
|
||||||
@@ -17,6 +17,7 @@ from reversion.models import Version
|
|||||||
from django.contrib.contenttypes.models import ContentType # Used to lookup the content_type
|
from django.contrib.contenttypes.models import ContentType # Used to lookup the content_type
|
||||||
from django.core.paginator import Paginator, EmptyPage, PageNotAnInteger
|
from django.core.paginator import Paginator, EmptyPage, PageNotAnInteger
|
||||||
from django.db.models import ForeignKey, IntegerField, EmailField, TextField
|
from django.db.models import ForeignKey, IntegerField, EmailField, TextField
|
||||||
|
from diff_match_patch import diff_match_patch
|
||||||
|
|
||||||
from RIGS import models, forms
|
from RIGS import models, forms
|
||||||
import datetime
|
import datetime
|
||||||
@@ -64,6 +65,25 @@ def model_compare(oldObj, newObj, excluded_keys=[]):
|
|||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
@property
|
||||||
|
def diff(self):
|
||||||
|
oldText = unicode(self.display_value(self._old)) or ""
|
||||||
|
newText = unicode(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 = []
|
changes = []
|
||||||
|
|
||||||
for thisField in theFields:
|
for thisField in theFields:
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
diff-match-patch==20121119
|
||||||
dj-database-url==0.3.0
|
dj-database-url==0.3.0
|
||||||
dj-static==0.0.6
|
dj-static==0.0.6
|
||||||
Django==1.8.2
|
Django==1.8.2
|
||||||
|
|||||||
Reference in New Issue
Block a user