Files
training-software/cms/tasks.py
Paperclip CTO b087a63b56
Some checks failed
CI / Tests (Python 3.12) (push) Has been cancelled
CI / Lint (push) Has been cancelled
CI / OpenAPI Schema (push) Has been cancelled
feat(TRA-237): CMS content blocks, media upload pipeline, and course theme
- MediaAsset model with file metadata and AV scan status tracking
- ContentBlock model (richtext/image/video/embed/download) with ordered
  blocks per page and unique constraint on (page, order)
- CourseTheme one-to-one per course with primary/secondary color and logo
- validate_upload/save_upload helpers with extension and size enforcement
- scan_media_asset_task Celery stub (marks clean; replace with ClamAV)
- REST API: media upload, page content blocks CRUD, block patch/delete
- Admin registrations for all three models
- Factory-boy factories and pytest test suite for views, upload, and task

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-07 09:28:54 +02:00

21 lines
670 B
Python

from celery import shared_task
@shared_task(name="cms.scan_media_asset")
def scan_media_asset_task(asset_id: str):
"""
Async media scan hook. Marks the asset CLEAN by default.
Replace the body with a real AV scanner call (e.g., ClamAV) when available.
"""
from .models import MediaAsset, ScanStatus
try:
asset = MediaAsset.objects.get(pk=asset_id)
except MediaAsset.DoesNotExist:
return {"error": "not found"}
# Stub: always mark clean — replace with real AV integration
asset.scan_status = ScanStatus.CLEAN
asset.save(update_fields=["scan_status"])
return {"asset_id": asset_id, "scan_status": "clean"}