Revert "Major refactor of many things."

This reverts commit 6b843f1fc2.
This commit is contained in:
2020-04-11 00:42:44 +03:00
parent 75b2fc6bfe
commit dbc74fbc0a
28 changed files with 182 additions and 375 deletions

View File

@ -3,7 +3,7 @@ from django.http import JsonResponse
from django.views.generic import View
from YtManagerApp.models import Video
from YtManagerApp.services.scheduler.jobs.synchronize_job import SynchronizeJob
from YtManagerApp.scheduler.jobs.synchronize_job import SynchronizeJob
class SyncNowView(LoginRequiredMixin, View):

View File

@ -36,7 +36,7 @@ class RegisterView(FormView):
return context
def post(self, request, *args, **kwargs):
if not Services.appConfig().allow_registrations:
if not Services.appConfig.allow_registrations:
return HttpResponseForbidden("Registrations are disabled!")
return super().post(request, *args, **kwargs)

View File

@ -8,7 +8,7 @@ from django.shortcuts import redirect
from django.urls import reverse_lazy
from django.views.generic import FormView
from YtManagerApp.services.scheduler.jobs.synchronize_job import SynchronizeJob
from YtManagerApp.scheduler.jobs.synchronize_job import SynchronizeJob
from YtManagerApp.services import Services
from YtManagerApp.views.forms.first_time import WelcomeForm, ApiKeyForm, PickAdminUserForm, ServerConfigForm, DoneForm, \
UserCreationForm, LoginForm
@ -24,7 +24,7 @@ class WizardStepMixin:
def get(self, request, *args, **kwargs):
# Prevent access if application is already initialized
if Services.appConfig().initialized:
if Services.appConfig.initialized:
logger.debug(f"Attempted to access {request.path}, but first time setup already run. Redirected to home "
f"page.")
return redirect('home')
@ -32,7 +32,7 @@ class WizardStepMixin:
return super().get(request, *args, **kwargs)
def post(self, request, *args, **kwargs):
if Services.appConfig().initialized:
if Services.appConfig.initialized:
logger.debug(f"Attempted to post {request.path}, but first time setup already run.")
return HttpResponseForbidden()
return super().post(request, *args, **kwargs)
@ -65,14 +65,14 @@ class Step1ApiKeyView(WizardStepMixin, FormView):
def get_initial(self):
initial = super().get_initial()
initial['api_key'] = Services.appConfig().youtube_api_key
initial['api_key'] = Services.appConfig.youtube_api_key
return initial
def form_valid(self, form):
key = form.cleaned_data['api_key']
# TODO: validate key
if key is not None and len(key) > 0:
Services.appConfig().youtube_api_key = key
Services.appConfig.youtube_api_key = key
return super().form_valid(form)
@ -149,8 +149,8 @@ class Step3ConfigureView(WizardStepMixin, FormView):
def get_initial(self):
initial = super().get_initial()
initial['allow_registrations'] = Services.appConfig().allow_registrations
initial['sync_schedule'] = Services.appConfig().sync_schedule
initial['allow_registrations'] = Services.appConfig.allow_registrations
initial['sync_schedule'] = Services.appConfig.sync_schedule
initial['auto_download'] = self.request.user.preferences['auto_download']
initial['download_location'] = self.request.user.preferences['download_path']
return initial
@ -158,11 +158,11 @@ class Step3ConfigureView(WizardStepMixin, FormView):
def form_valid(self, form):
allow_registrations = form.cleaned_data['allow_registrations']
if allow_registrations is not None:
Services.appConfig().allow_registrations = allow_registrations
Services.appConfig.allow_registrations = allow_registrations
sync_schedule = form.cleaned_data['sync_schedule']
if sync_schedule is not None and len(sync_schedule) > 0:
Services.appConfig().sync_schedule = sync_schedule
Services.appConfig.sync_schedule = sync_schedule
auto_download = form.cleaned_data['auto_download']
if auto_download is not None:
@ -173,7 +173,7 @@ class Step3ConfigureView(WizardStepMixin, FormView):
self.request.user.preferences['download_path'] = download_location
# Set initialized to true
Services.appConfig().initialized = True
Services.appConfig.initialized = True
# Start scheduler if not started
Services.scheduler.initialize()

View File

@ -7,7 +7,7 @@ from YtManagerApp.dynamic_preferences_registry import MarkDeletedAsWatched, Auto
DownloadPath, DownloadFilePattern, DownloadFormat, DownloadSubtitles, DownloadAutogeneratedSubtitles, \
DownloadAllSubtitles, DownloadSubtitlesLangs, DownloadSubtitlesFormat
from YtManagerApp.models import VIDEO_ORDER_CHOICES
from YtManagerApp.management.services import Services
from YtManagerApp.services import Services
class SettingsForm(forms.Form):

View File

@ -12,7 +12,7 @@ from django.conf import settings
from django.core.paginator import Paginator
from YtManagerApp.management.videos import get_videos
from YtManagerApp.models import Subscription, SubscriptionFolder, VIDEO_ORDER_CHOICES, VIDEO_ORDER_MAPPING
from YtManagerApp.management.services import Services
from YtManagerApp.services import Services
from YtManagerApp.utils import youtube, subscription_file_parser
from YtManagerApp.views.controls.modal import ModalMixin

View File

@ -3,7 +3,7 @@ from django.http import HttpResponseForbidden
from django.urls import reverse_lazy
from django.views.generic import FormView
from YtManagerApp.management.scheduler.jobs.synchronize_job import SynchronizeJob
from YtManagerApp.scheduler.jobs.synchronize_job import SynchronizeJob
from YtManagerApp.views.forms.settings import SettingsForm, AdminSettingsForm