コード例 #1
0
    def test_should_not_register_user_given_invalid_username_and_LUHP(self):
        self.login_user(self.admin_user)
        user_credentials = dict(username="******",
                                password="",
                                password_confirm="",
                                salary=1000)
        with self.client as client:
            client.post(url_for('user.register'), data=user_credentials)

        self.assertEqual(User.search('Test'), None)
コード例 #2
0
def users():
    users = User.query.all()
    if request.method == "POST":
        user = User.search(request.form['search_term'])
        if user:
            return redirect(
                url_for('user.profile', id=user.id)
            )

    return render_template(
        "user/users.html",
        user_heads=username_head,
        users=users
    )
コード例 #3
0
ファイル: admin.py プロジェクト: ChrisPoul/Industrias-EnGo
def main_page():
    users = User.get_all()
    views = View.get_all()
    if request.method == "POST":
        search_term = request.form['search_term']
        user = User.search(search_term)
        if user:
            return redirect(
                url_for('user.update', id=user.id)
            )
        view = View.search(search_term)
        if view:
            return redirect(
                url_for('view.update', id=view.id)
            )

    return render_template(
        "admin/main-page.html",
        user_heads=username_head,
        users=users,
        views=views
    )
コード例 #4
0
def search_bar():
    search_term = request.form['search_term']
    try:
        customer = Customer.search_all(search_term)[0]
    except IndexError:
        customer = None
    if customer:
        return redirect(
            url_for("customer.update", id=customer.id)
        )
    user = User.search(search_term)
    if user:
        return redirect(
            url_for("user.profile", id=user.id)
        )
    product = Product.search(search_term)
    if product:
        return redirect(
            url_for("product.update", id=product.id)
        )

    return redirect(
        request.referrer
    )
コード例 #5
0
    def test_should_return_none_given_invalid_username(self):
        user = User.search("Non existent name")

        self.assertEqual(user, None)
コード例 #6
0
    def test_should_return_permission_given_valid_username(self):
        user = User.search("Test User")

        self.assertEqual(user, self.user)