auth: Split off vote data from the user

Now that the application is going to have multiple pages, vote data makes no sense
to keep with the user.
The user struct will be used everywhere to check for authentication, which is not
the case for previous votes.

Create a new struct and function in src/vote.rs to retrieve existing votes and
use them in places where user.votes was used previously.
Remove vote-related code from src/auth.rs and the week number dependence that it
required.
This commit is contained in:
trotFunky 2024-07-28 14:36:52 +01:00
parent 1419bb6d51
commit 1b4a934398
7 changed files with 47 additions and 35 deletions

View file

@ -1,6 +1,6 @@
{%- set is_disabled = "" -%}
{# If we are not during the active week, prevent changing vote but not sending a missing one. #}
{%- if week_data.is_last_week != true and user.votes | filter(attribute="truth_id", value=truth.id) -%}
{%- if week_data.is_last_week != true and vote_data.votes | filter(attribute="truth_id", value=truth.id) -%}
{%- set is_disabled = "disabled" -%}
{%- endif -%}
@ -19,7 +19,7 @@
{% for player in other_players %}
{# Check if we should pre-select an existing vote. #}
{% set_global is_selected = "" %}
{% for vote in user.votes %}
{% for vote in vote_data.votes %}
{% if truth.id == vote.truth_id and player.id == vote.voted_id %}
{% set_global is_selected = "selected" %}
{% break %}