add media upload functionality and management interface
This commit is contained in:
5
.vscode/extensions.json
vendored
Normal file
5
.vscode/extensions.json
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"recommendations": [
|
||||
"github.copilot"
|
||||
]
|
||||
}
|
||||
20
app.py
20
app.py
@@ -114,8 +114,24 @@ def logout():
|
||||
@admin_required
|
||||
def upload_content():
|
||||
if request.method == 'POST':
|
||||
# Handle file upload logic here
|
||||
pass
|
||||
target_type = request.form['target_type']
|
||||
target_id = int(request.form['target_id'])
|
||||
files = request.files.getlist('files')
|
||||
duration = int(request.form['duration'])
|
||||
return_url = request.form['return_url']
|
||||
|
||||
for file in files:
|
||||
filename = secure_filename(file.filename)
|
||||
file_path = os.path.join(app.config['UPLOAD_FOLDER'], filename)
|
||||
file.save(file_path)
|
||||
if target_type == 'player':
|
||||
new_content = Content(file_name=filename, duration=duration, player_id=target_id)
|
||||
elif target_type == 'group':
|
||||
new_content = Content(file_name=filename, duration=duration, group_id=target_id)
|
||||
db.session.add(new_content)
|
||||
|
||||
db.session.commit()
|
||||
return redirect(return_url)
|
||||
|
||||
target_type = request.args.get('target_type')
|
||||
target_id = request.args.get('target_id')
|
||||
|
||||
Binary file not shown.
BIN
static/uploads/Ibex_450.jpg
Normal file
BIN
static/uploads/Ibex_450.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 148 KiB |
BIN
static/uploads/cropped-cropped-main-picture-scaled-1.jpeg
Normal file
BIN
static/uploads/cropped-cropped-main-picture-scaled-1.jpeg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 410 KiB |
@@ -17,12 +17,12 @@
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body class="{{ 'dark-mode' if theme == 'dark' else '' }}">
|
||||
<body class="{% if theme == 'dark' %}dark-mode{% endif %}">
|
||||
<div class="container py-5">
|
||||
<h1 class="text-center mb-4">Player Schedule for {{ player.username }}</h1>
|
||||
|
||||
<!-- Player Info Section -->
|
||||
<div class="card mb-4 {{ 'dark-mode' if theme == 'dark' else '' }}">
|
||||
<div class="card mb-4 {% if theme == 'dark' %}dark-mode{% endif %}">
|
||||
<div class="card-header bg-info text-white">
|
||||
<h2>Player Info</h2>
|
||||
</div>
|
||||
@@ -45,7 +45,7 @@
|
||||
<h4 class="text-center">Member of Group(s):</h4>
|
||||
<ul class="list-group">
|
||||
{% for group in player.groups %}
|
||||
<li class="list-group-item {{ 'dark-mode' if theme == 'dark' else '' }}">{{ group.name }}</li>
|
||||
<li class="list-group-item {% if theme == 'dark' %}dark-mode{% endif %}">{{ group.name }}</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
{% else %}
|
||||
@@ -53,15 +53,41 @@
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
<!-- Replace Upload Content Card with Button -->
|
||||
<!-- Media Management Section -->
|
||||
{% if current_user.role == 'admin' %}
|
||||
<div class="text-center mb-4">
|
||||
<a href="{{ url_for('upload_content', target_type='player', target_id=player.id, return_url=request.url) }}" class="btn btn-primary">Upload Content</a>
|
||||
<div class="card mb-4 {% if theme == 'dark' %}dark-mode{% endif %}">
|
||||
<div class="card-header bg-info text-white">
|
||||
<h2>Manage Media</h2>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
{% if content %}
|
||||
<ul class="list-group">
|
||||
{% for media in content %}
|
||||
<li class="list-group-item {% if theme == 'dark' %}dark-mode{% endif %}">
|
||||
<p><strong>Media Name:</strong> {{ media.file_name }}</p>
|
||||
<p><strong>Duration:</strong> {{ media.duration }} minutes</p>
|
||||
<form action="{{ url_for('edit_content', content_id=media.id) }}" method="post" style="display:inline;">
|
||||
<div class="input-group mb-3">
|
||||
<input type="number" class="form-control" name="duration" value="{{ media.duration }}" required>
|
||||
<button type="submit" class="btn btn-warning">Edit</button>
|
||||
</div>
|
||||
</form>
|
||||
<form action="{{ url_for('delete_content', 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>
|
||||
</form>
|
||||
</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
{% else %}
|
||||
<p class="text-center">No media uploaded for this player.</p>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
<a href="{{ url_for('dashboard') }}" class="btn btn-secondary">Back to Dashboard</a>
|
||||
<a href="{{ url_for('player_fullscreen', player_id=player.id) }}" class="btn btn-primary">Full Screen</a>
|
||||
<a href="{{ url_for('upload_content', target_type='player', target_id=player.id, return_url=url_for('player_page', player_id=player.id)) }}" class="btn btn-success">Upload Media</a>
|
||||
</div>
|
||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha3/dist/js/bootstrap.bundle.min.js"></script>
|
||||
</body>
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
<div class="container py-5">
|
||||
<h1 class="text-center mb-4">Upload Content</h1>
|
||||
<form method="POST" enctype="multipart/form-data">
|
||||
<input type="hidden" name="return_url" value="{{ return_url }}">
|
||||
<div class="mb-3">
|
||||
<label for="target_type" class="form-label">Target Type:</label>
|
||||
<select name="target_type" id="target_type" class="form-select" required {% if target_type %}disabled{% endif %}>
|
||||
|
||||
Reference in New Issue
Block a user