Add content assets for cataloging uploaded files
ContentAsset records metadata (kind, title, description, release date, season/episode/sequence) for an UploadedAsset, scoped to a studio. ContentGroup groups episodes into a series or movies into a collection. The studio page now has tabs for uploaded files and content, both loaded with htmx. Files without content get a "Create content" button. Content opens read-only with an Edit button; the form shows immediately when a save fails validation. Also adds the draft job status to the migration. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
d73dddc3d9
commit
3fe49b47ea
@@ -0,0 +1,75 @@
|
||||
{% extends "privatestudio/base.html" %}
|
||||
|
||||
{% block content %}
|
||||
<nav aria-label="breadcrumb">
|
||||
<ol class="breadcrumb">
|
||||
<li class="breadcrumb-item"><a href="{% url 'studio:detail' studio.bucket_name %}?tab=content">{{ studio.name }}</a></li>
|
||||
<li class="breadcrumb-item active" aria-current="page">{{ content_asset.title }}</li>
|
||||
</ol>
|
||||
</nav>
|
||||
|
||||
<h1>{{ content_asset.title }}</h1>
|
||||
|
||||
<dl class="row">
|
||||
<dt class="col-sm-3">File</dt>
|
||||
<dd class="col-sm-9">{{ content_asset.uploaded_asset.s3_path }}</dd>
|
||||
<dt class="col-sm-3">Size (bytes)</dt>
|
||||
<dd class="col-sm-9">{{ content_asset.uploaded_asset.size }}</dd>
|
||||
<dt class="col-sm-3">Uploaded</dt>
|
||||
<dd class="col-sm-9">{{ content_asset.uploaded_asset.upload_timestamp }}</dd>
|
||||
<dt class="col-sm-3">Last updated</dt>
|
||||
<dd class="col-sm-9">{{ content_asset.updated_at }}</dd>
|
||||
</dl>
|
||||
|
||||
{% with editing=form.errors %}
|
||||
{% if not editing %}
|
||||
<div id="content-details" class="collapse show content-edit-toggle">
|
||||
<dl class="row">
|
||||
<dt class="col-sm-3">Kind</dt>
|
||||
<dd class="col-sm-9">{{ content_asset.get_kind_display }}</dd>
|
||||
<dt class="col-sm-3">Title</dt>
|
||||
<dd class="col-sm-9">{{ content_asset.title }}</dd>
|
||||
<dt class="col-sm-3">Description</dt>
|
||||
<dd class="col-sm-9">{{ content_asset.description|linebreaksbr|default:"—" }}</dd>
|
||||
<dt class="col-sm-3">Release date</dt>
|
||||
<dd class="col-sm-9">{{ content_asset.release_date|default:"—" }}</dd>
|
||||
<dt class="col-sm-3">Series / Collection</dt>
|
||||
<dd class="col-sm-9">{{ content_asset.group|default:"—" }}</dd>
|
||||
{% if content_asset.season_number is not None or content_asset.episode_number is not None %}
|
||||
<dt class="col-sm-3">Season</dt>
|
||||
<dd class="col-sm-9">{{ content_asset.season_number|default:"—" }}</dd>
|
||||
<dt class="col-sm-3">Episode</dt>
|
||||
<dd class="col-sm-9">{{ content_asset.episode_number|default:"—" }}</dd>
|
||||
{% endif %}
|
||||
{% if content_asset.sequence_number is not None %}
|
||||
<dt class="col-sm-3">Sequence</dt>
|
||||
<dd class="col-sm-9">{{ content_asset.sequence_number }}</dd>
|
||||
{% endif %}
|
||||
</dl>
|
||||
<button type="button" class="btn btn-primary" data-bs-toggle="collapse" data-bs-target=".content-edit-toggle" aria-controls="content-details content-form">Edit</button>
|
||||
<a href="{% url 'studio:detail' studio.bucket_name %}?tab=content" class="btn btn-link">Back to content</a>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
<form id="content-form" method="post" novalidate{% if not editing %} class="collapse content-edit-toggle"{% endif %}>
|
||||
{% csrf_token %}
|
||||
{% for error in form.non_field_errors %}
|
||||
<div class="alert alert-danger">{{ error }}</div>
|
||||
{% endfor %}
|
||||
{% for field in form %}
|
||||
<div class="mb-3">
|
||||
<label for="{{ field.id_for_label }}" class="form-label">{{ field.label }}</label>
|
||||
{{ field }}
|
||||
{% if field.help_text %}<div class="form-text">{{ field.help_text }}</div>{% endif %}
|
||||
{% for error in field.errors %}<div class="invalid-feedback d-block">{{ error }}</div>{% endfor %}
|
||||
</div>
|
||||
{% endfor %}
|
||||
<button type="submit" class="btn btn-primary">Save</button>
|
||||
{% if editing %}
|
||||
<a href="{{ request.path }}" class="btn btn-secondary">Cancel</a>
|
||||
{% else %}
|
||||
<button type="button" class="btn btn-secondary" data-bs-toggle="collapse" data-bs-target=".content-edit-toggle" aria-controls="content-details content-form">Cancel</button>
|
||||
{% endif %}
|
||||
</form>
|
||||
{% endwith %}
|
||||
{% endblock %}
|
||||
@@ -0,0 +1,30 @@
|
||||
<table class="table table-striped table-sm align-middle">
|
||||
<tr>
|
||||
<th>Title</th>
|
||||
<th>Kind</th>
|
||||
<th>Series / Collection</th>
|
||||
<th>Position</th>
|
||||
<th>Release Date</th>
|
||||
<th>File</th>
|
||||
</tr>
|
||||
{% for content in content_assets %}
|
||||
<tr>
|
||||
<td><a href="{% url 'studio:content_asset' studio.bucket_name content.pk %}">{{ content.title }}</a></td>
|
||||
<td>{{ content.get_kind_display }}</td>
|
||||
<td>{{ content.group.title|default:"" }}</td>
|
||||
<td>
|
||||
{% if content.season_number or content.episode_number %}
|
||||
{% if content.season_number %}S{{ content.season_number }}{% endif %}{% if content.episode_number %}E{{ content.episode_number }}{% endif %}
|
||||
{% elif content.sequence_number %}
|
||||
#{{ content.sequence_number }}
|
||||
{% endif %}
|
||||
</td>
|
||||
<td>{{ content.release_date|default:"" }}</td>
|
||||
<td>{{ content.uploaded_asset.s3_path }}</td>
|
||||
</tr>
|
||||
{% empty %}
|
||||
<tr>
|
||||
<td colspan="6">No content yet. Use "Create content" on an uploaded file.</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</table>
|
||||
@@ -1,21 +1,32 @@
|
||||
<table class="table table-striped table-sm">
|
||||
<table class="table table-striped table-sm align-middle">
|
||||
<tr>
|
||||
<th>File Name</th>
|
||||
<th>Size (bytes)</th>
|
||||
<th>Upload Timestamp</th>
|
||||
<th>Content</th>
|
||||
</tr>
|
||||
{% for asset in uploaded_assets %}
|
||||
<tr>
|
||||
<td>{{ asset.s3_path }}</td>
|
||||
<td>{{ asset.size }}</td>
|
||||
<td>{{ asset.upload_timestamp }}</td>
|
||||
<td>
|
||||
{% if asset.content_asset_id %}
|
||||
<a href="{% url 'studio:content_asset' asset.studio.bucket_name asset.content_asset_id %}">View content</a>
|
||||
{% else %}
|
||||
<form method="post" action="{% url 'studio:content_asset_create' asset.studio.bucket_name asset.id %}" hx-boost="false" class="m-0">
|
||||
{% csrf_token %}
|
||||
<button type="submit" class="btn btn-outline-primary btn-sm">Create content</button>
|
||||
</form>
|
||||
{% endif %}
|
||||
</td>
|
||||
</tr>
|
||||
<tr style="display:none;" id="asset_{{ asset.id }}">
|
||||
<td colspan="3">Click to refresh</td>
|
||||
<td colspan="4">Click to refresh</td>
|
||||
</tr>
|
||||
{% empty %}
|
||||
<tr>
|
||||
<td colspan="3">No uploaded assets found.</td>
|
||||
<td colspan="4">No uploaded assets found.</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</table>
|
||||
</table>
|
||||
|
||||
@@ -5,10 +5,30 @@
|
||||
<p>Bucket Name: {{ studio.bucket_name }}</p>
|
||||
<p>Group: {{ studio.group.name }}</p>
|
||||
|
||||
<div id="uploaded_assets" hx-get="{% url 'studio:uploaded_assets' studio.bucket_name %}" hx-trigger="load, assets-changed from:body" hx-target="#uploaded_assets" hx-swap="innerHTML">
|
||||
<p>Loading uploaded assets...</p>
|
||||
</div>
|
||||
{% with content_tab=request.GET.tab %}
|
||||
<ul class="nav nav-tabs mb-3" role="tablist">
|
||||
<li class="nav-item" role="presentation">
|
||||
<button class="nav-link{% if content_tab != 'content' %} active{% endif %}" id="files-tab" data-bs-toggle="tab" data-bs-target="#files-pane" type="button" role="tab" aria-controls="files-pane" aria-selected="{% if content_tab != 'content' %}true{% else %}false{% endif %}">Uploaded files</button>
|
||||
</li>
|
||||
<li class="nav-item" role="presentation">
|
||||
<button class="nav-link{% if content_tab == 'content' %} active{% endif %}" id="content-tab" data-bs-toggle="tab" data-bs-target="#content-pane" type="button" role="tab" aria-controls="content-pane" aria-selected="{% if content_tab == 'content' %}true{% else %}false{% endif %}">Content</button>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
{% include "privatestudio/_file_uploader.html" %}
|
||||
<div class="tab-content">
|
||||
<div class="tab-pane fade{% if content_tab != 'content' %} show active{% endif %}" id="files-pane" role="tabpanel" aria-labelledby="files-tab" tabindex="0">
|
||||
<div id="uploaded_assets" hx-get="{% url 'studio:uploaded_assets' studio.bucket_name %}" hx-trigger="load, assets-changed from:body" hx-target="#uploaded_assets" hx-swap="innerHTML">
|
||||
<p>Loading uploaded assets...</p>
|
||||
</div>
|
||||
|
||||
{% include "privatestudio/_file_uploader.html" %}
|
||||
</div>
|
||||
<div class="tab-pane fade{% if content_tab == 'content' %} show active{% endif %}" id="content-pane" role="tabpanel" aria-labelledby="content-tab" tabindex="0">
|
||||
<div id="content_assets" hx-get="{% url 'studio:content_assets' studio.bucket_name %}" hx-trigger="load, assets-changed from:body" hx-target="#content_assets" hx-swap="innerHTML">
|
||||
<p>Loading content...</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endwith %}
|
||||
|
||||
{% endblock %}
|
||||
|
||||
Reference in New Issue
Block a user