Skip to content

Commit

Permalink
Fix redirect bug
Browse files Browse the repository at this point in the history
  • Loading branch information
dansahagian committed Sep 6, 2024
1 parent 3cf5dc9 commit 1c9bc1f
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 13 deletions.
4 changes: 2 additions & 2 deletions dev/init-db
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/zsh

ssh dan@linode "pg_dump -U fbsurvivor2 fbsurvivor2 > /tmp/fbsurvivor_dump"
scp dan@linode:/tmp/fbsurvivor_dump ~/d/code/fbsurvivor/tmp/fbsurvivor_dump
scp dan@linode:/tmp/fbsurvivor_dump ~/d/code/dansahagian/fbsurvivor/tmp/fbsurvivor_dump
ssh dan@linode "rm /tmp/fbsurvivor_dump"

psql -U postgres -d fbsurvivor2 -c "DROP SCHEMA IF EXISTS public CASCADE;"
Expand All @@ -14,4 +14,4 @@ psql -U postgres -d postgres -c "GRANT ALL ON DATABASE fbsurvivor2 to fbsurvivor
psql -U postgres -d fbsurvivor2 -c "DROP SCHEMA IF EXISTS public;"
psql -U postgres -d fbsurvivor2 -c "CREATE SCHEMA IF NOT EXISTS public AUTHORIZATION fbsurvivor2;"

psql fbsurvivor2 < ~/d/code/fbsurvivor/tmp/fbsurvivor_dump
psql fbsurvivor2 < ~/d/code/dansahagian/fbsurvivor/tmp/fbsurvivor_dump
5 changes: 2 additions & 3 deletions fbsurvivor/core/utils/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,8 @@ def get_current_season() -> Season:
return Season.objects.get(is_current=True)


def send_to_latest_season_played(request):
username = request.session.get("username")
ps = PlayerStatus.objects.filter(player__username=username).order_by("-season__year")
def send_to_latest_season_played(request, player: Player):
ps = PlayerStatus.objects.filter(player=player).order_by("-season__year")
if ps:
latest = ps[0].season.year
messages.info(request, f"No record for the requested year. Here is {latest}")
Expand Down
8 changes: 3 additions & 5 deletions fbsurvivor/core/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ def board(request, year: int, **kwargs):
season, player_status, context = get_player_context(player, year)

if season.is_locked and not player_status:
return send_to_latest_season_played(request)
return send_to_latest_season_played(request, player)

can_play = not player_status and season.is_current and not season.is_locked
weeks = (
Expand Down Expand Up @@ -143,7 +143,7 @@ def play(request, year: int, **kwargs):
return redirect(reverse("board", args=[year]))

if season.is_locked:
return send_to_latest_season_played(request)
return send_to_latest_season_played(request, player)

context.update(
{
Expand Down Expand Up @@ -446,9 +446,7 @@ def remind(request, year, **kwargs):
def get_players(request, year, **kwargs):
season, context = get_season_context(year, **kwargs)
context["players"] = (
PlayerStatus.objects.values_list("player__username", flat=True)
.distinct()
.order_by("player__username")
Player.objects.values_list("username", flat=True).distinct().order_by("username")
)

return render(request, "players.html", context=context)
Expand Down
5 changes: 2 additions & 3 deletions fbsurvivor/templates/rules.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,8 @@ <h3>Rules</h3>
<strong>Payouts:</strong><br>
Payouts are dependent on participation!<br>
Survivor: at least 7x the buy in.<br>
Best Record: 2-4x the buy in.<br>
2nd Best Record: 1-2x the buy in.<br>
Lottery: Free play next season.<br><br>
Best Record: at least 3x the buy in.<br>
Lottery: Cash prize (1-2x buy in).<br><br>
To be eligible for the lottery:<br>
- don't be Dan<br>
- pick every week<br>
Expand Down

0 comments on commit 1c9bc1f

Please sign in to comment.