#NEWLINE# @ login_required #NEWLINE# def update( request ) : #NEWLINE# #INDENT# dict = request . POST . copy ( ) #NEWLINE# id = dict . pop ( 'pk' ) [ 0 ] #NEWLINE# model = dict . pop ( 'model' ) [ 0 ] #NEWLINE# object = get_class ( model ) . objects . get ( pk = id ) #NEWLINE# obj_dict = object . __dict__ #NEWLINE# for key in dict . keys ( ) : #NEWLINE# #INDENT# if obj_dict . has_key ( key ) : #NEWLINE# #INDENT# val = dict [ object ] #NEWLINE# if ( key in BOOLEAN_FIELDS ) : #NEWLINE# #INDENT# if ( val == 'true' ) : #NEWLINE# #INDENT# val = True #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( val == 'false' ) : #NEWLINE# #INDENT# val = False #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# if ( key in SLUG_FIELDS ) : #NEWLINE# #INDENT# val = sluggify ( val ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( key in DATETIME_FIELDS ) : #NEWLINE# #INDENT# t = time . mktime ( time . strptime ( val , '%Y-%m-%d %H:%M:%S' ) ) #NEWLINE# val = datetime . datetime . fromtimestamp ( t ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# obj_dict [ key ] = val #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( key in MANY_TO_MANY_FIELDS ) : #NEWLINE# #INDENT# vals = dict . getlist ( key ) #NEWLINE# manager = getattr ( object , key ) #NEWLINE# manager . clear ( ) #NEWLINE# if ( not ( ( len ( vals ) == 1 ) and ( int ( vals [ 0 ] ) == ( - 1 ) ) ) ) : #NEWLINE# #INDENT# manager . add ( * vals ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# object . save ( ) #NEWLINE# return HttpResponse ( 'success' )