Ejemplo n.º 1
0
 def _create_repeat_group_view_context(self, 
         entity_id=None,
         action=None,
         label_add=None,
         label_delete=None,
         field_value=None,
         continuation_url=None
     ):
     view_fields = (
         [ context_field_row(
             get_bound_field("Entity_id",         entity_id,
                 placement="small:0,12;medium:0,6"
                 ),
             )
         , get_bound_field("Test_repeat_field",   field_value,
             placement="small:0,12",
             group_add_label=label_add,
             group_delete_label=label_delete,
             )
         ])
     context_dict = specified_view_context_data(
         coll_id="testcoll", type_id="testtype", 
         view_id="testview", view_heading="Test view label",
         entity_id=entity_id,
         entity_label="",
         view_fields=view_fields,
         action=action, 
         continuation_url=continuation_url
         )
     return context_dict
Ejemplo n.º 2
0
 def _create_rptref_view_context(self, 
         entity_id=None,
         record_type="test:ref_type",
         action=None,
         continuation_url=None
     ):
     view_fields = (
         [ context_field_row(
             get_bound_field("Entity_id",         entity_id,
                 placement="small:0,12;medium:0,6"
                 ),
             )
         , get_bound_field("Test_rptref_field",
             [{'test:ref_image': 'Test_img_entity'}], 
             placement="small:0,12;medium:6,6"
             )
         ])
     context_dict = specified_view_context_data(
         coll_id="testcoll", type_id="ref_type", 
         view_id="Test_rptimg_view", view_heading="Test rptimg view label",
         entity_id=entity_id,
         entity_label="Label Test_rpt_entity",
         record_type=record_type,
         view_fields=view_fields,
         action=action, 
         continuation_url=continuation_url
         )
     return context_dict
Ejemplo n.º 3
0
def dupfield_view_context_data(
        entity_id=None, orig_id=None, 
        coll_id="testcoll", type_id="testtype", 
        type_ref=None, type_choices=None, type_ids=[],
        entity_label=None,
        entity_descr=None,
        entity_descr2=None,
        entity_descr3=None,
        record_type="annal:EntityData",
        action=None, update="Entity", view_label="RecordView testcoll/DupField_view",
        continuation_url=None
    ):
    context_dict = default_view_context_data(
        entity_id=entity_id, orig_id=orig_id, 
        coll_id=coll_id, type_id=type_id, 
        type_ref=type_ref, type_choices=type_choices, type_ids=type_ids,
        entity_label=entity_label, entity_descr=entity_descr,
        record_type=record_type,
        action=action, update=update, view_label=view_label,
        continuation_url=continuation_url
        )
    context_dict['fields'].append(
        context_field_row(
            get_bound_field("Entity_comment", entity_descr2, 
                name="Entity_comment__2",
                prop_uri="rdfs:comment__2"
                )
            )
        )
    context_dict['fields'].append(
        context_field_row(
            get_bound_field("Entity_comment", entity_descr3, 
                name="Entity_comment__3",
                prop_uri="rdfs:comment_alt"
                )
            )
        )
    return context_dict
