Ejemplo n.º 1
0
    def form_valid(self, form):
        allow_registrations = form.cleaned_data['allow_registrations']
        if allow_registrations is not None:
            appconfig.allow_registrations = allow_registrations

        sync_schedule = form.cleaned_data['sync_schedule']
        if sync_schedule is not None and len(sync_schedule) > 0:
            appconfig.sync_schedule = sync_schedule

        auto_download = form.cleaned_data['auto_download']
        if auto_download is not None:
            self.request.user.preferences['auto_download'] = auto_download

        download_location = form.cleaned_data['download_location']
        if download_location is not None and len(download_location) > 0:
            self.request.user.preferences['download_path'] = download_location

        # Set initialized to true
        appconfig.initialized = True

        # Start scheduler if not started
        scheduler.initialize()
        SynchronizeJob.schedule_global_job()

        return super().form_valid(form)
Ejemplo n.º 2
0
 def post(self, *args, **kwargs):
     if 'pk' in kwargs:
         SynchronizeJob.schedule_now_for_subscription(Subscription.objects.get(id=kwargs['pk']))
     else:
         SynchronizeJob.schedule_now()
     return JsonResponse({
         'success': True
     })
Ejemplo n.º 3
0
    def delete_files(self):
        if self.downloaded_path is not None:
            from YtManagerApp.management.jobs.delete_video import DeleteVideoJob
            from YtManagerApp.management.appconfig import appconfig
            from YtManagerApp.management.jobs.synchronize import SynchronizeJob

            DeleteVideoJob.schedule(self)

            # Mark watched?
            if self.subscription.user.preferences['mark_deleted_as_watched']:
                self.watched = True
                SynchronizeJob.schedule_now_for_subscription(self.subscription)
Ejemplo n.º 4
0
    def mark_watched(self):
        self.watched = True
        self.save()
        if self.downloaded_path is not None:
            from YtManagerApp.management.appconfig import appconfig
            from YtManagerApp.management.jobs.delete_video import DeleteVideoJob
            from YtManagerApp.management.jobs.synchronize import SynchronizeJob

            if appconfig.for_sub(self.subscription,
                                 'automatically_delete_watched'):
                DeleteVideoJob.schedule(self)
                SynchronizeJob.schedule_now_for_subscription(self.subscription)
Ejemplo n.º 5
0
 def mark_unwatched(self):
     from YtManagerApp.management.jobs.synchronize import SynchronizeJob
     self.watched = False
     self.save()
     SynchronizeJob.schedule_now_for_subscription(self.subscription)
Ejemplo n.º 6
0
 def synchronize_now(self):
     from YtManagerApp.management.jobs.synchronize import SynchronizeJob
     SynchronizeJob.schedule_now_for_subscription(self)
Ejemplo n.º 7
0
 def form_valid(self, form):
     form.save()
     SynchronizeJob.schedule_global_job()
     return super().form_valid(form)