Browse Source

stuff

testing
Burathar 4 years ago
parent
commit
d9eb2f7ff9
  1. 4
      app/main/forms.py
  2. 3
      app/main/routes.py
  3. 4
      app/templates/_game_player_info.html
  4. 5
      app/templates/base.html
  5. 28
      app/templates/create_game.html
  6. 1
      app/templates/game_bunny_dashboard.html
  7. 1
      app/templates/game_hunter_dashboard.html
  8. 5
      app/templates/game_owner_dashboard.html
  9. 1
      app/templates/game_player.html

4
app/main/forms.py

@ -24,12 +24,16 @@ class CreateGameForm(FlaskForm): @@ -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 == '':

3
app/main/routes.py

@ -39,9 +39,6 @@ def create_game(): @@ -39,9 +39,6 @@ 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,
start_time=form.start_time.data,
end_time=form.end_time.data,

4
app/templates/_game_player_info.html

@ -19,11 +19,11 @@ @@ -19,11 +19,11 @@
</tr>
<tr>
<th>Start Time</th>
<td>{% if game.start_time %}{{ moment(game.start_time).format('DD-MM-YYYY, hh:mm')}}{% else %}-{% endif %}</td>
<td>{% if game.start_time %}{{ moment(game.start_time).format('DD-MM-YYYY, HH:mm')}}{% else %}-{% endif %}</td>
</tr>
<tr>
<th>End Time</th>
<td>{% if game.end_time %}{{ moment(game.end_time).format('DD-MM-YYYY, hh:mm')}}{% else %}-{% endif %}</td>
<td>{% if game.end_time %}{{ moment(game.end_time).format('DD-MM-YYYY, HH:mm')}}{% else %}-{% endif %}</td>
</tr>
{% if current_user.role_in_game(game).name == 'bunny' %}
<tr>

5
app/templates/base.html

@ -55,3 +55,8 @@ @@ -55,3 +55,8 @@
{% block app_content %}{% endblock %}
</div>
{% endblock %}
{% block scripts %}
{{ super() }}
{{ moment.include_moment() }}
{% endblock %}

28
app/templates/create_game.html

@ -55,38 +55,35 @@ @@ -55,38 +55,35 @@
<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">
$(function () {
'{% if not form.start_time_disabled.data %}'
var startDate = new Date()
'{% else %}'
var startDate = null
'{% endif %}'
'{% if not form.end_time_disabled.data %}'
var endDate = new Date()
'{% else %}'
var endDate = null
'{% endif %}'
var date = moment()
$('#datetimepicker_start').datetimepicker({
//useCurrent: false, //Important! See issue #1075
locale: 'en-gb',
format: 'DD-MM-YYYY HH:mm',
keepInvalid: true,
sideBySide: true,
defaultDate: startDate,
defaultDate: null,
timeZone: moment.tz.guess()
});
//date.setDate(date.getDate() + 1)
'{% if not form.start_time_disabled.data and not form.start_time %}'
$('#datetimepicker_start')[0].value = date.format('DD-MM-YYYY HH:mm');
date.add(1, 'hour');
'{% endif %}'
$('#datetimepicker_end').datetimepicker({
//useCurrent: false, //Important! See issue #1075
locale: 'en-gb',
format: 'DD-MM-YYYY HH:mm',
keepInvalid: true,
sideBySide: true,
defaultDate: endDate,
defaultDate: null,
timeZone: moment.tz.guess()
});
var date = new Date()
'{% if not form.end_time_disabled.data and not form.end_time %}'
$('#datetimepicker_end')[0].value = date.format('DD-MM-YYYY HH:mm');
'{% endif %}'
$("#datetimepicker_start").on("dp.change", function (e) {
$('#datetimepicker_end').data("DateTimePicker").minDate(e.date);
});
@ -105,6 +102,9 @@ @@ -105,6 +102,9 @@
}
else {
$(picker).data("DateTimePicker").enable();
if ($(picker).data("DateTimePicker") == null){
$(picker).data("DateTimePicker") = moment().format('DD-MM-YYYY HH:mm');
}
}
}
updateDateTimePicker('#datetimepicker_start', '#start_time_disabled');

1
app/templates/game_bunny_dashboard.html

@ -57,7 +57,6 @@ @@ -57,7 +57,6 @@
{% block scripts %}
{{ super() }}
{{ moment.include_moment() }}
<script type="text/javascript", crossorigin="anonymous">
// Leaflet Map
map = getMap()

1
app/templates/game_hunter_dashboard.html

@ -67,7 +67,6 @@ @@ -67,7 +67,6 @@
{% block scripts %}
{{ super() }}
{{ moment.include_moment() }}
<script type="text/javascript", crossorigin="anonymous">
// Leaflet Map
map = getMap()

5
app/templates/game_owner_dashboard.html

@ -19,8 +19,8 @@ @@ -19,8 +19,8 @@
</a>
{% endif %}
<br><br>
<p><b>Start Time: </b>{{ game.start_time }}</p>
<p><b>End Time: </b>{{ game.end_time }}</p>
<p><b>Start Time: </b>{% if game.start_time %}{{ moment(game.start_time).format('DD-MM-YYYY, HH:mm') }}{% else %}None{% endif %}</p>
<p><b>End Time: </b>{% if game.end_time %}{{ moment(game.end_time).format('DD-MM-YYYY, HH:mm') }}{% else %}None{% endif %}</p>
<p><b>State: </b>{{ game.state.name.title() }}</p>
<h2>Players:</h2>
<p><a href="{{ url_for('main.add_player', game_name = game.name) }}">Add player</a></p>
@ -98,7 +98,6 @@ @@ -98,7 +98,6 @@
{% block scripts %}
{{ super() }}
{{ moment.include_moment() }}
<script type="text/javascript", crossorigin="anonymous">
// Leaflet Map
map = getMap()

1
app/templates/game_player.html

@ -73,7 +73,6 @@ @@ -73,7 +73,6 @@
{% block scripts %}
{{ super() }}
{{ moment.include_moment() }}
<script type="text/javascript" , crossorigin="anonymous">
// Leaflet Map
'{% set last_location = player.last_location() %}'

Loading…
Cancel
Save