def _tag_set_with_collections(tag_sets_id, show_only_public_collections): # TODO use which mc or user_mc here tag_set = mc.tagSet(tag_sets_id) # page through tags more_tags = True all_tags = [] last_tags_id = 0 while more_tags: tags = mc.tagList(tag_sets_id=tag_set['tag_sets_id'], last_tags_id=last_tags_id, rows=100, public_only=show_only_public_collections) all_tags = all_tags + tags if len(tags) > 0: last_tags_id = tags[-1]['tags_id'] more_tags = len(tags) != 0 collection_list = [ t for t in all_tags if t['show_on_media'] is 1 ] # double check the show_on_media because that controls public or not collection_list = sorted(collection_list, key=itemgetter('label')) return { 'name': tag_set['label'], 'description': tag_set['description'], 'collections': collection_list }
def cached_tags_in_tag_set(tag_sets_id): ''' This is cached at the app level, so it doesn't need a user key. This is because the list of tags here shouldn't change (ie. metadata values don't change within a category) ''' all_tags = [] last_id = 0 more = True while more: current_list = mc.tagList(tag_sets_id=tag_sets_id, rows=100, last_tags_id=last_id) last_id = current_list[-1]['tags_id'] more = (len(current_list) == 100) and (len(current_list) != 0) all_tags = all_tags + current_list all_tags = sorted(all_tags, key=lambda tag: tag['label']) return all_tags
def _tag_set_with_collections(tag_sets_id, show_only_public_collections): # TODO use which mc or user_mc here tag_set = mc.tagSet(tag_sets_id) # page through tags more_tags = True all_tags = [] last_tags_id = 0 while more_tags: tags = mc.tagList(tag_sets_id=tag_set['tag_sets_id'], last_tags_id=last_tags_id, rows=100, public_only=show_only_public_collections) all_tags = all_tags + tags if len(tags) > 0: last_tags_id = tags[-1]['tags_id'] more_tags = len(tags) != 0 # double check the show_on_media because that controls public or not collection_list = [t for t in all_tags if t['show_on_media'] is 1] collection_list = sorted(collection_list, key=itemgetter('label')) return { 'name': tag_set['label'], 'description': tag_set['description'], 'collections': collection_list }
def similar_collections(collection_id): info = {'similarCollections': mc.tagList(similar_tags_id=collection_id)} return jsonify({'results': info})
def similar_collections(collection_id): info = { 'similarCollections': mc.tagList(similar_tags_id=collection_id) } return jsonify({'results': info})