Example #1
0
def show_talk(seminar_id, talkid):
    token = request.args.get("token", "")  # save the token so user can toggle between view and edit
    talk = talks_lucky({"seminar_id": seminar_id, "seminar_ctr": talkid}, prequery={})
    if talk is None:
        return abort(404, "Talk not found")
    if not talk.visible():
        # There may be a non-API version of the seminar that can be shown
        talk = talks_lucky({"seminar_id": seminar_id, "seminar_ctr": talkid})
        if talk is None or not talk.visible():
            flash_error("You do not have permission to view %s/%s", seminar_id, talkid)
            return redirect(url_for("semseries_index"))
    kwds = dict(
        title="View talk", talk=talk, seminar=talk.seminar, subsection="viewtalk", token=token
    )
    if token:
        kwds["section"] = "Manage"
        # Also want to override top menu
        from seminars.utils import top_menu

        menu = top_menu()
        menu[1] = (url_for("create.index"), "", "Manage")
        kwds["top_menu"] = menu
    elif (
        current_user.is_subject_admin(talk)
        or current_user.email_confirmed
        and (
            current_user.email in talk.seminar.editors() or current_user.email == talk.speaker_email
        )
    ):
        kwds["section"] = "Manage"
    return render_template("talk.html", **kwds)
Example #2
0
def ctx_proc_userdata():
    # insert an empty info={} as default
    # set the body class to some default, blueprints should
    # overwrite it with their name, using @<blueprint_object>.context_processor
    # see http://flask.pocoo.org/docs/api/?highlight=context_processor#flask.Blueprint.context_processor
    data = {"info": {}, "body_class": ""}

    # insert the default bread crumb hierarchy
    # overwrite this variable when you want to customize it
    # For example, [ ('Bread', '.'), ('Crumb', '.'), ('Hierarchy', '.')]
    data["bread"] = None

    # default title - Math seminars already included in base.html
    data["title"] = r""

    # meta_description appears in the meta tag "description"
    data[
        "meta_description"] = r"Welcome to Math Seminars, a listing of mathematical research seminars, talks and conferences!"
    data[
        "feedbackpage"] = r"https://docs.google.com/forms/d/e/1FAIpQLSdJNJ0MwBXzqZleN5ibAI9u1gPPu9Aokzsy08ot802UitiDRw/viewform"
    data["LINK_EXT"] = lambda a, b: '<a href="%s" target="_blank">%s</a>' % (b,
                                                                             a)

    # debug mode?
    data["DEBUG"] = is_debug_mode()

    data["topics"] = topics()
    data["top_menu"] = top_menu()

    data["talks_header"] = talks_header
    data["seminars_header"] = seminars_header
    data["languages_dict"] = languages_dict()

    return data
Example #3
0
def show_talk(semid, talkid):
    token = request.args.get(
        "token", "")  # save the token so user can toggle between view and edit
    talk = talks_lucky({"seminar_id": semid, "seminar_ctr": talkid})
    if talk is None:
        return not_found_404("Talk not found")
    kwds = dict(title="View talk",
                talk=talk,
                seminar=talk.seminar,
                subsection="viewtalk",
                token=token)
    if token:
        kwds["section"] = "Manage"
        # Also want to override top menu
        from seminars.utils import top_menu

        menu = top_menu()
        menu[2] = (url_for("create.index"), "", "Manage")
        kwds["top_menu"] = menu
    elif (current_user.is_subject_admin(talk)
          or current_user.email_confirmed and
          (current_user.email in talk.seminar.editors()
           or current_user.email == talk.speaker_email)):
        kwds["section"] = "Manage"
    return render_template("talk.html", **kwds)
Example #4
0
def edit_talk():
    if request.method == "POST":
        data = request.form
    else:
        data = request.args
    token = data.get("token", "")
    resp, talk = can_edit_talk(data.get("seminar_id", ""),
                               data.get("seminar_ctr", ""), token)
    if resp is not None:
        return resp
    if token:
        # Also want to override top menu
        from seminars.utils import top_menu

        menu = top_menu()
        menu[2] = (url_for("create.index"), "", "Manage")
        extras = {"top_menu": menu}
    else:
        extras = {}
    # The seminar schedule page adds in a date and times
    if data.get("date", "").strip():
        tz = talk.seminar.tz
        date = process_user_input(data["date"], "date", "date", tz)
        try:
            # TODO: clean this up
            start_time = process_user_input(data.get("start_time"),
                                            "start_time", "time", tz)
            end_time = process_user_input(data.get("end_time"), "end_time",
                                          "time", tz)
            start_time = localize_time(datetime.combine(date, start_time), tz)
            end_time = localize_time(datetime.combine(date, end_time), tz)
        except ValueError:
            return redirect(
                url_for(".edit_seminar_schedule", shortname=talk.seminar_id),
                302)
        talk.start_time = start_time
        talk.end_time = end_time
    # lock = get_lock(seminar_id, data.get("lock"))
    title = "Create talk" if talk.new else "Edit talk"
    return render_template("edit_talk.html",
                           talk=talk,
                           seminar=talk.seminar,
                           title=title,
                           section="Manage",
                           subsection="edittalk",
                           institutions=institutions(),
                           timezones=timezones,
                           token=token,
                           **extras)