Compare commits

..

No commits in common. "f65338562e13e18a113cb3edf3cc80619b913126" and "43d25d643371f25741b889bd8722a3d1620173dc" have entirely different histories.

12 changed files with 100 additions and 54 deletions

View File

@ -201,10 +201,7 @@ class LanguageAdmin(admin.ModelAdmin):
class SubtitleAdmin(admin.ModelAdmin): class SubtitleAdmin(admin.ModelAdmin):
list_display = ["id", "language", "media"] pass
list_filter = ["language"]
search_fields = ["media__title"]
readonly_fields = ("media", "user")
class VideoTrimRequestAdmin(admin.ModelAdmin): class VideoTrimRequestAdmin(admin.ModelAdmin):

View File

@ -672,9 +672,6 @@ def change_media_owner(media_id, new_user):
permission.owner_user = new_user permission.owner_user = new_user
permission.save(update_fields=["owner_user"]) permission.save(update_fields=["owner_user"])
# remove any existing permissions for the new user, since they are now owner
models.MediaPermission.objects.filter(media=media, user=new_user).delete()
return media return media

View File

@ -42,8 +42,6 @@ class Subtitle(models.Model):
user = models.ForeignKey("users.User", on_delete=models.CASCADE) user = models.ForeignKey("users.User", on_delete=models.CASCADE)
class Meta: class Meta:
verbose_name = "Caption"
verbose_name_plural = "Captions"
ordering = ["language__title"] ordering = ["language__title"]
def __str__(self): def __str__(self):

View File

@ -94,7 +94,7 @@ def add_subtitle(request):
if not media: if not media:
return HttpResponseRedirect("/") return HttpResponseRedirect("/")
if not (is_mediacms_editor(request.user) or request.user.has_contributor_access_to_media(media)): if not (request.user == media.user or is_mediacms_editor(request.user)):
return HttpResponseRedirect("/") return HttpResponseRedirect("/")
# Initialize variables # Initialize variables
@ -146,7 +146,7 @@ def edit_subtitle(request):
if not subtitle: if not subtitle:
return HttpResponseRedirect("/") return HttpResponseRedirect("/")
if not (is_mediacms_editor(request.user) or request.user.has_contributor_access_to_media(subtitle.media)): if not (request.user == subtitle.user or is_mediacms_editor(request.user)):
return HttpResponseRedirect("/") return HttpResponseRedirect("/")
context = {"subtitle": subtitle, "action": action} context = {"subtitle": subtitle, "action": action}
@ -252,7 +252,7 @@ def video_chapters(request, friendly_token):
if not media: if not media:
return HttpResponseRedirect("/") return HttpResponseRedirect("/")
if not (is_mediacms_editor(request.user) or request.user.has_contributor_access_to_media(media)): if not (request.user == media.user or is_mediacms_editor(request.user)):
return HttpResponseRedirect("/") return HttpResponseRedirect("/")
try: try:
@ -370,7 +370,7 @@ def edit_chapters(request):
if not media: if not media:
return HttpResponseRedirect("/") return HttpResponseRedirect("/")
if not (is_mediacms_editor(request.user) or request.user.has_contributor_access_to_media(media)): if not (request.user == media.user or is_mediacms_editor(request.user)):
return HttpResponseRedirect("/") return HttpResponseRedirect("/")
chapters = media.chapter_data chapters = media.chapter_data
@ -395,7 +395,7 @@ def trim_video(request, friendly_token):
if not media: if not media:
return HttpResponseRedirect("/") return HttpResponseRedirect("/")
if not (is_mediacms_editor(request.user) or request.user.has_contributor_access_to_media(media)): if not (request.user == media.user or is_mediacms_editor(request.user)):
return HttpResponseRedirect("/") return HttpResponseRedirect("/")
existing_requests = VideoTrimRequest.objects.filter(media=media, status__in=["initial", "running"]).exists() existing_requests = VideoTrimRequest.objects.filter(media=media, status__in=["initial", "running"]).exists()
@ -426,7 +426,7 @@ def edit_video(request):
if not media: if not media:
return HttpResponseRedirect("/") return HttpResponseRedirect("/")
if not (is_mediacms_editor(request.user) or request.user.has_contributor_access_to_media(media)): if not (request.user == media.user or is_mediacms_editor(request.user)):
return HttpResponseRedirect("/") return HttpResponseRedirect("/")
if media.media_type not in ["video", "audio"]: if media.media_type not in ["video", "audio"]:
@ -629,12 +629,10 @@ def view_media(request):
if request.user.is_authenticated: if request.user.is_authenticated:
if request.user.has_contributor_access_to_media(media) or is_mediacms_editor(request.user): if request.user.has_contributor_access_to_media(media) or is_mediacms_editor(request.user):
context["CAN_DELETE_MEDIA"] = True
context["CAN_EDIT_MEDIA"] = True context["CAN_EDIT_MEDIA"] = True
context["CAN_DELETE_COMMENTS"] = True context["CAN_DELETE_COMMENTS"] = True
if request.user == media.user or is_mediacms_editor(request.user):
context["CAN_DELETE_MEDIA"] = True
# in case media is video and is processing (eg the case a video was just uploaded) # in case media is video and is processing (eg the case a video was just uploaded)
# attempt to show it (rather than showing a blank video player) # attempt to show it (rather than showing a blank video player)
if media.media_type == 'video': if media.media_type == 'video':

View File

