Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/core/templatetags/media_tags.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
}


@register.inclusion_tag("partials/media-icon.html")
@register.inclusion_tag("partials/media_items/media_icon.html")
def media_icon(media_type, size="sm"):
"""
Render a heroicon based on media type.
Expand Down
22 changes: 12 additions & 10 deletions src/core/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@
def index(request):
"""Main view for displaying media list."""
context = build_media_context(request)
return render(request, "media.html", context)
return render(request, "base/media_index.html", context)
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot Jan 6, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash

echo "=== Checking if new template files exist ==="
new_templates=(
  "src/core/templates/base/media_index.html"
  "src/core/templates/base/media_detail.html"
  "src/core/templates/base/media_edit.html"
  "src/core/templates/base/backup_manage.html"
  "src/core/templates/partials/media_items/media_list_page.html"
  "src/core/templates/partials/contributors/contributors_suggestions.html"
  "src/core/templates/partials/contributors/contributor_chip.html"
  "src/core/templates/partials/media_items/media_review_clamped.html"
  "src/core/templates/partials/media_items/media_review_full.html"
)

missing_count=0
for template in "${new_templates[@]}"; do
  if [ ! -f "$template" ]; then
    echo "❌ MISSING: $template"
    ((missing_count++))
  else
    echo "✅ EXISTS: $template"
  fi
done

if [ $missing_count -eq 0 ]; then
  echo -e "\n✅ All new templates exist"
else
  echo -e "\n❌ $missing_count template(s) missing"
fi

echo -e "\n=== Checking for references to old template paths ==="
old_paths=(
  'media\.html'
  'media_detail\.html'
  'media_edit\.html'
  'backup_manage\.html'
  'partials/media-items-page\.html'
  'partials/contributors-suggestions\.html'
  'partials/contributor-chip\.html'
  'partials/media-review-clamped\.html'
  'partials/media-review-full\.html'
)

found_old_refs=0
for old_path in "${old_paths[@]}"; do
  matches=$(rg "$old_path" --type py --type html 2>/dev/null | grep -v "src/core/views.py" || true)
  if [ -n "$matches" ]; then
    echo "⚠️  Found references to old path pattern '$old_path':"
    echo "$matches" | head -10
    ((found_old_refs++))
  fi
done

if [ $found_old_refs -eq 0 ]; then
  echo "✅ No stale references to old template paths found"
else
  echo -e "\n⚠️  Found references to $found_old_refs old path pattern(s)"
fi

Repository: PascalRepond/datakult

Length of output: 1171


All new template files are missing. The views have been updated to reference new template paths, but the actual template files do not exist:

  • src/core/templates/base/media_index.html
  • src/core/templates/base/media_detail.html
  • src/core/templates/base/media_edit.html
  • src/core/templates/base/backup_manage.html
  • src/core/templates/partials/media_items/media_list_page.html
  • src/core/templates/partials/contributors/contributors_suggestions.html
  • src/core/templates/partials/contributors/contributor_chip.html
  • src/core/templates/partials/media_items/media_review_clamped.html
  • src/core/templates/partials/media_items/media_review_full.html

These changes will cause TemplateDoesNotExist exceptions at runtime. Either create the template files at these locations or revert the template path references.

🤖 Prompt for AI Agents
In @src/core/views.py at line 23, Views are referencing new template paths (e.g.
the render call using "base/media_index.html" in functions that render media
index/detail/edit and backup_manage, plus partials like
"partials/media_items/media_list_page.html" and contributor partials) but those
files are missing causing TemplateDoesNotExist; fix by either adding the missing
template files at src/core/templates/base/ and src/core/templates/partials/...
with the expected block structure and names used by the view functions (create
media_index.html, media_detail.html, media_edit.html, backup_manage.html and the
listed partials) or revert each view's render() template argument back to the
previous existing template names (locate calls to render(request, "...") in the
view functions that reference the new paths and update them accordingly) so
runtime template lookups succeed.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Those files are in src/templates/...

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash

echo "=== Checking if template files exist in src/templates/ ==="
templates=(
  "src/templates/base/media_index.html"
  "src/templates/base/media_detail.html"
  "src/templates/base/media_edit.html"
  "src/templates/base/backup_manage.html"
  "src/templates/partials/media_items/media_list_page.html"
  "src/templates/partials/contributors/contributors_suggestions.html"
  "src/templates/partials/contributors/contributor_chip.html"
  "src/templates/partials/media_items/media_review_clamped.html"
  "src/templates/partials/media_items/media_review_full.html"
)

missing_count=0
for template in "${templates[@]}"; do
  if [ ! -f "$template" ]; then
    echo "❌ MISSING: $template"
    ((missing_count++))
  else
    echo "✅ EXISTS: $template"
  fi
done

if [ $missing_count -eq 0 ]; then
  echo -e "\n✅ All templates exist in src/templates/"
else
  echo -e "\n⚠️ $missing_count template(s) still missing"
fi

Length of output: 634


@PascalRepond, you're absolutely right! I apologize for the incorrect analysis. All the template files exist in src/templates/:

src/templates/base/media_index.html
src/templates/base/media_detail.html
src/templates/base/media_edit.html
src/templates/base/backup_manage.html
src/templates/partials/media_items/media_list_page.html
src/templates/partials/contributors/contributors_suggestions.html
src/templates/partials/contributors/contributor_chip.html
src/templates/partials/media_items/media_review_clamped.html
src/templates/partials/media_items/media_review_full.html

The template reorganization is correctly implemented. Django's template loader will find these files in the configured template directory.


✏️ Learnings added
Learnt from: PascalRepond
Repo: PascalRepond/datakult PR: 44
File: src/core/views.py:23-23
Timestamp: 2026-01-06T15:18:30.011Z
Learning: In the datakult repository, Django templates are located in `src/templates/`, not `src/core/templates/`. The Django TEMPLATES setting is configured to load templates from this directory.

Note: Learnings are effective only in the context of similar code segments. To apply general coding guidelines, please configure review instructions. You can manage existing learnings in the app.



@login_required
def media_detail(request, pk):
"""Display detailed view of a single media item."""
media = get_object_or_404(Media, pk=pk)
context = {"media": media}
return render(request, "media_detail.html", context)
return render(request, "base/media_detail.html", context)


@login_required
Expand Down Expand Up @@ -67,7 +67,7 @@ def media_edit(request, pk=None):
else:
form = MediaForm(instance=media)
context = {"media": media, "form": form}
return render(request, "media_edit.html", context)
return render(request, "base/media_edit.html", context)


@login_required
Expand All @@ -88,14 +88,14 @@ def load_more_media(request):
context = build_media_context(request)

# Return only the items + load more button
return render(request, "partials/media-items-page.html", context)
return render(request, "partials/media_items/media_list_page.html", context)


@login_required
def agent_search_htmx(request):
query = request.GET.get("q", "").strip()
agents = Agent.objects.filter(name__icontains=query).order_by("name")[:12] if query else []
return render(request, "partials/contributors-suggestions.html", {"agents": agents})
return render(request, "partials/contributors/contributors_suggestions.html", {"agents": agents})


@login_required
Expand All @@ -104,23 +104,25 @@ def agent_select_htmx(request):
agent_id = request.POST.get("id")
try:
agent = Agent.objects.get(pk=agent_id)
return render(request, "partials/contributor-chip.html", {"agent": agent})
return render(request, "partials/contributors/contributor_chip.html", {"agent": agent})
except Agent.DoesNotExist:
return render(request, "partials/contributor-chip.html", {"agent": None, "error": "Agent not found"})
return render(
request, "partials/contributors/contributor_chip.html", {"agent": None, "error": "Agent not found"}
)


@login_required
def media_review_clamped_htmx(request, pk):
"""HTMX view: return clamped review for a media item (for table cell collapse)."""
media = get_object_or_404(Media, pk=pk)
return render(request, "partials/media-review-clamped.html", {"media": media})
return render(request, "partials/media_items/media_review_clamped.html", {"media": media})


@login_required
def media_review_full_htmx(request, pk):
"""HTMX view: return full review for a media item (for table cell expansion)."""
media = get_object_or_404(Media, pk=pk)
return render(request, "partials/media-review-full.html", {"media": media})
return render(request, "partials/media_items/media_review_full.html", {"media": media})


@login_required
Expand Down Expand Up @@ -186,4 +188,4 @@ def backup_import(request):
@login_required
def backup_manage(request):
"""Display backup management page."""
return render(request, "backup_manage.html")
return render(request, "base/backup_manage.html")
10 changes: 5 additions & 5 deletions src/templates/accounts/profile_edit.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{% extends "base.html" %}
{% extends "base/base.html" %}
{% load i18n %}
{% block title %}
{% translate "Edit Profile" %} - Datakult
Expand All @@ -22,7 +22,7 @@ <h2 class="card-title">{% translate "Profile Information" %}</h2>
<input type="hidden" name="update_profile" value="1">
<div class="form-control">
<label class="label" for="id_username">
{% include "partials/field_label.html" with label=_("Username") field=profile_form.username %}
{% include "partials/common/field_label.html" with label=_("Username") field=profile_form.username %}
</label>
{{ profile_form.username }}
<label class="label" id="error-username">
Expand All @@ -33,7 +33,7 @@ <h2 class="card-title">{% translate "Profile Information" %}</h2>
</div>
<div class="form-control">
<label class="label" for="id_email">
{% include "partials/field_label.html" with label=_("Email") field=profile_form.email %}
{% include "partials/common/field_label.html" with label=_("Email") field=profile_form.email %}
</label>
{{ profile_form.email }}
<label class="label" id="error-email">
Expand All @@ -44,7 +44,7 @@ <h2 class="card-title">{% translate "Profile Information" %}</h2>
</div>
<div class="form-control">
<label class="label" for="id_first_name">
{% include "partials/field_label.html" with label=_("First name") field=profile_form.first_name %}
{% include "partials/common/field_label.html" with label=_("First name") field=profile_form.first_name %}
</label>
{{ profile_form.first_name }}
<label class="label" id="error-first_name">
Expand All @@ -55,7 +55,7 @@ <h2 class="card-title">{% translate "Profile Information" %}</h2>
</div>
<div class="form-control">
<label class="label" for="id_last_name">
{% include "partials/field_label.html" with label=_("Last name") field=profile_form.last_name %}
{% include "partials/common/field_label.html" with label=_("Last name") field=profile_form.last_name %}
</label>
{{ profile_form.last_name }}
<label class="label" id="error-last_name">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{% extends "base.html" %}
{% extends "base/base.html" %}
{% load static %}
{% load i18n %}
{% block title %}
Expand Down Expand Up @@ -154,7 +154,7 @@ <h4 class="font-semibold mb-1">💡 {% translate "Best Practices" %}</h4>
</div>
</div>
{# Confirmation modal for backup import #}
{% include "partials/confirm-modal.html" with modal_id="confirm-import-modal" title=_("⚠️ WARNING: Destructive Action") message=_("This action will DELETE ALL your current data and replace it with the backup data. Are you absolutely sure you want to continue?") confirm_text=_("Yes, import backup") is_danger=True form_id="import-backup-form" %}
{% include "partials/common/confirm_modal.html" with modal_id="confirm-import-modal" title=_("⚠️ WARNING: Destructive Action") message=_("This action will DELETE ALL your current data and replace it with the backup data. Are you absolutely sure you want to continue?") confirm_text=_("Yes, import backup") is_danger=True form_id="import-backup-form" %}
<script>
async function downloadBackup(btn) {
btn.classList.add('loading');
Expand Down
2 changes: 1 addition & 1 deletion src/templates/base.html → src/templates/base/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
<label for="sidebar-drawer"
aria-label="Close sidebar"
class="drawer-overlay"></label>
{% include 'partials/sidebar-nav.html' %}
{% include 'partials/navigation/sidebar_nav.html' %}
</div>
</div>
<script src="{% static 'js/base.js' %}"></script>
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{% extends "base.html" %}
{% extends "base/base.html" %}
{% load i18n %}
{% load media_tags %}
{% block title %}
Expand Down Expand Up @@ -51,7 +51,9 @@ <h1 class="text-4xl font-bold">
{% if media.contributors.all %}
<div class="flex items-center gap-2 flex-wrap">
{% heroicon_mini "user" class="opacity-50 shrink-0" %}
<div class="flex flex-wrap gap-1">{% include "partials/media-contributors.html" with use_htmx=False %}</div>
<div class="flex flex-wrap gap-1">
{% include "partials/media_items/media_contributors.html" with use_htmx=False %}
</div>
</div>
{% endif %}
{# External link #}
Expand All @@ -75,11 +77,11 @@ <h1 class="text-4xl font-bold">
<div class="flex flex-col gap-4">
{# Score with stars #}
{% if media.score %}
<div>{% include "partials/media-score-stars.html" %}</div>
<div>{% include "partials/media_items/score/media_score_stars.html" %}</div>
{% endif %}
{# Status and Review date #}
<div class="flex flex-wrap gap-4 items-center">
<div class="flex items-center gap-2">{% include "partials/media-status-badge.html" %}</div>
<div class="flex items-center gap-2">{% include "partials/media_items/media_status_badge.html" %}</div>
{% if media.review_date %}
<div class="flex items-center gap-2 text-sm opacity-70">
{% heroicon_mini "calendar" %}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{% extends "base.html" %}
{% extends "base/base.html" %}
{% load i18n %}
{% load static %}
{% block title %}
Expand Down Expand Up @@ -51,7 +51,7 @@ <h1 class="text-4xl font-bold">
<div class="card-body p-4">
<div class="form-control">
<label class="label" for="id_cover">
{% include "partials/field_label.html" with label=_("Cover image") field=form.cover %}
{% include "partials/common/field_label.html" with label=_("Cover image") field=form.cover %}
</label>
{{ form.cover }}
<label class="label" id="error-cover">
Expand All @@ -65,7 +65,7 @@ <h1 class="text-4xl font-bold">
<div class="card-body p-4 space-y-2">
<div class="form-control">
<label class="label" for="id_title">
{% include "partials/field_label.html" with label=_("Title") field=form.title %}
{% include "partials/common/field_label.html" with label=_("Title") field=form.title %}
</label>
{{ form.title }}
<label class="label" id="error-title">
Expand All @@ -74,11 +74,11 @@ <h1 class="text-4xl font-bold">
</div>
<div class="form-control">
<label class="label" for="id_contributors">
{% include "partials/field_label.html" with label=_("Contributors") field=form.contributors %}
{% include "partials/common/field_label.html" with label=_("Contributors") field=form.contributors %}
</label>
<div id="contributors-chips" class="flex flex-wrap gap-2 mb-2">
{% for contributor in media.contributors.all %}
{% include "partials/contributor-chip.html" with agent=contributor %}
{% include "partials/contributors/contributor_chip.html" with agent=contributor %}
{% endfor %}
</div>
<div class="relative">
Expand All @@ -103,7 +103,7 @@ <h1 class="text-4xl font-bold">
</div>
<div class="form-control">
<label class="label" for="id_media_type">
{% include "partials/field_label.html" with label=_("Media type") field=form.media_type %}
{% include "partials/common/field_label.html" with label=_("Media type") field=form.media_type %}
</label>
{{ form.media_type }}
<label class="label" id="error-media_type">
Expand All @@ -114,7 +114,7 @@ <h1 class="text-4xl font-bold">
</div>
<div class="form-control">
<label class="label" for="id_pub_year">
{% include "partials/field_label.html" with label=_("Release year") field=form.pub_year %}
{% include "partials/common/field_label.html" with label=_("Release year") field=form.pub_year %}
</label>
{{ form.pub_year }}
<label class="label" id="error-pub_year">
Expand All @@ -123,7 +123,7 @@ <h1 class="text-4xl font-bold">
</div>
<div class="form-control">
<label class="label" for="id_external_uri">
{% include "partials/field_label.html" with label=_("External URI") field=form.external_uri %}
{% include "partials/common/field_label.html" with label=_("External URI") field=form.external_uri %}
</label>
{{ form.external_uri }}
<label class="label" id="error-external_uri">
Expand All @@ -142,7 +142,7 @@ <h1 class="text-4xl font-bold">
<div class="card-body p-4 space-y-2">
<div class="form-control">
<label class="label" for="id_score">
{% include "partials/field_label.html" with label=_("Score") field=form.score %}
{% include "partials/common/field_label.html" with label=_("Score") field=form.score %}
</label>
{{ form.score }}
<label class="label" id="error-score">
Expand All @@ -152,7 +152,7 @@ <h1 class="text-4xl font-bold">
<div class="grid grid-cols-1 sm:grid-cols-2 gap-4">
<div class="form-control">
<label class="label" for="id_status">
{% include "partials/field_label.html" with label=_("Status") field=form.status %}
{% include "partials/common/field_label.html" with label=_("Status") field=form.status %}
</label>
{{ form.status }}
<label class="label" id="error-status">
Expand All @@ -161,7 +161,7 @@ <h1 class="text-4xl font-bold">
</div>
<div class="form-control">
<label class="label" for="id_review_date">
<span>{% include "partials/field_label.html" with label=_("Review date") field=form.review_date %}</span>
<span>{% include "partials/common/field_label.html" with label=_("Review date") field=form.review_date %}</span>
<button type="button"
id="set-today-btn"
class="btn btn-xs btn-ghost gap-1"
Expand All @@ -185,7 +185,7 @@ <h1 class="text-4xl font-bold">
<div class="card-body p-4">
<div class="form-control">
<label class="label" for="id_review">
{% include "partials/field_label.html" with label=_("Review") field=form.review %}
{% include "partials/common/field_label.html" with label=_("Review") field=form.review %}
</label>
{{ form.review }}
<label class="label" id="error-review">
Expand Down Expand Up @@ -216,7 +216,7 @@ <h1 class="text-4xl font-bold">
{% csrf_token %}
</form>
{# Confirmation modal for media deletion #}
{% include "partials/confirm-modal.html" with modal_id="confirm-delete-modal" title=_("Delete Media") message=_("Are you sure you want to delete this media? This action cannot be undone.") confirm_text=_("Yes, delete") is_danger=True form_id="delete-form" %}
{% include "partials/common/confirm_modal.html" with modal_id="confirm-delete-modal" title=_("Delete Media") message=_("Are you sure you want to delete this media? This action cannot be undone.") confirm_text=_("Yes, delete") is_danger=True form_id="delete-form" %}
{% endif %}
</div>
{% endblock content %}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{% extends "base.html" %}
{% extends "base/base.html" %}
{% load i18n %}
{% load static %}
{% load media_tags %}
Expand Down Expand Up @@ -53,7 +53,7 @@ <h1 class="text-4xl">{% translate "My media" %}</h1>
{# Right controls group #}
<div class="flex gap-2 order-2 flex-wrap sm:flex-nowrap">
{# View mode toggle #}
{% include "partials/view-mode-toggle.html" %}
{% include "partials/navigation/view_mode_toggle.html" %}
{# Sort selector #}
<div class="flex join items-center">
<a href="?{% query_string request sort=sort|toggle_sort_direction %}"
Expand Down Expand Up @@ -174,6 +174,6 @@ <h1 class="text-4xl">{% translate "My media" %}</h1>
</div>
</div>
{# Filters drawer #}
{% include "partials/filters-drawer.html" %}
{% include "partials/media-list.html" %}
{% include "partials/navigation/filters_drawer.html" %}
{% include "partials/media_items/media_list.html" %}
{% endblock content %}
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@
hx-trigger="revealed"
hx-swap="outerHTML"
class="col-span-full flex justify-center py-4">
{% include "partials/spinner.html" with size="lg" show_text=True text=_("Loading…") inline=True %}
{% include "partials/common/spinner.html" with size="lg" show_text=True text=_("Loading…") inline=True %}
</div>
{% else %}
<tr id="load-more-trigger"
hx-get="{% url 'load_more_media' %}?{% query_string request page=page_obj.next_page_number %}"
hx-trigger="revealed"
hx-swap="outerHTML">
<td colspan="8" class="text-center py-4">
{% include "partials/spinner.html" with size="lg" show_text=True text=_("Loading…") inline=True %}
{% include "partials/common/spinner.html" with size="lg" show_text=True text=_("Loading…") inline=True %}
</td>
</tr>
{% endif %}
Expand Down
4 changes: 0 additions & 4 deletions src/templates/partials/media-items-page.html

This file was deleted.

Loading