fix review sharing
This commit is contained in:
parent
9a8389cd49
commit
88a688e32b
2 changed files with 6 additions and 6 deletions
|
@ -4,9 +4,7 @@ from typing import TYPE_CHECKING, cast
|
||||||
import mistune
|
import mistune
|
||||||
from django.utils.html import escape
|
from django.utils.html import escape
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
from catalog.models import Item, ItemCategory
|
||||||
from catalog.models import Item
|
|
||||||
from users.models import User
|
|
||||||
|
|
||||||
_mistune_plugins = [
|
_mistune_plugins = [
|
||||||
"url",
|
"url",
|
||||||
|
@ -56,9 +54,11 @@ def render_text(s: str) -> str:
|
||||||
return _spolier(s).strip().replace("\n", "<br>")
|
return _spolier(s).strip().replace("\n", "<br>")
|
||||||
|
|
||||||
|
|
||||||
def render_post_with_macro(txt: str, item: "Item") -> str:
|
def render_post_with_macro(txt: str, item: Item) -> str:
|
||||||
|
if not txt:
|
||||||
|
return ""
|
||||||
return (
|
return (
|
||||||
txt.replace("[category]", item.category.name)
|
txt.replace("[category]", str(ItemCategory(item.category).label))
|
||||||
.replace("[title]", item.display_title)
|
.replace("[title]", item.display_title)
|
||||||
.replace("[url]", item.absolute_url)
|
.replace("[url]", item.absolute_url)
|
||||||
)
|
)
|
||||||
|
|
|
@ -735,7 +735,7 @@ def share_review(review):
|
||||||
tpl = ShelfManager.get_action_template("reviewed", review.item.category)
|
tpl = ShelfManager.get_action_template("reviewed", review.item.category)
|
||||||
content = (
|
content = (
|
||||||
_(tpl).format(item=review.item.display_title)
|
_(tpl).format(item=review.item.display_title)
|
||||||
+ "\n{review.title}\n{review.absolute_url} "
|
+ f"\n{review.title}\n{review.absolute_url} "
|
||||||
+ tags
|
+ tags
|
||||||
)
|
)
|
||||||
update_id = None
|
update_id = None
|
||||||
|
|
Loading…
Add table
Reference in a new issue