From 85092935a6a421f25a0d337f68b2b85bbad5ed35 Mon Sep 17 00:00:00 2001 From: "Jacob Mansfield [root@Helix]" Date: Fri, 22 Nov 2019 17:11:52 +0000 Subject: [PATCH] Allow syncing a single channel --- app/YtManagerApp/models.py | 4 ++++ .../controls/subscription_update_modal.html | 15 ++++++++++++++- app/YtManagerApp/urls.py | 1 + app/YtManagerApp/views/actions.py | 7 +++++-- 4 files changed, 24 insertions(+), 3 deletions(-) diff --git a/app/YtManagerApp/models.py b/app/YtManagerApp/models.py index 3b779d3..17b5984 100644 --- a/app/YtManagerApp/models.py +++ b/app/YtManagerApp/models.py @@ -162,6 +162,10 @@ class Subscription(models.Model): def delete_subscription(self, keep_downloaded_videos: bool): self.delete() + def synchronize_now(self): + from YtManagerApp.management.jobs.synchronize import SynchronizeJob + SynchronizeJob.schedule_now_for_subscription(self) + class Video(models.Model): video_id = models.CharField(null=False, max_length=12) diff --git a/app/YtManagerApp/templates/YtManagerApp/controls/subscription_update_modal.html b/app/YtManagerApp/templates/YtManagerApp/controls/subscription_update_modal.html index 6cecc2e..6d61db4 100644 --- a/app/YtManagerApp/templates/YtManagerApp/controls/subscription_update_modal.html +++ b/app/YtManagerApp/templates/YtManagerApp/controls/subscription_update_modal.html @@ -18,4 +18,17 @@ {% block modal_footer %} -{% endblock modal_footer %} \ No newline at end of file + +{% endblock modal_footer %} + +{% block modal_scripts %} + +{% endblock %} + diff --git a/app/YtManagerApp/urls.py b/app/YtManagerApp/urls.py index f33336c..9d13997 100644 --- a/app/YtManagerApp/urls.py +++ b/app/YtManagerApp/urls.py @@ -37,6 +37,7 @@ urlpatterns = [ # 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/delete_video_files/', DeleteVideoFilesView.as_view(), name='ajax_action_delete_video_files'), path('ajax/action/download_video_files/', DownloadVideoFilesView.as_view(), name='ajax_action_download_video_files'), path('ajax/action/mark_video_watched/', MarkVideoWatchedView.as_view(), name='ajax_action_mark_video_watched'), diff --git a/app/YtManagerApp/views/actions.py b/app/YtManagerApp/views/actions.py index bbab4ca..e1bfce0 100644 --- a/app/YtManagerApp/views/actions.py +++ b/app/YtManagerApp/views/actions.py @@ -3,12 +3,15 @@ from django.http import JsonResponse from django.views.generic import View from YtManagerApp.management.jobs.synchronize import SynchronizeJob -from YtManagerApp.models import Video +from YtManagerApp.models import Video, Subscription class SyncNowView(LoginRequiredMixin, View): 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({ 'success': True })