#NEWLINE# def copy_versions( self ) : #NEWLINE# #INDENT# 'copies versions from one task to another\n        ' #NEWLINE# from_task = self . get_task_from_tree_view ( self . from_task_tree_view ) #NEWLINE# logged_in_user = self . get_logged_in_user ( ) #NEWLINE# if ( not to_task ) : #NEWLINE# #INDENT# QtGui . QMessageBox . critical ( self , 'Error' , 'Please select a task from <b>From Task</b> list' ) #NEWLINE# return #NEWLINE# #UNINDENT# to_task = self . get_task_from_tree_view ( self . to_task_tree_view ) #NEWLINE# if ( not to_task ) : #NEWLINE# #INDENT# QtGui . QMessageBox . critical ( self , 'Error' , 'Please select a task from <b>To Task</b> list' ) #NEWLINE# return #NEWLINE# #UNINDENT# if ( from_task == to_task ) : #NEWLINE# #INDENT# QtGui . QMessageBox . critical ( self , 'Error' , 'Please select two different tasks' ) #NEWLINE# return #NEWLINE# #UNINDENT# from_take_names = map ( ( lambda x : x [ 0 ] ) , db . DBSession . query ( distinct ( Version . take_name ) ) . filter ( ( Version . task == from_task ) ) . order_by ( Version . take_name ) . all ( ) ) #NEWLINE# answer = QtGui . QMessageBox . question ( self , 'Info' , ( 'Will copy %s versions from take names:<br><br>%s<br><br>Is that Ok?' % ( len ( from_take_names ) , '<br>' . join ( from_take_names ) ) ) , QtGui . QMessageBox . Yes , QtGui . QMessageBox . No ) #NEWLINE# if ( answer == QtGui . QMessageBox . Yes ) : #NEWLINE# #INDENT# for take_name in from_take_names : #NEWLINE# #INDENT# latest_version = Version . query . filter_by ( task = from_task ) . filter_by ( take_name = take_name ) . order_by ( Version . version_number . desc ( ) ) . first ( ) #NEWLINE# new_version = Version ( task = to_task , take_name = take_name ) #NEWLINE# new_version . created_by = logged_in_user #NEWLINE# new_version . extension = latest_version . extension #NEWLINE# new_version . description = ( 'Moved from another task (id=%s) with Version Mover' % latest_version . task . id ) #NEWLINE# new_version . created_with = latest_version . created_with #NEWLINE# db . DBSession . add ( new_version ) #NEWLINE# db . DBSession . commit ( ) #NEWLINE# new_version . update_paths ( ) #NEWLINE# db . DBSession . add ( new_version ) #NEWLINE# db . DBSession . commit ( ) #NEWLINE# try : #NEWLINE# #INDENT# os . makedirs ( new_version . absolute_path ) #NEWLINE# #UNINDENT# except OSError : #NEWLINE# #INDENT# pass #NEWLINE# #UNINDENT# shutil . copyfile ( latest_version . absolute_full_path , new_version . absolute_full_path ) #NEWLINE# #UNINDENT# QtGui . QMessageBox . information ( self , 'Success' , ( 'Successfully copied %s versions' % len ( from_take_names ) ) )