Exemple #1
0
def login():
    if request.method == 'POST':
        user = OA_User.query.filter_by(login_name=request.form['login_name'], login_password=GetStringMD5(request.form['login_password'])).first()
        if user:
            login_user(user)
            role = OA_UserRole.query.filter_by(user_id=current_user.id).first().oa_userrole_ibfk_2
            privileges = OA_Privilege.query.filter_by(privilege_master="OA_Role",privilege_master_id=role.id,privilege_access="OA_Menu").all()
            
            count_1=len(OA_Reimbursement.query.filter_by(create_user=current_user.id,is_paid=0).all())
            count_2=getCount()
            
            orgs = OA_Org.query.filter("manager="+str(current_user.id)+" and version='2015'").all()
            result = []
            for obj in orgs:
                tmp = {}
                tmp["name"] = obj.name
                tmp["total_apply"]=costs_statistics.get_total_apply_costs(obj.id)
                tmp["total_paid"]=costs_statistics.get_total_paid_costs(obj.id)
                tmp["monthly"]=costs_statistics.get_monthly_paid_costs(obj.id)
                tmp["season"]=costs_statistics.get_season_paid_costs(obj.id)
                result.append(tmp)
                
            return render_template("welcome.html",role=role,count_1=count_1,count_2=count_2,result=result,privileges=privileges)
        else:
            flash('用户名或密码错误','error')
            return render_template("login.html")

    else:
        return render_template("login.html")
Exemple #2
0
def welcome():
    role = OA_UserRole.query.filter_by(user_id=current_user.id).first().oa_userrole_ibfk_2
    privileges = OA_Privilege.query.filter_by(privilege_master="OA_Role",privilege_master_id=role.id,privilege_access="OA_Menu").all()
    
    count_1=len(OA_Reimbursement.query.filter_by(create_user=current_user.id,is_paid=0).all())
    count_2=getCount()
    
    orgs = OA_Org.query.filter("manager="+str(current_user.id)+" and version='2015'").all()
    result = []
    for obj in orgs:
        tmp = {}
        tmp["name"] = obj.name
        tmp["total_apply"]=costs_statistics.get_total_apply_costs(obj.id)
        tmp["total_paid"]=costs_statistics.get_total_paid_costs(obj.id)
        tmp["monthly"]=costs_statistics.get_monthly_paid_costs(obj.id)
        tmp["season"]=costs_statistics.get_season_paid_costs(obj.id)
        result.append(tmp)
                
    return render_template("welcome.html",role=role,count_1=count_1,count_2=count_2,result=result,privileges=privileges)