Пример #1
0
    def post_save(self, sender, document, created, **kwargs):
        """
        If created, the :class:`~core.models.Tenant` should be initialized.
        """
        from core.models import VosaeGroup
        # Removed related TTL
        document.remove_related_ttl()

        if created:
            # Ensure that an index with the current search settings is present in ElasticSearch
            # Done synchronously since we can't currently chain all the related tasks from here
            conn = pyes.ES(settings.ES_SERVERS, basic_auth=settings.ES_AUTH)
            conn.ensure_index(document.slug, get_search_settings())

            # Creates an admin group
            admin_group = VosaeGroup(tenant=document, name=pgettext('group_name', 'Administrators'), is_admin=True)
            for perm, perm_data in admin_group.permissions.perms.iteritems():
                admin_group.permissions.perms[perm]['authorization'] = True
            admin_group.save()