Fix orientation parameter handling and template URL endpoints
- Add orientation parameter support to create_group and edit_group functions - Fix manage_group.html template URL endpoint from 'update_group_content_order' to 'update_group_content_order_route' - Add orientation field and filtering to edit_group.html template with JavaScript functionality - Update group_player_management.py to handle orientation validation in create and edit operations - Fix docker-compose.yml to include build directive and correct volume paths - Update entrypoint.sh to handle fresh deployments without migrations - Ensure orientation consistency across group and player management These changes resolve: - Internal Server Error on manage_group page - Missing orientation parameter in group creation/editing - Template URL endpoint mismatches - Docker deployment issues with fresh installations
This commit is contained in:
@@ -49,12 +49,24 @@
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-6 col-12">
|
||||
<div class="mb-3">
|
||||
<label for="orientation" class="form-label">Group Orientation</label>
|
||||
<select class="form-control {{ 'dark-mode' if theme == 'dark' else '' }}" id="orientation" name="orientation" required>
|
||||
<option value="Landscape" {% if group.orientation == 'Landscape' %}selected{% endif %}>Landscape</option>
|
||||
<option value="Portret" {% if group.orientation == 'Portret' %}selected{% endif %}>Portret</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- Add this above the player selection -->
|
||||
<div class="alert alert-warning" role="alert">
|
||||
<strong>Warning:</strong> Adding new players to this group will delete their individual playlists.
|
||||
Removing players from the group will allow them to have their own playlists again.
|
||||
</div>
|
||||
<div id="orientation-warning" class="alert alert-danger d-none" role="alert">
|
||||
No players with the selected orientation are available.
|
||||
</div>
|
||||
<div class="text-center">
|
||||
<button type="submit" class="btn btn-primary">Save Changes</button>
|
||||
<a href="{{ url_for('dashboard') }}" class="btn btn-secondary mt-3">Back to Dashboard</a>
|
||||
@@ -62,5 +74,45 @@
|
||||
</form>
|
||||
</div>
|
||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha3/dist/js/bootstrap.bundle.min.js"></script>
|
||||
<script>
|
||||
// Get all players and their orientations from the backend
|
||||
const players = [
|
||||
{% for player in players %}
|
||||
{id: {{ player.id }}, username: "{{ player.username }}", orientation: "{{ player.orientation }}", inGroup: {% if player in group.players %}true{% else %}false{% endif %}},
|
||||
{% endfor %}
|
||||
];
|
||||
|
||||
const orientationSelect = document.getElementById('orientation');
|
||||
const playersSelect = document.getElementById('players');
|
||||
const orientationWarning = document.getElementById('orientation-warning');
|
||||
|
||||
function filterPlayers() {
|
||||
const selectedOrientation = orientationSelect.value;
|
||||
const currentSelection = Array.from(playersSelect.selectedOptions).map(option => option.value);
|
||||
playersSelect.innerHTML = '';
|
||||
let compatibleCount = 0;
|
||||
|
||||
players.forEach(player => {
|
||||
if (player.orientation === selectedOrientation) {
|
||||
const option = document.createElement('option');
|
||||
option.value = player.id;
|
||||
option.textContent = player.username;
|
||||
// Re-select if it was previously selected
|
||||
if (currentSelection.includes(player.id.toString()) || player.inGroup) {
|
||||
option.selected = true;
|
||||
}
|
||||
playersSelect.appendChild(option);
|
||||
compatibleCount++;
|
||||
}
|
||||
});
|
||||
|
||||
orientationWarning.classList.toggle('d-none', compatibleCount > 0);
|
||||
}
|
||||
|
||||
orientationSelect.addEventListener('change', filterPlayers);
|
||||
|
||||
// Initial filter on page load
|
||||
filterPlayers();
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -189,7 +189,7 @@ document.addEventListener('DOMContentLoaded', function() {
|
||||
});
|
||||
|
||||
// Send to server
|
||||
fetch('{{ url_for("update_group_content_order", group_id=group.id) }}', {
|
||||
fetch('{{ url_for("update_group_content_order_route", group_id=group.id) }}', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
|
||||
Reference in New Issue
Block a user