Handle thumbnail redownload requests
This commit is contained in:
1 parent
ea545d49a6
commit
bd0ad3682a
1 file changed
+19
@@ -546,6 +546,7 @@ class MediaItemView(DetailView):
|
|||||||
template_name = 'sync/media-item.html'
|
template_name = 'sync/media-item.html'
|
||||||
model = Media
|
model = Media
|
||||||
messages = {
|
messages = {
|
||||||
|
'thumbnail': _('Thumbnail has been scheduled to redownload'),
|
||||||
'redownloading': _('Media file has been deleted and scheduled to redownload'),
|
'redownloading': _('Media file has been deleted and scheduled to redownload'),
|
||||||
'skipped': _('Media file has been deleted and marked to never download'),
|
'skipped': _('Media file has been deleted and marked to never download'),
|
||||||
'enabled': _('Media has been re-enabled and will be downloaded'),
|
'enabled': _('Media has been re-enabled and will be downloaded'),
|
||||||
@@ -581,6 +582,24 @@ class MediaItemView(DetailView):
|
|||||||
data['media_file_path'] = pathlib.Path(self.object.media_file.path) if self.object.media_file else None
|
data['media_file_path'] = pathlib.Path(self.object.media_file.path) if self.object.media_file else None
|
||||||
return data
|
return data
|
||||||
|
|
||||||
|
def get(self, *args, **kwargs):
|
||||||
|
if args[0].path.startswith("/media-thumb-redownload/"):
|
||||||
|
media = Media.objects.get(pk=kwargs["pk"])
|
||||||
|
if media is None:
|
||||||
|
return HttpResponseNotFound()
|
||||||
|
|
||||||
|
verbose_name = _('Redownload thumbnail for "{}": {}')
|
||||||
|
download_media_thumbnail(
|
||||||
|
str(media.pk),
|
||||||
|
media.thumbnail,
|
||||||
|
verbose_name=verbose_name.format(media.key, media.name),
|
||||||
|
)
|
||||||
|
url = reverse_lazy('sync:media-item')
|
||||||
|
url = append_uri_params(url, {'message': 'thumbnail'})
|
||||||
|
return HttpResponseRedirect(url)
|
||||||
|
else:
|
||||||
|
return super().get(self, *args, **kwargs)
|
||||||
|
|
||||||
|
|
||||||
class MediaRedownloadView(FormView, SingleObjectMixin):
|
class MediaRedownloadView(FormView, SingleObjectMixin):
|
||||||
'''
|
'''
|
||||||
|
|||||||
Reference in new issue
Block a user