Example #1
0
    def setUp(self):
        delete_index()
        create_index()

        self.category = CategoryFactory()
        put_category_mapping(self.category.id)
        user = UserFactory(email='*****@*****.**', password='******',
                           is_superuser=True,
                           category=self.category)

        connect_signals()
        for doc_id in xrange(20):
            doc = DocumentFactory(
                document_key='hazop-report-%d' % doc_id,
                category=self.category,
            )
            index_document(doc.id)

        # ES needs some time to finish indexing
        time.sleep(1)

        document_list_url = reverse('category_document_list', args=[
            self.category.organisation.slug,
            self.category.slug
        ])
        self.url = '%s%s' % (self.live_server_url, document_list_url)
        self.client.login(email=user.email, password='******')
        self.test_file = os.path.join(
            os.path.dirname(__file__),
            'casper_tests',
            'tests.js'
        )
Example #2
0
    def setUp(self):
        delete_index()
        create_index()

        self.category = CategoryFactory()
        put_category_mapping(self.category.id)
        user = UserFactory(email='*****@*****.**', password='******',
                           is_superuser=True,
                           category=self.category)

        connect_signals()
        for doc_id in range(20):
            doc = DocumentFactory(
                document_key='hazop-report-%d' % doc_id,
                category=self.category,
            )
            index_document(doc.id)

        # ES needs some time to finish indexing
        time.sleep(1)

        document_list_url = reverse('category_document_list', args=[
            self.category.organisation.slug,
            self.category.slug
        ])
        self.url = '%s%s' % (self.live_server_url, document_list_url)
        self.client.login(email=user.email, password='******')
        self.test_file = os.path.join(
            os.path.dirname(__file__),
            'casper_tests',
            'tests.js'
        )
Example #3
0
def update_index(sender, instance, **kwargs):
    created = kwargs.pop('created')

    # When a document is first created, the Document is saved
    # before the Metadata and MetadataRevision are created.
    # Then, the Document is saved again
    # Thus, we MUST not index the document on the first save, since the
    # metadata and revision does not exist yet
    if not created and instance.is_indexable:
        index_document(instance.pk)
Example #4
0
def update_index(**kwargs):
    if 'instance' in kwargs:
        doc = kwargs.get('instance')
    else:
        doc = kwargs.get('document')

    # When a document is first created, the Document is saved
    # before the Metadata and MetadataRevision are created.
    # Then, the Document is saved again
    # Thus, we MUST not index the document on the first save, since the
    # metadata and revision does not exist yet
    created = kwargs.pop('created', False)
    if not created and doc.is_indexable:
        index_document(doc.pk)
    refresh_index()
Example #5
0
def update_index(**kwargs):
    if 'instance' in kwargs:
        doc = kwargs.get('instance')
    else:
        doc = kwargs.get('document')

    # When a document is first created, the Document is saved
    # before the Metadata and MetadataRevision are created.
    # Then, the Document is saved again
    # Thus, we MUST not index the document on the first save, since the
    # metadata and revision does not exist yet
    created = kwargs.pop('created', False)
    if not created and doc.is_indexable:
        index_document(doc.pk)
    refresh_index()