feat: add scripts for dummy item generation and thumbnail population, fix avatar foreign key constraint on item deletion, and improve admin approve view for empty trash.
This commit is contained in:
@@ -249,6 +249,17 @@ export default (router, tpl) => {
|
||||
// Delete DB entries
|
||||
console.log('[ADMIN DENY] Deleting DB entries...');
|
||||
try {
|
||||
// Fix FK constraint: Check if this item is used as an avatar
|
||||
try {
|
||||
const fallback = await db`select id from items where active = true limit 1`;
|
||||
if (fallback.length > 0) {
|
||||
const safeId = fallback[0].id;
|
||||
await db`update "user_options" set avatar = ${safeId} where avatar = ${id}`;
|
||||
}
|
||||
} catch (fkErr) {
|
||||
console.error('[ADMIN DENY FK FIX ERROR]', fkErr);
|
||||
}
|
||||
|
||||
await db`delete from "tags_assign" where item_id = ${id}`;
|
||||
await db`delete from "favorites" where item_id = ${id}`;
|
||||
await db`delete from "comments" where item_id = ${id}`.catch(() => { });
|
||||
|
||||
@@ -44,10 +44,11 @@
|
||||
</table>
|
||||
@endif
|
||||
|
||||
@if(trash.length > 0)
|
||||
<h2 style="color: #ff6b6b; margin-top: 40px;">Reference / Soft Deleted</h2>
|
||||
<p class="text-muted">These items are in the deleted folder but not purged from DB. Approving them will restore
|
||||
them.</p>
|
||||
|
||||
@if(trash.length > 0)
|
||||
<table class="table" style="width: 100%; opacity: 0.8;">
|
||||
<thead>
|
||||
<tr>
|
||||
@@ -85,6 +86,8 @@
|
||||
@endeach
|
||||
</tbody>
|
||||
</table>
|
||||
@else
|
||||
<p style="padding: 20px; border: 1px dashed #444; color: #888;">Trash is empty.</p>
|
||||
@endif
|
||||
|
||||
@if(pending.length === 0 && trash.length === 0)
|
||||
|
||||
Reference in New Issue
Block a user