Exemple #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()
Exemple #2
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()
Exemple #3
0
    def forwards(self, orm):
        # Tenant
        for tenant in Tenant.objects():
            tenant._changed_fields = ['svg_logo', 'img_logo', 'terms', 'tenant_settings']
            tenant.save()

        # VosaeFile - Can't use `save()` because `uploaded_field` is required
        for vosae_file in VosaeFile.objects():
            vosae_file.update(set__tenant=vosae_file.tenant, set__issuer=vosae_file.issuer)

        # VosaeGroup
        for vosae_group in VosaeGroup.objects():
            vosae_group._changed_fields = ['tenant', 'created_by']
            vosae_group.save(force=True)

        # VosaeUser
        for vosae_user in VosaeUser.objects():
            vosae_user._changed_fields = ['tenant', 'groups']
            vosae_user.save()