mirror of
https://github.com/nottinghamtec/PyRIGS.git
synced 2026-01-27 10:22:17 +00:00
Move selection logic from template to view
Required adding some extra data to the dict directly. In theory this should produce better performance.
This commit is contained in:
@@ -9,10 +9,9 @@
|
|||||||
<div class="list-group-item">
|
<div class="list-group-item">
|
||||||
<div class="media">
|
<div class="media">
|
||||||
{% for version in object_list %}
|
{% for version in object_list %}
|
||||||
{% if version.item_changes or version.field_changes or version.old == None %}
|
|
||||||
|
|
||||||
{% ifchanged version.revision.user %}
|
{% ifchanged version.revision.user %}
|
||||||
{% if version != object_list|first %}
|
{% if not forloop.first %}
|
||||||
</div> {#/.media-body#}
|
</div> {#/.media-body#}
|
||||||
</div> {#/.media#}
|
</div> {#/.media#}
|
||||||
</div>
|
</div>
|
||||||
@@ -38,8 +37,7 @@
|
|||||||
{% include 'RIGS/object_button.html' with object=version.new %}
|
{% include 'RIGS/object_button.html' with object=version.new %}
|
||||||
</small>
|
</small>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
{% endif %}
|
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -128,11 +128,17 @@ def get_changes_for_version(newVersion, oldVersion=None):
|
|||||||
|
|
||||||
modelClass = newVersion.content_type.model_class()
|
modelClass = newVersion.content_type.model_class()
|
||||||
|
|
||||||
compare = {}
|
compare = {
|
||||||
compare['revision'] = newVersion.revision
|
'revision': newVersion.revision,
|
||||||
compare['new'] = newVersion.object_version.object
|
'new': newVersion.object_version.object,
|
||||||
compare['current'] = modelClass.objects.filter(pk=compare['new'].pk).first()
|
'current': modelClass.objects.filter(pk=newVersion.pk).first(),
|
||||||
compare['version'] = newVersion
|
'version': newVersion,
|
||||||
|
|
||||||
|
# Old things that may not be used
|
||||||
|
'old': None,
|
||||||
|
'field_changes': None,
|
||||||
|
'item_changes': None,
|
||||||
|
}
|
||||||
|
|
||||||
if oldVersion:
|
if oldVersion:
|
||||||
compare['old'] = oldVersion.object_version.object
|
compare['old'] = oldVersion.object_version.object
|
||||||
@@ -219,7 +225,8 @@ class ActivityFeed(generic.ListView):
|
|||||||
|
|
||||||
for thisVersion in context['object_list']:
|
for thisVersion in context['object_list']:
|
||||||
thisItem = get_changes_for_version(thisVersion, None)
|
thisItem = get_changes_for_version(thisVersion, None)
|
||||||
items.append(thisItem)
|
if thisItem['item_changes'] or thisItem['field_changes'] or thisItem['old'] == None:
|
||||||
|
items.append(thisItem)
|
||||||
|
|
||||||
context ['object_list'] = items
|
context ['object_list'] = items
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user