diff --git a/app.py b/app.py index d36c055..874b8f5 100644 --- a/app.py +++ b/app.py @@ -427,7 +427,15 @@ def create_group(): @admin_required def manage_group(group_id): group = Group.query.get_or_404(group_id) - content = Content.query.filter(Content.player_id.in_([player.id for player in group.players])).all() + + # Get unique media files for the group + content = ( + db.session.query(Content.id, Content.file_name, db.func.min(Content.duration).label('duration')) + .filter(Content.player_id.in_([player.id for player in group.players])) + .group_by(Content.file_name) + .all() + ) + return render_template('manage_group.html', group=group, content=content) @app.route('/group//edit', methods=['GET', 'POST']) @@ -460,6 +468,38 @@ def group_fullscreen(group_id): content = Content.query.filter(Content.player_id.in_([player.id for player in group.players])).all() return render_template('group_fullscreen.html', group=group, content=content) +@app.route('/group//media//edit', methods=['POST']) +@login_required +@admin_required +def edit_group_media(group_id, content_id): + group = Group.query.get_or_404(group_id) + new_duration = int(request.form['duration']) + + # Update the duration for all players in the group + for player in group.players: + content = Content.query.filter_by(player_id=player.id, file_name=Content.query.get(content_id).file_name).first() + if content: + content.duration = new_duration + + db.session.commit() + return redirect(url_for('manage_group', group_id=group_id)) + +@app.route('/group//media//delete', methods=['POST']) +@login_required +@admin_required +def delete_group_media(group_id, content_id): + group = Group.query.get_or_404(group_id) + file_name = Content.query.get(content_id).file_name + + # Delete the media for all players in the group + for player in group.players: + content = Content.query.filter_by(player_id=player.id, file_name=file_name).first() + if content: + db.session.delete(content) + + db.session.commit() + return redirect(url_for('manage_group', group_id=group_id)) + if __name__ == '__main__': with app.app_context(): db.create_all() # Creează toate tabelele diff --git a/instance/dashboard.db b/instance/dashboard.db index bb35af4..5af911d 100644 Binary files a/instance/dashboard.db and b/instance/dashboard.db differ diff --git a/static/uploads/ESP32-C6-EVB_Rev_A.pdf b/static/uploads/ESP32-C6-EVB_Rev_A.pdf new file mode 100644 index 0000000..89ffcbb Binary files /dev/null and b/static/uploads/ESP32-C6-EVB_Rev_A.pdf differ diff --git a/static/uploads/track.png b/static/uploads/track.png new file mode 100644 index 0000000..eb097c1 Binary files /dev/null and b/static/uploads/track.png differ diff --git a/templates/manage_group.html b/templates/manage_group.html index 5808f01..a2c4925 100644 --- a/templates/manage_group.html +++ b/templates/manage_group.html @@ -52,14 +52,14 @@

Media Name: {{ media.file_name }}

-
+
seconds
-
+