Exemple #1
0
def get_user(id):
    user_db = User.query.filter(User.id == id).first()
    if user_db:
        user = admin_user_schema.dump(user_db)
        user_proposals = Proposal.query.filter(Proposal.team.any(id=user['id'])).all()
        user['proposals'] = proposals_schema.dump(user_proposals)
        user_comments = Comment.get_by_user(user_db)
        user['comments'] = user_comments_schema.dump(user_comments)
        return user
    return {"message": f"Could not find user with id {id}"}, 404
Exemple #2
0
def get_users():
    users = User.query.all()
    result = users_schema.dump(users)
    for user in result:
        user_proposals = Proposal.query.filter(
            Proposal.team.any(id=user['userid'])).all()
        user['proposals'] = proposals_schema.dump(user_proposals)
        user_comments = Comment.query.filter(
            Comment.user_id == user['userid']).all()
        user['comments'] = comments_schema.dump(user_comments)
    return result
Exemple #3
0
def get_home_content():
    latest_proposals = (Proposal.query.filter_by(
        status=ProposalStatus.LIVE).filter(
            Proposal.stage != ProposalStage.CANCELED).filter(
                Proposal.stage != ProposalStage.FAILED).order_by(
                    Proposal.date_created.desc()).limit(3).all())
    latest_rfps = (RFP.query.filter_by(status=RFPStatus.LIVE).filter(
        or_(RFP.date_closes == None,
            RFP.date_closes > datetime.now())).order_by(
                RFP.date_opened).limit(3).all())

    return {
        "latest_proposals": proposals_schema.dump(latest_proposals),
        "latest_rfps": rfps_schema.dump(latest_rfps),
    }
Exemple #4
0
def get_proposals():
    proposals = Proposal.query.order_by(Proposal.date_created.desc()).all()
    dumped_proposals = proposals_schema.dump(proposals)
    return dumped_proposals