@register.function
@jinja2.contextfunction
def favorites_widget(context, addon, condensed=False):
    """Displays 'Add to Favorites' widget."""
    c = dict(context.items())
    request = c['request']
    if request.user.is_authenticated():
        is_favorite = addon.id in request.user.favorite_addons
        faved_class = 'faved' if is_favorite else ''

        unfaved_text = '' if condensed else _('Add to favorites')
        faved_text = _('Favorite') if condensed else _('Remove from favorites')

        add_url = reverse('collections.alter',
                          args=[request.user.username, 'favorites', 'add'])
        remove_url = reverse('collections.alter',
                             args=[request.user.username,
                                   'favorites', 'remove'])

        c.update(locals())
        t = get_env().get_template('bandwagon/favorites_widget.html').render(c)
        return jinja2.Markup(t)
dataset/ETHPy150Open mozilla/addons-server/src/olympia/bandwagon/helpers.py/favorites_widget/original