Add Themis application with custom widgets, views, and utilities
- Implemented custom form widgets for date, time, and datetime fields with DaisyUI styling. - Created utility functions for formatting dates, times, and numbers according to user preferences. - Developed views for profile settings, API key management, and notifications, including health check endpoints. - Added URL configurations for Themis tests and main application routes. - Established test cases for custom widgets to ensure proper functionality and integration. - Defined project metadata and dependencies in pyproject.toml for package management.
This commit is contained in:
43
mnemosyne/library/management/commands/embed_collection.py
Normal file
43
mnemosyne/library/management/commands/embed_collection.py
Normal file
@@ -0,0 +1,43 @@
|
||||
"""
|
||||
Management command to embed all items in a Collection.
|
||||
|
||||
Usage:
|
||||
python manage.py embed_collection <collection_uid>
|
||||
"""
|
||||
|
||||
import logging
|
||||
|
||||
from django.core.management.base import BaseCommand, CommandError
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class Command(BaseCommand):
|
||||
help = "Queue embedding tasks for all items in a Collection."
|
||||
|
||||
def add_arguments(self, parser):
|
||||
parser.add_argument(
|
||||
"collection_uid", type=str, help="UID of the Collection to embed"
|
||||
)
|
||||
|
||||
def handle(self, *args, **options):
|
||||
collection_uid = options["collection_uid"]
|
||||
|
||||
try:
|
||||
from library.models import Collection
|
||||
|
||||
col = Collection.nodes.get(uid=collection_uid)
|
||||
except Exception as exc:
|
||||
raise CommandError(f"Collection not found: {collection_uid} ({exc})")
|
||||
|
||||
items = col.items.all()
|
||||
self.stdout.write(f"Collection: {col.name} ({len(items)} items)")
|
||||
|
||||
from library.tasks import embed_collection
|
||||
|
||||
task = embed_collection.delay(collection_uid)
|
||||
self.stdout.write(
|
||||
self.style.SUCCESS(
|
||||
f"Batch task queued: {task.id} ({len(items)} items)"
|
||||
)
|
||||
)
|
||||
Reference in New Issue
Block a user