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

RFC on a changing GuestManager.convert to update in-place #4

Closed
mbhynes opened this issue Dec 21, 2022 · 3 comments
Closed

RFC on a changing GuestManager.convert to update in-place #4

mbhynes opened this issue Dec 21, 2022 · 3 comments

Comments

@mbhynes
Copy link

mbhynes commented Dec 21, 2022

Hi @julianwachholz,

First off, thank you very much for maintaining this package for new versions of Django!

I've opened this ticket to propose a relatively simple change (or addition) of the GuestManager in the package that I think would enable greater functionality for devs wanting to create guest users.

Background

Business Use Case

I started using this package to enable guest users functionality on a site, with the goal that:

  • ephemeral guest users would be able to modify the db (ie CRUD their own objects like a regular user)
  • after conversion all of the state in related models would be maintained

After reading the documentation for django-guest-user I didn't see any flags that stated this usage wasn't possible, but after installing the package and trying to use it, to the best of my understanding, the use case above is not supported. I think this has also been raised previously in #3.

EDIT:

  • This use case is supported; I had a misconfigured form and had misread the guest creation workflow when debugging.

Thanks very much for your time!

@julianwachholz
Copy link
Owner

julianwachholz commented Dec 21, 2022

Heya! Thanks for the kind words!
I'm going to have to take a deeper look into your other concerns one by one at a later date but I want to address your first point, the business use case.

What you're describing is exactly how guest users are intended to be used and working. It's possible you may have found a bug where converting will create a new user instead of only deleting the Guest instance?

The last line in this test verifies that converting a Guest keeps the User PK

@mbhynes
Copy link
Author

mbhynes commented Dec 21, 2022

Thanks very for your reply! I must have something miscondigured on my end, and I'll take a closer look.

@mbhynes
Copy link
Author

mbhynes commented Dec 21, 2022

Ah, I see my problems:

  • I had a misconfigured GUEST_USER_CONVERT_FORM that subclassed UserCreationForm, but was pointing to the wrong post endpoint; so I was creating new users rather than upserting an existing one 🤦
  • I also misread the guest_user.models code and mistakenly thought that the guest User record was being deleted in GuestManager.convert(), when it's just the Guest record being deleted, and had missed that the User instance was supposed to be bound in the form view (because I had the wrong endpoint, my guest User instances were not being bound)

Thanks very much for your time and helping me debug from afar ...

@mbhynes mbhynes closed this as completed Dec 21, 2022
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

No branches or pull requests

2 participants