mirror of
https://github.com/nottinghamtec/PyRIGS.git
synced 2026-02-10 00:39:40 +00:00
Restrict versioning to one level of depth for speed
Also fixed the template for nested changes
This commit is contained in:
@@ -254,3 +254,4 @@ class EventChecklistForm(forms.ModelForm):
|
|||||||
class Meta:
|
class Meta:
|
||||||
model = models.EventChecklist
|
model = models.EventChecklist
|
||||||
fields = '__all__'
|
fields = '__all__'
|
||||||
|
exclude = ['reviewed_at', 'reviewed_by']
|
||||||
|
|||||||
@@ -382,7 +382,7 @@ class EventAuthorisationTestCase(TestCase):
|
|||||||
order=1)
|
order=1)
|
||||||
|
|
||||||
def test_event_property(self):
|
def test_event_property(self):
|
||||||
auth1 = models.EventAuthorisation.objects.create(event=self.event, email="authroisation@model.test.case",
|
auth1 = models.EventAuthorisation.objects.create(event=self.event, email="authorisation@model.test.case",
|
||||||
name="Test Auth 1", amount=self.event.total - 1,
|
name="Test Auth 1", amount=self.event.total - 1,
|
||||||
sent_by=self.profile)
|
sent_by=self.profile)
|
||||||
self.assertFalse(self.event.authorised)
|
self.assertFalse(self.event.authorised)
|
||||||
@@ -392,7 +392,7 @@ class EventAuthorisationTestCase(TestCase):
|
|||||||
|
|
||||||
def test_last_edited(self):
|
def test_last_edited(self):
|
||||||
with reversion.create_revision():
|
with reversion.create_revision():
|
||||||
auth = models.EventAuthorisation.objects.create(event=self.event, email="authroisation@model.test.case",
|
auth = models.EventAuthorisation.objects.create(event=self.event, email="authorisation@model.test.case",
|
||||||
name="Test Auth", amount=self.event.total,
|
name="Test Auth", amount=self.event.total,
|
||||||
sent_by=self.profile)
|
sent_by=self.profile)
|
||||||
self.assertIsNotNone(auth.last_edited_at)
|
self.assertIsNotNone(auth.last_edited_at)
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
{% for change in itemchange.field_changes %}
|
{% for change in itemchange.field_changes %}
|
||||||
<li class="list-group-item">
|
<li class="list-group-item">
|
||||||
<p>{{ change.field.verbose_name|title }}:</p>
|
<p>{{ change.field.verbose_name|title }}:</p>
|
||||||
<div class="dont-break-out">{% include 'partials/version_changes_change.html' with change=itemchange %}</div>
|
<div class="dont-break-out">{% include 'partials/version_changes_change.html' with change=change %}</div>
|
||||||
</li>
|
</li>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</ul>
|
</ul>
|
||||||
|
|||||||
@@ -69,7 +69,7 @@ class FieldComparison(object):
|
|||||||
|
|
||||||
|
|
||||||
class ModelComparison(object):
|
class ModelComparison(object):
|
||||||
def __init__(self, old=None, new=None, version=None, excluded_keys=[]):
|
def __init__(self, old=None, new=None, version=None, follow=False, excluded_keys=[]):
|
||||||
# recieves two objects of the same model, and compares them. Returns an array of FieldCompare objects
|
# recieves two objects of the same model, and compares them. Returns an array of FieldCompare objects
|
||||||
try:
|
try:
|
||||||
self.fields = old._meta.get_fields()
|
self.fields = old._meta.get_fields()
|
||||||
@@ -80,6 +80,7 @@ class ModelComparison(object):
|
|||||||
self.new = new
|
self.new = new
|
||||||
self.excluded_keys = excluded_keys
|
self.excluded_keys = excluded_keys
|
||||||
self.version = version
|
self.version = version
|
||||||
|
self.follow = follow
|
||||||
|
|
||||||
@cached_property
|
@cached_property
|
||||||
def revision(self):
|
def revision(self):
|
||||||
@@ -117,6 +118,7 @@ class ModelComparison(object):
|
|||||||
|
|
||||||
@cached_property
|
@cached_property
|
||||||
def item_changes(self):
|
def item_changes(self):
|
||||||
|
if self.follow:
|
||||||
item_type = ContentType.objects.get_for_model(self.version.object)
|
item_type = ContentType.objects.get_for_model(self.version.object)
|
||||||
old_item_versions = self.version.parent.revision.version_set.exclude(content_type=item_type)
|
old_item_versions = self.version.parent.revision.version_set.exclude(content_type=item_type)
|
||||||
new_item_versions = self.version.revision.version_set.exclude(content_type=item_type)
|
new_item_versions = self.version.revision.version_set.exclude(content_type=item_type)
|
||||||
@@ -125,9 +127,7 @@ class ModelComparison(object):
|
|||||||
|
|
||||||
# Build some dicts of what we have
|
# Build some dicts of what we have
|
||||||
item_dict = {} # build a list of items, key is the item_pk
|
item_dict = {} # build a list of items, key is the item_pk
|
||||||
# FIXME Removing the if checks makes things REALLY slow...
|
|
||||||
for version in old_item_versions: # put all the old versions in a list
|
for version in old_item_versions: # put all the old versions in a list
|
||||||
print(version)
|
|
||||||
# if version.field_dict["event_id"] == int(self.new.pk):
|
# if version.field_dict["event_id"] == int(self.new.pk):
|
||||||
compare = ModelComparison(old=version._object_version.object, **comparisonParams)
|
compare = ModelComparison(old=version._object_version.object, **comparisonParams)
|
||||||
item_dict[version.object_id] = compare
|
item_dict[version.object_id] = compare
|
||||||
@@ -199,5 +199,6 @@ class RIGSVersion(Version):
|
|||||||
return ModelComparison(
|
return ModelComparison(
|
||||||
version=self,
|
version=self,
|
||||||
new=self._object_version.object,
|
new=self._object_version.object,
|
||||||
old=self.parent._object_version.object if self.parent else None
|
old=self.parent._object_version.object if self.parent else None,
|
||||||
|
follow=True
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user