Esempio n. 1
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
Esempio n. 2
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
Esempio 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
def entitydata_recordtype_view_context_data(entity_id=None,
                                            orig_id=None,
                                            coll_id="testcoll",
                                            type_id="testtype",
                                            type_uri=None,
                                            type_ids=[],
                                            action=None,
                                            update="Entity",
                                            view_label="Type definition"):
    if entity_id:
        entity_label = '%s %s/%s/%s' % (update, coll_id, type_id, entity_id)
        entity_descr = '%s coll %s, type %s, entity %s' % (update, coll_id,
                                                           type_id, entity_id)
    else:
        entity_label = '%s data ... (%s/%s)' % (update, coll_id, type_id)
        entity_descr = '%s description ... (%s/%s)' % (update, coll_id,
                                                       type_id)
    context_dict = ({
        'title':
        "%s - %s - Collection %s" % (entity_label, view_label, coll_id),
        'heading':
        view_label,
        'coll_id':
        coll_id,
        'type_id':
        type_id,
        'orig_id':
        'orig_entity_id',
        'fields': [
            context_field_row({
                'field_label':
                'Type Id',
                'field_name':
                'entity_id',
                'field_placement':
                get_placement_classes('small:0,12;medium:0,6'),
                'field_id':
                'Type_id',
                'field_value_mode':
                'Value_direct',
                'field_value_type':
                'annal:Slug'
                # , 'field_value':      (Supplied separately)
                ,
                'options': []
            }),
            context_field_row({
                'field_label':
                'Label',
                'field_name':
                'Type_label',
                'field_placement':
                get_placement_classes('small:0,12'),
                'field_id':
                'Type_label',
                'field_value_mode':
                'Value_direct',
                'field_value_type':
                'annal:Text',
                'field_value':
                entity_label,
                'options': []
            }),
            context_field_row({
                'field_label':
                'Comment',
                'field_name':
                'Type_comment',
                'field_placement':
                get_placement_classes('small:0,12'),
                'field_id':
                'Type_comment',
                'field_value_mode':
                'Value_direct',
                'field_value_type':
                'annal:Richtext',
                'field_value':
                entity_descr,
                'options': []
            }),
            context_field_row({
                'field_label':
                'Type URI',
                'field_name':
                'Type_uri',
                'field_placement':
                get_placement_classes('small:0,12'),
                'field_id':
                'Type_uri',
                'field_value_mode':
                'Value_direct',
                'field_value_type':
                'annal:Identifier',
                'field_value':
                "",
                'options': []
            })
        ],
        'continuation_url':
        entitydata_list_type_url(coll_id, type_id)
    })
    if entity_id:
        context_dict['fields'][0]['row_field_descs'][0][
            'field_value'] = entity_id
        context_dict['orig_id'] = entity_id
    if type_uri:
        context_dict['fields'][3]['row_field_descs'][0][
            'field_value'] = type_uri
    if orig_id:
        context_dict['orig_id'] = orig_id
    if action:
        context_dict['action'] = action
    return context_dict
def entitydata_context_data(entity_id=None,
                            orig_id=None,
                            coll_id="testcoll",
                            type_id="testtype",
                            type_ids=[],
                            action=None,
                            update="Entity",
                            view_label="Default record view"):
    if entity_id:
        entity_label = '%s %s/%s/%s' % (update, coll_id, type_id, entity_id)
        entity_descr = '%s coll %s, type %s, entity %s' % (update, coll_id,
                                                           type_id, entity_id)
    else:
        entity_label = '%s data ... (%s/%s)' % (update, coll_id, type_id)
        entity_descr = '%s description ... (%s/%s)' % (update, coll_id,
                                                       type_id)
    context_dict = ({
        'title':
        "%s - %s - Collection %s" % (entity_label, view_label, coll_id),
        'heading':
        view_label,
        'coll_id':
        'testcoll',
        'type_id':
        'testtype',
        'orig_id':
        'orig_entity_id',
        'fields': [
            context_field_row(
                {
                    'field_label':
                    'Id',
                    'field_id':
                    'Entity_id',
                    'field_name':
                    'entity_id',
                    'field_render_type':
                    'EntityId',
                    'field_placement':
                    get_placement_classes('small:0,12;medium:0,6'),
                    'field_value_mode':
                    'Value_direct',
                    'field_value_type':
                    "annal:Slug"
                    # , 'field_value':      (Supplied separately)
                    ,
                    'options': []
                },
                {
                    'field_label':
                    'Type',
                    'field_id':
                    'Entity_type',
                    'field_name':
                    'entity_type',
                    'field_render_type':
                    'EntityTypeId',
                    'field_value_type':
                    "annal:Slug",
                    'field_placement':
                    get_placement_classes('small:0,12;medium:6,6'),
                    'field_value_mode':
                    'Value_direct'
                    # , 'field_value':      (Supplied separately)
                    ,
                    'options': []
                }),
            context_field_row({
                'field_label':
                'Label',
                'field_id':
                'Entity_label',
                'field_name':
                'Entity_label',
                'field_render_type':
                'Text',
                'field_placement':
                get_placement_classes('small:0,12'),
                'field_value_mode':
                'Value_direct',
                'field_value_type':
                "annal:Text",
                'field_value':
                entity_label,
                'options': []
            }),
            context_field_row({
                'field_label':
                'Comment',
                'field_id':
                'Entity_comment',
                'field_name':
                'Entity_comment',
                'field_render_type':
                'Markdown',
                'field_placement':
                get_placement_classes('small:0,12'),
                'field_value_mode':
                'Value_direct',
                'field_value_type':
                "annal:Richtext",
                'field_value':
                entity_descr,
                'options': []
            })
        ],
        'continuation_url':
        entitydata_list_type_url("testcoll", type_id)
    })
    if entity_id:
        context_dict['fields'][0]['row_field_descs'][0][
            'field_value'] = entity_id
        context_dict['fields'][0]['row_field_descs'][1][
            'field_value'] = "_type/" + type_id if valid_id(type_id) else None
        context_dict['orig_id'] = entity_id
    if orig_id:
        context_dict['orig_id'] = orig_id
    if action:
        context_dict['action'] = action
    return context_dict
