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 })