示例#1
0
def message(message_id):
    msg = AdminMessage.get_by_id(message_id)
    form = AdminMessageForm()

    if form.validate_on_submit():
        form.update_message(msg)
        db.session.commit()

        flash("Updated message")
        return redirect(url_for(".all_messages"))

    form.init_with_message(msg)
    return render_template("admin/messages/edit.html", message=msg, form=form)
示例#2
0
def message(message_id):
    msg = AdminMessage.get_by_id(message_id)
    form = AdminMessageForm()

    if form.validate_on_submit():
        form.update_message(msg)
        db.session.commit()

        flash('Updated message')
        return redirect(url_for('.all_messages'))

    form.init_with_message(msg)
    return render_template('admin/messages/edit.html', message=msg, form=form)
示例#3
0
def new_message():
    form = AdminMessageForm()

    if form.validate_on_submit():
        msg = AdminMessage(creator=current_user)
        form.update_message(msg)

        db.session.add(msg)
        db.session.commit()

        flash("Created new message")
        return redirect(url_for(".all_messages"))

    return render_template("admin/messages/new.html", form=form)
示例#4
0
def greenroom():
    def greenroom_message(message):
        app.logger.info(f"Creating new message '{message}'")
        end = datetime.now() + timedelta(hours=1)
        return AdminMessage(
            f"[greenroom] -- {message}", current_user, end=end, topic="heralds"
        )

    show = request.args.get("show", default=10, type=int)
    form = GreenroomForm()

    upcoming = (
        Proposal.query.filter(
            Proposal.type.in_(["talk", "workshop", "youthworkshop", "performance"]),
            Proposal.state.in_(["accepted", "finished"]),
            Proposal.scheduled_time > pendulum.now(event_tz),
            Proposal.scheduled_duration.isnot(None),
            Proposal.hide_from_schedule.isnot(True),
        )
        .order_by(Proposal.scheduled_time)
        .limit(show)
        .all()
    )
    form.speakers.choices = [
        (prop.published_names or prop.user.name) for prop in upcoming
    ]

    if form.validate_on_submit():
        app.logger.info(f"{form.speakers.data} arrived.")
        if form.arrived.data:
            msg = greenroom_message(f"{form.speakers.data} arrived.")

        elif form.send_message.data:
            msg = greenroom_message(form.message.data)

        db.session.add(msg)
        db.session.commit()

        return redirect(url_for(".greenroom"))

    messages = AdminMessage.get_all_for_topic("heralds")

    return render_template(
        "schedule/herald/greenroom.html",
        form=form,
        messages=messages,
        upcoming=upcoming,
    )
示例#5
0
def now_and_next():
    proposals = _get_upcoming(request.args)
    arg_venues = request.args.getlist("venue", type=str)
    venues = [html.escape(v) for v in arg_venues]

    admin_messages = AdminMessage.get_visible_messages()

    for msg in admin_messages:
        flash(msg.message)

    if request.args.get("fullscreen", default=False, type=bool):
        template = "schedule/now-and-next-fullscreen.html"
    else:
        template = "schedule/now-and-next.html"

    return render_template(template, venues=venues, proposals_by_venue=proposals)
示例#6
0
def all_messages():
    return render_template("admin/messages/all.html", messages=AdminMessage.get_all())
示例#7
0
 def greenroom_message(message):
     app.logger.info(f"Creating new message '{message}'")
     end = datetime.now() + timedelta(hours=1)
     return AdminMessage(
         f"[greenroom] -- {message}", current_user, end=end, topic="heralds"
     )
示例#8
0
 def herald_message(message, proposal):
     app.logger.info(f"Creating new message {message}")
     end = proposal.scheduled_time + timedelta(minutes=proposal.scheduled_duration)
     return AdminMessage(
         f"[{venue_name}] -- {message}", current_user, end=end, topic="heralds"
     )
示例#9
0
def herald_venue(venue_name):
    def herald_message(message, proposal):
        app.logger.info(f"Creating new message {message}")
        end = proposal.scheduled_time + timedelta(minutes=proposal.scheduled_duration)
        return AdminMessage(
            f"[{venue_name}] -- {message}", current_user, end=end, topic="heralds"
        )

    now, next = (
        Proposal.query.join(Venue, Venue.id == Proposal.scheduled_venue_id)
        .filter(
            Venue.name == venue_name,
            Proposal.state.in_(["accepted", "finished"]),
            Proposal.scheduled_time > pendulum.now(event_tz),
            Proposal.scheduled_duration.isnot(None),
            Proposal.hide_from_schedule.isnot(True),
        )
        .order_by(Proposal.scheduled_time)
        .limit(2)
        .all()
    )

    form = HeraldStageForm()

    if form.validate_on_submit():
        if form.now.update.data:
            if form.now.talk_id.data != now.id:
                flash("'now' changed, please refresh")
                return redirect(url_for(".herald_venue", venue_name=venue_name))

            change = "may" if form.now.may_record else "may not"
            msg = herald_message(f"Change: {change} record '{now.title}'", now)
            now.may_record = form.now.may_record.data

        elif form.next.update.data:
            if form.next.talk_id.data != next.id:
                flash("'next' changed, please refresh")
                return redirect(url_for(".herald_venue", venue_name=venue_name))
            change = "may" if form.next.may_record else "may not"
            msg = herald_message(f"Change: {change} record '{next.title}'", next)
            next.may_record = form.next.may_record.data

        elif form.now.speaker_here.data:
            msg = herald_message(f"{now.user.name}, arrived.", now)

        elif form.next.speaker_here.data:
            msg = herald_message(f"{next.user.name}, arrived.", next)

        elif form.send_message.data:
            # in lieu of a better time set TTL to end of next talk
            msg = herald_message(form.message.data, next)

        db.session.add(msg)
        db.session.commit()
        return redirect(url_for(".herald_venue", venue_name=venue_name))

    messages = AdminMessage.get_all_for_topic("heralds")

    form.now.talk_id.data = now.id
    form.now.may_record.data = now.may_record

    form.next.talk_id.data = next.id
    form.next.may_record.data = next.may_record

    return render_template(
        "schedule/herald/venue.html",
        messages=messages,
        venue_name=venue_name,
        form=form,
        now=now,
        next=next,
    )
示例#10
0
 def populate_topics(self):
     self.topic.choices = []
     for topic in AdminMessage.get_topic_counts():
         self.topic.choices.append(topic)
示例#11
0
    def get(self):
        records = AdminMessage.get_visible_messages()
        messages = list(map(renderScheduleMessage, records))

        return messages
示例#12
0
def all_messages():
    return render_template('admin/messages/all.html', messages=AdminMessage.get_all())