示例#1
0
    def obj_create(self, bundle, **kwargs):
        """
        Some mandatory actions shoud be synchrounous after Tenant creation but
        before returning the response and should not be in `post_save` hooks since
        issuer is required (got from request).

        These actions are:

        - Adding the creator to the Django group (represents the Tenant)
        - Creation of the VosaeUser linked to the tenant
        - Initial data filling
        """
        from core.models import VosaeUser, VosaeGroup
        bundle = super(TenantResource, self).obj_create(bundle, **kwargs)

        # Update django group associated to the Tenant
        group = Group.objects.get(name=bundle.obj.slug)
        group.user_set.add(bundle.request.user)
        group.save()

        # VosaeUser creation
        user = VosaeUser(
            tenant=bundle.obj,
            email=bundle.request.user.email,
            groups=list(VosaeGroup.objects.filter(tenant=bundle.obj))
        ).save()

        # Fill tenant initial data (Tenant and VosaeUser are required)
        fill_tenant_initial_data.delay(bundle.obj, bundle.request.LANGUAGE_CODE)

        # Fill first user initial data (Tenant and VosaeUser are required)
        fill_user_initial_data.delay(user, bundle.request.LANGUAGE_CODE)

        return bundle
示例#2
0
    def post_create(self, sender, resource, bundle, **kwargs):
        """
        Some mandatory actions shoud be synchrounous after Tenant creation but
        before returning the response and should not be in `post_save` hooks since
        issuer is required (got from request).

        These actions are:

        - Adding the creator to the Django group (represents the Tenant)
        - Creation of the VosaeUser linked to the tenant
        - Initial data filling
        """
        from core.models import VosaeUser, VosaeGroup
        
        # Update django group associated to the Tenant
        group = Group.objects.get(name=bundle.obj.slug)
        group.user_set.add(bundle.request.user)
        group.save()

        # VosaeUser creation
        user = VosaeUser(
            tenant=bundle.obj,
            email=bundle.request.user.email,
            groups=list(VosaeGroup.objects.filter(tenant=bundle.obj))
        ).save()

        # Fill tenant initial data (Tenant and VosaeUser are required)
        fill_tenant_initial_data.delay(bundle.obj, bundle.request.LANGUAGE_CODE)

        # Fill first user initial data (Tenant and VosaeUser are required)
        fill_user_initial_data.delay(user, bundle.request.LANGUAGE_CODE)
示例#3
0
    def post_create(self, sender, resource, bundle, **kwargs):
        """
        Post create hook.

        Fills initial data (based on request's language) after VosaeUser creation
        """
        # Fill user initial data (Tenant and VosaeUser are required)
        fill_user_initial_data.delay(bundle.obj, bundle.request.LANGUAGE_CODE)
示例#4
0
    def post_create(self, sender, resource, bundle, **kwargs):
        """
        Post create hook.

        Fills initial data (based on request's language) after VosaeUser creation
        """
        # Fill user initial data (Tenant and VosaeUser are required)
        fill_user_initial_data.delay(bundle.obj, bundle.request.LANGUAGE_CODE)
示例#5
0
    def obj_create(self, bundle, **kwargs):
        """Fills initial data (based on request's language) after VosaeUser creation"""
        bundle = super(VosaeUserResource, self).obj_create(bundle, **kwargs)

        # Fill user initial data (Tenant and VosaeUser are required)
        fill_user_initial_data.delay(bundle.obj, bundle.request.LANGUAGE_CODE)

        return bundle