Created
January 16, 2013 18:53
-
-
Save pije76/4549702 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from socialregistration.signals import connect as profile_connect | |
PERMISSIONS = { | |
'profile': ('view_profile', 'change_profile'), | |
'user': ('change_user', 'delete_user') | |
} | |
def social_connect_callback(sender, user, profile, client, **kwargs): | |
""" | |
Create a profile for this user after connecting | |
""" | |
# Create a userena user. | |
# TODO: You could make it prettier by setting a ``activation_key`` of ``ALREADY_ACTIVATED`` | |
# and looking at good values for the other fields of the model. | |
userenaSignup = UserenaSignup.objects.get_or_create(user=user) | |
# Create profile for user | |
try: | |
new_profile = Profile.objects.get(user=user) | |
except: | |
new_profile = Profile.objects.create(user=user) | |
# Set some minimal permissions | |
for perm in PERMISSIONS['profile']: | |
assign(perm, new_profile.user, new_profile) | |
for perm in PERMISSIONS['user']: | |
assign(perm, new_profile.user, new_profile.user) | |
profile_connect.connect(social_connect_callback) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment