def setUp(self): init_annalist_test_site() self.testsite = Site(TestBaseUri, TestBaseDir) self.testcoll = Collection.create(self.testsite, "testcoll", collection_create_values("testcoll")) self.testtype = RecordType.create(self.testcoll, "testtype", recordtype_create_values("testcoll", "testtype")) self.testtype2 = RecordType.create(self.testcoll, "testtype2", recordtype_create_values("testcoll", "testtype2")) self.testdata = RecordTypeData.create(self.testcoll, "testtype", {}) self.testdata2 = RecordTypeData.create(self.testcoll, "testtype2", {}) e1 = self._create_entity_data("entity1") e2 = self._create_entity_data("entity2") e3 = self._create_entity_data("entity3") e4 = EntityData.create(self.testdata2, "entity4", entitydata_create_values("entity4", type_id="testtype2") ) self.type_ids = get_site_types_linked("testcoll") self.type_ids.append(FieldChoice("_type/testtype", label="RecordType testcoll/_type/testtype", link=recordtype_url("testcoll", "testtype") )) self.type_ids.append(FieldChoice("_type/testtype2", label="RecordType testcoll/_type/testtype2", link=recordtype_url("testcoll", "testtype2") )) self.list_ids = get_site_lists_linked("testcoll") # Login and permissions create_test_user(self.testcoll, "testuser", "testpassword") self.client = Client(HTTP_HOST=TestHost) loggedin = self.client.login(username="******", password="******") self.assertTrue(loggedin) return
def _check_record_type_values(self, type_id, update="RecordType"): "Helper function checks content of record type entry with supplied type_id" self.assertTrue(RecordType.exists(self.testcoll, type_id)) t = RecordType.load(self.testcoll, type_id) self.assertEqual(t.get_id(), type_id) self.assertEqual(t.get_view_url(), TestHostUri + recordtype_url("testcoll", type_id)) v = recordtype_values(type_id=type_id, update=update) self.assertDictionaryMatch(t.get_values(), v) return t
def _check_record_type_values(self, type_id, update="RecordType", type_uri=None, extra_values=None): "Helper function checks content of record type entry with supplied type_id" self.assertTrue(RecordType.exists(self.testcoll, type_id)) t = RecordType.load(self.testcoll, type_id) self.assertEqual(t.get_id(), type_id) self.assertEqual(t.get_view_url(), TestHostUri + recordtype_url("testcoll", type_id)) v = recordtype_values(type_id=type_id, update=update, type_uri=type_uri) if extra_values: v.update(extra_values) # print "t: "+repr(t.get_values()) # print "v: "+repr(v) self.assertDictionaryMatch(t.get_values(), v) return t
def _check_record_type_values(self, type_id, update="RecordType", type_uri=None, extra_values=None ): "Helper function checks content of record type entry with supplied type_id" self.assertTrue(RecordType.exists(self.testcoll, type_id)) t = RecordType.load(self.testcoll, type_id) self.assertEqual(t.get_id(), type_id) self.assertEqual(t.get_view_url(), TestHostUri + recordtype_url("testcoll", type_id)) v = recordtype_values( type_id=type_id, update=update, type_uri=type_uri ) if extra_values: v.update(extra_values) # print "t: "+repr(t.get_values()) # print "v: "+repr(v) self.assertDictionaryMatch(t.get_values(), v) return t
def setUp(self): init_annalist_test_site() init_annalist_test_coll() self.testsite = Site(TestBaseUri, TestBaseDir) self.testcoll = Collection.create(self.testsite, "testcoll", collection_create_values("testcoll")) self.testtype = RecordType.create( self.testcoll, "testtype", recordtype_create_values("testcoll", "testtype")) self.testdata = RecordTypeData.create(self.testcoll, "testtype", {}) self.type_ids = get_site_types_linked("testcoll") self.type_ids.append( FieldChoice("_type/testtype", label="RecordType testcoll/testtype", link=recordtype_url("testcoll", "testtype"))) self.no_options = [FieldChoice('', label="(no options)")] # Login and permissions create_test_user(self.testcoll, "testuser", "testpassword") self.client = Client(HTTP_HOST=TestHost) loggedin = self.client.login(username="******", password="******") self.assertTrue(loggedin) return
def setUp(self): init_annalist_test_site() self.testsite = Site(TestBaseUri, TestBaseDir) self.testcoll = Collection.create(self.testsite, "testcoll", collection_create_values("testcoll") ) self.testtype = RecordType.create(self.testcoll, "testtype", recordtype_create_values("testcoll", "testtype") ) self.testdata = RecordTypeData.create(self.testcoll, "testtype", {}) # Create view with repeated field id self.viewdata = recordview_create_values(view_id="DupField_view") recordview_values_add_field( self.viewdata, field_id="Entity_comment", field_placement="small:0,12" ) recordview_values_add_field( self.viewdata, field_id="Entity_comment", field_property_uri="rdfs:comment_alt", field_placement="small:0,12" ) self.testview = RecordView.create(self.testcoll, "DupField_view", self.viewdata) # Other data self.type_ids = get_site_types_linked("testcoll") self.type_ids.append(FieldChoice("_type/testtype", label="RecordType testcoll/_type/testtype", link=recordtype_url("testcoll", "testtype") )) # Login and permissions create_test_user(self.testcoll, "testuser", "testpassword") self.client = Client(HTTP_HOST=TestHost) loggedin = self.client.login(username="******", password="******") self.assertTrue(loggedin) return
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