Пример #1
0
def seller(seller_email: str):
    username: str = flask.session.get('username') or ''
    return flask.render_template(
        'seller_items.html',
        is_logged_in=security.is_logged_in(),
        username=seller_email,
        is_customer=auth_manager.is_customer(username))
Пример #2
0
def item(seller_email, item_id):
    username: str = flask.session.get('username') or ''
    item = __DATABASE.retrieve_item_info(seller_email, item_id)
    return flask.render_template(
        'item.html',
        is_logged_in=security.is_logged_in(),
        username=username,
        is_customer=auth_manager.is_customer(username),
        name=item[0],
        price=item[1],
        quantity=item[2],
        image_path=f'/get_image/{username}/{item_id}')
Пример #3
0
def is_logged_in(customer_required: bool = False, seller_required: bool = False,
                 admin_required: bool = False, developer_required: bool = False) -> bool:
    "Check if the user is loggged in with appropriate permissions or not."
    username = flask.session.get('username')

    if not username:
        return False
    if auth_manager.is_developer(username):
        return True
    if admin_required and auth_manager.is_admin(username):
        return True
    if seller_required and auth_manager.is_seller(username):
        return True
    if customer_required and auth_manager.is_customer(username):
        return True
    if not (customer_required or seller_required or admin_required or
            developer_required) and auth_manager.is_registered(username):
        return True

    flask.session.pop('username')
    return False
Пример #4
0
def items():
    username: str = flask.session.get('username') or ''
    return flask.render_template(
        'all_items.html',
        is_logged_in=security.is_logged_in(),
        is_customer=auth_manager.is_customer(username))