172 lines
7.4 KiB
HTML
172 lines
7.4 KiB
HTML
{% extends "base.html" %}
|
|
{% load l10n %}
|
|
{% load tz %}
|
|
|
|
{% block content %}
|
|
<div class="d-flex justify-content-between align-items-center mb-3">
|
|
<h2>Dashboard</h2>
|
|
<div>
|
|
{% if user.coached_teams.all or user.assisted_teams.all %}
|
|
<a href="{% url 'select-event-type' %}" class="btn btn-primary">Create New Event</a>
|
|
{% endif %}
|
|
</div>
|
|
</div>
|
|
|
|
<h3>Your Events</h3>
|
|
{% if events_with_participation %}
|
|
<div class="list-group">
|
|
{% for item in events_with_participation %}
|
|
<div class="list-group-item list-group-item-action flex-column align-items-start
|
|
{% if item.event.game %}
|
|
event-game
|
|
{% if user.team in item.event.game.opened_for_teams.all %}
|
|
support-game
|
|
{% endif %}
|
|
{% elif item.event.training %}
|
|
event-training
|
|
{% else %}
|
|
event-generic
|
|
{% endif %}
|
|
">
|
|
<div class="d-flex w-100 justify-content-between">
|
|
<h5 class="mb-1">
|
|
{{ item.event.title }}
|
|
{% if item.event.game.is_home_game %}
|
|
<i class="bi bi-house-door-fill"></i>
|
|
{% endif %}
|
|
</h5>
|
|
<small>{{ item.event.start_time|timezone:'Europe/Berlin'}}</small>
|
|
</div>
|
|
<p class="mb-1"><strong>Team:</strong> {{ item.event.team.name }}</p>
|
|
{% if item.event.game %}
|
|
<p class="mb-1"><strong>Opponent:</strong> {{ item.event.game.opponent }}</p>
|
|
{% if item.event.game.opened_for_teams.all %}
|
|
<p class="mb-1"><strong>Supporter Teams:</strong>
|
|
{% for team in item.event.game.opened_for_teams.all %}
|
|
{{ team.name }}{% if not forloop.last %}, {% endif %}
|
|
{% endfor %}
|
|
</p>
|
|
{% endif %}
|
|
{% endif %}
|
|
<p class="mb-1">{{ item.event.description }}</p>
|
|
<small>Location: {{ item.event.location_address }}</small>
|
|
<a href="{{ item.event.maps_shortlink }}" target="_blank" class="btn btn-secondary btn-sm">View on Map</a>
|
|
{% if user == item.event.team.head_coach or user in item.event.team.assistant_coaches.all %}
|
|
<a href="{% url 'event-update' item.event.pk %}" class="btn btn-warning btn-sm">Edit</a>
|
|
<a href="{% url 'event-delete' item.event.pk %}" class="btn btn-danger btn-sm">Delete</a>
|
|
|
|
{% if item.event.game %}
|
|
<a href="{% url 'record-results' item.event.game.id %}" class="btn btn-success btn-sm record-results-btn" style="display: none;" data-start-time="{{ item.local_start_time_iso }}">Record Results</a>
|
|
{% endif %}
|
|
{% if item.event.game and item.days_until_event >= 0 and item.days_until_event < 7 and item.accepted_count < item.required_players and item.event.team.club.teams.count > 1 %}
|
|
<a href="{% url 'open-game' item.event.game.id %}" class="btn btn-info btn-sm">Open Game</a>
|
|
{% endif %}
|
|
|
|
<div class="mt-3">
|
|
<h6>Player Participation ({{ item.accepted_count }}/{{ item.required_players }})</h6>
|
|
<div style="column-count: 3;">
|
|
<ul class="list-unstyled">
|
|
{% for p in item.player_participations %}
|
|
{% if not p.player.team in item.event.game.opened_for_teams.all or p.status != 'maybe' %}
|
|
<li class="
|
|
{% if p.status == 'attending' %}
|
|
text-success
|
|
{% elif p.status == 'rejected' %}
|
|
text-danger
|
|
{% else %} {# status is 'maybe' #}
|
|
text-warning
|
|
{% endif %}
|
|
">
|
|
{{ p.player.first_name }} {{ p.player.last_name }}
|
|
{% if p.player.team in item.event.game.opened_for_teams.all and p.status != 'maybe' %}
|
|
*
|
|
{% endif %}
|
|
</li>
|
|
{% endif %}
|
|
{% endfor %}
|
|
</ul>
|
|
</div>
|
|
</div>
|
|
{% endif %}
|
|
</div>
|
|
{% endfor %}
|
|
</div>
|
|
{% else %}
|
|
<p>No events found for you.</p>
|
|
{% endif %}
|
|
|
|
DEBUGGER: {{ mtp_debug }}
|
|
{% if children_events %}
|
|
<hr>
|
|
<h3>Your Children's Events</h3>
|
|
{% for child_data in children_events %}
|
|
<h4>{{ child_data.child.first_name }}'s Events</h4>
|
|
{% if child_data.events %}
|
|
<div class="list-group">
|
|
{% for item in child_data.events %}
|
|
<div class="list-group-item list-group-item-action flex-column align-items-start
|
|
{% if item.event.game %}
|
|
event-game
|
|
{% elif item.event.training %}
|
|
event-training
|
|
{% else %}
|
|
event-generic
|
|
{% endif %}
|
|
">
|
|
<div class="d-flex w-100 justify-content-between">
|
|
<h5 class="mb-1">
|
|
{{ item.event.title }}
|
|
{% if item.event.game.is_home_game %}
|
|
<i class="bi bi-house-door-fill"></i>
|
|
{% endif %}
|
|
</h5>
|
|
<small>{{ item.event.start_time|localize }}</small>
|
|
</div>
|
|
<p class="mb-1"><strong>Team:</strong> {{ item.event.team.name }}</p>
|
|
{% if item.event.game %}
|
|
<p class="mb-1"><strong>Opponent:</strong> {{ item.event.game.opponent }}</p>
|
|
{% endif %}
|
|
<p class="mb-1">{{ item.event.description }}</p>
|
|
<small>Location: {{ item.event.location_address }}</small>
|
|
<a href="{{ item.event.maps_shortlink }}" target="_blank" class="btn btn-secondary btn-sm">View on Map</a>
|
|
<div>
|
|
Participation: <strong>{{ item.participation.get_status_display }}</strong>
|
|
<a href="{% url 'manage-participation' child_data.child.id item.event.id 'attending' %}" class="btn btn-success btn-sm">Accept</a>
|
|
<a href="{% url 'manage-participation' child_data.child.id item.event.id 'rejected' %}" class="btn btn-danger btn-sm">Reject</a>
|
|
</div>
|
|
</div>
|
|
{% endfor %}
|
|
</div>
|
|
{% else %}
|
|
<p>No events found for {{ child_data.child.first_name }}.</p>
|
|
{% endif %}
|
|
{% endfor %}
|
|
{% endif %}
|
|
{% endblock %}
|
|
|
|
{% block javascript %}
|
|
<script>
|
|
document.addEventListener('DOMContentLoaded', function() {
|
|
console.log('DOM fully loaded and parsed');
|
|
const recordButtons = document.querySelectorAll('.record-results-btn');
|
|
console.log('Found buttons:', recordButtons.length);
|
|
const now = new Date();
|
|
console.log('Current client time:', now);
|
|
|
|
recordButtons.forEach(button => {
|
|
const startTimeString = button.dataset.startTime;
|
|
console.log('Button start time string:', startTimeString);
|
|
const startTime = new Date(startTimeString);
|
|
console.log('Button start time object:', startTime);
|
|
|
|
if (now > startTime) {
|
|
console.log('Showing button for event starting at', startTime);
|
|
button.style.display = 'inline-block';
|
|
} else {
|
|
console.log('Hiding button for event starting at', startTime);
|
|
}
|
|
});
|
|
});
|
|
</script>
|
|
{% endblock %}
|