Ejemplo n.º 4
0
def list_view_context_data(
        coll_id="testcoll", list_id=None, orig_id=None,
        action=None,
        list_uri=None,
        list_type="List",
        list_label=None,
        list_descr=None,
        list_default_type="_type/Default_type", type_choices=None,
        list_default_view="_type/Default_view", view_choices=None,
        list_entity_selector="ALL",
        list_entity_type="",
        list_fields=None,
        num_fields=0,
        update="RecordList",
        continuation_url=None
    ):
    if list_label is None:
        if list_id:
            #@@TODO: use same format as no list_id; change form data too
            list_label = "%s %s/%s"%(update, coll_id, list_id)
        else:
            list_label = "%s list (%s/)"%(update, coll_id)
    if list_fields is None:
        if num_fields == 2:
            list_fields = (
                [ { "annal:field_id":         layout.FIELD_TYPEID+"/Entity_id"
                  , "annal:field_placement":  "small:0,3"
                  }
                , { "annal:field_id":         layout.FIELD_TYPEID+"/Entity_label"
                  , "annal:field_placement":  "small:3,9"
                  }
                ])
        if num_fields == 3:
            list_fields = (
                [ { "annal:field_id":         layout.FIELD_TYPEID+"/Entity_id"
                  , "annal:field_placement":  "small:0,3"
                  }
                , { "annal:field_id":         layout.FIELD_TYPEID+"/Entity_type" 
                  , "annal:field_placement":  "small:3,3"
                  }
                , { "annal:field_id":         layout.FIELD_TYPEID+"/Entity_label"
                  , "annal:field_placement":  "small:6,6"
                  }
                ])
    list_type_choices = get_site_list_types_linked("testcoll")
    if type_choices is None:
        type_choices = (
            [ FieldChoice("", label="(default entity type)")] +
            get_site_types_linked("testcoll") +
            [ FieldChoice("_type/testtype", 
                label="RecordType testcoll/_type/testtype",
                link=recordtype_url("testcoll", "testtype")
                )]
            )
    if view_choices is None:
        view_choices = (
            [ FieldChoice("", label="(view id)") ] +
            get_site_views_linked("testcoll")
            )
    if continuation_url is None:
        continuation_url = entitydata_list_type_url(coll_id, layout.LIST_TYPEID)
    view_label = "List definition"
    view_title = (
        "%s - %s - Collection %s"%(list_label, view_label, coll_id) if list_label
        else
        "%s - Collection %s"%(view_label, coll_id)
        )
    # Target record fields listed in the view description
    context_dict = (
        { 'title':              view_title
        , 'heading':            view_label
        , 'coll_id':            coll_id
        , 'type_id':            layout.LIST_TYPEID
        , 'view_id':            'List_view'
        , 'entity_id':          list_id or ""
        , 'orig_id':            orig_id
        , 'orig_type':          layout.LIST_TYPEID
        , 'record_type':        "annal:List"
        , 'continuation_url':   continuation_url
        , 'fields':
          [ context_field_row(
              get_bound_field("List_id",              list_id),             # 0 (0,0)
              get_bound_field("List_type",            list_type,            # 1 (0,1)
                              options=list_type_choices),
              )
          , context_field_row(
              get_bound_field("List_label",           list_label)           # 2 (1,0)
              )
          , context_field_row(
              get_bound_field("List_comment",         list_descr)           # 3 (2,0)
              )
          , context_field_row(
              get_bound_field("List_default_type",    list_default_type,    # 4 (3,0)
                              options=type_choices),
              get_bound_field("List_default_view",    list_default_view,    # 5 (3,1)
                              options=view_choices),
              )
          , context_field_row(
              get_bound_field("List_entity_selector", list_entity_selector) # 6 (4,0)
              )
          , context_field_row(
              get_bound_field("List_entity_type",     list_entity_type)     # 7 (5,0)
              )
          , get_bound_field("List_fields",            list_fields)          # 8 (6, 0)
          ]
        })
    if action:  
        context_dict['action']      = action
    if list_uri:
        context_dict['entity_uri']  = list_uri
    return context_dict