Esempio n. 6
0
def recordlist_view_context_data(
        coll_id="testcoll", list_id=None, orig_id=None, view_ids=[],
        action=None, update="RecordList"
    ):
    if list_id:
        list_label = "%s %s/%s"%(update, coll_id, list_id)
        list_descr = "%s help for %s/%s"%(update, coll_id, list_id)
    else:
        list_label = "%s list (%s/@@list_id@@)"%(update, coll_id)
        list_descr = "%s description ... (%s/%s)"%(update, coll_id, list_id)
    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"
          }
        ])
    context_dict = (
        { "title":              "%s - List definition - Collection %s"%(list_label, coll_id)
        , 'heading':            "List definition"
        , "coll_id":            coll_id
        , "type_id":            "_list"
        , "orig_id":            "orig_list_id"
        , "continuation_url":   entitydata_list_type_url(coll_id, "_list")
        , "fields":
          [ context_field_row(
              { "field_id":           "List_id"                   # fields[0]
              , "field_name":         "entity_id"
              , "field_value_type":   "annal:Slug"
              , "field_label":        "List Id"
              , "field_render_type":  "Slug"
              , "field_value_mode":   "Value_direct"
              , "field_placement":    get_placement_classes("small:0,12;medium:0,6")
              # , "field_value":      (Supplied separately, below)
              , "options":            []
              },
              { "field_id":           "List_type"                 # fields[1]
              , "field_name":         "List_type"
              , "field_value_type":  "annal:List_type"
              , "field_label":        "List display type"
              , "field_render_type":  "Enum_choice"
              , "field_value_mode":   "Value_direct"
              , "field_placement":    get_placement_classes("small:0,12;medium:6,6")
              , "field_value":        "Enum_list_type/List"
              , "options":            [] # ["list", "grid"]
              })
          , context_field_row(
              { "field_id":           "List_label"                # fields[2]
              , "field_name":         "List_label"
              , "field_value_type":   "annal:Text"
              , "field_label":        "Label"
              , "field_render_type":  "Text"
              , "field_value_mode":   "Value_direct"
              , "field_placement":    get_placement_classes("small:0,12")
              # , "field_value":      (Supplied separately, below)
              , "options":            []
              })
          , context_field_row(
              { "field_id":           "List_comment"              # fields[3]
              , "field_name":         "List_comment"
              , "field_label":        "Help"
              , "field_value_type":   "annal:Richtext"
              , "field_render_type":  "Markdown"
              , "field_value_mode":   "Value_direct"
              , "field_placement":    get_placement_classes("small:0,12")
              # , "field_value":      (Supplied separately, below)
              , "options":            []
              })
          , context_field_row(
              { "field_id":           "List_default_type"         # fields[4]
              , "field_name":         "List_default_type"
              , "field_value_type":   "annal:Type"
              , "field_label":        "Default type"
              , "field_render_type":  "Enum_optional"
              , "field_value_mode":   "Value_direct"
              , "field_placement":    get_placement_classes("small:0,12;medium:0,6")
              , "field_value":        "_type/Default_type"
              , "options":            []
              },
              { "field_id":           "List_default_view"         # fields[5]
              , "field_name":         "List_default_view"
              , "field_value_type":   "annal:View"
              , "field_label":        "Default view"
              , "field_render_type":  "Enum_optional"
              , "field_value_mode":   "Value_direct"
              , "field_placement":    get_placement_classes("small:0,12;medium:6,6")
              , "field_value":        "_view/Default_view"
              , "options":            []
              })
          , context_field_row(
              { "field_id":           "List_entity_selector"      # fields[6]
              , "field_name":         "List_entity_selector"
              , "field_value_type":   "annal:Text"
              , "field_label":        "Selector"
              , "field_render_type":  "Text"
              , "field_value_mode":   "Value_direct"
              , "field_placement":    get_placement_classes("small:0,12")
              , "field_value":        "ALL"
              , "options":            []
              })
          , context_field_row(
              { "field_id":           "List_target_type"          # fields[7]
              , "field_name":         "List_target_type"
              , "field_value_type":   "annal:Identifier"
              , "field_label":        "List entity type"
              , "field_render_type":  "Identifier"
              , "field_value_mode":   "Value_direct"
              , "field_placement":    get_placement_classes("small:0,12")
              , "field_value":        ""
              , "options":            []
              })
          , { "field_id":           "List_fields"           # fields[8]
            , "field_name":         "List_fields"
            , "field_value_type":   "annal:Field_group"
            , "field_label":        "Fields"
            , "field_render_type":  "RepeatGroupRow"
            , "field_value_mode":   "Value_direct"
            , "field_placement":    get_placement_classes("small:0,12")
            , "field_value":        list_fields
            , "options":            []
            }
          ]
        })
    if list_id:
        context_dict['fields'][0]['row_field_descs'][0]['field_value'] = list_id
        context_dict['fields'][1]['row_field_descs'][0]['field_value'] = list_label
        context_dict['fields'][2]['row_field_descs'][0]['field_value'] = list_descr
        context_dict['orig_id']     = list_id
    if orig_id:
        context_dict['orig_id']     = orig_id
    if action:  
        context_dict['action']      = action
    return context_dict
Esempio n. 7
0
def recordtype_entity_view_context_data(
        coll_id="testcoll", type_id="", orig_id=None, type_ids=[],
        action=None, update="RecordType",
        type_uri=None, supertype_uris=None #@@ need to deal with these.
    ):
    if type_id:
        type_label = "%s %s/%s"%(update, coll_id, type_id)
        type_descr = "%s help for %s in collection %s"%(update, type_id, coll_id)
    else:
        type_label = "%s data ... (%s/%s)"%(update, coll_id, type_id)
        type_descr = "%s description ... (%s/%s)"%(update, coll_id, type_id)
    context_dict = (
        { 'title':              "%s - Type definition - Collection %s"%(type_label, coll_id)
        , 'heading':            "Type definition"
        , 'coll_id':            coll_id
        , 'type_id':            '_type'
        , 'orig_id':            'orig_type_id'
        , 'fields':
          [ context_field_row(
              { 'field_id':           'Type_id'
              , 'field_name':         'entity_id'
              , 'field_value_type':  'annal:Slug'
              , 'field_label':        'Type Id'
              , 'field_render_type':  'EntityId'
              , 'field_value_mode':   'Value_direct'
              , 'field_placement':    get_placement_classes('small:0,12;medium:0,6')
              # , 'field_value':      (Supplied separately)
              , 'options':            []
              })
          , context_field_row(
              { 'field_id':           'Type_label'
              , 'field_name':         'Type_label'
              , 'field_value_type':  'annal:Text'
              , 'field_label':        'Label'
              , 'field_render_type':  'Text'
              , 'field_value_mode':   'Value_direct'
              , 'field_placement':    get_placement_classes('small:0,12')
              , 'field_value':        type_label
              , 'options':            []
              })
          , context_field_row(
              { 'field_id':           'Type_comment'
              , 'field_name':         'Type_comment'
              , 'field_label':        'Comment'
              , 'field_value_type':  'annal:Richtext'
              , 'field_render_type':  'Markdown'
              , 'field_value_mode':   'Value_direct'
              , 'field_placement':    get_placement_classes('small:0,12')
              , 'field_value':        type_descr
              , 'options':            []
              })
          , context_field_row(
              { 'field_id':           'Type_uri'
              , 'field_name':         'Type_uri'
              , 'field_value_type':  'annal:Identifier'
              , 'field_label':        'Type URI'
              , 'field_render_type':  'Identifier'
              , 'field_value_mode':   'Value_direct'
              , 'field_placement':    get_placement_classes('small:0,12')
              # , 'field_value':      (Supplied separately)
              , 'options':            []
              })
          , { 'field_id':           'Type_supertype_uris'
            , 'field_name':         'Type_supertype_uris'
            , 'field_value_type':  'annal:Type_supertype_uri'
            , 'field_label':        'Supertype URIs'
            , 'field_render_type':  'RepeatGroupRow'
            , 'field_value_mode':   'Value_direct'
            , 'field_placement':    get_placement_classes('small:0,12')
            # , 'field_value':      (Supplied separately)
            , 'options':            []
            }
          , context_field_row(
              { 'field_id':           'Type_view'
              , 'field_name':         'Type_view'
              , 'field_value_type':  'annal:View'
              , 'field_label':        'Default view'
              , 'field_render_type':  'Enum_optional'
              , 'field_value_mode':   'Value_direct'
              , 'field_placement':    get_placement_classes('small:0,12;medium:0,6')
              # , 'field_value':      (Supplied separately)
              , 'options':            []
              },
              { 'field_id':           'Type_list'
              , 'field_name':         'Type_list'
              , 'field_value_type':  'annal:List'
              , 'field_label':        'Default list'
              , 'field_render_type':  'Enum_optional'
              , 'field_value_mode':   'Value_direct'
              , 'field_placement':    get_placement_classes('small:0,12;medium:6,6')
              # , 'field_value':      (Supplied separately)
              , 'options':            []
              })
          ]
        , 'continuation_url':   entitydata_list_type_url(coll_id, "_type")
        })
    if type_id:
        type_url = recordtype_url(coll_id=coll_id, type_id=type_id)
        context_dict['fields'][0]['row_field_descs'][0]['field_value'] = type_id
        context_dict['fields'][3]['row_field_descs'][0]['field_value'] = type_url or ""
        context_dict['orig_id']     = type_id
    if orig_id:
        context_dict['orig_id']     = orig_id
    if action:  
        context_dict['action']      = action
    return context_dict
def entitydata_recordtype_view_context_data(
        entity_id=None, orig_id=None, coll_id="testcoll", type_id="testtype", type_uri=None, type_ids=[],
        action=None, update="Entity", view_label="Type definition"
    ):
    if entity_id:
        entity_label = '%s %s/%s/%s'%(update, coll_id, type_id, entity_id)
        entity_descr = '%s coll %s, type %s, entity %s'%(update, coll_id, type_id, entity_id)
    else:
        entity_label = '%s data ... (%s/%s)'%(update, coll_id, type_id)
        entity_descr = '%s description ... (%s/%s)'%(update, coll_id, type_id)
    context_dict = (
        { 'title':              "%s - %s - Collection %s"%(entity_label, view_label, coll_id)
        , 'heading':            view_label
        , 'coll_id':            coll_id
        , 'type_id':            type_id
        , 'orig_id':            'orig_entity_id'
        , 'fields':
          [ context_field_row(
              { 'field_label':        'Type Id'
              , 'field_name':         'entity_id'
              , 'field_placement':    get_placement_classes('small:0,12;medium:0,6')
              , 'field_id':           'Type_id'
              , 'field_value_mode':   'Value_direct'
              , 'field_value_type':  'annal:Slug'
              # , 'field_value':      (Supplied separately)
              , 'options':            []
              })
          , context_field_row(
              { 'field_label':        'Label'
              , 'field_name':         'Type_label'
              , 'field_placement':    get_placement_classes('small:0,12')
              , 'field_id':           'Type_label'
              , 'field_value_mode':   'Value_direct'
              , 'field_value_type':  'annal:Text'
              , 'field_value':        entity_label
              , 'options':            []
              })
          , context_field_row(
              { 'field_label':        'Comment'
              , 'field_name':         'Type_comment'
              , 'field_placement':    get_placement_classes('small:0,12')
              , 'field_id':           'Type_comment'
              , 'field_value_mode':   'Value_direct'
              , 'field_value_type':  'annal:Richtext'
              , 'field_value':        entity_descr
              , 'options':            []
              })
          , context_field_row(
              { 'field_label':        'Type URI'
              , 'field_name':         'Type_uri'
              , 'field_placement':    get_placement_classes('small:0,12')
              , 'field_id':           'Type_uri'
              , 'field_value_mode':   'Value_direct'
              , 'field_value_type':  'annal:Identifier'
              , 'field_value':        ""
              , 'options':            []
              })
          ]
        , 'continuation_url':   entitydata_list_type_url(coll_id, type_id)
        })
    if entity_id:
        context_dict['fields'][0]['row_field_descs'][0]['field_value'] = entity_id
        context_dict['orig_id']                  = entity_id
    if type_uri:
        context_dict['fields'][3]['row_field_descs'][0]['field_value'] = type_uri
    if orig_id:
        context_dict['orig_id']     = orig_id
    if action:  
        context_dict['action']      = action
    return context_dict
