This commit is contained in:
parent
08b69e5d0a
commit
7a3830653e
|
@ -229,7 +229,11 @@ def handle_proposing(session, r, shout):
|
|||
replied_reaction = session.query(Reaction).filter(Reaction.id == r.reply_to).first()
|
||||
if replied_reaction and replied_reaction.kind is ReactionKind.PROPOSE.value and replied_reaction.quote:
|
||||
# patch all the proposals' quotes
|
||||
proposals = session.query(Reaction).filter(and_(Reaction.shout == r.shout, Reaction.kind == ReactionKind.PROPOSE.value)).all()
|
||||
proposals = (
|
||||
session.query(Reaction)
|
||||
.filter(and_(Reaction.shout == r.shout, Reaction.kind == ReactionKind.PROPOSE.value))
|
||||
.all()
|
||||
)
|
||||
for proposal in proposals:
|
||||
if proposal.quote:
|
||||
proposal_diff = get_diff(shout.body, proposal.quote)
|
||||
|
|
|
@ -141,7 +141,6 @@ def get_shout_followers(_, _info, slug: str = '', shout_id: int | None = None) -
|
|||
return followers
|
||||
|
||||
|
||||
|
||||
def reactions_follow(author_id, shout_id, auto=False):
|
||||
try:
|
||||
with local_session() as session:
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
from orm.reaction import ReactionKind
|
||||
|
||||
|
||||
|
@ -8,8 +7,8 @@ RATING_REACTIONS = [
|
|||
ReactionKind.AGREE.value,
|
||||
ReactionKind.DISLIKE.value,
|
||||
ReactionKind.REJECT.value,
|
||||
ReactionKind.DISAGREE.value]
|
||||
|
||||
ReactionKind.DISAGREE.value,
|
||||
]
|
||||
|
||||
|
||||
def is_negative(x):
|
||||
|
|
|
@ -50,6 +50,7 @@ def is_featured_author(session, author_id):
|
|||
> 0
|
||||
)
|
||||
|
||||
|
||||
def check_to_feature(session, approver_id, reaction):
|
||||
"""set shout to public if publicated approvers amount > 4"""
|
||||
if not reaction.reply_to and is_positive(reaction.kind):
|
||||
|
@ -70,7 +71,11 @@ def check_to_unfeature(session, rejecter_id, reaction):
|
|||
"""unfeature any shout if 20% of reactions are negative"""
|
||||
if not reaction.reply_to and is_negative(reaction.kind):
|
||||
if is_featured_author(session, rejecter_id):
|
||||
reactions = session.query(Reaction).where(and_(Reaction.shout == reaction.shout, Reaction.kind.in_(RATING_REACTIONS))).all()
|
||||
reactions = (
|
||||
session.query(Reaction)
|
||||
.where(and_(Reaction.shout == reaction.shout, Reaction.kind.in_(RATING_REACTIONS)))
|
||||
.all()
|
||||
)
|
||||
rejects = 0
|
||||
for r in reactions:
|
||||
approver = session.query(Author).filter(Author.id == r.created_by).first()
|
||||
|
|
|
@ -16,6 +16,7 @@ def get_diff(original, modified):
|
|||
diff = list(ndiff(original.split(), modified.split()))
|
||||
return diff
|
||||
|
||||
|
||||
def apply_diff(original, diff):
|
||||
"""
|
||||
Apply the difference to the original string.
|
||||
|
|
Loading…
Reference in New Issue
Block a user