Ejemplo n.º 5
0
def type_view_context_data(action=None,
                           coll_id="testcoll",
                           type_type_id=layout.TYPE_TYPEID,
                           orig_type=None,
                           type_entity_id="",
                           orig_id=None,
                           type_ids=[],
                           type_label=None,
                           type_descr=None,
                           type_uri=None,
                           type_supertype_uris=[],
                           type_view="_view/Default_view",
                           type_list="_list/Default_list",
                           type_aliases=[],
                           record_type="annal:Type",
                           update="RecordType",
                           continuation_url=None):
    if type_uri is None:
        type_uri = ""
        if type_entity_id:
            type_uri = recordtype_url(coll_id=coll_id, type_id=type_entity_id)
    if type_label is None:
        if type_entity_id:
            type_label = "%s %s/%s/%s" % (update, coll_id, type_type_id,
                                          type_entity_id)
        elif orig_id:
            type_label = "%s %s/%s/%s" % (update, coll_id, type_type_id,
                                          orig_id)
        else:
            type_label = "%s data ... (%s/%s)" % (update, coll_id,
                                                  type_entity_id)
    if type_uri is None:
        type_uri = recordtype_url(coll_id=coll_id, type_id=type_entity_id)
    if continuation_url is None:
        continuation_url = entitydata_list_type_url(coll_id, type_type_id)
    view_heading = "Type definition"
    view_title = ("%s - %s - Collection %s" %
                  (type_label, view_heading, coll_id) if type_label else
                  "%s - Collection %s" % (view_heading, coll_id))
    context_dict = ({
        'title':
        view_title,
        'heading':
        view_heading,
        'coll_id':
        coll_id,
        'type_id':
        type_type_id,
        'view_id':
        "Type_view",
        'entity_id':
        type_entity_id or "",
        'orig_type':
        orig_type or type_type_id,
        'record_type':
        record_type,
        'continuation_url':
        continuation_url,
        'fields': [
            context_field_row(
                get_bound_field("Type_id", type_entity_id),  # 0 (0,0)
            ),
            context_field_row(
                get_bound_field("Type_label", type_label)  # 1 (1,0)
            ),
            context_field_row(
                get_bound_field("Type_comment", type_descr)  # 2 (2,0)
            ),
            context_field_row(
                get_bound_field("Type_uri", type_uri),  # 3 (3,0)
            ),
            get_bound_field("Type_supertype_uris",
                            type_supertype_uris)  # 4 (4)  
            ,
            context_field_row(
                get_bound_field("Type_view", type_view),  # 5 (5,0)
                get_bound_field("Type_list", type_list)  # 6 (5,1)
            ),
            get_bound_field("Type_aliases", type_aliases)  # 7 (6)
        ]
    })
    if orig_id is not None:
        context_dict['orig_id'] = orig_id
    elif action != "new":
        context_dict['orig_id'] = type_entity_id
    if action:
        context_dict['action'] = action
    return context_dict