Esempio n. 9
0
def recordlist_view_context_data(coll_id="testcoll",
                                 list_id=None,
                                 orig_id=None,
                                 view_ids=[],
                                 action=None,
                                 update="RecordList"):
    if list_id:
        list_label = "%s %s/%s" % (update, coll_id, list_id)
        list_descr = "%s help for %s/%s" % (update, coll_id, list_id)
    else:
        list_label = "%s list (%s/@@list_id@@)" % (update, coll_id)
        list_descr = "%s description ... (%s/%s)" % (update, coll_id, list_id)
    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"
    }])
    context_dict = ({
        "title":
        "%s - List definition - Collection %s" % (list_label, coll_id),
        'heading':
        "List definition",
        "coll_id":
        coll_id,
        "type_id":
        "_list",
        "orig_id":
        "orig_list_id",
        "continuation_url":
        entitydata_list_type_url(coll_id, "_list"),
        "fields": [
            context_field_row(
                {
                    "field_id":
                    "List_id"  # fields[0]
                    ,
                    "field_name":
                    "entity_id",
                    "field_value_type":
                    "annal:Slug",
                    "field_label":
                    "List Id",
                    "field_render_type":
                    "Slug",
                    "field_value_mode":
                    "Value_direct",
                    "field_placement":
                    get_placement_classes("small:0,12;medium:0,6")
                    # , "field_value":      (Supplied separately, below)
                    ,
                    "options": []
                },
                {
                    "field_id":
                    "List_type"  # fields[1]
                    ,
                    "field_name":
                    "List_type",
                    "field_value_type":
                    "annal:List_type",
                    "field_label":
                    "List display type",
                    "field_render_type":
                    "Enum_choice",
                    "field_value_mode":
                    "Value_direct",
                    "field_placement":
                    get_placement_classes("small:0,12;medium:6,6"),
                    "field_value":
                    "Enum_list_type/List",
                    "options": []  # ["list", "grid"]
                }),
            context_field_row({
                "field_id":
                "List_label"  # fields[2]
                ,
                "field_name":
                "List_label",
                "field_value_type":
                "annal:Text",
                "field_label":
                "Label",
                "field_render_type":
                "Text",
                "field_value_mode":
                "Value_direct",
                "field_placement":
                get_placement_classes("small:0,12")
                # , "field_value":      (Supplied separately, below)
                ,
                "options": []
            }),
            context_field_row({
                "field_id":
                "List_comment"  # fields[3]
                ,
                "field_name":
                "List_comment",
                "field_label":
                "Help",
                "field_value_type":
                "annal:Richtext",
                "field_render_type":
                "Markdown",
                "field_value_mode":
                "Value_direct",
                "field_placement":
                get_placement_classes("small:0,12")
                # , "field_value":      (Supplied separately, below)
                ,
                "options": []
            }),
            context_field_row(
                {
                    "field_id":
                    "List_default_type"  # fields[4]
                    ,
                    "field_name":
                    "List_default_type",
                    "field_value_type":
                    "annal:Type",
                    "field_label":
                    "Default type",
                    "field_render_type":
                    "Enum_optional",
                    "field_value_mode":
                    "Value_direct",
                    "field_placement":
                    get_placement_classes("small:0,12;medium:0,6"),
                    "field_value":
                    "_type/Default_type",
                    "options": []
                },
                {
                    "field_id":
                    "List_default_view"  # fields[5]
                    ,
                    "field_name":
                    "List_default_view",
                    "field_value_type":
                    "annal:View",
                    "field_label":
                    "Default view",
                    "field_render_type":
                    "Enum_optional",
                    "field_value_mode":
                    "Value_direct",
                    "field_placement":
                    get_placement_classes("small:0,12;medium:6,6"),
                    "field_value":
                    "_view/Default_view",
                    "options": []
                }),
            context_field_row({
                "field_id":
                "List_entity_selector"  # fields[6]
                ,
                "field_name":
                "List_entity_selector",
                "field_value_type":
                "annal:Text",
                "field_label":
                "Selector",
                "field_render_type":
                "Text",
                "field_value_mode":
                "Value_direct",
                "field_placement":
                get_placement_classes("small:0,12"),
                "field_value":
                "ALL",
                "options": []
            }),
            context_field_row({
                "field_id":
                "List_target_type"  # fields[7]
                ,
                "field_name":
                "List_target_type",
                "field_value_type":
                "annal:Identifier",
                "field_label":
                "List entity type",
                "field_render_type":
                "Identifier",
                "field_value_mode":
                "Value_direct",
                "field_placement":
                get_placement_classes("small:0,12"),
                "field_value":
                "",
                "options": []
            }),
            {
                "field_id": "List_fields"  # fields[8]
                ,
                "field_name": "List_fields",
                "field_value_type": "annal:Field_group",
                "field_label": "Fields",
                "field_render_type": "RepeatGroupRow",
                "field_value_mode": "Value_direct",
                "field_placement": get_placement_classes("small:0,12"),
                "field_value": list_fields,
                "options": []
            }
        ]
    })
    if list_id:
        context_dict['fields'][0]['row_field_descs'][0][
            'field_value'] = list_id
        context_dict['fields'][1]['row_field_descs'][0][
            'field_value'] = list_label
        context_dict['fields'][2]['row_field_descs'][0][
            'field_value'] = list_descr
        context_dict['orig_id'] = list_id
    if orig_id:
        context_dict['orig_id'] = orig_id
    if action:
        context_dict['action'] = action
    return context_dict
