Browse Source

Improve create_game datepicker, add game_dashboard

feature_tests
Burathar 5 years ago
parent
commit
6faa6b609c
  1. 3
      app/forms.py
  2. 7
      app/routes.py
  3. 2
      app/templates/base.html
  4. 26
      app/templates/create_game.html
  5. 5
      app/templates/game_dashboard.html
  6. 6
      requirements.txt
  7. 3
      the_hunt.py

3
app/forms.py

@ -23,5 +23,6 @@ class RegistrationForm(FlaskForm):
class CreateGameForm(FlaskForm): class CreateGameForm(FlaskForm):
game_name = StringField('Game Name', validators=[DataRequired(), Length(min=0, max=64)]) game_name = StringField('Game Name', validators=[DataRequired(), Length(min=0, max=64)])
start_time = DateTimeField(id='datepick') start_time = DateTimeField(id='datetimepicker1')
end_time = DateTimeField(id='datetimepicker2')
submit = SubmitField('Register') submit = SubmitField('Register')

7
app/routes.py

@ -50,4 +50,9 @@ def create_game():
if form.validate_on_submit(): if form.validate_on_submit():
game = Game(name=form.game_name.data) game = Game(name=form.game_name.data)
return render_template('create_game.html', title='Create Game!', form=form) return render_template('create_game.html', title='Create Game!', form=form)
return render_template('create_game.html', title='Create Game', form=form) return render_template('create_game.html', title='Create Game', form=form)
@login_required
@app.route('/game/<game_name>/admin')
def game_dashboard():
return render_template('game_dashboard.html', title = 'Game Dashboard')

2
app/templates/base.html

@ -19,7 +19,9 @@
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1"> <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav"> <ul class="nav navbar-nav">
<li><a href="{{ url_for('index') }}">Home</a></li> <li><a href="{{ url_for('index') }}">Home</a></li>
{% if current_user.is_authenticated %}
<li><a href="{{ url_for('create_game') }}">Create Game</a></li> <li><a href="{{ url_for('create_game') }}">Create Game</a></li>
{% endif %}
</ul> </ul>
<ul class="nav navbar-nav navbar-right"> <ul class="nav navbar-nav navbar-right">
{% if current_user.is_anonymous %} {% if current_user.is_anonymous %}

26
app/templates/create_game.html

@ -3,7 +3,7 @@
{% block head %} {% block head %}
{{ super() }} {{ super() }}
<link type="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datetimepicker/4.17.47/css/bootstrap-datetimepicker.min.css"> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datetimepicker/4.17.47/css/bootstrap-datetimepicker.min.css">
{% endblock %} {% endblock %}
{% block app_content %} {% block app_content %}
@ -15,13 +15,33 @@
</div> </div>
{% endblock %} {% endblock %}
TODO:
- maak time picker 24 uur based
https://eonasdan.github.io/bootstrap-datetimepicker/Options/#locale+
- optie voor nu
{% block scripts %} {% block scripts %}
{{ super() }} {{ super() }}
<!-- TODO: Scripts downloaden naar repo? -->
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.18.1/moment.min.js"></script> <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.18.1/moment.min.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.18.1/moment-with-locales.min.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datetimepicker/4.17.47/js/bootstrap-datetimepicker.min.js"></script> <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datetimepicker/4.17.47/js/bootstrap-datetimepicker.min.js"></script>
<script type="text/javascript"> <script type="text/javascript">
$(function () { $(function () {
$('#datepick').datetimepicker(); $('#datetimepicker1').datetimepicker({
useCurrent: false, //Important! See issue #1075
locale: 'en-gb'
});
$('#datetimepicker2').datetimepicker({
useCurrent: false, //Important! See issue #1075
locale: 'en-gb'
});
$("#datetimepicker1").on("dp.change", function (e) {
$('#datetimepicker2').data("DateTimePicker").minDate(e.date);
});
$("#datetimepicker2").on("dp.change", function (e) {
$('#datetimepicker1').data("DateTimePicker").maxDate(e.date);
});
}); });
</script> </script>
{% endblock %} {% endblock %}

5
app/templates/game_dashboard.html

@ -0,0 +1,5 @@
{% extends 'base.html' %}
{% block app_content %}
<h1>Dashboard</h1>
{% endblock %}

6
requirements.txt

@ -3,10 +3,13 @@ click==7.1.2
dominate==2.5.1 dominate==2.5.1
Flask==1.1.2 Flask==1.1.2
Flask-Bootstrap==3.3.7.1 Flask-Bootstrap==3.3.7.1
Flask-Login==0.5.0
Flask-Migrate==2.5.3 Flask-Migrate==2.5.3
Flask-SQLAlchemy==2.4.3 Flask-SQLAlchemy==2.4.3
Flask-WTF==0.14.3
itsdangerous==1.1.0 itsdangerous==1.1.0
Jinja2==2.11.2 Jinja2==2.11.2
lazy-object-proxy==1.4.3
Mako==1.1.3 Mako==1.1.3
MarkupSafe==1.1.1 MarkupSafe==1.1.1
python-dateutil==2.8.1 python-dateutil==2.8.1
@ -14,5 +17,8 @@ python-dotenv==0.13.0
python-editor==1.0.4 python-editor==1.0.4
six==1.15.0 six==1.15.0
SQLAlchemy==1.3.18 SQLAlchemy==1.3.18
typed-ast==1.4.1
visitor==0.1.3 visitor==0.1.3
Werkzeug==1.0.1 Werkzeug==1.0.1
wrapt==1.12.1
WTForms==2.3.1

3
the_hunt.py

@ -1,5 +1,6 @@
from app import app, db from app import app, db
from app.models import Game, Player, Objective, Location, Notification from app.models import Game, Player, Objective, Location, Notification, GamePlayer, \
PlayerFoundObjective, NotificationPlayer, PlayerCaughtPlayer, GameState
@app.shell_context_processor @app.shell_context_processor
def make_shell_context(): def make_shell_context():

Loading…
Cancel
Save