<s> import os <EOL> import random <EOL> from django . contrib . auth . models import User <EOL> from django . db . models import signals <EOL> from django . conf import settings <EOL> from user . models import UserProfile <EOL> from utils . system import remove_tree <EOL> def create_user_profile_signal ( sender , instance , created , ** kwargs ) : <EOL> """<STR_LIT>""" <EOL> if created : <EOL> stock_avatar_id = random . randint ( <NUM_LIT:0> , <NUM_LIT:9> ) + <NUM_LIT:1> <EOL> UserProfile . objects . create ( user = instance , avatar = '<STR_LIT>' . format ( stock_avatar_id ) ) <EOL> def create_user_fullname ( sender , instance , created , ** kwargs ) : <EOL> """<STR_LIT>""" <EOL> profile = UserProfile . objects . get ( user_id = instance . id ) <EOL> profile . name = '<STR_LIT>' . format ( instance . first_name , instance . last_name ) <EOL> profile . save ( ) <EOL> def create_user_deposit_signal ( sender , instance , created , ** kwargs ) : <EOL> """<STR_LIT>""" <EOL> if created : <EOL> os . makedirs ( os . path . join ( settings . GIT_DEPOSIT_ROOT , instance . username ) ) <EOL> def delete_user_deposit_signal ( sender , instance , using , ** kwargs ) : <EOL> """<STR_LIT>""" <EOL> remove_tree ( os . path . join ( settings . GIT_DEPOSIT_ROOT , instance . username ) ) <EOL> signals . post_save . connect ( create_user_profile_signal , sender = User , weak = False ) <EOL> signals . post_delete . connect ( delete_user_deposit_signal , sender = User , weak = False ) <EOL> signals . post_save . connect ( create_user_deposit_signal , sender = User , weak = False ) <EOL> signals . post_save . connect ( create_user_fullname , sender = User , weak = False ) </s>