Esempio n. 10
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
def recordtype_entity_view_context_data(
        coll_id="testcoll",
        type_id="",
        orig_id=None,
        type_ids=[],
        action=None,
        update="RecordType",
        type_uri=None,
        supertype_uris=None  #@@ need to deal with these.
):
    if type_id:
        type_label = "%s %s/%s" % (update, coll_id, type_id)
        type_descr = "%s help for %s in collection %s" % (update, type_id,
                                                          coll_id)
    else:
        type_label = "%s data ... (%s/%s)" % (update, coll_id, type_id)
        type_descr = "%s description ... (%s/%s)" % (update, coll_id, type_id)
    context_dict = ({
        'title':
        "%s - Type definition - Collection %s" % (type_label, coll_id),
        'heading':
        "Type definition",
        'coll_id':
        coll_id,
        'type_id':
        '_type',
        'orig_id':
        'orig_type_id',
        'fields': [
            context_field_row({
                'field_id':
                'Type_id',
                'field_name':
                'entity_id',
                'field_value_type':
                'annal:Slug',
                'field_label':
                'Type Id',
                'field_render_type':
                'EntityId',
                'field_value_mode':
                'Value_direct',
                'field_placement':
                get_placement_classes('small:0,12;medium:0,6')
                # , 'field_value':      (Supplied separately)
                ,
                'options': []
            }),
            context_field_row({
                'field_id':
                'Type_label',
                'field_name':
                'Type_label',
                'field_value_type':
                'annal:Text',
                'field_label':
                'Label',
                'field_render_type':
                'Text',
                'field_value_mode':
                'Value_direct',
                'field_placement':
                get_placement_classes('small:0,12'),
                'field_value':
                type_label,
                'options': []
            }),
            context_field_row({
                'field_id':
                'Type_comment',
                'field_name':
                'Type_comment',
                'field_label':
                'Comment',
                'field_value_type':
                'annal:Richtext',
                'field_render_type':
                'Markdown',
                'field_value_mode':
                'Value_direct',
                'field_placement':
                get_placement_classes('small:0,12'),
                'field_value':
                type_descr,
                'options': []
            }),
            context_field_row({
                'field_id':
                'Type_uri',
                'field_name':
                'Type_uri',
                'field_value_type':
                'annal:Identifier',
                'field_label':
                'Type URI',
                'field_render_type':
                'Identifier',
                'field_value_mode':
                'Value_direct',
                'field_placement':
                get_placement_classes('small:0,12')
                # , 'field_value':      (Supplied separately)
                ,
                'options': []
            }),
            {
                'field_id': 'Type_supertype_uris',
                'field_name': 'Type_supertype_uris',
                'field_value_type': 'annal:Type_supertype_uri',
                'field_label': 'Supertype URIs',
                'field_render_type': 'RepeatGroupRow',
                'field_value_mode': 'Value_direct',
                'field_placement': get_placement_classes('small:0,12')
                # , 'field_value':      (Supplied separately)
                ,
                'options': []
            },
            context_field_row(
                {
                    'field_id':
                    'Type_view',
                    'field_name':
                    'Type_view',
                    'field_value_type':
                    'annal:View',
                    'field_label':
                    'Default view',
                    'field_render_type':
                    'Enum_optional',
                    'field_value_mode':
                    'Value_direct',
                    'field_placement':
                    get_placement_classes('small:0,12;medium:0,6')
                    # , 'field_value':      (Supplied separately)
                    ,
                    'options': []
                },
                {
                    'field_id':
                    'Type_list',
                    'field_name':
                    'Type_list',
                    'field_value_type':
                    'annal:List',
                    'field_label':
                    'Default list',
                    'field_render_type':
                    'Enum_optional',
                    'field_value_mode':
                    'Value_direct',
                    'field_placement':
                    get_placement_classes('small:0,12;medium:6,6')
                    # , 'field_value':      (Supplied separately)
                    ,
                    'options': []
                })
        ],
        'continuation_url':
        entitydata_list_type_url(coll_id, "_type")
    })
    if type_id:
        type_url = recordtype_url(coll_id=coll_id, type_id=type_id)
        context_dict['fields'][0]['row_field_descs'][0][
            'field_value'] = type_id
        context_dict['fields'][3]['row_field_descs'][0][
            'field_value'] = type_url or ""
        context_dict['orig_id'] = type_id
    if orig_id:
        context_dict['orig_id'] = orig_id
    if action:
        context_dict['action'] = action
    return context_dict
Esempio n. 12
0
def recordview_entity_view_context_data(
        coll_id="testcoll", view_id="", orig_id=None, view_ids=[],
        action=None, 
        target_record_type="annal:View",
        add_field=None, remove_field=None, move_up=None, move_down=None,
        update="RecordView"
    ):
    if view_id:
        view_label = "%s %s/%s"%(update, coll_id, view_id)
        view_descr = "%s help for %s in collection %s"%(update, view_id, coll_id)
    else:
        view_label = "%s data ... (%s/%s)"%(update, coll_id, view_id)
        view_descr = "%s description ... (%s/%s)"%(update, coll_id, view_id)
    # Target record fields listed in the view description
    view_fields = (
          [ { 'annal:field_id':         layout.FIELD_TYPEID+"/Entity_id"
            , 'annal:field_placement':  "small:0,12;medium:0,6"
            }
          , { 'annal:field_id':         layout.FIELD_TYPEID+"/Entity_type"
            , 'annal:field_placement':  "small:0,12;medium:6,6"
            }
          , { 'annal:field_id':         layout.FIELD_TYPEID+"/Entity_label"
            , 'annal:property_uri':     "rdfs:label"
            , 'annal:field_placement':  "small:0,12"
            }
          , { 'annal:field_id':         layout.FIELD_TYPEID+"/Entity_comment"
            , 'annal:property_uri':     "rdfs:comment"
            # , 'annal:field_placement':  field3_placement
            }
          ])
    # NOTE: context['fields'][i]['field_id'] comes from FieldDescription instance via
    #       bound_field, so type prefix is stripped.  This does not apply to the field
    #       ids actually coming from the view form.
    context_dict = (
        { 'title':              "%s - View definition - Collection %s"%(view_label, coll_id)
        , 'heading':            "View definition"
        , 'coll_id':            coll_id
        , 'type_id':            '_view'
        , 'orig_id':            'orig_view_id'
        , 'record_type':        'annal:View'
        , 'fields':
          [ context_field_row(
              { 'field_id':           'View_id'               # fields[0]
              , 'field_name':         'entity_id'
              , 'field_value_type':   'annal:Slug'
              , 'field_label':        'View Id'
              , 'field_render_type':  'Enum_render_type/EntityId'
              , 'field_value_mode':   'Enum_value_mode/Value_direct'
              , 'field_placement':    get_placement_classes('small:0,12;medium:0,6')
              # , 'field_value':      (Supplied separately)
              , 'options':            []
              })
          , context_field_row(
              { 'field_id':           'View_label'            # fields[1]
              , 'field_name':         'View_label'
              , 'field_value_type':   'annal:Text'
              , 'field_label':        'Label'
              , 'field_render_type':  'Enum_render_type/Text'
              , 'field_value_mode':   'Enum_value_mode/Value_direct'
              , 'field_placement':    get_placement_classes('small:0,12')
              , 'field_value':        view_label
              , 'options':            []
              })
          , context_field_row(
              { 'field_id':           'View_comment'          # fields[2]
              , 'field_name':         'View_comment'
              , 'field_label':        'Help'
              , 'field_value_type':   'annal:Richtext'
              , 'field_render_type':  'Enum_render_type/Markdown'
              , 'field_value_mode':   'Enum_value_mode/Value_direct'
              , 'field_placement':    get_placement_classes('small:0,12')
              , 'field_value':        view_descr
              , 'options':            []
              })
          , context_field_row(
              { 'field_id':           'View_target_type'      # fields[3]
              , 'field_name':         'View_target_type'
              , 'field_value_type':   'annal:Identifier'
              , 'field_label':        'View entity type'
              , 'field_render_type':  'Enum_render_type/Identifier'
              , 'field_value_mode':   'Enum_value_mode/Value_direct'
              , 'field_placement':    get_placement_classes('small:0,12')
              , 'field_value':        target_record_type
              , 'options':            []
              })
          , context_field_row(
              { 'field_id':           'View_edit_view'        # fields[4]
              , 'field_name':         'View_edit_view'
              , 'field_value_type':   'annal:Boolean'
              , 'field_label':        'Editable view?'
              , 'field_render_type':  'Enum_render_type/CheckBox'
              , 'field_value_mode':   'Enum_value_mode/Value_direct'
              , 'field_placement':    get_placement_classes('small:0,12;medium:0,6')
              , 'field_value':        True
              , 'options':            []
              })
          , { "field_id":           'View_fields'           # fields[5]
            , 'field_name':         'View_fields'
            , 'field_value_type':   'annal:Field_group'
            , 'field_label':        'Fields'
            , 'field_render_type':  'Enum_render_type/Group_Seq_Row'
            , 'field_value_mode':   'Enum_value_mode/Value_direct'
            , 'field_placement':    get_placement_classes('small:0,12')
            , 'field_value':        view_fields
            , 'options':            []
            }
          ]
        , 'continuation_url':   entitydata_list_type_url(coll_id, "_view")
        })
    if view_id:
        context_dict['fields'][0]['row_field_descs'][0]['field_value'] = view_id
        context_dict['fields'][1]['row_field_descs'][0]['field_value'] = view_label
        context_dict['fields'][2]['row_field_descs'][0]['field_value'] = '%s help for %s in collection %s'%(update, view_id, coll_id)
        context_dict['orig_id']     = view_id
    if orig_id:
        context_dict['orig_id']     = orig_id
    if action:  
        context_dict['action']      = action
    if add_field:
        context_dict['fields'][5]['field_value'].append(
            { 'annal:field_id':         None
            , 'annal:property_uri':     None
            , 'annal:field_placement':  None
            })
    if remove_field:
        context_dict['fields'][5]['field_value'][3:4] = []
    if move_up:
        assert move_up == [2,3]
        fields = context_dict['fields'][5]['field_value']
        context_dict['fields'][5]['field_value'] = [ fields[i]  for i in [0,2,3,1] ]
    if move_down:
        assert move_down == [1]
        fields = context_dict['fields'][5]['field_value']
        context_dict['fields'][5]['field_value'] = [ fields[i]  for i in [0,2,1,3] ]
    return context_dict
