denshoproject / ddr-local

Web UI used for interacting with DDR collections and entities on a local machine.
Other
3 stars 0 forks source link

Cannot delete Entities #297

Open gjost opened 2 years ago

gjost commented 2 years ago

When attempting to remove an Entity from a test collection, the following:

Traceback (most recent call last):
File "/opt/ddr-local/venv/ddrlocal/lib/python3.7/site-packages/celery/app/trace.py", line 412, in trace_task
R = retval = fun(*args, **kwargs)
File "/opt/ddr-local/venv/ddrlocal/lib/python3.7/site-packages/celery/app/trace.py", line 704, in __protected_call__
return self.run(*args, **kwargs)
File "/opt/ddr-local/ddrlocal/webui/tasks/entity.py", line 162, in entity_delete
git_name, git_mail, agent, commit=True
File "/opt/ddr-local/venv/ddrlocal/lib/python3.7/site-packages/ddr_cmdln-5.0.17-py3.7.egg/DDR/models/entity.py", line 284, in delete
parent.remove_child(self.id)
AttributeError: 'Collection' object has no attribute 'remove_child'

This looks like a case where code was copied between File.delete() and Entity.delete() functions in an attempt to keep the code as uniform as possible but where different things are actually supposed to happen.

When deleting a File, not only do the JSON and binary files be deleted, but the file must be removed from the parent Entity, hence the Entity.remove_child function.

When deleting Entities we don't need to modify the parent Collection at all. This should be a simple matter of just removing the parent.remove_child code. BUT...

When users delete an Entity, the child File(s) should also be deleted. We probably want a confirmation page. Thoughts?