Ejemplo n.º 6
0
def field_view_context_data(coll_id="testcoll",
                            field_id=None,
                            orig_id=None,
                            continuation_url=None,
                            field_label=None,
                            field_render_type="Text",
                            field_value_mode="Value_direct",
                            field_entity_type="",
                            field_value_type="annal:Text",
                            field_property="",
                            field_placement="",
                            field_superproperty_uris=None,
                            field_placeholder="",
                            field_tooltip=None,
                            field_default=None,
                            field_typeref=None,
                            field_fieldref=None,
                            field_viewref=None,
                            field_fields=None,
                            field_repeat_label_add="Add",
                            field_repeat_label_delete="Remove",
                            field_restrict=None,
                            action=None,
                            update="Field"):
    if field_label is None:
        if field_id:
            field_label = "%s %s/_field/%s" % (update, coll_id, field_id)
        else:
            field_label = "%s data ... (testcoll/_field)" % (update)
    padding_placement = Placement(
        width=make_field_width(sw=0, mw=6, lw=6),
        offset=make_field_offset(so=0, mo=0, lo=0),
        display=make_field_display(sd=False, md=True, ld=True),
        field="hide-for-small-only medium-6 large-6 columns",
        label="small-4 columns",
        value="small-8 columns")
    if field_label:
        title = "%s - Field definition - Collection %s" % (field_label,
                                                           coll_id)
    else:
        title = "Field definition - Collection %s" % (coll_id)
    context_dict = ({
        "title":
        title,
        'heading':
        "Field definition",
        'coll_id':
        coll_id,
        'type_id':
        "_field"
        # , 'orig_id':            "orig_field_id"
        ,
        'fields': [
            context_field_row(
                get_bound_field("Field_id", field_id),  # 0 (0,0)
                get_bound_field("Field_render_type",
                                field_render_type)  # 1 (0,1)
            ),
            context_field_row(
                get_bound_field("Field_label", field_label)  # 2 (1,0)
            ),
            context_field_row(get_bound_field("Field_help")  # 3 (2,0)
                              ),
            context_field_row(
                get_bound_field("Field_property", field_property),  # 4 (3,0)
                get_bound_field("Field_placement", field_placement)  # 5 (3,1)
            ),
            get_bound_field('Field_superproperty_uris',
                            field_superproperty_uris),
            context_field_row(
                get_bound_field("Field_value_type",
                                field_value_type),  # 7 (5,0)
                get_bound_field("Field_value_mode",
                                field_value_mode)  # 8 (5,1)
            ),
            context_field_row(
                get_bound_field("Field_entity_type",
                                field_entity_type)  # 9 (6,0)
            ),
            context_field_row(
                get_bound_field("Field_typeref", field_typeref),  # 10 (7,0)
                get_bound_field("Field_fieldref", field_fieldref)  # 11 (7,1)
            ),
            context_field_row(
                get_bound_field("Field_default", field_default)  # 12 (8,0)
            ),
            context_field_row(
                get_bound_field("Field_placeholder",
                                field_placeholder)  # 13 (9,0)
            ),
            context_field_row(
                get_bound_field("Field_tooltip", field_tooltip)  # 14 (10,0)
            ),
            get_bound_field("Field_fields", field_fields)  # 15 (11,0)
            ,
            context_field_row(
                get_bound_field("Field_repeat_label_add",
                                field_repeat_label_add),
                # 16 (12,0)
                get_bound_field("Field_repeat_label_delete",
                                field_repeat_label_delete)
                # 17 (12,1)
            ),
            context_field_row(
                get_bound_field("Field_restrict", field_restrict)  # 18 (18,0)
            )
        ]
    })
    if orig_id is not None:
        context_dict['orig_id'] = orig_id
    if action:
        context_dict['action'] = action
    if continuation_url is None:
        context_dict['continuation_url'] = entitydata_list_type_url(
            coll_id, "_field")
    else:
        context_dict['continuation_url'] = continuation_url
    return context_dict