def recordview_entity_view_context_data(coll_id="testcoll",
                                        view_id="",
                                        orig_id=None,
                                        view_ids=[],
                                        action=None,
                                        target_record_type="annal:View",
                                        add_field=None,
                                        remove_field=None,
                                        move_up=None,
                                        move_down=None,
                                        update="RecordView"):
    if view_id:
        view_label = "%s %s/%s" % (update, coll_id, view_id)
        view_descr = "%s help for %s in collection %s" % (update, view_id,
                                                          coll_id)
    else:
        view_label = "%s data ... (%s/%s)" % (update, coll_id, view_id)
        view_descr = "%s description ... (%s/%s)" % (update, coll_id, view_id)
    # Target record fields listed in the view description
    view_fields = ([
        {
            'annal:field_id': layout.FIELD_TYPEID + "/Entity_id",
            'annal:field_placement': "small:0,12;medium:0,6"
        },
        {
            'annal:field_id': layout.FIELD_TYPEID + "/Entity_type",
            'annal:field_placement': "small:0,12;medium:6,6"
        },
        {
            'annal:field_id': layout.FIELD_TYPEID + "/Entity_label",
            'annal:property_uri': "rdfs:label",
            'annal:field_placement': "small:0,12"
        },
        {
            'annal:field_id': layout.FIELD_TYPEID + "/Entity_comment",
            'annal:property_uri': "rdfs:comment"
            # , 'annal:field_placement':  field3_placement
        }
    ])
    # NOTE: context['fields'][i]['field_id'] comes from FieldDescription instance via
    #       bound_field, so type prefix is stripped.  This does not apply to the field
    #       ids actually coming from the view form.
    context_dict = ({
        'title':
        "%s - View definition - Collection %s" % (view_label, coll_id),
        'heading':
        "View definition",
        'coll_id':
        coll_id,
        'type_id':
        '_view',
        'orig_id':
        'orig_view_id',
        'record_type':
        'annal:View',
        'fields': [
            context_field_row({
                'field_id':
                'View_id'  # fields[0]
                ,
                'field_name':
                'entity_id',
                'field_value_type':
                'annal:Slug',
                'field_label':
                'View Id',
                'field_render_type':
                'Enum_render_type/EntityId',
                'field_value_mode':
                'Enum_value_mode/Value_direct',
                'field_placement':
                get_placement_classes('small:0,12;medium:0,6')
                # , 'field_value':      (Supplied separately)
                ,
                'options': []
            }),
            context_field_row({
                'field_id':
                'View_label'  # fields[1]
                ,
                'field_name':
                'View_label',
                'field_value_type':
                'annal:Text',
                'field_label':
                'Label',
                'field_render_type':
                'Enum_render_type/Text',
                'field_value_mode':
                'Enum_value_mode/Value_direct',
                'field_placement':
                get_placement_classes('small:0,12'),
                'field_value':
                view_label,
                'options': []
            }),
            context_field_row({
                'field_id':
                'View_comment'  # fields[2]
                ,
                'field_name':
                'View_comment',
                'field_label':
                'Help',
                'field_value_type':
                'annal:Richtext',
                'field_render_type':
                'Enum_render_type/Markdown',
                'field_value_mode':
                'Enum_value_mode/Value_direct',
                'field_placement':
                get_placement_classes('small:0,12'),
                'field_value':
                view_descr,
                'options': []
            }),
            context_field_row({
                'field_id':
                'View_target_type'  # fields[3]
                ,
                'field_name':
                'View_target_type',
                'field_value_type':
                'annal:Identifier',
                'field_label':
                'View entity type',
                'field_render_type':
                'Enum_render_type/Identifier',
                'field_value_mode':
                'Enum_value_mode/Value_direct',
                'field_placement':
                get_placement_classes('small:0,12'),
                'field_value':
                target_record_type,
                'options': []
            }),
            context_field_row({
                'field_id':
                'View_edit_view'  # fields[4]
                ,
                'field_name':
                'View_edit_view',
                'field_value_type':
                'annal:Boolean',
                'field_label':
                'Editable view?',
                'field_render_type':
                'Enum_render_type/CheckBox',
                'field_value_mode':
                'Enum_value_mode/Value_direct',
                'field_placement':
                get_placement_classes('small:0,12;medium:0,6'),
                'field_value':
                True,
                'options': []
            }),
            {
                "field_id": 'View_fields'  # fields[5]
                ,
                'field_name': 'View_fields',
                'field_value_type': 'annal:Field_group',
                'field_label': 'Fields',
                'field_render_type': 'Enum_render_type/Group_Seq_Row',
                'field_value_mode': 'Enum_value_mode/Value_direct',
                'field_placement': get_placement_classes('small:0,12'),
                'field_value': view_fields,
                'options': []
            }
        ],
        'continuation_url':
        entitydata_list_type_url(coll_id, "_view")
    })
    if view_id:
        context_dict['fields'][0]['row_field_descs'][0][
            'field_value'] = view_id
        context_dict['fields'][1]['row_field_descs'][0][
            'field_value'] = view_label
        context_dict['fields'][2]['row_field_descs'][0][
            'field_value'] = '%s help for %s in collection %s' % (
                update, view_id, coll_id)
        context_dict['orig_id'] = view_id
    if orig_id:
        context_dict['orig_id'] = orig_id
    if action:
        context_dict['action'] = action
    if add_field:
        context_dict['fields'][5]['field_value'].append({
            'annal:field_id':
            None,
            'annal:property_uri':
            None,
            'annal:field_placement':
            None
        })
    if remove_field:
        context_dict['fields'][5]['field_value'][3:4] = []
    if move_up:
        assert move_up == [2, 3]
        fields = context_dict['fields'][5]['field_value']
        context_dict['fields'][5]['field_value'] = [
            fields[i] for i in [0, 2, 3, 1]
        ]
    if move_down:
        assert move_down == [1]
        fields = context_dict['fields'][5]['field_value']
        context_dict['fields'][5]['field_value'] = [
            fields[i] for i in [0, 2, 1, 3]
        ]
    return context_dict
