示例#1
0
def list_actions():
    if request.form["submit"] == "delete":
        action_id = uuid.uuid4().hex
        to_delete = [k for k, v in request.form.to_dict().items() if v == "on"]
        if to_delete:
            data = {"action": "delete", "items": to_delete}
            cache.set(action_id, data, timeout=5 * 60)
            return render_template(
                "events/approve.html", action="delete {} events".format(len(to_delete)), action_id=action_id
            )
    elif request.form["submit"] == "preview":
        events_list = [k for k, v in request.form.to_dict().items() if v == "on"]
        if events_list:
            subset_id = init_digest(events_list, {})
            set_variable(subset_id, "template", "main.html")  # FIXME: hardcoded
            set_variable(subset_id, "variables", {})  # FIXME: hardcoded
            set_default_template_variables(subset_id)
            generate_preview(subset_id)
            return redirect(url_for("digestmonkey.preview_content", subset_id=subset_id))
    elif request.form["submit"] == "approve":
        data = cache.get(request.form["action_id"])
        if not data:
            return render_template("events/error.html", errors=["Expired"])
        if data["action"] == "delete":
            for item in data["items"]:
                try:
                    current_app.events_api.delete_event(g.user.team.events_token, item)
                except EventsServiceAPIError as e:
                    return render_template("events/error.html", errors=e)

    return redirect(request.url)
示例#2
0
def list_actions():
    if request.form['submit'] == 'delete':
        action_id = uuid.uuid4().hex
        to_delete = [k for k, v in request.form.to_dict().items() if v == 'on']
        if to_delete:
            data = {'action': 'delete', 'items': to_delete}
            cache.set(action_id, data, timeout=5*60)
            return render_template('events/approve.html', action='delete {} events'.format(len(to_delete)), action_id=action_id)
    elif request.form['submit'] == 'preview':
        events_list = [k for k, v in request.form.to_dict().items() if v == 'on']
        if events_list:
            subset_id = init_digest(events_list, {})
            set_variable(subset_id, 'template', 'main.html')  # FIXME: hardcoded
            set_variable(subset_id, 'variables', {})  # FIXME: hardcoded
            set_default_template_variables(subset_id)
            generate_preview(subset_id)
            return redirect(url_for('digestmonkey.preview_content', subset_id=subset_id))
    elif request.form['submit'] == 'approve':
        data = cache.get(request.form['action_id'])
        if not data:
            return render_template('events/error.html', errors=['Expired'])
        if data['action'] == 'delete':
            for item in data['items']:
                try:
                    current_app.events_api.delete_event(g.user.team.events_token, item)
                except EventsServiceAPIError as e:
                    return render_template('events/error.html', errors=e)

    return redirect(request.url)
示例#3
0
def list_actions():
    if request.form['submit'] == 'delete':
        action_id = uuid.uuid4().hex
        to_delete = [k for k, v in request.form.to_dict().items() if v == 'on']
        if to_delete:
            data = {'action': 'delete', 'items': to_delete}
            cache.set(action_id, data, timeout=5 * 60)
            return render_template('events/approve.html',
                                   action='delete {} events'.format(
                                       len(to_delete)),
                                   action_id=action_id)
    elif request.form['submit'] == 'preview':
        events_list = [
            k for k, v in request.form.to_dict().items() if v == 'on'
        ]
        if events_list:
            subset_id = init_digest(events_list, {})
            set_variable(subset_id, 'template',
                         'main.html')  # FIXME: hardcoded
            set_variable(subset_id, 'variables', {})  # FIXME: hardcoded
            set_default_template_variables(subset_id)
            generate_preview(subset_id)
            return redirect(
                url_for('digestmonkey.preview_content', subset_id=subset_id))
    elif request.form['submit'] == 'approve':
        data = cache.get(request.form['action_id'])
        if not data:
            return render_template('events/error.html', errors=['Expired'])
        if data['action'] == 'delete':
            for item in data['items']:
                try:
                    current_app.events_api.delete_event(
                        g.user.team.events_token, item)
                except EventsServiceAPIError as e:
                    return render_template('events/error.html', errors=e)

    return redirect(request.url)
示例#4
0
def preview(subset_id):
    generate_preview(subset_id)
    return redirect(
        url_for('digestmonkey.choose_maillist', subset_id=subset_id))
示例#5
0
def preview(subset_id):
    generate_preview(subset_id)
    return redirect(url_for('digestmonkey.choose_maillist', subset_id=subset_id))