def usage_button(context): response = used_packages_list(context['request']) response['STATIC_URL'] = context['STATIC_URL'] response['package'] = context['package'] if context['package'].pk in response['used_packages_list']: response['usage_action'] = "remove" response['image'] = "usage_triangle_filled" else: response['usage_action'] = "add" response['image'] = "usage_triangle_hollow" return response
def fav_button(context): response = used_packages_list(context['request']) response['STATIC_URL'] = context['STATIC_URL'] response['package'] = context['package'] if context['package'].pk in response['used_packages_list']: response['title'] = "Remove from favorites" response['usage_action'] = "remove" response['in_favorites'] = True else: response['title'] = "Add to favorites" response['usage_action'] = "add" response['in_favorites'] = False return response
def fav_button(context, size=None): response = used_packages_list(context['request']) is_fav = context['package'].pk in response['used_packages_list'] response.update({ "size": size, "is_fav": is_fav, "title": "Remove from favorites" if is_fav else "Add to favorites", "url": reverse("usage", args=(context["package"].slug, "remove" if is_fav else "add")) }) return response