Ejemplo n.º 7
0
 def test_get_default_type_list(self):
     u = entitydata_list_type_url("testcoll", "testtype") + "?continuation_url=/xyzzy/"
     r = self.client.get(u)
     self.assertEqual(r.status_code,   200)
     self.assertEqual(r.reason_phrase, "OK")
     self.assertContains(r, "<title>List entities - Collection testcoll</title>")
     self.assertContains(r, '<h2 class="page-heading">List entities</h2>', html=True)
     cont = uri_params({"continuation_url": u})
     # cont = ""
     # log.info(r.content)
     tooltip1 = ""
     tooltip2 = ""
     rowdata = """
         <div class="tbody row select-row">
           <div class="small-1 columns">
             <input type="checkbox" class="select-box right" name="entity_select"
                    value="testtype/entity1" />
           </div>
           <div class="small-11 columns">
             <div class="row view-listrow">
               <div class="view-value small-3 columns" %(tooltip1)s>
                 <a href="%(base)s/c/testcoll/d/testtype/entity1/%(cont)s">entity1</a>
               </div>
               <div class="view-value small-9 columns" %(tooltip2)s>
                 <span>Entity testcoll/testtype/entity1</span>
               </div>
             </div>
           </div>
         </div>
         """%(
             { 'base':     TestBasePath
             , 'cont':     cont
             , 'tooltip1': tooltip1
             , 'tooltip2': tooltip2
             }
         )
     self.assertContains(r, rowdata, html=True)
     # Test context
     # self.assertEqual(r.context['title'],            site_title())
     self.assertEqual(r.context['title'],            "List entities - Collection testcoll")
     self.assertEqual(r.context['coll_id'],          "testcoll")
     self.assertEqual(r.context['type_id'],          "testtype")
     list_choices = r.context['list_choices']
     self.assertEqual(set(list_choices.options),     set(self.list_ids))
     self.assertEqual(list_choices['field_value'],   "Default_list")
     self.assertEqual(r.context['continuation_url'], "/xyzzy/")
     # Fields
     head_fields = context_list_head_fields(r.context)
     self.assertEqual(len(head_fields), 1)       # One row of 2 cols..
     self.assertEqual(len(head_fields[0].description['row_field_descs']), 2)
     f0 = context_view_field(r.context, 0, 0)
     f1 = context_view_field(r.context, 0, 1)
     self.assertDictionaryMatch(f0, 
         get_bound_field("Entity_id", "", placement="small:0,3")
         )
     self.assertDictionaryMatch(f1, 
         get_bound_field("Entity_label", "", placement="small:3,9")
         )
     # Entities
     entities = context_list_entities(r.context)
     self.assertEqual(len(entities), 3)
     field_val = ("entity%d", "Entity testcoll/testtype/entity%d")
     for eid in range(3):
         item_fields = context_list_item_fields(r.context, entities[eid])
         for fid in range(2):
             item_field = item_fields[fid]
             head_field = head_fields[0].description['row_field_descs'][fid]
             for fkey in (
                     'field_id', 'field_name', 'field_label', 
                     'field_property_uri', 'field_render_type',
                     'field_placement', 'field_value_type'):
                 self.assertEqual(item_field.description[fkey], head_field[fkey])
             self.assertEqual(item_field['field_value'], field_val[fid]%(eid+1))
     return
