mirror of
https://github.com/mediacms-io/mediacms.git
synced 2026-04-23 07:49:15 -04:00
a
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
# Generated by Django 5.2.6 on 2026-04-21 15:54
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('files', '0016_category_lti_platform'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='mediapermission',
|
||||
name='source',
|
||||
field=models.CharField(choices=[('lti_embed', 'LTI Embed'), ('explicit', 'Explicit')], default='explicit', max_length=32),
|
||||
),
|
||||
]
|
||||
@@ -981,10 +981,18 @@ class MediaPermission(models.Model):
|
||||
("owner", "Owner"),
|
||||
)
|
||||
|
||||
SOURCE_LTI_EMBED = 'lti_embed'
|
||||
SOURCE_EXPLICIT = 'explicit'
|
||||
SOURCE_CHOICES = (
|
||||
(SOURCE_LTI_EMBED, 'LTI Embed'),
|
||||
(SOURCE_EXPLICIT, 'Explicit'),
|
||||
)
|
||||
|
||||
owner_user = models.ForeignKey('users.User', on_delete=models.CASCADE, related_name='granted_permissions')
|
||||
user = models.ForeignKey('users.User', on_delete=models.CASCADE)
|
||||
media = models.ForeignKey('Media', on_delete=models.CASCADE, related_name='permissions')
|
||||
permission = models.CharField(max_length=20, choices=PERMISSION_CHOICES)
|
||||
source = models.CharField(max_length=32, choices=SOURCE_CHOICES, default=SOURCE_EXPLICIT)
|
||||
created_at = models.DateTimeField(auto_now_add=True)
|
||||
|
||||
class Meta:
|
||||
|
||||
@@ -183,8 +183,11 @@ class MediaList(APIView):
|
||||
else:
|
||||
base_queryset = Media.objects.prefetch_related("user", "tags")
|
||||
|
||||
# Build OR conditions similar to _get_media_queryset
|
||||
conditions = Q(permissions__user=request.user)
|
||||
exclude_lti_embed = request.GET.get('exclude_lti_embed') == '1'
|
||||
if exclude_lti_embed:
|
||||
conditions = Q(permissions__user=request.user, permissions__source=MediaPermission.SOURCE_EXPLICIT)
|
||||
else:
|
||||
conditions = Q(permissions__user=request.user)
|
||||
|
||||
if getattr(settings, 'USE_RBAC', False):
|
||||
rbac_categories = request.user.get_rbac_categories_as_member()
|
||||
|
||||
@@ -5,7 +5,7 @@ import { LinksContext, MemberContext, SiteContext } from '../../utils/contexts/'
|
||||
import { PageStore, ProfilePageStore } from '../../utils/stores/';
|
||||
import { PageActions, ProfilePageActions } from '../../utils/actions/';
|
||||
import { CircleIconButton, PopupMain } from '../_shared';
|
||||
import { translateString, inEmbeddedApp, inSelectMediaEmbedMode, isSelectMediaMode, isShareMediaDisabled } from '../../utils/helpers/';
|
||||
import { translateString, inEmbeddedApp, inSelectMediaEmbedMode, isSelectMediaMode } from '../../utils/helpers/';
|
||||
|
||||
class ProfileSearchBar extends React.PureComponent {
|
||||
constructor(props) {
|
||||
@@ -373,7 +373,6 @@ class NavMenuInlineTabs extends React.PureComponent {
|
||||
|
||||
render() {
|
||||
const isSelectMediaMode = inSelectMediaEmbedMode();
|
||||
const shareMediaDisabled = isShareMediaDisabled();
|
||||
|
||||
// Append action=select_media to links when in select mode
|
||||
const mediaLink = isSelectMediaMode
|
||||
@@ -416,7 +415,7 @@ class NavMenuInlineTabs extends React.PureComponent {
|
||||
link={sharedByMeLink}
|
||||
/>
|
||||
) : null}
|
||||
{this.userIsAuthor && !shareMediaDisabled ? (
|
||||
{this.userIsAuthor ? (
|
||||
<InlineTab
|
||||
id="shared_with_me"
|
||||
isActive={'shared_with_me' === this.props.type}
|
||||
|
||||
@@ -11,7 +11,7 @@ import { ProfileMediaFilters } from '../components/search-filters/ProfileMediaFi
|
||||
import { ProfileMediaTags } from '../components/search-filters/ProfileMediaTags';
|
||||
import { ProfileMediaSharing } from '../components/search-filters/ProfileMediaSharing';
|
||||
import { ProfileMediaSorting } from '../components/search-filters/ProfileMediaSorting';
|
||||
import { inEmbeddedApp, inSelectMediaEmbedMode } from '../utils/helpers';
|
||||
import { inEmbeddedApp, inSelectMediaEmbedMode, isShareMediaDisabled } from '../utils/helpers';
|
||||
|
||||
import { Page } from './_Page';
|
||||
|
||||
@@ -86,6 +86,7 @@ export class ProfileSharedWithMePage extends Page {
|
||||
let requestUrl = this.state.requestUrl;
|
||||
|
||||
if (author) {
|
||||
const excludeLtiEmbed = isShareMediaDisabled() ? '&exclude_lti_embed=1' : '';
|
||||
if (this.state.query) {
|
||||
requestUrl =
|
||||
ApiUrlContext._currentValue.media +
|
||||
@@ -93,6 +94,7 @@ export class ProfileSharedWithMePage extends Page {
|
||||
author.id +
|
||||
'&show=shared_with_me&q=' +
|
||||
encodeURIComponent(this.state.query) +
|
||||
excludeLtiEmbed +
|
||||
this.state.filterArgs;
|
||||
} else {
|
||||
requestUrl =
|
||||
@@ -100,6 +102,7 @@ export class ProfileSharedWithMePage extends Page {
|
||||
'?author=' +
|
||||
author.id +
|
||||
'&show=shared_with_me' +
|
||||
excludeLtiEmbed +
|
||||
this.state.filterArgs;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -744,6 +744,7 @@ class EmbedMediaLTIView(View):
|
||||
defaults={
|
||||
'owner_user': media.user,
|
||||
'permission': 'viewer',
|
||||
'source': MediaPermission.SOURCE_LTI_EMBED,
|
||||
},
|
||||
)
|
||||
can_view = True
|
||||
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user