hotfix: proposals, chatmembers, footnotes, etc
This commit is contained in:
@@ -157,6 +157,23 @@ async def create_reaction(_, info, reaction={}):
|
||||
reaction['createdBy'] = auth.user_id
|
||||
with local_session() as session:
|
||||
r = Reaction.create(**reaction)
|
||||
shout = session.query(Shout).where(Shout.id == r.shout).one()
|
||||
|
||||
# Proposal accepting logix
|
||||
if r.replyTo is not None and \
|
||||
r.kind == ReactionKind.ACCEPT and \
|
||||
user_id in shout.dict()['authors']:
|
||||
replied_reaction = session.query(Reaction).when(Reaction.id == r.replyTo).first()
|
||||
if replied_reaction and replied_reaction.kind == ReactionKind.PROPOSE:
|
||||
if replied_reaction.range:
|
||||
old_body = shout.body
|
||||
start, end = replied_reaction.range.split(':')
|
||||
start = int(start)
|
||||
end = int(end)
|
||||
new_body = old_body[:start] + replied_reaction.body + old_body[end:]
|
||||
shout.body = new_body
|
||||
# TODO: update git version control
|
||||
|
||||
session.add(r)
|
||||
session.commit()
|
||||
|
||||
@@ -230,9 +247,9 @@ async def delete_reaction(_, info, reaction=None):
|
||||
return {"error": "access denied"}
|
||||
r.deletedAt = datetime.now(tz=timezone.utc)
|
||||
session.commit()
|
||||
return {
|
||||
"reaction": r
|
||||
}
|
||||
return {
|
||||
"reaction": r
|
||||
}
|
||||
|
||||
|
||||
@query.field("loadReactionsBy")
|
||||
|
@@ -1,48 +0,0 @@
|
||||
|
||||
from datetime import datetime, timedelta, timezone
|
||||
from sqlalchemy.orm import joinedload, aliased
|
||||
from sqlalchemy.sql.expression import desc, asc, select, func
|
||||
from base.orm import local_session
|
||||
from base.resolvers import query, mutation
|
||||
from base.exceptions import ObjectNotExist
|
||||
from orm.remark import Remark
|
||||
|
||||
|
||||
@mutation.field("createRemark")
|
||||
@login_required
|
||||
async def create_remark(_, info, slug, body):
|
||||
auth = info.context["request"].auth
|
||||
user_id = auth.user_id
|
||||
with local_session() as session:
|
||||
tt = Remark.create(slug=slug, body=body)
|
||||
session.commit()
|
||||
return
|
||||
|
||||
@mutation.field("updateRemark")
|
||||
@login_required
|
||||
async def update_remark(_, info, slug, body = ''):
|
||||
auth = info.context["request"].auth
|
||||
user_id = auth.user_id
|
||||
with local_session() as session:
|
||||
rmrk = session.query(Remark).where(Remark.slug == slug).one()
|
||||
if body:
|
||||
tt.body = body
|
||||
session.add(rmrk)
|
||||
session.commit()
|
||||
return
|
||||
|
||||
@mutation.field("deleteRemark")
|
||||
@login_required
|
||||
async def delete_remark(_, info, slug):
|
||||
auth = info.context["request"].auth
|
||||
user_id = auth.user_id
|
||||
with local_session() as session:
|
||||
rmrk = session.query(Remark).where(Remark.slug == slug).one()
|
||||
rmrk.remove()
|
||||
session.commit()
|
||||
return
|
||||
|
||||
@query.field("loadRemark")
|
||||
@login_required
|
||||
async def load_remark(_, info, slug):
|
||||
pass
|
Reference in New Issue
Block a user