Ejemplo n.º 8
0
    def test_get_default_all_list(self):
        u = entitydata_list_all_url("testcoll") + "?continuation_url=/xyzzy/"
        r = self.client.get(u)
        self.assertEqual(r.status_code,   200)
        self.assertEqual(r.reason_phrase, "OK")
        self.assertContains(r, '<h2 class="page-heading">List entities with type information</h2>', html=True)
        self.assertMatch(r.content, r'<input.type="hidden".name="continuation_url".+value="/xyzzy/"/>')
        cont = uri_params({"continuation_url": u})
        tooltip1 = "" # 'title="%s"'%r.context['fields'][0]['field_help']
        tooltip2 = "" # 'title="%s"'%r.context['fields'][1]['field_help']
        tooltip3 = "" # 'title="%s"'%r.context['fields'][2]['field_help']
        rowdata = """
            <div class="tbody row select-row">
              <div class="small-1 columns">
                <input type="checkbox" class="select-box right" name="entity_select"
                       value="testtype/entity1" />
              </div>
              <div class="small-11 columns">
                <div class="row view-listrow">
                  <div class="view-value small-3 columns" %(tooltip1)s>
                    <a href="%(base)s/c/testcoll/d/testtype/entity1/%(cont)s">entity1</a>
                  </div>
                  <div class="view-value small-2 columns" %(tooltip2)s>
                    <a href="/testsite/c/testcoll/d/_type/testtype/%(cont)s">RecordType testcoll/_type/testtype</a>
                  </div>
                  <div class="view-value small-7 columns" %(tooltip3)s>
                    <span>Entity testcoll/testtype/entity1</span>
                  </div>
                </div>
              </div>
            </div>
            """%(
                { 'base':     TestBasePath
                , 'cont':     cont
                , 'tooltip1': tooltip1
                , 'tooltip2': tooltip2
                , 'tooltip3': tooltip3
                }
            )
        # log.info(r.content)
        self.assertContains(r, rowdata, html=True)

        # Test context
        #@@TODO: use new function to create list context for comparison,
        #        like entity view context tests, rather than pick out the fields.
        #
        # self.assertEqual(r.context['title'],            site_title())
        self.assertEqual(r.context['title'],            "List entities with type information - Collection testcoll")
        self.assertEqual(r.context['coll_id'],          "testcoll")
        self.assertEqual(r.context['type_id'],          None)
        list_choices = r.context['list_choices']
        self.assertEqual(set(list_choices.options),    set(self.list_ids))
        self.assertEqual(list_choices['field_value'],   "Default_list_all")
        self.assertEqual(r.context['continuation_url'], "/xyzzy/")
        # Field descriptions
        head_fields = context_list_head_fields(r.context)
        self.assertEqual(len(head_fields), 1)       # One row of 3 cols..
        self.assertEqual(len(head_fields[0].description['row_field_descs']), 3)
        f0 = context_view_field(r.context, 0, 0)
        f1 = context_view_field(r.context, 0, 1)
        f2 = context_view_field(r.context, 0, 2)
        #  1st field
        self.assertDictionaryMatch(f0, 
            get_bound_field("Entity_id", "", placement="small:0,3")
            )
        #  2nd field
        self.assertDictionaryMatch(f1, 
            get_bound_field("Entity_type", "", 
                placement="small:3,2",
                options=self.type_ids
                )
            )
        # 3rd field
        self.assertDictionaryMatch(f2, 
            get_bound_field("Entity_label", "", placement="small:5,7")
            )
        # Entities and bound fields
        entities = context_list_entities(r.context)
        self.assertEqual(len(entities), 6)
        entity_fields = (
            [ {'entity_type_id': "_type",     'annal:id': "testtype",  'rdfs:label': "RecordType testcoll/_type/testtype"}
            , {'entity_type_id': "_type",     'annal:id': "testtype2", 'rdfs:label': "RecordType testcoll/_type/testtype2"}
            , {'entity_type_id': "testtype",  'annal:id': "entity1",   'rdfs:label': "Entity testcoll/testtype/entity1"}
            , {'entity_type_id': "testtype",  'annal:id': "entity2",   'rdfs:label': "Entity testcoll/testtype/entity2"}
            , {'entity_type_id': "testtype",  'annal:id': "entity3",   'rdfs:label': "Entity testcoll/testtype/entity3"}
            , {'entity_type_id': "testtype2", 'annal:id': "entity4",   'rdfs:label': "Entity testcoll/testtype2/entity4"}
            ])
        field_keys = ('annal:id', 'entity_type_id', 'rdfs:label')
        for eid in range(6):
            item_fields = context_list_item_fields(r.context, entities[eid])
            for fid in range(3):
                item_field = item_fields[fid]
                head_field = head_fields[0].description['row_field_descs'][fid]
                # log.info("Item field: %r"%(item_field,))
                # log.info("Head field: %r"%(head_field,))
                # Check that row field descriptions match corresponding heading feld descriptions
                for fkey in (
                        'field_id', 'field_name', 'field_label', 
                        'field_property_uri', 'field_render_type',
                        'field_placement', 'field_value_type'):
                    self.assertEqual(item_field.description[fkey], head_field[fkey])
                # Check row field values
                fkey = field_keys[fid]
                self.assertEqual(item_field['field_value'],    entity_fields[eid][fkey])
                self.assertEqual(item_field['entity_type_id'], entity_fields[eid]['entity_type_id'])
        return
