Ejemplo n.º 1
0
def user_ics_file(token):
    from itsdangerous.exc import BadSignature
    try:
        try:
            uid = read_token(token, "ics")
        except BadSignature:
            # old key
            uid = read_token(token, "ics", key="vVjYyCM99DtirZqMaGMrle")
        user = SeminarsUser(uid=int(uid))
        if not user.email_confirmed:
            return flask.abort(404, "The email has not yet been confirmed!")
    except NotImplementedError:
        return flask.abort(404, "Invalid link")

    talks = [t for t in user.talks if not (t.hidden or t.seminar.visibility == 0)]
    for seminar in user.seminars:
        # Organizers may have hidden seminar
        if seminar.visibility == 0:
            continue
        for talk in seminar.talks():
            talks.append(talk)
    return ics_file(
        talks=talks,
        filename="seminars.ics",
        user=user)
Ejemplo n.º 2
0
def ics_talk_file(seminar_id, talkid):
    talk = talks_lucky({"seminar_id": seminar_id, "seminar_ctr": talkid})
    if talk is None:
        return abort(404, "Talk not found")
    return ics_file([talk],
                    filename="{}_{}.ics".format(seminar_id, talkid),
                    user=current_user)
Ejemplo n.º 3
0
def ics_seminar_file(shortname):
    seminar = seminars_lucky({"shortname": shortname})
    if seminar is None or not seminar.visible():
        return not_found_404("Seminar not found")

    return ics_file(seminar.talks(),
                    filename="{}.ics".format(shortname),
                    user=current_user)
Ejemplo n.º 4
0
def ics_seminar_file(shortname):
    seminar = seminars_lucky({"shortname": shortname})
    if seminar is None or not seminar.visible():
        # There may be a non-API version of the seminar that can be shown
        seminar = seminars_lucky({"shortname": shortname})
        if seminar is None or not seminar.visible():
            return abort(404, "Seminar not found")

    return ics_file(seminar.talks(),
                    filename="{}.ics".format(shortname),
                    user=current_user)
Ejemplo n.º 5
0
def user_ics_file(token):
    from itsdangerous.exc import BadSignature
    try:
        try:
            uid = read_token(token, "ics")
        except BadSignature:
            # old key
            return flask.abort(404, "Invalid link")
        user = SeminarsUser(uid=int(uid))
        if not user.email_confirmed:
            return flask.abort(404, "The email address has not yet been confirmed!")
    except Exception:
        return flask.abort(404, "Invalid link")
    return ics_file(
        talks=user.ics_talks,
        filename="seminars.ics",
        user=user)