def create_profile_and_userdetail(self, user): userDetail = UserDetail() userDetail.user = user userDetail.save() userena_profile = UserenaSignup.objects.create_userena_profile(user) # All users have an empty profile profile_model = get_profile_model() try: new_profile = user.get_profile() except profile_model.DoesNotExist: new_profile = profile_model(user=user) new_profile.save(using=self._db) # Give permissions to view and change profile for perm in ASSIGNED_PERMISSIONS['profile']: assign(perm[0], user, new_profile) # Give permissions to view and change itself for perm in ASSIGNED_PERMISSIONS['user']: assign(perm[0], user, user) if settings.USERENA_ACTIVATION_REQUIRED: userena_profile.send_activation_email() return user
def get_user_details(user): user_details_list = UserDetail.objects.filter(user = user.id) if len(user_details_list) == 0: user_details = UserDetail() user_details.user = user user_details.smartphone = True user_details.no_messages = False user_details.save() return user_details else: return user_details_list[0]
def fix_profile_and_userdetail(self, user): userDetail = UserDetail() userDetail.user = user userDetail.save() # All users have an empty profile profile_model = get_profile_model() try: new_profile = user.get_profile() except profile_model.DoesNotExist: new_profile = profile_model(user=user) new_profile.save(using=self._db) # Give permissions to view and change profile for perm in ASSIGNED_PERMISSIONS['profile']: assign(perm[0], user, new_profile) # Give permissions to view and change itself for perm in ASSIGNED_PERMISSIONS['user']: assign(perm[0], user, user) return user