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

Deleting user causes cascade delete on glosses #201

Open
henrinie opened this issue Nov 21, 2016 · 5 comments
Open

Deleting user causes cascade delete on glosses #201

henrinie opened this issue Nov 21, 2016 · 5 comments

Comments

@henrinie
Copy link
Member

Django-admin wants to cascade delete on user to glosses the user created.
We need to remove this behaviour to avoid possible mistakes causing losses of glosses.

At this moment, if you want to delete a user, just set Active false on the user instead.

@henrinie
Copy link
Member Author

henrinie commented Nov 21, 2016

Also, some weird character problem occurs when deleting users and language is set to Finnish. This probably has to do with users that registered with the registration feature and filled in some information having weird characters, or something like that. Hopefully #177 will fix this.

@ocrasborn
Copy link

@Woseseltops , could you check if this is a problem for us as well?

@Woseseltops
Copy link

@ocrasborn based on Henri's descriptions I would have thought so, but apparently not: I created a gloss with the test user, and then deleted the test user, and the gloss is still there (now without a creator). The admin did mention it was going to remove the 'gloss-creator' relationship, which apparently means: not the gloss.

@henrinie
Copy link
Member Author

I think I have spotted the reason for this.
In FinSL we have: https://github.com/Signbank/FinSL-signbank/blob/master/signbank/dictionary/models.py#L324
And in NGT you have this: https://github.com/Signbank/NGT-signbank/blob/master/signbank/dictionary/models.py#L432

So in FinSL we use ForeignKey field for the gloss creator, in NGT m2m field is used. FKey field seems to default to on_delete=models.CASCADE

We need to set on_delete=models.SET_NULL, but then we have to have make the field nullable as well. More info at: https://docs.djangoproject.com/en/1.10/ref/models/fields/#django.db.models.ForeignKey.on_delete

@henrinie henrinie added the minor label Nov 25, 2016
@henrinie
Copy link
Member Author

Django docs suggests that you don't delete users. Therefore this issue might be irrelevant, at least it is not a very high priority.
It might still be useful to change to 'on_delete=models.SET_NULL', if someone some day tries to delete a user, and ignores the warning that the glosses created by this user will be deleted as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants