Add registry curation system with role-based moderation
Implement comprehensive moderation system for the CmdForge registry: - Role-based access control (user, moderator, admin) - Tool moderation workflow: pending → approved/rejected/removed - Tool visibility: public, private, unlisted - Publisher management: ban/unban with token revocation - Report resolution with configurable actions - Audit logging for all moderation actions Database changes: - Add role, banned columns to publishers table - Add visibility, moderation_status columns to tools table - Create audit_log table for accountability API additions: - Admin endpoints for tool moderation (approve/reject/remove) - Publisher management endpoints (ban/unban/role) - Report resolution endpoint - Audit log query endpoint Web UI: - Admin dashboard with stats overview - Pending tools queue with approve/reject - Publisher management with ban/role controls - Report queue with resolve actions - Role badge in dashboard sidebar Existing tools grandfathered as approved, all publishers default to user role. Co-Authored-By: Claude Opus 4.5 <[email protected]>
This commit is contained in:
@@ -0,0 +1,164 @@
|
||||
{% extends "dashboard/base.html" %}
|
||||
|
||||
{% block dashboard_header %}
|
||||
<div class="flex items-center justify-between">
|
||||
<div>
|
||||
<h1 class="text-2xl font-bold text-gray-900">Pending Tools</h1>
|
||||
<p class="mt-1 text-gray-600">Review and approve submitted tools</p>
|
||||
</div>
|
||||
<a href="{{ url_for('web.admin_dashboard') }}" class="text-sm text-indigo-600 hover:text-indigo-700">← Back to Admin</a>
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
||||
{% block dashboard_content %}
|
||||
<div class="bg-white rounded-lg border border-gray-200">
|
||||
{% if tools %}
|
||||
<div class="overflow-x-auto">
|
||||
<table class="min-w-full divide-y divide-gray-200">
|
||||
<thead class="bg-gray-50">
|
||||
<tr>
|
||||
<th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Tool</th>
|
||||
<th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Publisher</th>
|
||||
<th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Category</th>
|
||||
<th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Submitted</th>
|
||||
<th scope="col" class="px-6 py-3 text-right text-xs font-medium text-gray-500 uppercase tracking-wider">Actions</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody class="bg-white divide-y divide-gray-200">
|
||||
{% for tool in tools %}
|
||||
<tr id="tool-row-{{ tool.id }}" class="hover:bg-gray-50">
|
||||
<td class="px-6 py-4 whitespace-nowrap">
|
||||
<div class="flex items-center">
|
||||
<div>
|
||||
<div class="text-sm font-medium text-gray-900">{{ tool.owner }}/{{ tool.name }}</div>
|
||||
<div class="text-sm text-gray-500">v{{ tool.version }}</div>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
<td class="px-6 py-4 whitespace-nowrap">
|
||||
<div class="text-sm text-gray-900">{{ tool.publisher_name }}</div>
|
||||
</td>
|
||||
<td class="px-6 py-4 whitespace-nowrap">
|
||||
<span class="px-2 inline-flex text-xs leading-5 font-semibold rounded-full bg-gray-100 text-gray-800">
|
||||
{{ tool.category or 'Uncategorized' }}
|
||||
</span>
|
||||
</td>
|
||||
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">
|
||||
{{ tool.published_at[:10] if tool.published_at else 'Unknown' }}
|
||||
</td>
|
||||
<td class="px-6 py-4 whitespace-nowrap text-right text-sm font-medium">
|
||||
<button onclick="approveTool({{ tool.id }})" class="text-green-600 hover:text-green-900 mr-3">Approve</button>
|
||||
<button onclick="rejectTool({{ tool.id }})" class="text-red-600 hover:text-red-900">Reject</button>
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<!-- Pagination -->
|
||||
{% if meta.total_pages > 1 %}
|
||||
<div class="bg-gray-50 px-6 py-3 flex items-center justify-between border-t border-gray-200">
|
||||
<div class="text-sm text-gray-700">
|
||||
Page {{ meta.page }} of {{ meta.total_pages }} ({{ meta.total }} total)
|
||||
</div>
|
||||
<div class="flex space-x-2">
|
||||
{% if meta.page > 1 %}
|
||||
<a href="?page={{ meta.page - 1 }}" class="px-3 py-1 border rounded text-sm hover:bg-gray-100">Previous</a>
|
||||
{% endif %}
|
||||
{% if meta.page < meta.total_pages %}
|
||||
<a href="?page={{ meta.page + 1 }}" class="px-3 py-1 border rounded text-sm hover:bg-gray-100">Next</a>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% else %}
|
||||
<div class="text-center py-12">
|
||||
<svg class="mx-auto h-12 w-12 text-gray-400" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z"/>
|
||||
</svg>
|
||||
<h3 class="mt-2 text-sm font-medium text-gray-900">No pending tools</h3>
|
||||
<p class="mt-1 text-sm text-gray-500">All submitted tools have been reviewed.</p>
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
<!-- Reject Modal -->
|
||||
<div id="reject-modal" class="fixed inset-0 bg-gray-600 bg-opacity-50 hidden overflow-y-auto h-full w-full z-50">
|
||||
<div class="relative top-20 mx-auto p-5 border w-96 shadow-lg rounded-md bg-white">
|
||||
<div class="mt-3">
|
||||
<h3 class="text-lg font-medium text-gray-900 mb-4">Reject Tool</h3>
|
||||
<textarea id="reject-reason" rows="3" class="w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-indigo-500" placeholder="Reason for rejection (required)"></textarea>
|
||||
<div class="mt-4 flex justify-end space-x-3">
|
||||
<button onclick="closeRejectModal()" class="px-4 py-2 text-sm font-medium text-gray-700 hover:text-gray-500">Cancel</button>
|
||||
<button onclick="confirmReject()" class="px-4 py-2 bg-red-600 text-white text-sm font-medium rounded-md hover:bg-red-700">Reject</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
let currentToolId = null;
|
||||
|
||||
async function approveTool(toolId) {
|
||||
if (!confirm('Approve this tool?')) return;
|
||||
try {
|
||||
const response = await fetch(`/api/v1/admin/tools/${toolId}/approve`, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Authorization': 'Bearer {{ session.get("auth_token") }}',
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
});
|
||||
if (response.ok) {
|
||||
document.getElementById(`tool-row-${toolId}`).remove();
|
||||
location.reload();
|
||||
} else {
|
||||
const data = await response.json();
|
||||
alert(data.error?.message || 'Failed to approve tool');
|
||||
}
|
||||
} catch (error) {
|
||||
alert('Network error');
|
||||
}
|
||||
}
|
||||
|
||||
function rejectTool(toolId) {
|
||||
currentToolId = toolId;
|
||||
document.getElementById('reject-modal').classList.remove('hidden');
|
||||
document.getElementById('reject-reason').value = '';
|
||||
}
|
||||
|
||||
function closeRejectModal() {
|
||||
document.getElementById('reject-modal').classList.add('hidden');
|
||||
currentToolId = null;
|
||||
}
|
||||
|
||||
async function confirmReject() {
|
||||
const reason = document.getElementById('reject-reason').value.trim();
|
||||
if (!reason) {
|
||||
alert('Rejection reason is required');
|
||||
return;
|
||||
}
|
||||
try {
|
||||
const response = await fetch(`/api/v1/admin/tools/${currentToolId}/reject`, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Authorization': 'Bearer {{ session.get("auth_token") }}',
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
body: JSON.stringify({ reason })
|
||||
});
|
||||
if (response.ok) {
|
||||
closeRejectModal();
|
||||
document.getElementById(`tool-row-${currentToolId}`).remove();
|
||||
location.reload();
|
||||
} else {
|
||||
const data = await response.json();
|
||||
alert(data.error?.message || 'Failed to reject tool');
|
||||
}
|
||||
} catch (error) {
|
||||
alert('Network error');
|
||||
}
|
||||
}
|
||||
</script>
|
||||
{% endblock %}
|
||||
Reference in New Issue
Block a user