Browse Source

stuff

testing
Burathar 4 years ago
parent
commit
d9eb2f7ff9
  1. 4
      app/main/forms.py
  2. 7
      app/main/routes.py
  3. 4
      app/templates/_game_player_info.html
  4. 5
      app/templates/base.html
  5. 30
      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):
self.date_time_validator(self.end_time_disabled, end_time) self.date_time_validator(self.end_time_disabled, end_time)
def date_time_validator(self, disabled, date_time): def date_time_validator(self, disabled, date_time):
print(1)
if disabled.data: if disabled.data:
date_time.data = None date_time.data = None
return return
clientzone = timezone(self.timezone.data) clientzone = timezone(self.timezone.data)
print(clientzone)
print(date_time.data)
date_time_utc = clientzone.localize(date_time.data).astimezone(timezone('UTC')) date_time_utc = clientzone.localize(date_time.data).astimezone(timezone('UTC'))
date_time.data = date_time_utc date_time.data = date_time_utc
print(date_time.data)
def validate_game_name(self, game_name): def validate_game_name(self, game_name):
if game_name.data == '': if game_name.data == '':

7
app/main/routes.py

@ -39,12 +39,9 @@ def create_game():
form.state.choices = [(state.value, state.name) for state in GameState] form.state.choices = [(state.value, state.name) for state in GameState]
if form.validate_on_submit(): if form.validate_on_submit():
if Game.query.filter_by(name=form.game_name.data).first(): game = Game(name=form.game_name.data,
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, start_time=form.start_time.data,
end_time=form.end_time.data, end_time=form.end_time.data,
state=GameState(form.state.data)) state=GameState(form.state.data))
game.players.append(GamePlayer(user=current_user, role=Role['owner'])) game.players.append(GamePlayer(user=current_user, role=Role['owner']))
db.session.add(game) db.session.add(game)

4
app/templates/_game_player_info.html

@ -19,11 +19,11 @@
</tr> </tr>
<tr> <tr>
<th>Start Time</th> <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>
<tr> <tr>
<th>End Time</th> <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> </tr>
{% if current_user.role_in_game(game).name == 'bunny' %} {% if current_user.role_in_game(game).name == 'bunny' %}
<tr> <tr>

5
app/templates/base.html

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

30
app/templates/create_game.html

@ -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" 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 () {
'{% 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({ $('#datetimepicker_start').datetimepicker({
//useCurrent: false, //Important! See issue #1075 //useCurrent: false, //Important! See issue #1075
locale: 'en-gb', locale: 'en-gb',
format: 'DD-MM-YYYY HH:mm', format: 'DD-MM-YYYY HH:mm',
keepInvalid: true, keepInvalid: true,
sideBySide: true, sideBySide: true,
defaultDate: startDate, defaultDate: null,
timeZone: moment.tz.guess() 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({ $('#datetimepicker_end').datetimepicker({
//useCurrent: false, //Important! See issue #1075 //useCurrent: false, //Important! See issue #1075
locale: 'en-gb', locale: 'en-gb',
format: 'DD-MM-YYYY HH:mm', format: 'DD-MM-YYYY HH:mm',
keepInvalid: true, keepInvalid: true,
sideBySide: true, sideBySide: true,
defaultDate: endDate, defaultDate: null,
timeZone: moment.tz.guess() 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_start").on("dp.change", function (e) {
$('#datetimepicker_end').data("DateTimePicker").minDate(e.date); $('#datetimepicker_end').data("DateTimePicker").minDate(e.date);
}); });
@ -105,6 +102,9 @@
} }
else { else {
$(picker).data("DateTimePicker").enable(); $(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'); updateDateTimePicker('#datetimepicker_start', '#start_time_disabled');

1
app/templates/game_bunny_dashboard.html

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

1
app/templates/game_hunter_dashboard.html

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

5
app/templates/game_owner_dashboard.html

@ -19,8 +19,8 @@
</a> </a>
{% endif %} {% endif %}
<br><br> <br><br>
<p><b>Start Time: </b>{{ game.start_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>{{ game.end_time }}</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> <p><b>State: </b>{{ game.state.name.title() }}</p>
<h2>Players:</h2> <h2>Players:</h2>
<p><a href="{{ url_for('main.add_player', game_name = game.name) }}">Add player</a></p> <p><a href="{{ url_for('main.add_player', game_name = game.name) }}">Add player</a></p>
@ -98,7 +98,6 @@
{% block scripts %} {% block scripts %}
{{ super() }} {{ super() }}
{{ moment.include_moment() }}
<script type="text/javascript", crossorigin="anonymous"> <script type="text/javascript", crossorigin="anonymous">
// Leaflet Map // Leaflet Map
map = getMap() map = getMap()

1
app/templates/game_player.html

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

Loading…
Cancel
Save