コード例 #1
0
ファイル: views.py プロジェクト: CeasarMwangi/amphora
def entity_prune(request, entity_id):
    """
    Curator can remove duplicate :class:`.Relation` instances from a
    :class:`.ConceptEntity` instance.
    """
    entity = _get_entity_by_id(request, entity_id)
    operations.prune_relations(entity, request.user)
    return HttpResponseRedirect(entity.get_absolute_url())
コード例 #2
0
ファイル: resource.py プロジェクト: abegibson/amphora
def resource_prune(request, resource_id):
    """
    Curator can remove duplicate :class:`.Relation` instances from a
    :class:`.Resource` instance.
    """
    resource = _get_resource_by_id(request, resource_id)
    operations.prune_relations(resource, request.user)
    return HttpResponseRedirect(resource.get_absolute_url())
コード例 #3
0
    def test_prune_relations_identical_target(self):
        resource_1 = Resource.objects.create(name='The first one')
        a_value = Value.objects.create()
        a_value.name = 'The value'
        a_value.save()
        some_predicate = Field.objects.create(name='related')
        for i in xrange(5):
            Relation.objects.create(source=resource_1, predicate=some_predicate, target=a_value)

        operations.prune_relations(resource_1)
        resource_1.refresh_from_db()
        self.assertEqual(resource_1.relations_from.count(), 1)