mirror of
https://github.com/godotengine/godot-showreel-voting.git
synced 2026-01-05 22:09:47 +03:00
* initial backend setup
* copied db setup
* added login
* added autoincrement to ids
* update db again
* added script to populate with test data
* added functionality to fetch videos
* added vote functionality
* added logic to update video info
* added history
* updated readme
* Update thank you page
* fixed small bugs
* small improvements
* added admin view, UI fix
* fix vote buttons style
* added pagination
* added command to load sample data from csv
* Autoplay videos
* Adding before you vote page
* added yt video id extractor
* improve visibility for the history page votes
* added logic for before you vote disclaimer
* Remind people to set videos to unlisted and allowed for embed
* Update home.html
* Update home.html
* Add progress bar to total
* Small adjustments
* fix home {% if user %}
* Update macros.html
* limit vote views to users with specific roles
* added endpoint to delete votes
* added confirmation to the delete vote action
* Update non-fund members CTA
* allow voting to specific fund members
* added result csv endpoint
* updated auth
* revert adding 'vote_allowed' column, merged it into is_staff
* added `is_fund_member` attribute to table and updated code
* refactored code
* update style for voting page
* updated readme
* Add static files
* remove options from dropdown for users that can't vote
* added keyboard shortcuts to vote buttons
* added azerty support for shortcuts
* update skip to S key
* remove placeholder
---------
Co-authored-by: Emi <2206700+coppolaemilio@users.noreply.github.com>
27 lines
797 B
Python
27 lines
797 B
Python
from typing import Optional
|
|
from flask_wtf import FlaskForm
|
|
from wtforms import IntegerField, StringField, ValidationError
|
|
from wtforms.validators import InputRequired
|
|
|
|
from gdshowreelvote.utils import downvote_video, upvote_video
|
|
|
|
|
|
VOTE_ACTIONS = {
|
|
'upvote': upvote_video,
|
|
'downvote': downvote_video,
|
|
'skip': lambda *args: None
|
|
}
|
|
|
|
def validate_action(form, field):
|
|
if field.data:
|
|
if VOTE_ACTIONS.get(field.data) is None:
|
|
raise ValidationError(f"Action '{field.data}' is not supported.")
|
|
|
|
|
|
class CastVoteForm(FlaskForm):
|
|
action = StringField('Action', validators=[validate_action])
|
|
video_id = IntegerField('Video ID', validators=[InputRequired()])
|
|
|
|
|
|
class SelectVideoForm(FlaskForm):
|
|
video_id = IntegerField('Video ID', validators=[InputRequired()]) |