Пример #1
0
def set_mentor_tags(tags: List[str]):
    """
    Callback that gets called when a tag is added or deleted

    :param tags: List of tags, comma separated.
    """
    log.info("User %s set mentor tags: %s", current_user_email(), tags)
    get_current_user().set_tags(tags)
Пример #2
0
def get_matches_for_current_user_role(
        skipped_matches: List[str]) -> List[PossibleMatch]:
    if on_mentee_tab():
        current_matches = get_matches_for_mentee(get_current_user(),
                                                 skipped_matches)
    else:
        current_matches = get_matches_for_mentor(get_current_user(),
                                                 skipped_matches)
    return current_matches
Пример #3
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",
    )
Пример #4
0
def delete_account():
    """
    Callback that gets called when the user requests account deletion.
    """
    user = get_current_user()
    user_email = user.email
    log.info("User %s requested account deletion.", user_email)
    user.delete()
    log.info("User %s deleted.", user_email)
    logout()
Пример #5
0
def handle_mentor_accept_match(matched_user: User, request: Request):
    print("mentor accepted match:", matched_user, request)
    mentor = get_current_user()
    mentee = matched_user
    request.handle_mentor_accept_mentee(mentor)

    email_text = "You're a match!"
    email_text += "\n\n"
    email_text += request.comment

    tinder_email.send_match_email([mentor.email, mentee.email], email_text)
Пример #6
0
def set_mentor_tags(bio: str):
    """
    Callback that gets called when a tag is added or deleted

    :param bio: Biography of the users.
    """
    log.info("User %s set bio: %s", current_user_email(), bio)
    user = get_current_user()
    user.bio = bio
    user.commit()

    return "Saved!"
Пример #7
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")
Пример #8
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)
Пример #9
0
def layout():
    user = get_current_user()

    return html.Div(
        [
            create_equal_row([html.Label("Tell us what you know about:")]),
            *tags_dropdown_with_add_new_entry_box(categories_id,
                                                  init_selection=user.tags),
            html.Br(),
            create_equal_row(
                [html.Label("Additional details about your skills:")]),
            create_equal_row([
                dcc.Input(value="", type="text", id="details-{}".format(NAME))
            ]),
            html.Div(id="dummy-{}".format(NAME), hidden=True),
        ],
        className="container",
    )
Пример #10
0
def children_matches(completed_matches: List[Request]) -> List:
    table_rows = [
        html.Tr(
            [
                html.Td("Partner"),
                html.Td("Request tags"),
                html.Td("Request description"),
            ],
            className="table-active",
        )
    ]

    for match in completed_matches:
        if match.maker == current_user_email():
            # Current user is the mentee
            other_user = get_user(match.mentor)
            name = other_user.name if other_user else "unknown"
            partner_name = "{} (mentor)".format(name)
        else:
            # Current user is the mentor
            other_user = get_user(match.maker)
            name = other_user.name if other_user else "unknown"
            partner_name = "{} (mentee)".format(name)

        table_rows.append(
            html.Tr(
                [
                    html.Td(partner_name),
                    html.Td(", ".join(match.tags)),
                    html.Td(match.comment),
                ],
                className="table-light",
            ))
    return [
        html.H1("{}, here are your completed matches".format(
            get_current_user().name)),
        html.Table([*table_rows], className="table table-condensed"),
    ]
Пример #11
0
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",
    )
Пример #12
0
def handle_mentor_reject_match(matched_user: User, request: Request):
    print("mentor rejected match:", matched_user, request)
    request.handle_mentor_reject_mentee(get_current_user())
Пример #13
0
def get_request_id_by_index(index: int) -> str:
    """Get the request of the current user by numerical index."""
    return get_current_user().get_requests_as_mentee()[index]