ipol-journal / ipolDevel

IPOL demo system development
GNU Affero General Public License v3.0
23 stars 3 forks source link

[CP/fix] user email sync with demoinfo db #165

Closed hmaciasc closed 1 year ago

hmaciasc commented 1 year ago

Since as of now demoinfo returns OK but no information in some cases due to mismatch between CP database and demoinfo database concerning editors I've changed it so if no editor is returned it will asume editors will be added to demoinfo if the email is not in there yet.

It is a small change but wanted to make everyone review instead of just commit it.

hmaciasc commented 1 year ago

The case that motivated this fix, it was having an empty email from a new user. It should go to "elif not old_editor_exists and not editor_exists" and it'll assign a None to the email. If I understood correctly, this is what is intended. Can't reply to your message @mcolom so I'll quote. It will assign None to the email in that signal and won't send anything to demoinfo since demoinfo can't save an editor with no email which is a DISTINCT field on the DB. It will only add_editor when we have an email and that email is not in use. If we find old_email in demoinfo and new email is different then we update editor in demoinfo. If somehow (errors or manual changes) an editor is not updated in demoinfo while being updated on CP it will probably create problems in the future but those cases should be very rare. Until we remove one of the DBs, django or demoinfo editor we will keep having such problems, hopefully less and less with this fix.

mcolom commented 1 year ago

The case that motivated this fix, it was having an empty email from a new user. It should go to "elif not old_editor_exists and not editor_exists" and it'll assign a None to the email. If I understood correctly, this is what is intended. Can't reply to your message @mcolom so I'll quote. It will assign None to the email in that signal and won't send anything to demoinfo since demoinfo can't save an editor with no email which is a DISTINCT field on the DB. It will only add_editor when we have an email and that email is not in use. If we find old_email in demoinfo and new email is different then we update editor in demoinfo. If somehow (errors or manual changes) an editor is not updated in demoinfo while being updated on CP it will probably create problems in the future but those cases should be very rare. Until we remove one of the DBs, django or demoinfo editor we will keep having such problems, hopefully less and less with this fix.

Ok, thanks for the explanation! And for adding the comments in the code also.