Files
core/orm/rating.py
Untone 143157a771
Some checks failed
Deploy on push / deploy (push) Failing after 1m33s
rating-patch
2025-09-01 16:29:50 +03:00

36 lines
1.2 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
from orm.reaction import ReactionKind
PROPOSAL_REACTIONS = [
ReactionKind.ACCEPT.value,
ReactionKind.REJECT.value,
ReactionKind.AGREE.value,
ReactionKind.DISAGREE.value,
ReactionKind.ASK.value,
ReactionKind.PROPOSE.value,
]
PROOF_REACTIONS = [ReactionKind.PROOF.value, ReactionKind.DISPROOF.value]
RATING_REACTIONS = [ReactionKind.LIKE.value, ReactionKind.DISLIKE.value]
POSITIVE_REACTIONS = [ReactionKind.ACCEPT.value, ReactionKind.LIKE.value, ReactionKind.PROOF.value]
NEGATIVE_REACTIONS = [ReactionKind.REJECT.value, ReactionKind.DISLIKE.value, ReactionKind.DISPROOF.value]
def is_negative(x: ReactionKind | str) -> bool:
"""Проверяет, является ли реакция негативной.
Args:
x: ReactionKind enum или строка с названием реакции
"""
value = x.value if isinstance(x, ReactionKind) else x
return value in NEGATIVE_REACTIONS
def is_positive(x: ReactionKind | str) -> bool:
"""Проверяет, является ли реакция позитивной.
Args:
x: ReactionKind enum или строка с названием реакции
"""
value = x.value if isinstance(x, ReactionKind) else x
return value in POSITIVE_REACTIONS