def update_collections(self, collection_id, writeable): for coll in self.collections: if coll.id == self.source_collection_id: continue if coll.id not in collection_id and coll.id in writeable: self.collections.remove(coll) for coll_id in collection_id: if coll_id in writeable: coll = Collection.by_id(coll_id) if coll not in self.collections: self.collections.append(coll) db.session.add(self)
def facets(cls, start_collection, start_entity_id=None, end_collection_id=[], labels=[], types=[], collection_id=[]): facets = {} facets['label'] = cls.facet_array(cls.labels, start_collection, start_entity_id=start_entity_id, end_collection_id=end_collection_id, types=types) facets['type'] = cls.facet_array(cls.types, start_collection, start_entity_id=start_entity_id, end_collection_id=end_collection_id, labels=labels) collection_id = cls.facet_array(cls.end_collection_id, start_collection, start_entity_id=start_entity_id, end_collection_id=collection_id, labels=labels, types=types) objs = Collection.all_by_ids([f['value'] for f in collection_id]) for facet in collection_id: for obj in objs: if facet['value'] == obj.id: facet['label'] = obj.label facets['collection_id'] = collection_id return facets