@receiver(pre_save, sender=Locale)
def create_locale_managers_group(sender, **kwargs):
    """
    Creates respective managers group in django's permission system.
    Managers should be able to translate and manage locale.
    """
    instance = kwargs['instance']

    if kwargs['raw'] or instance.managers_group is not None:
        return

    try:
        locale_ct = ContentType.objects.get(app_label='base', model='locale')
        locale_group, _ = Group.objects.get_or_create(name='{} managers'.format(instance.code))
        can_translate = Permission.objects.get(content_type=locale_ct, codename='can_translate_locale')
        can_manage = Permission.objects.get(content_type=locale_ct, codename='can_manage_locale')
        locale_group.permissions.add(can_translate)
        locale_group.permissions.add(can_manage)
        instance.managers_group = locale_group
    except __HOLE__ as e:
        errors.send_exception(e)
dataset/ETHPy150Open mozilla/pontoon/pontoon/base/signals.py/create_locale_managers_group