From d9eb2f7ff990f167512263c239a0411f3d3a255e Mon Sep 17 00:00:00 2001 From: Burathar Date: Fri, 24 Jul 2020 14:49:15 +0200 Subject: [PATCH] stuff --- app/main/forms.py | 4 ++++ app/main/routes.py | 7 ++---- app/templates/_game_player_info.html | 4 ++-- app/templates/base.html | 5 ++++ app/templates/create_game.html | 30 ++++++++++++------------ app/templates/game_bunny_dashboard.html | 1 - app/templates/game_hunter_dashboard.html | 1 - app/templates/game_owner_dashboard.html | 5 ++-- app/templates/game_player.html | 1 - 9 files changed, 30 insertions(+), 28 deletions(-) diff --git a/app/main/forms.py b/app/main/forms.py index f692e31..cfb1e27 100644 --- a/app/main/forms.py +++ b/app/main/forms.py @@ -24,12 +24,16 @@ class CreateGameForm(FlaskForm): self.date_time_validator(self.end_time_disabled, end_time) def date_time_validator(self, disabled, date_time): + print(1) if disabled.data: date_time.data = None return clientzone = timezone(self.timezone.data) + print(clientzone) + print(date_time.data) date_time_utc = clientzone.localize(date_time.data).astimezone(timezone('UTC')) date_time.data = date_time_utc + print(date_time.data) def validate_game_name(self, game_name): if game_name.data == '': diff --git a/app/main/routes.py b/app/main/routes.py index e063f72..9b746f7 100644 --- a/app/main/routes.py +++ b/app/main/routes.py @@ -39,12 +39,9 @@ def create_game(): form.state.choices = [(state.value, state.name) for state in GameState] if form.validate_on_submit(): - if Game.query.filter_by(name=form.game_name.data).first(): - flash('Please choose a different game name') - return render_template('create_game.html', title='Create Game', form=form) - game = Game(name=form.game_name.data, + game = Game(name=form.game_name.data, start_time=form.start_time.data, - end_time=form.end_time.data, + end_time=form.end_time.data, state=GameState(form.state.data)) game.players.append(GamePlayer(user=current_user, role=Role['owner'])) db.session.add(game) diff --git a/app/templates/_game_player_info.html b/app/templates/_game_player_info.html index 9c9be1b..3843b12 100644 --- a/app/templates/_game_player_info.html +++ b/app/templates/_game_player_info.html @@ -19,11 +19,11 @@ Start Time - {% if game.start_time %}{{ moment(game.start_time).format('DD-MM-YYYY, hh:mm')}}{% else %}-{% endif %} + {% if game.start_time %}{{ moment(game.start_time).format('DD-MM-YYYY, HH:mm')}}{% else %}-{% endif %} End Time - {% if game.end_time %}{{ moment(game.end_time).format('DD-MM-YYYY, hh:mm')}}{% else %}-{% endif %} + {% if game.end_time %}{{ moment(game.end_time).format('DD-MM-YYYY, HH:mm')}}{% else %}-{% endif %} {% if current_user.role_in_game(game).name == 'bunny' %} diff --git a/app/templates/base.html b/app/templates/base.html index 7c28494..3f08298 100644 --- a/app/templates/base.html +++ b/app/templates/base.html @@ -55,3 +55,8 @@ {% block app_content %}{% endblock %} {% endblock %} + +{% block scripts %} + {{ super() }} + {{ moment.include_moment() }} +{% endblock %} \ No newline at end of file diff --git a/app/templates/create_game.html b/app/templates/create_game.html index 7443b30..9be4aed 100644 --- a/app/templates/create_game.html +++ b/app/templates/create_game.html @@ -55,38 +55,35 @@