<%namespace file="/display_common.mako" import="get_controller_name, modern_route_for_controller" /> <%! from markupsafe import escape %> ## Render a tagging element if there is a tagged_item. %if tagged_item is not None: %if tag_type == "individual": ${render_individual_tagging_element( user=user, tagged_item=tagged_item, elt_context=elt_context, tag_click_fn=tag_click_fn, use_toggle_link=use_toggle_link )} %elif tag_type == "community": ${render_community_tagging_element( tagged_item=tagged_item, elt_context=elt_context, tag_click_fn=tag_click_fn )} %endif %endif <%def name="render_community_tagging_element( tagged_item=None, elt_context=None, use_toggle_link=False, tag_click_fn='default_tag_click_fn')"> <% tagged_item_id = str( trans.security.encode_id ( tagged_item.id ) ) controller_name = get_controller_name(tagged_item) click_url = h.url_for( controller='/' + modern_route_for_controller(controller_name) , action='list_published') community_tag_names = community_tags = tagged_item.make_tag_string_list() %>
<%def name="render_individual_tagging_element( user=None, tagged_item=None, elt_context=None, use_toggle_link=True, tag_click_fn='default_tag_click_fn', get_toggle_link_text_fn='default_get_toggle_link_text_fn', editable=True)"> <% tagged_item_id = str( trans.security.encode_id ( tagged_item.id ) ) item_tags = [ tag for tag in tagged_item.tags if ( tag.user == user ) ] item_tag_names = [] for ta in item_tags: item_tag_names.append(escape(f"#{ta.value}" if ta.value else ta.tag.name)) %>
<%def name="community_tag_js( controller_name )"> ## TODO: Note that this function no longer has anything to do with community ## tags. the ratings code and tagging initialization were previously co-mingled ## in here. Will remove this script when we write the ratings components ## set up comminity tag and rating handling - used for page start up / set up ## controller_name: the model controller for the item being tagged - generally gotten with get_controller_name( item )