from crispy_forms.helper import FormHelper from crispy_forms.layout import Layout, HTML, Submit from django import forms from YtManagerApp.models import UserSettings class SettingsForm(forms.ModelForm): class Meta: model = UserSettings exclude = ['user'] def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.helper = FormHelper() self.helper.form_class = 'form-horizontal' self.helper.label_class = 'col-lg-3' self.helper.field_class = 'col-lg-9' self.helper.layout = Layout( 'mark_deleted_as_watched', 'delete_watched', HTML('

Download settings

'), 'auto_download', 'download_path', 'download_file_pattern', 'download_format', 'download_order', 'download_global_limit', 'download_subscription_limit', HTML('

Subtitles download settings

'), 'download_subtitles', 'download_subtitles_langs', 'download_subtitles_all', 'download_autogenerated_subtitles', 'download_subtitles_format', Submit('submit', value='Save') ) class AdminSettingsForm(forms.Form): api_key = forms.CharField(label="YouTube API key") allow_registrations = forms.BooleanField( label="Allow user registrations", help_text="Disabling this option will prevent anyone from registering to the site.", initial=True, required=False ) sync_schedule = forms.CharField( label="Synchronization schedule", help_text="How often should the application look for new videos.", initial="5 * * * *", required=True ) scheduler_concurrency = forms.IntegerField( label="Synchronization concurrency", help_text="How many jobs are executed executed in parallel. Since most jobs are I/O bound (mostly use the hard " "drive and network), there is no significant advantage to increase it.", initial=2, required=True ) def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.helper = FormHelper() self.helper.form_class = 'form-horizontal' self.helper.label_class = 'col-lg-3' self.helper.field_class = 'col-lg-9' self.helper.layout = Layout( HTML('

General settings

'), 'api_key', 'allow_registrations', HTML('

Scheduler settings

'), 'sync_schedule', 'scheduler_concurrency', Submit('submit', value='Save') )