Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed Issues/412 ability to clear sections/instance web/api #522

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

billy3321
Copy link

@billy3321 billy3321 commented Feb 25, 2017

Fixed the issue #412

  • Section delete will delete children sections and speeches.
  • Add delete section button to section_form.
  • Fixed the lack of required packages.

@dracos
Copy link
Member

dracos commented Mar 4, 2017

Thanks for looking at this! Just to note that an easier way to go than a signal might be to change the on_delete of Speech's section column to CASCADE – which would mean when a Section was deleted, all its speeches would be deleted too, if I understand https://docs.djangoproject.com/en/1.8/ref/models/fields/#django.db.models.ForeignKey.on_delete correctly. I believe Section's parent is already set to CASCADE, as that is the default, and so child sections should already be deleted automatically when a Section is deleted – is that not happening for you?

However, I'm not sure if we want to make this always happen – I think it would be possible that someone would want to delete a section but keep all the speeches in it (perhaps they had them in a section, but then changed their mind and wanted to remove the section without having to update every speech). I think it would be good if the web interface would let you, when you are confirming the delete, also say whether you want to delete all the associated speeches – that way, people can pick what they wish to do. If that's something you could look at adding, that'd be great :) You'd need to expand SectionDelete so that it asked this question and then did something different depending on the answer.

@patcon
Copy link

patcon commented Mar 22, 2017

Hi @dracos! Would it be sensible to treat that ask as a value-add? Seems that the deletes are already cascading, so this just adds an easier UI. If @billy3321 has become busy and you're still interested, I could re-test this feature, adding a confirmation message with warning if it's not there. Then I could open another issue to making it optional via the UI :)

Would that be satisfactory?

Y'all are awesome regardless!

@billy3321
Copy link
Author

billy3321 commented Mar 23, 2017

Hi, @dracos, @patcon, thanks for your advice!

I use sayit often, and sometimes when I import a wrong an file, it appear wrong section with a lot of speeches. If I delete the section, it leaves a lot of orphan speeches, and I have no way to delete it all. so I send this pull request, avoid another user have this problem.

In before, I didn't have experience about Django, and I had read the manual about the CASCADE, but I'm not sure that does it cause parent delete while child delete. Thanks for your advice, I change the pre_delete to use the CASCADE.

But, the pull request have some problem about the test, it seems not cause by the code I modified. I don't know how to fix it. May you help me to fix the test? Thank you.

@dracos
Copy link
Member

dracos commented Mar 23, 2017

@billy3321 Thanks! The flake8 test failures aren't related to your changes, no, and I'll try and look at them soon, but the actual test failure is – it is testing that a speech is not deleted when a section is, which your code changes. So you would need to update the test in section_tests.py.

@patcon The section delete does not at present cascade to its speeches, meaning currently you can delete a section without deleting its speeches. As you could delete all the speeches of a section programmatically by deleting each speech individually and then the section (not ideal but possible), the issue I mentioned with this PR is that it would remove that possibility – removing a section would always remove the speeches, even if you didn't want to do that (well, you could programmatically remove the section from each speech first instead).

However, as two people have asked for this and actively want it, it would make no sense to just let this languish and annoy you both/put you off! So I'd be happy to go with this for now, and hopefully address making it optional as with @patcon's suggestion later. What @billy3321 did originally with some code in a signal would presumably actually make that easier (because then in future that code could be called optionally rather than a forced CASCADE on the model). So sorry about that diversion, and hope what I've said makes sense. I will try and fix the flake8 issue on this branch soon.

@patcon
Copy link

patcon commented Mar 24, 2017

@dracos Aaaaaand you are wonderful.

Let me know if I can help @billy3321

@dracos dracos force-pushed the master branch 2 times, most recently from b84d271 to 89952e6 Compare June 11, 2018 14:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants