def kf_group_interfaces_manage_checkjoin_refuse(group_id, review_id):
    data = G.autodata(request)

    token = G.auto_verify(request)
    user = model.getuser_uuid(token.get("user"))
    user_uuid = user.uuid
    group = G.get_group(group_id)

    manager = G.isManager(group_id, user_uuid)

    selectResult = model.review.select().where(
        (model.review.id == review_id) &
        (model.review.group == group_id)
    )
    if not selectResult:
        raise Exceptions.InvalidToken()
    selectResult = selectResult.get()
    if selectResult.isEnable != True:
        raise Exceptions.InvalidRequestData()
    selectResult.isEnable = False
    selectResult.isAccessed = False

    for i in model.member.select().where(
        (model.member.group == selectResult.group) &
        ((model.member.permission == "manager") | (model.member.permission == "super_manager")) &
        (model.member.is_disabled == True) &
        (model.member.user != manager.uuid)
    ):
        model.message(
            to=i.user,

            title="用户 %(user)s 面向组 %(group)s 的加组申请被拒绝" % (
                [user.uuid, user.username][bool(user.username)], group.name),
            body="用户 %(user)s 面向组 %(group)s 的加组申请被组管理员 %(manager)s 拒绝" % ([user.uuid, user.username][bool(
                user.username)], group.name, [manager.uuid, manager.username][bool(manager.username)]),
            extra=json.dumps({
                "user": user_uuid,
                "group": group.id,
                "manager": manager.uuid
            })
        )
    return Response(status=204)
Exemple #2
0
def form():
    if request.method == "POST":
        age = request.form.get("age")
        capital = request.form.get("capital")
        time = request.form.get("time")
        risk = request.form.get("risk")
        sectors = request.form.getlist("sectors")
        marketcap = request.form.get("marketcap")
        message = model.message(age, time)
        model.generate_port(capital, risk, sectors, marketcap)
        return render_template("results.html",
                               age=age,
                               capital=capital,
                               time=time,
                               risk=risk,
                               sectors=sectors,
                               marketcap=marketcap,
                               message=message)
    return render_template("welcome.html")
def kf_group_interfaces_signout(group_id):
    data = G.autodata(request)

    token = G.auto_verify(request)
    user_uuid = model.getuser_uuid(token.get("user")).uuid
    if not model.group.select().where(model.group.uuid == group_id):
        raise Exceptions.InvalidToken()
    group: model.group = G.get_group(group_id)

    known = G.get_member(group_id, user_uuid)
    if known.permission == "super_manager":
        if not data.get("force"):
            raise Exceptions.InvalidToken()
        else:
            manager_result = model.member.select().where(
                (model.member.is_disabled == False) &
                (model.member.permission == "manager") &
                (model.member.group == group_id)
            )
            if manager_result:
                # 有其他管理员可以被任命为组管理员
                # 随!机!选!择!
                manager_selected = manager_result[random.randint(
                    0, len(manager_result) - 1)]
                manager_result.permission = "super_manager"
                manager_result.save()
                model.message(
                    to=manager_result.user,
                    title='您已成为组 "%(groupname)s" 的组管理员' % (group.name),
                    body='因该组的原组管理员的退出, 您已成为该组的组管理员.',
                    extra=json.dumps({
                        "type": "group"
                    })
                )
            else:
                # 通知一波然后删掉, 解散的组不需要
                now_member = model.member.select().where(
                    (model.member.is_disabled == False) &
                    (model.member.group == group_id) &
                    (model.member.user != user_uuid)
                )
                for i in now_member:
                    model.message(
                        to=i.user,
                        title='您已被清理出组 "%(groupname)s"' % (group.name),
                        body="因该组的原组管理员的退出, 您已被清理出该组."
                    ).save()
                model.member.delete().where(model.member.group == group_id).execute()
    else:
        known.is_disabled = True
        known.move_times += 1
        known.save()
        manager_result = model.member.select().where(
            (model.member.is_disabled == False) &
            ((model.member.permission == "manager") | (model.member.permission == "super_manager")) &
            (model.member.group == group_id)
        )
        for i in manager_result:
            model.message(
                to=i.user,
                title='%(user)s 退出组 "%(groupname)s"' % (
                    model.getuser_uuid(user_uuid).username, group.name),
                body="因该成员的主动申请, 该成员已退出该组."
            ).save()
    return Response(status=204)
def _msg_add(flags,ruid,luid,fldr,cntnt, dbcon):
    return message(flags=str(flags),remoteuid=ruid,localuid=luid,folder=fldr,content=cntnt, connection=dbcon)
def add():
    form = request.form
    m = message(form)
    message.save(m)
    return redirect(url_for('messages.index'))