mirror of
https://github.com/nottinghamtec/PyRIGS.git
synced 2026-01-29 03:12:15 +00:00
Rework version name method to avoid blank names on eventchecklist vehicles/crew
This commit is contained in:
@@ -153,12 +153,18 @@ LOGGING = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
# Tests lock up SQLite otherwise
|
# Tests lock up SQLite otherwise
|
||||||
if DEBUG or STAGING or CI:
|
if STAGING or CI:
|
||||||
CACHES = {
|
CACHES = {
|
||||||
'default': {
|
'default': {
|
||||||
'BACKEND': 'django.core.cache.backends.locmem.LocMemCache'
|
'BACKEND': 'django.core.cache.backends.locmem.LocMemCache'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
elif DEBUG:
|
||||||
|
CACHES = {
|
||||||
|
'default': {
|
||||||
|
'BACKEND': 'django.core.cache.backends.dummy.DummyCache'
|
||||||
|
}
|
||||||
|
}
|
||||||
else:
|
else:
|
||||||
CACHES = {
|
CACHES = {
|
||||||
'default': {
|
'default': {
|
||||||
|
|||||||
@@ -35,17 +35,13 @@
|
|||||||
</h5>
|
</h5>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<p>
|
<p>
|
||||||
<small>
|
|
||||||
{% if version.changes.old == None %}
|
{% if version.changes.old == None %}
|
||||||
Created
|
Created
|
||||||
{% else %}
|
{% else %}
|
||||||
Changed {% include 'partials/version_changes.html' %} in
|
Changed {% include 'partials/version_changes.html' %} in
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{% include 'partials/object_button.html' with object=version.changes.new %}
|
{% include 'partials/object_button.html' with object=version.changes.new %}
|
||||||
</small>
|
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -20,6 +20,8 @@
|
|||||||
<td>
|
<td>
|
||||||
{% if version.changes.old == None %}
|
{% if version.changes.old == None %}
|
||||||
Created {{version.changes.new|to_class_name}}
|
Created {{version.changes.new|to_class_name}}
|
||||||
|
{% elif version.changes.new == None %}
|
||||||
|
Deleted {{version.changes.old|to_class_name}}
|
||||||
{% else %}
|
{% else %}
|
||||||
{% include 'partials/version_changes.html' %}
|
{% include 'partials/version_changes.html' %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|||||||
@@ -114,7 +114,6 @@ class ModelComparison(object):
|
|||||||
if oldValue != newValue and not bothBlank:
|
if oldValue != newValue and not bothBlank:
|
||||||
comparison = FieldComparison(field, oldValue, newValue)
|
comparison = FieldComparison(field, oldValue, newValue)
|
||||||
changes.append(comparison)
|
changes.append(comparison)
|
||||||
|
|
||||||
return changes
|
return changes
|
||||||
|
|
||||||
@cached_property
|
@cached_property
|
||||||
@@ -143,17 +142,6 @@ class ModelComparison(object):
|
|||||||
except KeyError: # there's no matching old version, so add this item to the dictionary by itself
|
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)
|
compare = ModelComparison(new=version._object_version.object, **comparisonParams)
|
||||||
|
|
||||||
if compare.new:
|
|
||||||
if(hasattr(compare.new, 'activity_feed_string')):
|
|
||||||
compare.name = compare.new.activity_feed_string
|
|
||||||
else:
|
|
||||||
compare.name = str(compare.new)
|
|
||||||
else:
|
|
||||||
if(hasattr(compare.old, 'activity_feed_string')):
|
|
||||||
compare.name = compare.old.activity_feed_string
|
|
||||||
else:
|
|
||||||
compare.name = str(compare.old)
|
|
||||||
|
|
||||||
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 = []
|
changes = []
|
||||||
@@ -163,6 +151,19 @@ class ModelComparison(object):
|
|||||||
|
|
||||||
return changes
|
return changes
|
||||||
|
|
||||||
|
@cached_property
|
||||||
|
def name(self):
|
||||||
|
if self.new:
|
||||||
|
if(hasattr(self.new, 'activity_feed_string')):
|
||||||
|
return self.new.activity_feed_string
|
||||||
|
else:
|
||||||
|
return str(compare.new)
|
||||||
|
else:
|
||||||
|
if(hasattr(self.old, 'activity_feed_string')):
|
||||||
|
return self.old.activity_feed_string
|
||||||
|
elif str(self.old):
|
||||||
|
return str(self.old)
|
||||||
|
|
||||||
@cached_property
|
@cached_property
|
||||||
def items_changed(self):
|
def items_changed(self):
|
||||||
return self.item_changes is not None and len(self.item_changes) > 0
|
return self.item_changes is not None and len(self.item_changes) > 0
|
||||||
|
|||||||
Reference in New Issue
Block a user