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

Assign group while creating a signup code #318

Open
alexlopespereira opened this issue Jul 18, 2019 · 2 comments
Open

Assign group while creating a signup code #318

alexlopespereira opened this issue Jul 18, 2019 · 2 comments

Comments

@alexlopespereira
Copy link

I would like to assign a user to a group on the SignupCode admin view. So that when the user signs up, I check the group associated to a code and add the user to the corresponding group without the burden to do that manualy for a large number of users (more than 1000 users).

How could I do that?

@alexlopespereira
Copy link
Author

I found a clever way to do that. I created a code pattern like this: my_group_name-0001
Then, in the after_signup method I do this:
code = SignupCode.objects.get(email=self.created_user.email).code
group_name = code.split('-')[0]
group = Group.objects.get(name=group_name)
group.user_set.add(self.created_user)

This way I didn't need to customize the SignupCode model nor the Admin view.

Anyway, it would be a nice to do it the right way (changing the Admin view an add a relationship to groups) project so that we do not depend on a code pattern to enable this feature. Consider adding this to the project.

@jonathan-s
Copy link
Contributor

I'd say the correct way is to listen to the signal signup_code_used which is emitted here:

signup_code_used.send(sender=result.__class__, signup_code_result=result)

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