#132 EMA recording
* automatically record migrated ema using the created data (user + timestamp)
This commit is contained in:
		
							parent
							
								
									5c15f84fba
								
							
						
					
					
						commit
						d19a563491
					
				@ -8,6 +8,7 @@ from ema.models import EmaDocument, Ema
 | 
			
		||||
from intervention.models import Handler, Responsibility
 | 
			
		||||
from konova.management.commands.kspMigrater.compensation_migrater import CompensationMigrater
 | 
			
		||||
from konova.models import DeadlineType, Deadline
 | 
			
		||||
from user.models import UserActionLogEntry
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class EmaMigrater(CompensationMigrater):
 | 
			
		||||
@ -48,7 +49,7 @@ class EmaMigrater(CompensationMigrater):
 | 
			
		||||
            with transaction.atomic():
 | 
			
		||||
                ema_identifier = ema[0]
 | 
			
		||||
                ema_title = ema[1]
 | 
			
		||||
                ema_comment = ema[5]
 | 
			
		||||
                ema_comment = ema[5] or ""
 | 
			
		||||
                ema_obj = Ema.objects.get_or_create(
 | 
			
		||||
                    identifier=ema_identifier
 | 
			
		||||
                )[0]
 | 
			
		||||
@ -65,6 +66,7 @@ class EmaMigrater(CompensationMigrater):
 | 
			
		||||
                ema_obj = self._migrate_finance_volume_to_comment(ema_obj, ema)
 | 
			
		||||
                ema_obj = self._migrate_log(ema_obj, ema)
 | 
			
		||||
                ema_obj = self._migrate_documents(ema_obj, EmaDocument, ema)
 | 
			
		||||
                ema_obj = self._migrate_recorded(ema_obj, ema)
 | 
			
		||||
                ema_obj.save()
 | 
			
		||||
 | 
			
		||||
                num_processed += 1
 | 
			
		||||
@ -86,7 +88,7 @@ class EmaMigrater(CompensationMigrater):
 | 
			
		||||
        db_results = tmp_cursor.fetchall()
 | 
			
		||||
        for result in db_results:
 | 
			
		||||
            deadline_type = result[0]
 | 
			
		||||
            deadline_comment = None
 | 
			
		||||
            deadline_comment = ""
 | 
			
		||||
            if deadline_type == 708166:
 | 
			
		||||
                deadline_comment = "Wiedervorlage"
 | 
			
		||||
            elif deadline_type == 708163:
 | 
			
		||||
@ -197,4 +199,13 @@ class EmaMigrater(CompensationMigrater):
 | 
			
		||||
            ema_obj.comment = comment
 | 
			
		||||
 | 
			
		||||
        tmp_cursor.close()
 | 
			
		||||
        return ema_obj
 | 
			
		||||
        return ema_obj
 | 
			
		||||
 | 
			
		||||
    def _migrate_recorded(self, instance, db_result):
 | 
			
		||||
        instance.recorded = instance.recorded or UserActionLogEntry.get_recorded_action(
 | 
			
		||||
            instance.created.user,
 | 
			
		||||
            "Migriertes Verzeichnen"
 | 
			
		||||
        )
 | 
			
		||||
        instance.recorded.timestamp = instance.created.timestamp
 | 
			
		||||
        instance.recorded.save()
 | 
			
		||||
        return instance
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user