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:
parent
1419bb6d51
commit
1b4a934398
7 changed files with 47 additions and 35 deletions
|
@ -22,7 +22,7 @@
|
|||
{%- endmacro display -%}
|
||||
|
||||
{# Remove the form if all votes are locked, to reduce confusion. #}
|
||||
{% set lock_truth_form = user.votes | length + 1 == truths | length and week_data.is_last_week != true %}
|
||||
{% set lock_truth_form = vote_data.votes | length + 1 == truths | length and week_data.is_last_week != true %}
|
||||
|
||||
{% block body %}
|
||||
|
||||
|
@ -91,7 +91,7 @@
|
|||
{% if user.logged_in == true and user.is_admin == false and not lock_truth_form %}
|
||||
<br/>
|
||||
<button form="truths">
|
||||
{%- if user.logged_in == true and user.has_week_vote == true -%}
|
||||
{%- if user.logged_in == true and vote_data.has_week_vote == true -%}
|
||||
Changer de vote
|
||||
{% else %}
|
||||
À voter !
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue