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

OLD_CODE = """# These are the default roles that are created when importing users
# The "#" sign marks a comment. Everything to its right is ignored

# Menupoints
01100214 # R39 MP Anwender

# Roles
01100225 # Mitarbeiter

# To access these roles from Python use the following snippet:
# from ppms.module_subclasses.interface import get_default_roles
# roles = get_default_roles()"""

NEW_CODE = """# These are the default roles that are created when importing users
# The "#" sign marks a comment. Everything to its right is ignored

# Menupoints
01100214 # R39 MP Anwender

# Roles
01100225 # Mitarbeiter

# To access these roles from Python use the following snippet:
# from ppms.interface import get_default_roles
# roles = get_default_roles()"""


class ChangeDefaultRolesGlobalSetting(ChangeDTPPacket):
    '''Changes the default_roles global setting to point at the right Python package'''
    version = 1
    done_after_success = True
    run_on_startup = True
    category = PacketCategory.CATEGORY_MANDATORY
    wi_number = 11921

    def fix(self, runner):
        record = self.get_record(333, ['b0296ff4-796c-4062-93aa-6dea3bfecc60'], ['template_code'])
        if not self.change_value(record, 'template_code', OLD_CODE, NEW_CODE):
            return self.fail()

        return self.success()
