Beispiel #1
0
    def setUp(self):

        setUpAccounts(self)
        setUpLocations(self)
        setUpResources(self)

        # reload these to avoid errors.
        self.resource6 = Resource.objects.get(id=self.resource6.id)
        self.resource7 = Resource.objects.get(id=self.resource7.id)

        self.curation1 = Curation(outcome='',
                                  tags=['#aliss-story'],
                                  note='This is my story, this is my song',
                                  owner=self.bob)
        self.curation1.item_metadata.update(author=self.bob)
        add_curation(self.resource6, self.curation1)

        self.curation2 = Curation(
            outcome='',
            tags=['#aliss-story'],
            note='Follow the hearts and, you can\'t go wrong',
            owner=self.bob)
        self.curation2.item_metadata.update(author=self.bob)
        add_curation(self.resource7, self.curation2)

        self.jorph.tags = ['#aliss-story']
        self.jorph.save()

        reindex_accounts(url=settings.TEST_SOLR_URL)
        reindex_resources(url=settings.TEST_SOLR_URL)

        from django.test.client import Client
        self.client = Client()
Beispiel #2
0
    def setUp(self):

        setUpAccounts(self)
        setUpLocations(self)
        setUpResources(self)

        # reload these to avoid errors.
        self.resource6 = Resource.objects.get(id=self.resource6.id)
        self.resource7 = Resource.objects.get(id=self.resource7.id)

        self.curation1 = Curation(
            outcome='',
            tags=['#aliss-story'],
            note='This is my story, this is my song',
            owner=self.bob)
        self.curation1.item_metadata.update(author=self.bob)
        add_curation(self.resource6, self.curation1)

        self.curation2 = Curation(
            outcome='',
            tags=['#aliss-story'],
            note='Follow the hearts and, you can\'t go wrong',
            owner=self.bob)
        self.curation2.item_metadata.update(author=self.bob)
        add_curation(self.resource7, self.curation2)

        self.jorph.tags = ['#aliss-story']
        self.jorph.save()

        reindex_accounts(url=settings.TEST_SOLR_URL)
        reindex_resources(url=settings.TEST_SOLR_URL)

        from django.test.client import Client
        self.client = Client()
Beispiel #3
0
    def test_curation(self):
        from resources.search import find_by_place_or_kwords

        # setting resource failed - no idea why, seems a valid object
        # reloading works
        self.resource6 = Resource.objects.get(id=self.resource6.id)
        curation = Curation(outcome="", tags=["blah"], note="bob curated this", owner=self.bob)
        curation.item_metadata.update(author=self.bob)
        add_curation(self.resource6, curation)

        loc, results = find_by_place_or_kwords("", "blah")
        self.assertEqual(loc, None)
        result = iter(results).next()
        self.assertEqual(result["title"], "title 6")
Beispiel #4
0
def curation_add(request, object_id, template_name='depot/curation_edit.html'):
    """docstring for curation_add"""
    resource = get_one_or_404(Resource, id=ObjectId(object_id))
    user = get_account(request.user.id)

    curation = get_curation_for_acct_resource(user, resource)
    if curation:
        index, cur = curation
        messages.warning(
            request,
            'You already have a curation for this resource- you can edit it if you need to make changes.'
        )
        return HttpResponseRedirect(
            reverse('curation', args=[resource.id, index]))

    if request.method == 'POST':
        result = request.POST.get('result', '')
        next = request.GET.get('next', '')
        if next:
            url = '%s#res_%s' % (next, resource.id)
        else:
            url = ''
        if result == 'Cancel':
            return HttpResponseRedirect(
                url or reverse('resource', args=[resource.id]))
        form = CurationForm(request.POST)
        if form.is_valid(request.user):
            curation = Curation(**form.cleaned_data)
            curation.owner = user
            curation.item_metadata.update(author=user)
            add_curation(resource, curation)
            # TODO: move this into resource.add_curation
            increment_resource_crud('curation_add', account=user)
            index = len(resource.curations) - 1
            return HttpResponseRedirect(
                url or reverse('curation', args=[resource.id, index]))
    else:
        initial = {'outcome': STATUS_OK}
        form = CurationForm(initial=initial)

    template_context = {
        'next': urlquote_plus(request.GET.get('next', '')),
        'form': form,
        'resource': resource,
        'new': True
    }

    return render_to_response(template_name, template_context,
                              RequestContext(request))
Beispiel #5
0
def curation_add(request, object_id, template_name='depot/curation_edit.html'):
    """docstring for curation_add"""
    resource = get_one_or_404(Resource, id=ObjectId(object_id))
    user = get_account(request.user.id)

    curation = get_curation_for_acct_resource(user, resource)
    if curation:
        index, cur = curation
        messages.warning(request, 'You already have a curation for this resource- you can edit it if you need to make changes.')
        return HttpResponseRedirect(reverse('curation', args=[resource.id, index]))

    if request.method == 'POST':
        result = request.POST.get('result', '')
        next = request.GET.get('next', '')
        if next:
            url = '%s#res_%s' % (next, resource.id)
        else:
            url = ''
        if result == 'Cancel':
            return HttpResponseRedirect(url or reverse('resource', args=[resource.id]))
        form = CurationForm(request.POST)
        if form.is_valid(request.user):
            curation = Curation(**form.cleaned_data)
            curation.owner = user
            curation.item_metadata.update(author=user)
            add_curation(resource, curation)
            # TODO: move this into resource.add_curation
            increment_resource_crud('curation_add', account=user)
            index = len(resource.curations) - 1
            return HttpResponseRedirect(url or reverse('curation', args=[resource.id, index]))
    else:
        initial = { 'outcome': STATUS_OK}
        form = CurationForm(initial=initial)

    template_context = {
        'next': urlquote_plus(request.GET.get('next', '')),
        'form': form,
        'resource': resource,
        'new': True
    }

    return render_to_response(
        template_name,
        template_context,
        RequestContext(request)
    )
Beispiel #6
0
    def test_curation(self):
        from resources.search import find_by_place_or_kwords

        # setting resource failed - no idea why, seems a valid object
        # reloading works
        self.resource6 = Resource.objects.get(id=self.resource6.id)
        curation = Curation(
            outcome='',
            tags=['blah'],
            note='bob curated this',
            owner=self.bob,
            )
        curation.item_metadata.update(author=self.bob)
        add_curation(self.resource6, curation)

        loc, results = find_by_place_or_kwords('', 'blah')
        self.assertEqual(loc, None)
        result = iter(results).next()
        self.assertEqual(result['title'], 'title 6')