def restore_object( self, attrs, instance=None ): graph_id = attrs.get( 'graph_id' ) if attrs.get( 'graph_id' )\ else helper_util.gen_id() d = attrs.get( 'last_updated' ) d = d.replace( tzinfo=ptz( 'UTC' ) ) try: instance = Graph.objects.get( graph_id = graph_id ) if instance.last_updated > d: return instance except Graph.DoesNotExist: instance = Graph( graph_id = graph_id ) instance.in_progress = attrs.get( 'in_progress' ) instance.matrix_size = attrs.get( 'matrix_size' ) instance.graph = attrs.get( 'graph' ) instance.last_updated = attrs.get( 'last_updated' ) return instance
def restore_object( self, attrs, instance=None ): graph_id = attrs.get( 'graph_id' ) if attrs.get( 'graph_id' )\ else helper_util.gen_id() if Graph.objects.filter( graph_id = graph_id ).count() < 1: instance = Graph.objects.get( graph_id = graph_id ) if instance.last_updated > attrs.get( 'last_updated' ): return instance else: instance = Graph( graph_id = graph_id ) instance.in_progress = attrs.get( 'in_progress' ) instance.matrix_size = attrs.get( 'matrix_size' ) instance.graph = attrs.get( 'graph' ) instance.last_updated = attrs.get( 'last_updated' ) instance.coin_id = attrs.get( 'coin_id' ) instance.coin_status = attrs.get( 'coin_status' ) instance.error_code = attrs.get( 'error_code' ) instance.is_solution = attrs.get( 'is_solution' ) instance.passed_isomorph_check = attrs.get( 'passed_isomorph_check' ) instance.is_to_validation = attrs.get( 'is_to_validation' ) instance.is_synced = attrs.get( 'is_synced' ) return instance