def recordfield_entity_view_context_data(coll_id="testcoll",
                                         field_id=None,
                                         orig_id=None,
                                         type_ids=[],
                                         action=None,
                                         update="Field"):
    if field_id:
        field_label = "%s %s/_field/%s" % (update, coll_id, field_id)
        field_descr = "%s help for %s in collection %s" % (update, field_id,
                                                           coll_id)
    else:
        field_label = "%s data ... (testcoll/_field)" % (update)
        field_descr = "%s description ... (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")
    context_dict = ({
        "title":
        "%s - Field definition - Collection %s" % (field_label, coll_id),
        'heading':
        "Field definition",
        'coll_id':
        coll_id,
        'type_id':
        "_field",
        'orig_id':
        "orig_field_id",
        'fields': [
            context_field_row(
                {
                    'field_id':
                    "Field_id"  # 0 (0,0)
                    ,
                    'field_name':
                    "entity_id",
                    'field_label':
                    "Field Id",
                    'field_value_type':
                    "annal:Slug",
                    'field_render_type':
                    "EntityId",
                    'field_value_mode':
                    "Value_direct",
                    'field_property_uri':
                    "annal:...",
                    'field_placement':
                    get_placement_classes('small:0,12;medium:0,6'),
                    'field_property_uri':
                    'annal:id',
                    'field_ref_type':
                    None,
                    'field_ref_field':
                    None,
                    'field_placeholder':
                    "(field id)",
                    'field_default_value':
                    None
                    # , 'field_value':          (Supplied separately)
                    ,
                    'options': []
                },
                {
                    'field_id':
                    "Field_render_type"  # 1 (0,1)
                    ,
                    'field_name':
                    "Field_render_type",
                    'field_label':
                    "Render type",
                    'field_value_type':
                    "annal:Slug",
                    'field_render_type':
                    "Enum_choice",
                    'field_value_mode':
                    "Value_direct",
                    'field_property_uri':
                    "annal:field_render_type",
                    'field_placement':
                    get_placement_classes('small:0,12;medium:6,6'),
                    'field_ref_type':
                    "Enum_render_type",
                    'field_ref_field':
                    None,
                    'field_placeholder':
                    "(field render type)",
                    'field_default_value':
                    "Text",
                    'field_value':
                    "Text",
                    'options': []
                }),
            context_field_row(
                {
                    'field_id':
                    "Field_value_type"  # 2 (1,0)
                    ,
                    'field_name':
                    "Field_value_type",
                    'field_label':
                    "Value type",
                    'field_value_type':
                    "annal:Identifier",
                    'field_render_type':
                    "Identifier",
                    'field_value_mode':
                    "Value_direct",
                    'field_property_uri':
                    "annal:field_value_type",
                    'field_placement':
                    get_placement_classes('small:0,12;medium:0,6'),
                    'field_ref_type':
                    None,
                    'field_ref_field':
                    None,
                    'field_placeholder':
                    "(field value type)",
                    'field_default_value':
                    "annal:Text",
                    'field_value':
                    "annal:Text",
                    'options': []
                },
                {
                    'field_id':
                    "Field_value_mode"  # 3 (1,1)
                    ,
                    'field_name':
                    "Field_value_mode",
                    'field_label':
                    "Value mode",
                    'field_value_type':
                    "annal:Slug",
                    'field_render_type':
                    "Enum_choice",
                    'field_value_mode':
                    "Value_direct",
                    'field_property_uri':
                    "annal:field_value_mode",
                    'field_placement':
                    get_placement_classes('small:0,12;medium:6,6'),
                    'field_ref_type':
                    "Enum_value_mode",
                    'field_ref_field':
                    None,
                    'field_placeholder':
                    "(field value mode)",
                    'field_default_value':
                    "Value_direct",
                    'field_value':
                    "Value_direct",
                    'options': []
                }),
            context_field_row({
                'field_id':
                "Field_label"  # 4 (2,0)
                ,
                'field_name':
                "Field_label",
                'field_label':
                "Label",
                'field_value_type':
                "annal:Text",
                'field_render_type':
                "Text",
                'field_value_mode':
                "Value_direct",
                'field_property_uri':
                "rdfs:label",
                'field_placement':
                get_placement_classes('small:0,12'),
                'field_ref_type':
                None,
                'field_ref_field':
                None,
                'field_placeholder':
                "(field label)",
                'field_default_value':
                "",
                'field_value':
                field_label,
                'options': []
            }),
            context_field_row({
                'field_id':
                "Field_comment"  # 5 (3,0)
                ,
                'field_name':
                "Field_comment",
                'field_label':
                "Help",
                'field_value_type':
                "annal:Longtext",
                'field_render_type':
                "Textarea",
                'field_value_mode':
                "Value_direct",
                'field_property_uri':
                "rdfs:comment",
                'field_placement':
                get_placement_classes('small:0,12'),
                'field_ref_type':
                None,
                'field_ref_field':
                None,
                'field_placeholder':
                "(field usage commentary or help text)",
                'field_default_value':
                "",
                'field_value':
                field_descr,
                'options': []
            }),
            context_field_row(
                {
                    'field_id':
                    "Field_property"  # 6 (4,0)
                    ,
                    'field_name':
                    "Field_property",
                    'field_label':
                    "Property URI",
                    'field_value_type':
                    "annal:Identifier",
                    'field_render_type':
                    "Identifier",
                    'field_value_mode':
                    "Value_direct",
                    'field_property_uri':
                    "annal:property_uri",
                    'field_placement':
                    get_placement_classes('small:0,12;medium:0,6'),
                    'field_ref_type':
                    None,
                    'field_ref_field':
                    None,
                    'field_placeholder':
                    "(field URI or CURIE)",
                    'field_default_value':
                    "",
                    'field_value':
                    "",
                    'options': []
                },
                {
                    'field_id':
                    "Field_placement"  # 7 (4,1)
                    ,
                    'field_name':
                    "Field_placement",
                    'field_label':
                    "Position/size",
                    'field_value_type':
                    "annal:Placement",
                    'field_render_type':
                    "Placement",
                    'field_value_mode':
                    "Value_direct",
                    'field_property_uri':
                    "annal:field_placement",
                    'field_placement':
                    get_placement_classes('small:0,12;medium:6,6'),
                    'field_ref_type':
                    None,
                    'field_ref_field':
                    None,
                    'field_placeholder':
                    "(field position and size)",
                    'field_default_value':
                    "",
                    'field_value':
                    "",
                    'options': []
                }),
            context_field_row(
                {
                    'field_id':
                    "Field_typeref"  # 8 (5,0)
                    ,
                    'field_name':
                    "Field_typeref",
                    'field_label':
                    "Refer to type",
                    'field_value_type':
                    "annal:Slug",
                    'field_render_type':
                    "Enum_optional",
                    'field_value_mode':
                    "Value_direct",
                    'field_property_uri':
                    "annal:field_ref_type",
                    'field_placement':
                    get_placement_classes('small:0,12;medium:0,6'),
                    'field_ref_type':
                    "_type",
                    'field_ref_field':
                    None,
                    'field_placeholder':
                    "(no type selected)",
                    'field_default_value':
                    "",
                    'field_value':
                    "",
                    'options': []
                },
                {
                    'field_id':
                    "Field_fieldref"  # 9 (5,1)
                    ,
                    'field_name':
                    "Field_fieldref",
                    'field_label':
                    "Refer to field",
                    'field_value_type':
                    "annal:Identifier",
                    'field_render_type':
                    "Identifier",
                    'field_value_mode':
                    "Value_direct",
                    'field_property_uri':
                    "annal:field_ref_field",
                    'field_placement':
                    get_placement_classes('small:0,12;medium:6,6'),
                    'field_ref_type':
                    None,
                    'field_ref_field':
                    None,
                    'field_placeholder':
                    "(field URI or CURIE)",
                    'field_default_value':
                    "",
                    'field_value':
                    "",
                    'options': []
                }),
            context_field_row({
                'field_id':
                "Field_placeholder"  # 10 (6,0)
                ,
                'field_name':
                "Field_placeholder",
                'field_label':
                "Placeholder",
                'field_value_type':
                "annal:Text",
                'field_render_type':
                "Text",
                'field_value_mode':
                "Value_direct",
                'field_property_uri':
                "annal:placeholder",
                'field_placement':
                get_placement_classes('small:0,12'),
                'field_ref_type':
                None,
                'field_ref_field':
                None,
                'field_placeholder':
                "(placeholder text)",
                'field_default_value':
                "",
                'field_value':
                "",
                'options': []
            }),
            context_field_row({
                'field_id':
                "Field_default"  # 11 (7,0)
                ,
                'field_name':
                "Field_default",
                'field_label':
                "Default",
                'field_value_type':
                "annal:Text",
                'field_render_type':
                "Text",
                'field_value_mode':
                "Value_direct",
                'field_property_uri':
                "annal:default_value",
                'field_placement':
                get_placement_classes('small:0,12'),
                'field_ref_type':
                None,
                'field_ref_field':
                None,
                'field_placeholder':
                "(field default value)",
                'field_default_value':
                "",
                'field_value':
                "",
                'options': []
            }),
            context_field_row({
                'field_id':
                "Field_groupref"  # 12 (8,0)
                ,
                'field_name':
                "Field_groupref",
                'field_label':
                "Field group",
                'field_value_type':
                "annal:Slug",
                'field_render_type':
                "Enum_optional",
                'field_value_mode':
                "Value_direct",
                'field_property_uri':
                "annal:group_ref",
                'field_placement':
                get_placement_classes('small:0,12;medium:0,6'),
                'field_ref_type':
                "_group",
                'field_ref_field':
                None,
                'field_placeholder':
                "(no field group selected)",
                'field_default_value':
                "",
                'field_value':
                "",
                'options': []
            }),
            context_field_row(
                {
                    'field_id':
                    "Field_repeat_label_add"  # 13 (9,0)
                    ,
                    'field_name':
                    "Field_repeat_label_add",
                    'field_label':
                    "Add value label",
                    'field_value_type':
                    "annal:Text",
                    'field_render_type':
                    "Text",
                    'field_value_mode':
                    "Value_direct",
                    'field_property_uri':
                    "annal:repeat_label_add",
                    'field_placement':
                    get_placement_classes('small:0,12;medium:0,6'),
                    'field_ref_type':
                    None,
                    'field_ref_field':
                    None
                    # , 'field_placeholder':      "..."
                    ,
                    'field_default_value':
                    "",
                    'field_value':
                    "",
                    'options': []
                },
                {
                    'field_id':
                    "Field_repeat_label_delete"  # 14 (9,1)
                    ,
                    'field_name':
                    "Field_repeat_label_delete",
                    'field_label':
                    "Delete value label",
                    'field_value_type':
                    "annal:Text",
                    'field_render_type':
                    "Text",
                    'field_value_mode':
                    "Value_direct",
                    'field_property_uri':
                    "annal:repeat_label_delete",
                    'field_placement':
                    get_placement_classes('small:0,12;medium:6,6'),
                    'field_ref_type':
                    None,
                    'field_ref_field':
                    None
                    # , 'field_placeholder':      "..."
                    ,
                    'field_default_value':
                    "",
                    'field_value':
                    "",
                    'options': []
                }),
            context_field_row({
                'field_id':
                "Field_entity_type"  # 15 (10,0)
                ,
                'field_name':
                "Field_entity_type",
                'field_label':
                "Entity type",
                'field_value_type':
                "annal:Identifier",
                'field_render_type':
                "Identifier",
                'field_value_mode':
                "Value_direct",
                'field_property_uri':
                "annal:field_entity_type",
                'field_placement':
                get_placement_classes('small:0,12'),
                'field_ref_type':
                None,
                'field_ref_field':
                None
                # , 'field_placeholder':      "..."
                ,
                'field_default_value':
                "",
                'field_value':
                "",
                'options': []
            }),
            context_field_row({
                'field_id':
                "Field_restrict"  # 16 (11,0)
                ,
                'field_name':
                "Field_restrict",
                'field_label':
                "Value restriction",
                'field_value_type':
                "annal:Text",
                'field_render_type':
                "Text",
                'field_value_mode':
                "Value_direct",
                'field_property_uri':
                "annal:field_ref_restriction",
                'field_placement':
                get_placement_classes('small:0,12'),
                'field_ref_type':
                None,
                'field_ref_field':
                None
                # , 'field_placeholder':      "..."
                ,
                'field_default_value':
                "",
                'field_value':
                "",
                'options': []
            })
        ],
        'continuation_url':
        entitydata_list_type_url(coll_id, "_field")
    })
    if field_id:
        context_dict['fields'][0]['row_field_descs'][0][
            'field_value'] = field_id
        context_dict['orig_id'] = field_id
    if orig_id:
        context_dict['orig_id'] = orig_id
    if action:
        context_dict['action'] = action
    return context_dict
