software updated
This commit is contained in:
42
app.py
42
app.py
@@ -427,7 +427,15 @@ def create_group():
|
|||||||
@admin_required
|
@admin_required
|
||||||
def manage_group(group_id):
|
def manage_group(group_id):
|
||||||
group = Group.query.get_or_404(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)
|
return render_template('manage_group.html', group=group, content=content)
|
||||||
|
|
||||||
@app.route('/group/<int:group_id>/edit', methods=['GET', 'POST'])
|
@app.route('/group/<int:group_id>/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()
|
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)
|
return render_template('group_fullscreen.html', group=group, content=content)
|
||||||
|
|
||||||
|
@app.route('/group/<int:group_id>/media/<int:content_id>/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/<int:group_id>/media/<int:content_id>/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__':
|
if __name__ == '__main__':
|
||||||
with app.app_context():
|
with app.app_context():
|
||||||
db.create_all() # Creează toate tabelele
|
db.create_all() # Creează toate tabelele
|
||||||
|
|||||||
Binary file not shown.
BIN
static/uploads/ESP32-C6-EVB_Rev_A.pdf
Normal file
BIN
static/uploads/ESP32-C6-EVB_Rev_A.pdf
Normal file
Binary file not shown.
BIN
static/uploads/track.png
Normal file
BIN
static/uploads/track.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 23 KiB |
@@ -52,14 +52,14 @@
|
|||||||
<div class="flex-grow-1">
|
<div class="flex-grow-1">
|
||||||
<p class="mb-0"><strong>Media Name:</strong> {{ media.file_name }}</p>
|
<p class="mb-0"><strong>Media Name:</strong> {{ media.file_name }}</p>
|
||||||
</div>
|
</div>
|
||||||
<form action="{{ url_for('edit_content', content_id=media.id) }}" method="post" class="d-flex align-items-center">
|
<form action="{{ url_for('edit_group_media', group_id=group.id, content_id=media.id) }}" method="post" class="d-flex align-items-center">
|
||||||
<div class="input-group me-2">
|
<div class="input-group me-2">
|
||||||
<span class="input-group-text">seconds</span>
|
<span class="input-group-text">seconds</span>
|
||||||
<input type="number" class="form-control {{ 'dark-mode' if theme == 'dark' else '' }}" name="duration" value="{{ media.duration }}" required>
|
<input type="number" class="form-control {{ 'dark-mode' if theme == 'dark' else '' }}" name="duration" value="{{ media.duration }}" required>
|
||||||
</div>
|
</div>
|
||||||
<button type="submit" class="btn btn-warning me-2">Edit</button>
|
<button type="submit" class="btn btn-warning me-2">Edit</button>
|
||||||
</form>
|
</form>
|
||||||
<form action="{{ url_for('delete_content', content_id=media.id) }}" method="post" style="display:inline;">
|
<form action="{{ url_for('delete_group_media', group_id=group.id, content_id=media.id) }}" method="post" style="display:inline;">
|
||||||
<button type="submit" class="btn btn-danger" onclick="return confirm('Are you sure you want to delete this media?');">Delete</button>
|
<button type="submit" class="btn btn-danger" onclick="return confirm('Are you sure you want to delete this media?');">Delete</button>
|
||||||
</form>
|
</form>
|
||||||
</li>
|
</li>
|
||||||
|
|||||||
Reference in New Issue
Block a user