mirror of
https://github.com/mediacms-io/mediacms.git
synced 2026-04-30 10:26:13 -04:00
tags
This commit is contained in:
+4
-4
@@ -7,7 +7,7 @@ from django import forms
|
||||
from django.conf import settings
|
||||
|
||||
from .methods import get_next_state, is_mediacms_editor
|
||||
from .models import MEDIA_STATES, Category, Media, MediaPermission, Subtitle, Tag
|
||||
from .models import MEDIA_STATES, Category, Media, MediaPermission, Subtitle
|
||||
from .widgets import CategoryModalWidget
|
||||
|
||||
_PUBLISH_STATE_HTML = (Path(__file__).parent.parent / 'templates/cms/partials/media_publish_state.html').read_text()
|
||||
@@ -245,9 +245,9 @@ class MediaPublishForm(forms.ModelForm):
|
||||
|
||||
media = super(MediaPublishForm, self).save(*args, **kwargs)
|
||||
|
||||
for course in media.category.filter(is_lms_course=True):
|
||||
tag, _ = Tag.objects.get_or_create(title=course.title[:100])
|
||||
media.tags.add(tag)
|
||||
# for course in media.category.filter(is_lms_course=True):
|
||||
# tag, _ = Tag.objects.get_or_create(title=course.title[:100])
|
||||
# media.tags.add(tag)
|
||||
|
||||
return media
|
||||
|
||||
|
||||
+11
-11
@@ -673,17 +673,17 @@ class MediaBulkUserActions(APIView):
|
||||
return Response({"detail": "No matching categories found or access denied"}, status=status.HTTP_400_BAD_REQUEST)
|
||||
|
||||
added_count = 0
|
||||
tag = None
|
||||
for category in categories:
|
||||
if category.is_lms_course:
|
||||
tag, _ = Tag.objects.get_or_create(title=category.title[:100])
|
||||
|
||||
for m in media:
|
||||
if not m.category.filter(uid=category.uid).exists():
|
||||
m.category.add(category)
|
||||
added_count += 1
|
||||
if tag:
|
||||
m.tags.add(tag)
|
||||
# tag = None
|
||||
# for category in categories:
|
||||
# if category.is_lms_course:
|
||||
# tag, _ = Tag.objects.get_or_create(title=category.title[:100])
|
||||
#
|
||||
# for m in media:
|
||||
# if not m.category.filter(uid=category.uid).exists():
|
||||
# m.category.add(category)
|
||||
# added_count += 1
|
||||
# if tag:
|
||||
# m.tags.add(tag)
|
||||
|
||||
return Response({"detail": f"Added {added_count} media items to {categories.count()} categories"})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user