Skip to content
Snippets Groups Projects
Commit 1dd63a52 authored by Martin Burchell's avatar Martin Burchell
Browse files

Fixed last_modified date for item updated on term

parent b833308f
No related branches found
No related tags found
1 merge request!7Data Layer updates a "last edit date" field on the Item
......@@ -55,6 +55,13 @@ Item = Message
@receiver(models.signals.m2m_changed, sender=Item.terms.through,
dispatch_uid="data_layer.models.terms_signal_handler")
def terms_signal_handler(sender, **kwargs):
if kwargs.get('action') == 'post_add':
instance = kwargs.get('instance')
instance.note_external_modification()
if kwargs.get('action') != 'post_add':
return
if kwargs.get('reverse'):
items = Item.objects.filter(pk__in=kwargs.get('pk_set'))
else:
items = [kwargs.get('instance')]
for item in items:
item.note_external_modification()
......@@ -56,10 +56,22 @@ def test_last_modified_date_updates_on_body_change(item, mock_time_now):
@pytest.mark.django_db
def test_last_modified_date_updates_on_category_change(item, mock_time_now):
def test_last_modified_date_updates_on_item_category_change(
item, mock_time_now):
with patch('django.utils.timezone.now', new=mock_time_now):
orig_last_modified = last_modified(item)
term = TermFactory()
item.terms.add(term)
assert num_updates(orig_last_modified, last_modified(item)) == 1
@pytest.mark.django_db
def test_last_modified_date_updates_on_category_item_change(
item, mock_time_now):
with patch('django.utils.timezone.now', new=mock_time_now):
orig_last_modified = last_modified(item)
term = TermFactory()
term.items.add(item)
assert num_updates(orig_last_modified, last_modified(item)) == 1
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment