コード例 #1
0
def team():
    admin = Worker.is_admin(current_user.id, g.current_invest.id)
    team = Worker.get_team(investment_id=g.current_invest.id)
    return render_template("team/team.html",
                           title="Team",
                           team=team,
                           admin=admin)
コード例 #2
0
 def test_post(client, test_with_authenticated_user):
     user = User.query.filter_by(username="******").first()
     form = InvestmentForm(name="New Invest", description="test text")
     response = client.post(url_for("investments.create"),
                            data=form.data,
                            follow_redirects=True)
     assert response.status_code == 200
     assert b"You have created new investment successfully." in response.data
     investment = Investment.query.filter_by(name="New Invest").first()
     workers = Worker.get_team(investment.id)
     assert investment.description == "test text"
     assert investment.workers.all() == workers
     assert workers[0].user_id == user.id
コード例 #3
0
    def test_get_team(app_and_db, active_user):
        db = app_and_db[1]
        db.session.add(Investment(name="test invest 1"))
        db.session.add(Worker(position="pos1", admin=True, investment_id=1))
        db.session.add(Worker(position="pos2", admin=False, investment_id=1))
        db.session.add(Worker(position="pos2", admin=False, investment_id=1))
        db.session.add(Investment(name="test invest 2"))
        db.session.add(Worker(position="pos2", admin=False, investment_id=2))
        db.session.add(Worker(position="pos2", admin=False, investment_id=2))
        db.session.commit()

        worker1 = Worker.query.get(1)
        worker2 = Worker.query.get(2)
        worker3 = Worker.query.get(3)

        assert Worker.get_team(investment_id=1) == [worker1, worker2, worker3]