Beispiel #1
0
def login():
    if session.is_logged_in():
        redirect_target = flask.session.get("signin_redirect", "/")
    elif "GOOGLE_ID" in os.environ:
        redirect_target = flask.url_for("login_with_google")
    else:
        redirect_target = href(__name__, debug_login_target)
    return flask.redirect(redirect_target)
Beispiel #2
0
def layout():
    if not is_logged_in():
        return html.Div(
            [html.Br(), html.H1("You must be logged in to do this")])

    return html.Div(
        children=get_matches_children(),
        className="container text-center",
        id="match-div",
    )
def submit_mentee_information(categories: List[str], details: str):
    print("mentee request", categories, details)

    if session.is_logged_in():
        database.models.create_request(session.current_user_email(),
                                       categories, details)
    else:
        session.store_signup_information("",
                                         request_categories=categories,
                                         request_details=details)
        session.set_post_login_redirect(href(__name__, submit_request))
def layout():
    if session.is_logged_in():
        log.debug("%s: already logged in.", NAME)
        btn = (dcc.Link(
            html.Button(
                "Submit my request!",
                id=submit_button,
                className="btn btn-lg btn-success btn-block",
            ),
            href=href(__name__, submit_request),
        ), )
    else:
        log.debug("%s: not logged in.", NAME)
        btn = (html.A(
            html.Button(
                "Submit my request and sign up!",
                id=submit_button,
                className="btn btn-lg btn-success btn-block",
            ),
            href="/login",
        ), )

    return html.Div(
        [
            html.Label("What topics do you want to learn about?"),
            html.Br(),
            *tags_dropdown_with_add_new_entry_box(categories_id),
            html.Br(),
            html.Label(
                "Describe in more detail what you're looking for:",
                className="text-center text-dark",
            ),
            html.Br(),
            create_equal_row([
                dcc.Textarea(
                    value="",
                    id=details_id,
                    rows=6,
                    placeholder="Try starting with one of the following:\n"
                    "  I'd like a code review of...\n"
                    "  I'd like weekly mentoring sessions...\n"
                    "  I'm looking for a one off education session about...\n"
                    "  I want a running partner.\n"
                    "  I'm looking for someone to play chess with.",
                    maxLength=2000,
                )
            ]),
            html.Br(),
            html.Div(btn),
            html.Div(id="dummy-submit-{}".format(NAME)),
        ],
        className="container",
        id="mentee-request-div",
    )
Beispiel #5
0
def layout():
    if is_logged_in():
        username = get_current_user().name
    else:
        return html.Div(
            [html.Br(), html.H1("You must be logged in to do this")])

    user = get_current_user()

    return html.Div(
        children=[
            html.H1("Hi {}! Want to update your details?".format(username)),
            html.Br(),
            create_equal_row([
                html.Label("Location:"),
                dcc.Input(
                    value="",
                    placeholder="Which office are you in?",
                    type="text",
                    id="location-{}".format(NAME),
                ),
            ]),
            html.Br(),
            create_equal_row([html.Label("Biography:")]),
            dcc.Textarea(
                placeholder="Enter a biography",
                value=user.bio,
                id=biography_id,
                style={"width": "100%"},
            ),
            html.Br(),
            html.Button(
                "Save",
                id=save_id,
                n_clicks=0,
                className="btn btn-lg btn-primary btn-block",
            ),
            html.Br(),
            html.Br(),
            dcc.Link(
                html.Button(
                    "Delete Account",
                    id=delete_id,
                    n_clicks=0,
                    className="btn btn-lg btn-warning btn-block",
                ),
                href="/",
            ),
            html.Div(id=_dummy1, hidden=True),
        ],
        className="container",
    )
Beispiel #6
0
def layout():
    if is_logged_in():
        user = get_current_user()
    else:
        return html.Div(
            [html.Br(), html.H1("You must be logged in to do this")])

    completed_matches = user.get_matches()  # type: List[Request]

    if not completed_matches:
        children = children_no_matches()
    else:
        children = children_matches(completed_matches)

    return html.Div(children=children, className="container")
Beispiel #7
0
def layout():
    """Main layout for the open requests tab."""
    if is_logged_in():
        user = get_current_user()
    else:
        return html.Div([html.Br(), html.H1("You must be logged in to do this")])

    requests = user.get_requests_as_mentee()  # type: List[Request]

    if not requests:
        children = children_no_requests()
    else:
        children = children_requests(requests)

    children.append(html.Div(id=current_request_id, hidden=True))

    return html.Div(children=children, className="container", id=NAME)
def layout():
    if session.is_logged_in():
        is_signed_in_fields = [
            html.H3(
                "Welcome {}!".format(session.get_current_user().name),
                className="text-center",
            ),
            html.Br(),
            html.Br(),
            html.H3("New mentoring request", className="text-center"),
        ]
    else:
        is_signed_in_fields = [
            html.H3("Existing Users", className="text-center"),
            html.A(
                "Sign in!",
                href="/login",
                id="signin-{}".format(NAME),
                className="btn btn-lg btn-primary btn-block",
            ),
            html.Br(),
            html.Br(),
            html.H3("New mentoring request", className="text-center"),
        ]

    return html.Div(
        [
            html.H1("Metaswitch Tinder", className="text-center"),
            html.Br(),
            *is_signed_in_fields,
            html.Br(),
            mentee_request.layout(),
            html.Div(id="dummy-signin-{}".format(NAME), hidden=True),
        ],
        className="container",
        id="my-div",
    )