@ -686,8 +686,9 @@ a.item-edit-link {
} }
} }
// Show checkbox only on hover // Show checkbox on hover or when any item is selected
&:hover .item-selection-checkbox { &:hover .item-selection-checkbox,
&.has-any-selection .item-selection-checkbox {
opacity: 1; opacity: 1;
} }
@ -708,6 +709,18 @@ a.item-edit-link {
border-radius: 10px; border-radius: 10px;
} }
} }
// Make the whole item clickable for selection when any selection is active
&.has-any-selection:not(.selected) {
.item-thumb {
cursor: pointer;
}
.item-main {
cursor: pointer;
pointer-events: auto;
}
}
} }
// Edit icon styles // Edit icon styles

View File

@ -24,8 +24,7 @@ export function MediaItem(props) {
const finalClassname = containerClassname + const finalClassname = containerClassname +
(props.showSelection ? ' with-selection' : '') + (props.showSelection ? ' with-selection' : '') +
(props.isSelected ? ' selected' : '') + (props.isSelected ? ' selected' : '');
(props.hasAnySelection ? ' has-any-selection' : '');
return ( return (
<div className={finalClassname}> <div className={finalClassname}>

View File

@ -70,8 +70,32 @@ export function MediaItemAudio(props) {
(props.isSelected ? ' selected' : '') + (props.isSelected ? ' selected' : '') +
(props.hasAnySelection ? ' has-any-selection' : ''); (props.hasAnySelection ? ' has-any-selection' : '');
const handleItemClick = (e) => {
// Only handle clicks when selection mode is active
if (props.showSelection) {
// Check if click was on the checkbox (already handled)
if (e.target.type === 'checkbox' || e.target.closest('.item-selection-checkbox')) {
return;
}
// Check if click was on the edit icon or view icon
if (e.target.closest('.item-edit-icon') || e.target.closest('.item-view-icon')) {
return;
}
// Prevent default link behavior
e.preventDefault();
e.stopPropagation();
// Toggle the checkbox
if (props.onCheckboxChange) {
props.onCheckboxChange({ target: { checked: !props.isSelected } });
}
}
};
return ( return (
<div className={finalClassname}> <div className={finalClassname} onClick={handleItemClick}>
{playlistOrderNumberComponent()} {playlistOrderNumberComponent()}
<div className="item-content"> <div className="item-content">

View File

@ -77,8 +77,32 @@ export function MediaItemVideo(props) {
(props.isSelected ? ' selected' : '') + (props.isSelected ? ' selected' : '') +
(props.hasAnySelection ? ' has-any-selection' : ''); (props.hasAnySelection ? ' has-any-selection' : '');
const handleItemClick = (e) => {
// Only handle clicks when selection mode is active
if (props.showSelection) {
// Check if click was on the checkbox (already handled)
if (e.target.type === 'checkbox' || e.target.closest('.item-selection-checkbox')) {
return;
}
// Check if click was on the edit icon or view icon
if (e.target.closest('.item-edit-icon') || e.target.closest('.item-view-icon')) {
return;
}
// Prevent default link behavior
e.preventDefault();
e.stopPropagation();
// Toggle the checkbox
if (props.onCheckboxChange) {
props.onCheckboxChange({ target: { checked: !props.isSelected } });
}
}
};
return ( return (
<div className={finalClassname}> <div className={finalClassname} onClick={handleItemClick}>
{playlistOrderNumberComponent()} {playlistOrderNumberComponent()}
<div className="item-content"> <div className="item-content">

View File

@ -217,37 +217,33 @@ export default function ViewerInfoContent(props) {
/> />
) : null} ) : null}
{userCan.editMedia ? ( {userCan.editMedia || userCan.deleteMedia ? (
<div className="media-author-actions"> <div className="media-author-actions">
{userCan.editMedia ? <EditMediaButton link={MediaPageStore.get('media-data').edit_url} /> : null} {userCan.editMedia ? <EditMediaButton link={MediaPageStore.get('media-data').edit_url} /> : null}
{userCan.deleteMedia ? ( <PopupTrigger contentRef={popupContentRef}>
<PopupTrigger contentRef={popupContentRef}> <button className="remove-media-icon" title={translateString('Delete media')}>
<button className="remove-media-icon" title={translateString('Delete media')}> <i className="material-icons">delete</i>
<i className="material-icons">delete</i> </button>
</button> </PopupTrigger>
</PopupTrigger>
) : null}
{userCan.deleteMedia ? ( <PopupContent contentRef={popupContentRef}>
<PopupContent contentRef={popupContentRef}> <PopupMain>
<PopupMain> <div className="popup-message">
<div className="popup-message"> <span className="popup-message-title">Media removal</span>
<span className="popup-message-title">Media removal</span> <span className="popup-message-main">You're willing to remove media permanently?</span>
<span className="popup-message-main">You're willing to remove media permanently?</span> </div>
</div> <hr />
<hr /> <span className="popup-message-bottom">
<span className="popup-message-bottom"> <button className="button-link cancel-comment-removal" onClick={cancelMediaRemoval}>
<button className="button-link cancel-comment-removal" onClick={cancelMediaRemoval}> CANCEL
CANCEL </button>
</button> <button className="button-link proceed-comment-removal" onClick={proceedMediaRemoval}>
<button className="button-link proceed-comment-removal" onClick={proceedMediaRemoval}> PROCEED
PROCEED </button>
</button> </span>
</span> </PopupMain>
</PopupMain> </PopupContent>
</PopupContent>
) : null}
</div> </div>
) : null} ) : null}
</div> </div>

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long