mirror of
https://github.com/chibicitiberiu/ytsm.git
synced 2024-02-24 05:43:31 +00:00
Allow syncing a single channel
This commit is contained in:
parent
794b9bd42d
commit
85092935a6
@ -162,6 +162,10 @@ class Subscription(models.Model):
|
|||||||
def delete_subscription(self, keep_downloaded_videos: bool):
|
def delete_subscription(self, keep_downloaded_videos: bool):
|
||||||
self.delete()
|
self.delete()
|
||||||
|
|
||||||
|
def synchronize_now(self):
|
||||||
|
from YtManagerApp.management.jobs.synchronize import SynchronizeJob
|
||||||
|
SynchronizeJob.schedule_now_for_subscription(self)
|
||||||
|
|
||||||
|
|
||||||
class Video(models.Model):
|
class Video(models.Model):
|
||||||
video_id = models.CharField(null=False, max_length=12)
|
video_id = models.CharField(null=False, max_length=12)
|
||||||
|
@ -18,4 +18,17 @@
|
|||||||
{% block modal_footer %}
|
{% block modal_footer %}
|
||||||
<input class="btn btn-primary" type="submit" value="Save" aria-label="Save">
|
<input class="btn btn-primary" type="submit" value="Save" aria-label="Save">
|
||||||
<input class="btn btn-secondary" type="button" value="Cancel" data-dismiss="modal" aria-label="Cancel">
|
<input class="btn btn-secondary" type="button" value="Cancel" data-dismiss="modal" aria-label="Cancel">
|
||||||
|
<input class="btn btn-secondary" type="button" value="Synchronize Now" aria-label="Synchronize Now" onclick="synchronizeChannelNow()">
|
||||||
{% endblock modal_footer %}
|
{% endblock modal_footer %}
|
||||||
|
|
||||||
|
{% block modal_scripts %}
|
||||||
|
<script>
|
||||||
|
function synchronizeChannelNow() {
|
||||||
|
$.post("{% url 'ajax_action_sync_now' form.instance.pk %}", {
|
||||||
|
csrfmiddlewaretoken: '{{ csrf_token }}'
|
||||||
|
}, function() {
|
||||||
|
});
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
@ -37,6 +37,7 @@ urlpatterns = [
|
|||||||
|
|
||||||
# Ajax
|
# Ajax
|
||||||
path('ajax/action/sync_now/', SyncNowView.as_view(), name='ajax_action_sync_now'),
|
path('ajax/action/sync_now/', SyncNowView.as_view(), name='ajax_action_sync_now'),
|
||||||
|
path('ajax/action/sync_now/<int:pk>', SyncNowView.as_view(), name='ajax_action_sync_now'),
|
||||||
path('ajax/action/delete_video_files/<int:pk>', DeleteVideoFilesView.as_view(), name='ajax_action_delete_video_files'),
|
path('ajax/action/delete_video_files/<int:pk>', DeleteVideoFilesView.as_view(), name='ajax_action_delete_video_files'),
|
||||||
path('ajax/action/download_video_files/<int:pk>', DownloadVideoFilesView.as_view(), name='ajax_action_download_video_files'),
|
path('ajax/action/download_video_files/<int:pk>', DownloadVideoFilesView.as_view(), name='ajax_action_download_video_files'),
|
||||||
path('ajax/action/mark_video_watched/<int:pk>', MarkVideoWatchedView.as_view(), name='ajax_action_mark_video_watched'),
|
path('ajax/action/mark_video_watched/<int:pk>', MarkVideoWatchedView.as_view(), name='ajax_action_mark_video_watched'),
|
||||||
|
@ -3,12 +3,15 @@ from django.http import JsonResponse
|
|||||||
from django.views.generic import View
|
from django.views.generic import View
|
||||||
|
|
||||||
from YtManagerApp.management.jobs.synchronize import SynchronizeJob
|
from YtManagerApp.management.jobs.synchronize import SynchronizeJob
|
||||||
from YtManagerApp.models import Video
|
from YtManagerApp.models import Video, Subscription
|
||||||
|
|
||||||
|
|
||||||
class SyncNowView(LoginRequiredMixin, View):
|
class SyncNowView(LoginRequiredMixin, View):
|
||||||
def post(self, *args, **kwargs):
|
def post(self, *args, **kwargs):
|
||||||
SynchronizeJob.schedule_now()
|
if 'pk' in kwargs:
|
||||||
|
SynchronizeJob.schedule_now_for_subscription(Subscription.objects.get(id=kwargs['pk']))
|
||||||
|
else:
|
||||||
|
SynchronizeJob.schedule_now()
|
||||||
return JsonResponse({
|
return JsonResponse({
|
||||||
'success': True
|
'success': True
|
||||||
})
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user