Skip to content

Commit

Permalink
Fix lineups not displaying youth workshops, fix favourites not displa…
Browse files Browse the repository at this point in the history
…ying anything
  • Loading branch information
lukegb committed May 23, 2024
1 parent 15649d1 commit 47ad1bc
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 11 deletions.
30 changes: 20 additions & 10 deletions apps/schedule/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

from main import db
from models import event_year
from models.cfp import Proposal, Venue
from models.cfp import Proposal, Venue, HUMAN_CFP_TYPES
from models.ical import CalendarSource, CalendarEvent
from models.user import generate_api_token
from models.admin_message import AdminMessage
Expand All @@ -37,6 +37,11 @@
from .data import _get_upcoming


# This controls both which types show on lineup and favourites, and in which order they are presented.
LINEUP_TYPE_ORDER = ["talk", "workshop", "youthworkshop", "performance"]
LINEUP_ORDER_HUMAN = [HUMAN_CFP_TYPES[t] for t in LINEUP_TYPE_ORDER]


@schedule.route("/schedule/")
def main():
return redirect(url_for(".main_year", year=event_year()))
Expand Down Expand Up @@ -73,13 +78,18 @@ def schedule_current():
)


def _group_proposals_by_human_type(proposals: list[Proposal]) -> dict[str, list[Proposal]]:
grouped = defaultdict(list)
for proposal in proposals:
grouped[proposal.human_type].append(proposal)
return grouped


def line_up():
# The order of these types also defines the order on the lineup page
types = ["talk", "workshop", "youthworkshop", "performance"]
proposals = Proposal.query.filter(
Proposal.scheduled_duration.isnot(None),
Proposal.is_accepted,
Proposal.type.in_(types),
Proposal.type.in_(LINEUP_TYPE_ORDER),
Proposal.user_scheduled.isnot(True),
Proposal.hide_from_schedule.isnot(True),
).all()
Expand All @@ -88,14 +98,13 @@ def line_up():
# (Because we don't want a bias in starring)
random.Random(current_user.get_id()).shuffle(proposals)

grouped = defaultdict(list)
for proposal in proposals:
grouped[proposal.human_type].append(proposal)

externals = CalendarSource.get_enabled_events()

return render_template(
"schedule/line-up.html", proposals=grouped, externals=externals, types=types
"schedule/line-up.html",
proposals=_group_proposals_by_human_type(proposals),
externals=externals,
human_types=LINEUP_ORDER_HUMAN,
)


Expand Down Expand Up @@ -168,9 +177,10 @@ def favourites():

return render_template(
"schedule/favourites.html",
proposals=proposals,
proposals=_group_proposals_by_human_type(proposals),
externals=externals,
token=token,
human_types=LINEUP_ORDER_HUMAN
)


Expand Down
2 changes: 1 addition & 1 deletion templates/schedule/_proposal_lister.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
{# List proposals - works for the current event year only #}
{% macro list_proposals(proposals) %}
{% include "schedule/_icon_key.html" %}
{% for human_type in types %}
{% for human_type in human_types %}
{% if proposals[human_type] %}
<h2 class="event-type" id="{{ proposals[human_type][0].type }}">{{ human_type | title }}s</h2>
<form method="post" action="{{url_for(".add_favourite")}}">
Expand Down

0 comments on commit 47ad1bc

Please sign in to comment.