Esempio n. 1
0
    def handle(self, *args, **options):
        interactive = True

        if len(args) and args[0] == '--no-input':
            interactive = False

        # Ask the user if interactive
        if interactive:
            correct = False
            print "This process will delete the tag indexes directory. Continue: [y/n]"
            while not correct:
                opt = read_from_cmd()
                if opt != 'y' and opt != 'n':
                    print "Please include 'y' or 'n'"
                else:
                    correct = True

            if opt == 'n':
                return

        # Remove the index directory
        index_path = os.path.join(settings.BASEDIR, 'wstore')
        index_path = os.path.join(index_path, 'social')
        index_path = os.path.join(index_path, 'indexes')

        rmtree(index_path, True)

        # Generate new search indexes
        tag_manager = TagManager(index_path)
        for o in Offering.objects.all():
            aux_tags = list(o.tags)
            o.tags = []
            o.save()
            tag_manager.update_tags(o, aux_tags)
Esempio n. 2
0
    def handle(self, *args, **options):
        interactive = True

        if len(args) and args[0] == '--no-input':
            interactive = False

        # Ask the user if interactive
        if interactive:
            correct = False
            print "This process will delete the tag indexes directory. Continue: [y/n]"
            while not correct:
                opt = read_from_cmd()
                if opt != 'y' and opt != 'n':
                    print "Please include 'y' or 'n'"
                else:
                    correct = True

            if opt == 'n':
                return

        # Remove the index directory
        index_path = os.path.join(settings.BASEDIR, 'wstore')
        index_path = os.path.join(index_path, 'social')
        index_path = os.path.join(index_path, 'indexes')

        rmtree(index_path, True)

        # Generate new search indexes
        tag_manager = TagManager(index_path)
        for o in Offering.objects.all():
            aux_tags = list(o.tags)
            o.tags = []
            o.save()
            tag_manager.update_tags(o, aux_tags)
Esempio n. 3
0
def _create_tags():
    tm = TagManager()
    offering1 = Offering.objects.get(name='test_offering1')
    offering2 = Offering.objects.get(name='test_offering2')
    offering3 = Offering.objects.get(name='test_offering3')

    tm.update_tags(offering1, ['service', 'tag'])
    tm.update_tags(offering2, ['dataset', 'tag'])
    tm.update_tags(offering3, ['widget'])
def _create_tags():
    tm = TagManager()
    offering1 = Offering.objects.get(name='test_offering1')
    offering2 = Offering.objects.get(name='test_offering2')
    offering3 = Offering.objects.get(name='test_offering3')

    tm.update_tags(offering1, ['service', 'tag'])
    tm.update_tags(offering2, ['dataset', 'tag'])
    tm.update_tags(offering3, ['widget'])
Esempio n. 5
0
    def update(self, request, organization, name, version):

        # Get offering
        try:
            org = Organization.objects.get(name=organization)
            offering = Offering.objects.get(owner_organization=org, name=name, version=version)
        except:
            return build_response(request, 404, 'Not found')

        # Check that the user has enough rights
        if request.user.userprofile.current_organization != org:
            return build_response(request, 403, 'Forbidden')

        # Build tag manager
        try:
            data = json.loads(request.raw_post_data)
            manager = TagManager()
            manager.update_tags(offering, data['tags'])
        except Exception, e:
            return build_response(request, 400, e.message)
Esempio n. 6
0
    def update(self, request, organization, name, version):

        # Get offering
        try:
            org = Organization.objects.get(name=organization)
            offering = Offering.objects.get(owner_organization=org,
                                            name=name,
                                            version=version)
        except:
            return build_response(request, 404, 'Not found')

        # Check that the user has enough rights
        if request.user.userprofile.current_organization != org\
        or (not offering.is_owner(request.user) and not request.user.pk in org.managers):
            return build_response(request, 403, 'Forbidden')

        # Build tag manager
        try:
            data = json.loads(request.raw_post_data)
            manager = TagManager()
            manager.update_tags(offering, data['tags'])
        except Exception, e:
            return build_response(request, 400, e.message)