예제 #1
0
def agree_joinapply(applyid):
    """"""
    apply = api_apply.get(applyid)
    u = api_user.get(apply.user_id)
    c = api_class.get(apply.class_id)
    assoc = ClassUserAssociation(user=u, clazz=c)
    #u.class_assocs.append(assoc)
    api_apply.delete(apply)
    return redirect(url_for('.list_class_apply', page=1))
예제 #2
0
def reject_joinapply():
    """拒绝请求"""
    form = SysMessageForm()
    form.csrf_enabled = False
    
    message = None
    applyid = request.json.get('apply_id', 0)
    apply = api_apply.get(applyid)
    if apply is None: 
        message = '申请无效'
    
    if form.validate_on_submit():
        userid = apply.user_id
        classname = apply.clazz.name
        reason = u"你的申请加入【%s】被拒绝了,理由为:【%s】" % (classname, form.content.data)
        api_sysmsg.create(receiver_id=userid, content=reason)
        api_apply.delete(apply)
        return jsonify(dict(success=True))
    
    message = u"填写不正确"
    return jsonify(dict(success=False, message=message))