@receiver(post_save, sender=Locale)
def assign_group_permissions(sender, **kwargs):
    """"
    After creation of locale, we have to assign translation and management
    permissions to groups of translators and managers assigned to locale.
    """
    if kwargs['raw'] or not kwargs['created']:
        return

    instance = kwargs['instance']

    try:
        locale_ct = ContentType.objects.get(app_label='base', model='locale')
        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')

        GroupObjectPermission.objects.get_or_create(object_pk=instance.pk,
            content_type=locale_ct,
            group=instance.translators_group,
            permission=can_translate)

        GroupObjectPermission.objects.get_or_create(object_pk=instance.pk,
            content_type=locale_ct,
            group=instance.managers_group,
            permission=can_translate)

        GroupObjectPermission.objects.get_or_create(object_pk=instance.pk,
            content_type=locale_ct,
            group=instance.managers_group,
            permission=can_manage)
    except __HOLE__ as e:
        errors.send_exception(e)
dataset/ETHPy150Open mozilla/pontoon/pontoon/base/signals.py/assign_group_permissions