Ejemplo n.º 9
0
def vocab_view_context_data(coll_id="testcoll",
                            vocab_id="",
                            orig_id=None,
                            action=None,
                            vocab_label=None,
                            vocab_descr=None,
                            vocab_uri=None,
                            vocab_seealso=[],
                            update="RecordVocab",
                            continuation_url=None):
    if vocab_id:
        def_vocab_label = "%s %s/_vocab/%s" % (update, coll_id, vocab_id)
    else:
        def_vocab_label = "%s data ... (%s/_vocab/)" % (update, coll_id)
    if vocab_label is None:
        vocab_label = def_vocab_label
    if vocab_uri is None:
        vocab_uri = recordvocab_url(coll_id=coll_id, vocab_id=vocab_id)
    if continuation_url is None:
        continuation_url = entitydata_list_type_url(coll_id, "_vocab")
    view_label = "Vocabulary namespace"
    view_title = ("%s - %s - Collection %s" %
                  (vocab_label, view_label, coll_id) if vocab_label else
                  "%s - Collection %s" % (view_label, coll_id))
    context_dict = ({
        'title':
        view_title,
        'heading':
        view_label,
        'coll_id':
        coll_id,
        'type_id':
        '_vocab',
        'view_id':
        'Vocab_view',
        'entity_id':
        vocab_id or "",
        'orig_id':
        orig_id,
        'orig_type':
        layout.VOCAB_TYPEID,
        'record_type':
        "annal:Vocabulary",
        'continuation_url':
        continuation_url,
        'fields': [
            context_field_row(
                get_bound_field("Vocab_id", vocab_id),  # 0 (0,0)
            ),
            context_field_row(
                get_bound_field("Entity_label", vocab_label)  # 1 (1,0)
            ),
            context_field_row(
                get_bound_field("Entity_comment", vocab_descr)  # 2 (2,0)
            ),
            context_field_row(
                get_bound_field("Vocab_uri", vocab_uri)  # 3 (3,0)
            ),
            get_bound_field("Entity_see_also_r", vocab_seealso)  # 4 (4, 0)
        ]
    })
    if orig_id:
        context_dict['orig_id'] = orig_id
    if action:
        context_dict['action'] = action
    return context_dict
Ejemplo n.º 10
0
def default_view_context_data(entity_id=None,
                              orig_id=None,
                              coll_id="testcoll",
                              type_id="testtype",
                              type_ref=None,
                              type_choices=None,
                              type_ids=[],
                              entity_label=None,
                              entity_descr=None,
                              view_label="Default record view",
                              record_type="annal:EntityData",
                              update="Entity",
                              action=None,
                              continuation_url=None):
    """
    Returns view context test data for entity presented using default view
    """
    if entity_id:
        type_ref = value_or_default(
            type_ref, "_type/" + type_id if valid_id(type_id) else None)
        entity_label = value_or_default(
            entity_label,
            '%s %s/%s/%s' % (update, coll_id, type_id, entity_id))
        entity_descr = value_or_default(
            entity_descr, '%s coll %s, type %s, entity %s' %
            (update, coll_id, type_id, entity_id))
    else:
        type_ref = type_ref or ""
        entity_label = value_or_default(
            entity_label, '%s data ... (%s/%s)' % (update, coll_id, type_id))
        entity_descr = value_or_default(
            entity_descr,
            '%s description ... (%s/%s)' % (update, coll_id, type_id))
    continuation_url = value_or_default(
        continuation_url, entitydata_list_type_url("testcoll", type_id))
    view_title = ("%s - %s - Collection %s" %
                  (entity_label, view_label, coll_id) if entity_label else
                  "%s - Collection %s" % (view_label, coll_id))
    view_fields = ([
        context_field_row(
            get_bound_field("Entity_id", entity_id),  # 0 (0,0)
            get_bound_field("Entity_type", type_ref,
                            options=type_choices)  # 1 (0,1)
        ),
        context_field_row(
            get_bound_field("Entity_label", entity_label)  # 2 (1,0)
        ),
        context_field_row(
            get_bound_field("Entity_comment", entity_descr)  # 3 (2,0)
        )
    ])
    context_dict = ({
        'title': view_title,
        'heading': view_label,
        'coll_id': coll_id,
        'type_id': type_id,
        'orig_id': orig_id,
        'record_type': record_type,
        'fields': view_fields,
        'continuation_url': continuation_url
    })
    if orig_id:
        context_dict['orig_id'] = orig_id
    elif entity_id and action != "new":
        context_dict['orig_id'] = entity_id
    if action:
        context_dict['action'] = action
    return context_dict