예제 #1
0
    def handle(self, *args, **options):

        # Loop over the namespaces
        for namespace in args:

            # Clear the index of this type of resource
            ix = ResourceBrowser.clear_index(namespace)

            if ix is None:
                raise CommandError('Resource "%s" does not exist' % namespace)

            # Get the model of this type of resource
            model = ResourceBrowser.get_resource_model(namespace)

            # Add model fields for each resource
            for resource in model.objects.all():
                ResourceBrowser.add_resource(namespace, resource=resource)

            self.stdout.write('The index of "%s" resource was updated successfully.\n' % namespace)
예제 #2
0
    def handle(self, *args, **options):

        # Loop over the namespaces
        for namespace in args:

            # Clear the index of this type of resource
            ix = ResourceBrowser.clear_index(namespace)

            if ix is None:
                raise CommandError('Resource "%s" does not exist' % namespace)

            # Get the model of this type of resource
            model = ResourceBrowser.get_resource_model(namespace)

            # Add model fields for each resource
            for resource in model.objects.all():
                ResourceBrowser.add_resource(namespace, resource=resource)

            self.stdout.write(
                'The index of "%s" resource was updated successfully.\n' %
                namespace)
예제 #3
0
def create_user_profile(sender, instance, created, **kwargs):

    if created:
        # Create a private organization for the user
        default_organization = Organization.objects.get_or_create(
            name=instance.username)
        default_organization[0].managers.append(instance.pk)
        default_organization[0].save()

        profile, created = UserProfile.objects.get_or_create(
            user=instance,
            organizations=[{
                'organization': default_organization[0].pk,
                'roles': ['customer', 'developer']
            }],
            current_organization=default_organization[0])
        if instance.first_name and instance.last_name:
            profile.complete_name = instance.first_name + ' ' + instance.last_name
            profile.save()

    # User search is only used for organization view that is
    # not needed when using external authentication
    if not settings.OILAUTH:
        ResourceBrowser.add_resource('user', resource=instance)
예제 #4
0
파일: models.py 프로젝트: perezdf/wstore
def create_user_profile(sender, instance, created, **kwargs):

    if created:
        # Create a private organization for the user
        default_organization = Organization.objects.get_or_create(name=instance.username)
        default_organization[0].managers.append(instance.pk)
        default_organization[0].save()

        profile, created = UserProfile.objects.get_or_create(
            user=instance,
            organizations=[{
                'organization': default_organization[0].pk,
                'roles': ['customer', 'developer']
            }],
            current_organization=default_organization[0]
        )
        if instance.first_name and instance.last_name:
            profile.complete_name = instance.first_name + ' ' + instance.last_name
            profile.save()

    # User search is only used for organization view that is
    # not needed when using external authentication
    if not settings.OILAUTH:
        ResourceBrowser.add_resource('user', resource=instance)