Esempio n. 15
0
def recordfield_entity_view_context_data(
        coll_id="testcoll", field_id=None, orig_id=None, type_ids=[],
        action=None, update="Field"
    ):
    if field_id:
        field_label = "%s %s/_field/%s"%(update, coll_id, field_id)
        field_descr = "%s help for %s in collection %s"%(update, field_id, coll_id)
    else:
        field_label = "%s data ... (testcoll/_field)"%(update)
        field_descr = "%s description ... (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"
        )
    context_dict = (
        { "title":              "%s - Field definition - Collection %s"%(field_label, coll_id)
        , 'heading':            "Field definition"
        , 'coll_id':            coll_id
        , 'type_id':            "_field"
        , 'orig_id':            "orig_field_id"
        , 'fields':
          [ context_field_row(
              { 'field_id':               "Field_id"                  # 0 (0,0)
              , 'field_name':             "entity_id"
              , 'field_label':            "Field Id"
              , 'field_value_type':       "annal:Slug"
              , 'field_render_type':      "EntityId"
              , 'field_value_mode':       "Value_direct"
              , 'field_property_uri':     "annal:..."
              , 'field_placement':        get_placement_classes('small:0,12;medium:0,6')
              , 'field_property_uri':     'annal:id'
              , 'field_ref_type':         None
              , 'field_ref_field':        None
              , 'field_placeholder':      "(field id)"
              , 'field_default_value':    None
              # , 'field_value':          (Supplied separately)
              , 'options':                []
              },
              { 'field_id':               "Field_render_type"              # 1 (0,1)
              , 'field_name':             "Field_render_type"
              , 'field_label':            "Render type"
              , 'field_value_type':       "annal:Slug"
              , 'field_render_type':      "Enum_choice"
              , 'field_value_mode':       "Value_direct"
              , 'field_property_uri':     "annal:field_render_type"
              , 'field_placement':        get_placement_classes('small:0,12;medium:6,6')
              , 'field_ref_type':         "Enum_render_type"
              , 'field_ref_field':        None
              , 'field_placeholder':      "(field render type)"
              , 'field_default_value':    "Text"
              , 'field_value':            "Text"
              , 'options':                []
              })
          , context_field_row(
              { 'field_id':               "Field_value_type"                # 2 (1,0)
              , 'field_name':             "Field_value_type"
              , 'field_label':            "Value type"
              , 'field_value_type':       "annal:Identifier"
              , 'field_render_type':      "Identifier"
              , 'field_value_mode':       "Value_direct"
              , 'field_property_uri':     "annal:field_value_type"
              , 'field_placement':        get_placement_classes('small:0,12;medium:0,6')
              , 'field_ref_type':         None
              , 'field_ref_field':        None
              , 'field_placeholder':      "(field value type)"
              , 'field_default_value':    "annal:Text"
              , 'field_value':            "annal:Text"
              , 'options':                []
              },
              { 'field_id':               "Field_value_mode"          # 3 (1,1)
              , 'field_name':             "Field_value_mode"
              , 'field_label':            "Value mode"
              , 'field_value_type':       "annal:Slug"
              , 'field_render_type':      "Enum_choice"
              , 'field_value_mode':       "Value_direct"
              , 'field_property_uri':     "annal:field_value_mode"
              , 'field_placement':        get_placement_classes('small:0,12;medium:6,6')
              , 'field_ref_type':         "Enum_value_mode"
              , 'field_ref_field':        None
              , 'field_placeholder':      "(field value mode)"
              , 'field_default_value':    "Value_direct"
              , 'field_value':            "Value_direct"
              , 'options':                []
              })
          , context_field_row(
              { 'field_id':               "Field_label"               # 4 (2,0)
              , 'field_name':             "Field_label"
              , 'field_label':            "Label"
              , 'field_value_type':       "annal:Text"
              , 'field_render_type':      "Text"
              , 'field_value_mode':       "Value_direct"
              , 'field_property_uri':     "rdfs:label"
              , 'field_placement':        get_placement_classes('small:0,12')
              , 'field_ref_type':         None
              , 'field_ref_field':        None
              , 'field_placeholder':      "(field label)"
              , 'field_default_value':    ""
              , 'field_value':            field_label
              , 'options':                []
              })
          , context_field_row(
              { 'field_id':               "Field_comment"             # 5 (3,0)
              , 'field_name':             "Field_comment"
              , 'field_label':            "Help"
              , 'field_value_type':       "annal:Longtext"
              , 'field_render_type':      "Textarea"
              , 'field_value_mode':       "Value_direct"
              , 'field_property_uri':     "rdfs:comment"
              , 'field_placement':        get_placement_classes('small:0,12')
              , 'field_ref_type':         None
              , 'field_ref_field':        None
              , 'field_placeholder':      "(field usage commentary or help text)"
              , 'field_default_value':    ""
              , 'field_value':            field_descr
              , 'options':                []
              })
          , context_field_row(
              { 'field_id':               "Field_property"            # 6 (4,0)
              , 'field_name':             "Field_property"
              , 'field_label':            "Property URI"
              , 'field_value_type':       "annal:Identifier"
              , 'field_render_type':      "Identifier"
              , 'field_value_mode':       "Value_direct"
              , 'field_property_uri':     "annal:property_uri"
              , 'field_placement':        get_placement_classes('small:0,12;medium:0,6')
              , 'field_ref_type':         None
              , 'field_ref_field':        None
              , 'field_placeholder':      "(field URI or CURIE)"
              , 'field_default_value':    ""
              , 'field_value':            ""
              , 'options':                []
              },
              { 'field_id':               "Field_placement"           # 7 (4,1)
              , 'field_name':             "Field_placement"
              , 'field_label':            "Position/size"
              , 'field_value_type':       "annal:Placement"
              , 'field_render_type':      "Placement"
              , 'field_value_mode':       "Value_direct"
              , 'field_property_uri':     "annal:field_placement"
              , 'field_placement':        get_placement_classes('small:0,12;medium:6,6')
              , 'field_ref_type':         None
              , 'field_ref_field':        None
              , 'field_placeholder':      "(field position and size)"
              , 'field_default_value':    ""
              , 'field_value':            ""
              , 'options':                []
              })
          , context_field_row(
              { 'field_id':               "Field_typeref"             # 8 (5,0)
              , 'field_name':             "Field_typeref"
              , 'field_label':            "Refer to type"
              , 'field_value_type':       "annal:Slug"
              , 'field_render_type':      "Enum_optional"
              , 'field_value_mode':       "Value_direct"
              , 'field_property_uri':     "annal:field_ref_type"
              , 'field_placement':        get_placement_classes('small:0,12;medium:0,6')
              , 'field_ref_type':         "_type"
              , 'field_ref_field':        None
              , 'field_placeholder':      "(no type selected)"
              , 'field_default_value':    ""
              , 'field_value':            ""
              , 'options':                []
              },
              { 'field_id':               "Field_fieldref"            # 9 (5,1)
              , 'field_name':             "Field_fieldref"
              , 'field_label':            "Refer to field"
              , 'field_value_type':       "annal:Identifier"
              , 'field_render_type':      "Identifier"
              , 'field_value_mode':       "Value_direct"
              , 'field_property_uri':     "annal:field_ref_field"
              , 'field_placement':        get_placement_classes('small:0,12;medium:6,6')
              , 'field_ref_type':         None
              , 'field_ref_field':        None
              , 'field_placeholder':      "(field URI or CURIE)"
              , 'field_default_value':    ""
              , 'field_value':            ""
              , 'options':                []
              })
          , context_field_row(
              { 'field_id':               "Field_placeholder"         # 10 (6,0)
              , 'field_name':             "Field_placeholder"
              , 'field_label':            "Placeholder"
              , 'field_value_type':       "annal:Text"
              , 'field_render_type':      "Text"
              , 'field_value_mode':       "Value_direct"
              , 'field_property_uri':     "annal:placeholder"
              , 'field_placement':        get_placement_classes('small:0,12')
              , 'field_ref_type':         None
              , 'field_ref_field':        None
              , 'field_placeholder':      "(placeholder text)"
              , 'field_default_value':    ""
              , 'field_value':            ""
              , 'options':                []
              })
          , context_field_row(
              { 'field_id':               "Field_default"             # 11 (7,0)
              , 'field_name':             "Field_default"
              , 'field_label':            "Default"
              , 'field_value_type':       "annal:Text"
              , 'field_render_type':      "Text"
              , 'field_value_mode':       "Value_direct"
              , 'field_property_uri':     "annal:default_value"
              , 'field_placement':        get_placement_classes('small:0,12')
              , 'field_ref_type':         None
              , 'field_ref_field':        None
              , 'field_placeholder':      "(field default value)"
              , 'field_default_value':    ""
              , 'field_value':            ""
              , 'options':                []
              })
          , context_field_row(
              { 'field_id':               "Field_groupref"            # 12 (8,0)
              , 'field_name':             "Field_groupref"
              , 'field_label':            "Field group"
              , 'field_value_type':       "annal:Slug"
              , 'field_render_type':      "Enum_optional"
              , 'field_value_mode':       "Value_direct"
              , 'field_property_uri':     "annal:group_ref"
              , 'field_placement':        get_placement_classes('small:0,12;medium:0,6')
              , 'field_ref_type':         "_group"
              , 'field_ref_field':        None
              , 'field_placeholder':      "(no field group selected)"
              , 'field_default_value':    ""
              , 'field_value':            ""
              , 'options':                []
              })
          , context_field_row(
              { 'field_id':                "Field_repeat_label_add"    # 13 (9,0)
              , 'field_name':             "Field_repeat_label_add"
              , 'field_label':            "Add value label"
              , 'field_value_type':       "annal:Text"
              , 'field_render_type':      "Text"
              , 'field_value_mode':       "Value_direct"
              , 'field_property_uri':     "annal:repeat_label_add"
              , 'field_placement':        get_placement_classes('small:0,12;medium:0,6')
              , 'field_ref_type':         None
              , 'field_ref_field':        None
              # , 'field_placeholder':      "..."
              , 'field_default_value':    ""
              , 'field_value':            ""
              , 'options':                []
              },
              { 'field_id':               "Field_repeat_label_delete" # 14 (9,1)
              , 'field_name':             "Field_repeat_label_delete"
              , 'field_label':            "Delete value label"
              , 'field_value_type':       "annal:Text"
              , 'field_render_type':      "Text"
              , 'field_value_mode':       "Value_direct"
              , 'field_property_uri':     "annal:repeat_label_delete"
              , 'field_placement':        get_placement_classes('small:0,12;medium:6,6')
              , 'field_ref_type':         None
              , 'field_ref_field':        None
              # , 'field_placeholder':      "..."
              , 'field_default_value':    ""
              , 'field_value':            ""
              , 'options':                []
              })
          , context_field_row(
              { 'field_id':               "Field_entity_type"         # 15 (10,0)
              , 'field_name':             "Field_entity_type" 
              , 'field_label':            "Entity type"
              , 'field_value_type':       "annal:Identifier"
              , 'field_render_type':      "Identifier"
              , 'field_value_mode':       "Value_direct"
              , 'field_property_uri':     "annal:field_entity_type"
              , 'field_placement':        get_placement_classes('small:0,12')
              , 'field_ref_type':         None
              , 'field_ref_field':        None
              # , 'field_placeholder':      "..."
              , 'field_default_value':    ""
              , 'field_value':            ""
              , 'options':                []
              })
          , context_field_row(
              { 'field_id':               "Field_restrict"            # 16 (11,0)
              , 'field_name':             "Field_restrict"
              , 'field_label':            "Value restriction"
              , 'field_value_type':      "annal:Text"
              , 'field_render_type':      "Text"
              , 'field_value_mode':       "Value_direct"
              , 'field_property_uri':     "annal:field_ref_restriction"
              , 'field_placement':        get_placement_classes('small:0,12')
              , 'field_ref_type':         None
              , 'field_ref_field':        None
              # , 'field_placeholder':      "..."
              , 'field_default_value':    ""
              , 'field_value':            ""
              , 'options':                []
              })
          ]
        , 'continuation_url':   entitydata_list_type_url(coll_id, "_field")
        })
    if field_id:
        context_dict['fields'][0]['row_field_descs'][0]['field_value'] = field_id
        context_dict['orig_id']     = field_id
    if orig_id:
        context_dict['orig_id']     = orig_id
    if action:  
        context_dict['action']      = action
    return context_dict
