mirror of
https://github.com/mediacms-io/mediacms.git
synced 2026-04-30 18:36:13 -04:00
course remove
This commit is contained in:
@@ -3,7 +3,7 @@ from .category import Category, Tag # noqa: F401
|
||||
from .comment import Comment # noqa: F401
|
||||
from .encoding import EncodeProfile, Encoding # noqa: F401
|
||||
from .license import License # noqa: F401
|
||||
from .media import Media, MediaPermission # noqa: F401
|
||||
from .media import EmbedMediaCourse, Media, MediaPermission # noqa: F401
|
||||
from .page import Page, TinyMCEMedia # noqa: F401
|
||||
from .playlist import Playlist, PlaylistMedia # noqa: F401
|
||||
from .rating import Rating, RatingCategory # noqa: F401
|
||||
|
||||
@@ -1002,6 +1002,29 @@ class MediaPermission(models.Model):
|
||||
return f"{self.user.username} - {self.media.title} ({self.permission})"
|
||||
|
||||
|
||||
class EmbedMediaCourse(models.Model):
|
||||
"""
|
||||
Records that a user shared a media item into a course during an LTI session.
|
||||
|
||||
This is a pure audit/tracking table used by the course cleanup bulk action to
|
||||
identify which MediaPermission records were created via LTI embedding and should
|
||||
be removed when the course is cleaned up.
|
||||
|
||||
It does NOT add the media to the category (Media.category M2M is untouched),
|
||||
so no m2m_changed signals fire and no category counts are affected.
|
||||
"""
|
||||
|
||||
media = models.ForeignKey('Media', on_delete=models.CASCADE, related_name='embed_courses')
|
||||
category = models.ForeignKey('Category', on_delete=models.CASCADE, related_name='embedded_media')
|
||||
created_at = models.DateTimeField(auto_now_add=True)
|
||||
|
||||
class Meta:
|
||||
unique_together = ('media', 'category')
|
||||
|
||||
def __str__(self):
|
||||
return f"{self.media.title} in {self.category.title}"
|
||||
|
||||
|
||||
@receiver(post_save, sender=Media)
|
||||
def media_save(sender, instance, created, **kwargs):
|
||||
# media_file path is not set correctly until mode is saved
|
||||
|
||||
Reference in New Issue
Block a user