def test_create_detailview02(self):
        "For a ContentType"
        self.assertFalse(BrickDetailviewLocation.config_exists(FakeContact))

        order = 4
        zone = BrickDetailviewLocation.LEFT
        brick_id = PropertiesBrick.id_
        loc = BrickDetailviewLocation.create_if_needed(brick_id=brick_id, order=order, zone=zone, model=FakeContact)
        loc = self.get_object_or_fail(BrickDetailviewLocation, pk=loc.pk)
        self.assertEqual(FakeContact, loc.content_type.model_class())
        self.assertEqual(brick_id, loc.brick_id)
        self.assertEqual(order,    loc.order)
        self.assertEqual(zone,     loc.zone)

        self.assertTrue(BrickDetailviewLocation.config_exists(FakeContact))
Beispiel #2
0
    def populate(self):
        Graph = get_graph_model()

        HeaderFilter.create(
            pk=DEFAULT_HFILTER_GRAPH,
            name=_(u'Graph view'),
            model=Graph,
            cells_desc=[(EntityCellRegularField, {
                'name': 'name'
            })],
        )

        SearchConfigItem.create_if_needed(Graph, ['name'])

        if not BrickDetailviewLocation.config_exists(
                Graph
        ):  # NB: no straightforward way to test that this populate script has not been already run
            create_bdl = BrickDetailviewLocation.create_if_needed
            LEFT = BrickDetailviewLocation.LEFT
            RIGHT = BrickDetailviewLocation.RIGHT

            BrickDetailviewLocation.create_4_model_brick(order=5,
                                                         zone=LEFT,
                                                         model=Graph)
            create_bdl(brick_id=core_bricks.CustomFieldsBrick.id_,
                       order=40,
                       zone=LEFT,
                       model=Graph)
            create_bdl(brick_id=bricks.RootNodesBrick.id_,
                       order=60,
                       zone=LEFT,
                       model=Graph)
            create_bdl(brick_id=bricks.OrbitalRelationTypesBrick.id_,
                       order=65,
                       zone=LEFT,
                       model=Graph)
            create_bdl(brick_id=core_bricks.PropertiesBrick.id_,
                       order=450,
                       zone=LEFT,
                       model=Graph)
            create_bdl(brick_id=core_bricks.RelationsBrick.id_,
                       order=500,
                       zone=LEFT,
                       model=Graph)
            create_bdl(brick_id=core_bricks.HistoryBrick.id_,
                       order=20,
                       zone=RIGHT,
                       model=Graph)

            if apps.is_installed('creme.assistants'):
                logger.info(
                    'Assistants app is installed => we use the assistants blocks on detail view'
                )

                from creme.assistants import bricks as a_bricks

                create_bdl(brick_id=a_bricks.TodosBrick.id_,
                           order=100,
                           zone=RIGHT,
                           model=Graph)
                create_bdl(brick_id=a_bricks.MemosBrick.id_,
                           order=200,
                           zone=RIGHT,
                           model=Graph)
                create_bdl(brick_id=a_bricks.AlertsBrick.id_,
                           order=300,
                           zone=RIGHT,
                           model=Graph)
                create_bdl(brick_id=a_bricks.UserMessagesBrick.id_,
                           order=400,
                           zone=RIGHT,
                           model=Graph)

            if apps.is_installed('creme.documents'):
                # logger.info('Documents app is installed => we use the documents blocks on detail view')

                from creme.documents.bricks import LinkedDocsBrick

                create_bdl(brick_id=LinkedDocsBrick.id_,
                           order=600,
                           zone=RIGHT,
                           model=Graph)