Esempio n. 16
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
Esempio n. 17
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
Esempio n. 18
0
def entitydata_context_data(
        entity_id=None, orig_id=None, coll_id="testcoll", type_id="testtype", type_ids=[],
        action=None, update="Entity", view_label="Default record view"
    ):
    if entity_id:
        entity_label = '%s %s/%s/%s'%(update, coll_id, type_id, entity_id)
        entity_descr = '%s coll %s, type %s, entity %s'%(update, coll_id, type_id, entity_id)
    else:
        entity_label = '%s data ... (%s/%s)'%(update, coll_id, type_id)
        entity_descr = '%s description ... (%s/%s)'%(update, coll_id, type_id)
    context_dict = (
        { 'title':              "%s - %s - Collection %s"%(entity_label, view_label, coll_id)
        , 'heading':            view_label
        , 'coll_id':            'testcoll'
        , 'type_id':            'testtype'
        , 'orig_id':            'orig_entity_id'
        , 'fields':
          [ context_field_row(
              { 'field_label':        'Id'
              , 'field_id':           'Entity_id'
              , 'field_name':         'entity_id'
              , 'field_render_type':  'EntityId'
              , 'field_placement':    get_placement_classes('small:0,12;medium:0,6')
              , 'field_value_mode':   'Value_direct'
              , 'field_value_type':  "annal:Slug"
              # , 'field_value':      (Supplied separately)
              , 'options':            []
              },
              { 'field_label':        'Type'
              , 'field_id':           'Entity_type'
              , 'field_name':         'entity_type'
              , 'field_render_type':  'EntityTypeId'
              , 'field_value_type':  "annal:Slug"
              , 'field_placement':    get_placement_classes('small:0,12;medium:6,6')
              , 'field_value_mode':   'Value_direct'
              # , 'field_value':      (Supplied separately)
              , 'options':            []
              })
          , context_field_row(
              { 'field_label':        'Label'
              , 'field_id':           'Entity_label'
              , 'field_name':         'Entity_label'
              , 'field_render_type':  'Text'
              , 'field_placement':    get_placement_classes('small:0,12')
              , 'field_value_mode':   'Value_direct'
              , 'field_value_type':  "annal:Text"
              , 'field_value':        entity_label
              , 'options':            []
              })
          , context_field_row(
              { 'field_label':        'Comment'
              , 'field_id':           'Entity_comment'
              , 'field_name':         'Entity_comment'
              , 'field_render_type':  'Markdown'
              , 'field_placement':    get_placement_classes('small:0,12')
              , 'field_value_mode':   'Value_direct'
              , 'field_value_type':  "annal:Richtext"
              , 'field_value':        entity_descr
              , 'options':            []
              })
          ]
        , 'continuation_url':   entitydata_list_type_url("testcoll", type_id)
        })
    if entity_id:
        context_dict['fields'][0]['row_field_descs'][0]['field_value'] = entity_id
        context_dict['fields'][0]['row_field_descs'][1]['field_value'] = "_type/"+type_id if valid_id(type_id) else None
        context_dict['orig_id']     = entity_id
    if orig_id:
        context_dict['orig_id']     = orig_id
    if action:  
        context_dict['action']      = action
    return context_dict
Esempio n. 19
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
Esempio n. 20
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