text: # -*- coding: utf-8 -*-
  # Generated by Django 1.11.17 on 2020-11-17 11:44
  from __future__ import unicode_literals
  from __future__ import unicode_literals
  
  from django.db import migrations, connection
  
  from bluebottle.clients import properties
  from bluebottle.clients.models import Client
  from bluebottle.clients.utils import LocalTenant
  from bluebottle.utils.utils import update_group_permissions
  
  
  def add_group_permissions(apps, schema_editor):
      tenant = Client.objects.get(schema_name=connection.tenant.schema_name)
      with LocalTenant(tenant):
          group_perms = {
              'Staff': {
                  'perms': (
                      'add_deedparticipant',
                      'change_deedparticipant',
                      'delete_deedparticipant',
                  )
              },
              'Anonymous': {
                  'perms': (
                      'api_read_deedparticipant',
                  ) if not properties.CLOSED_SITE else ()
              },
              'Authenticated': {
                  'perms': (
                      'api_read_deedparticipant',
                      'api_add_deedparticipant',
                      'api_change_own_deedparticipant',
                      'api_delete_own_deedparticipant',
                  )
              }
          }
  
      update_group_permissions('deeds', group_perms, apps)
  
  
  class Migration(migrations.Migration):
  
      dependencies = [
          ('deeds', '0006_auto_20210222_1643'),
      ]
  
      operations = [
          migrations.RunPython(add_group_permissions)
      ]
  