def create_user_profile(sender, instance, created, **kwargs): """signal handler for User post-save """ if created: user = instance from htk.apps.accounts.utils.general import get_user_profile_model UserProfileModel = get_user_profile_model() profile = UserProfileModel.objects.create(user=user) profile.save() if htk_setting('HTK_SLACK_NOTIFICATIONS_ENABLED'): try: from htk.utils.notifications import slack_notify slack_notify( 'A new user has registered on the site %s: *%s <%s>*' % ( htk_setting('HTK_SITE_NAME'), user.profile.get_display_name(), user.email, )) if htk_setting('HTK_SLACK_BOT_ENABLED'): slack_notify('htk: emaildig %s' % user.email) except: rollbar.report_exc_info() if htk_setting('HTK_ITERABLE_ENABLED'): try: from htk.lib.iterable.utils import get_iterable_api_client itbl = get_iterable_api_client() itbl.notify_sign_up(user) except: rollbar.report_exc_info()
def create_user_profile(sender, instance, created, **kwargs): """signal handler for User post-save """ if created: user = instance from htk.apps.accounts.utils.general import get_user_profile_model UserProfileModel = get_user_profile_model() profile = UserProfileModel.objects.create(user=user) profile.save() if not settings.TEST and htk_setting('HTK_SLACK_NOTIFICATIONS_ENABLED'): try: from htk.utils.notifications import slack_notify slack_notify('A new user has registered on the site %s: *%s <%s>*' % ( get_site_name(), user.profile.get_display_name(), user.email, )) if htk_setting('HTK_SLACK_BOT_ENABLED'): slack_notify('htk: emaildig %s' % user.email) except: rollbar.report_exc_info() if not settings.TEST and htk_setting('HTK_ITERABLE_ENABLED'): try: from htk.lib.iterable.utils import get_iterable_api_client itbl = get_iterable_api_client() itbl.notify_sign_up(user) except: rollbar.report_exc_info() if htk_setting('HTK_INVITATIONS_LIFECYCLE_SIGNALS_ENABLED'): from htk.apps.invitations.services import InvitationsService invitations_service = InvitationsService() invitations_service.process_user_created(user)
def create_user_profile(sender, instance, created, **kwargs): """signal handler for User post-save """ if created: user = instance UserProfileModel = get_user_profile_model() profile = UserProfileModel.objects.create(user=user) profile.save() if htk_setting('HTK_SLACK_NOTIFICATIONS_ENABLED'): slack_notify('A new user has registered on the site: *%s <%s>*' % (user.profile.get_display_name(), user.email,))
def create_missing_user_profiles(): """Create missing user profiles """ UserModel = get_user_model() UserProfileModel = get_user_profile_model() if UserProfileModel: users_without_profiles = UserModel.objects.filter( profile=None ) for user in users_without_profiles: profile = UserProfileModel.objects.create( user = user )
class UserProfileInline(admin.StackedInline): model = get_user_profile_model() fk_name = 'user' can_delete = False filter_horizontal = ()