# -*- coding: utf-8 -*-
from ppms.migration.packet import *

class FixPacketReleaseSorting(ChangeDTPPacket):
    '''Change sorting of the "Packet release" DF in the migration module.'''
    version = 1
    done_after_success = True
    run_on_startup = True
    category = PacketCategory.CATEGORY_MANDATORY
    wi_number = 11195

    def fix(self, runner):
        OLD_VAL = 0
        NEW_VAL = -1

        record_todo = self.get_record(411, ['053340', 742595], [220])
        if not self.change_value(record_todo, 'sorting', OLD_VAL, NEW_VAL):
            return self.fail()

        record_done = self.get_record(411, ['053345', 742652], [220])
        if not self.change_value(record_done, 'sorting', OLD_VAL, NEW_VAL):
            return self.fail()

        return self.success()
