mirror of
https://github.com/chibicitiberiu/ytsm.git
synced 2024-02-24 05:43:31 +00:00
109 lines
3.2 KiB
Python
109 lines
3.2 KiB
Python
|
import logging
|
||
|
|
||
|
from crispy_forms.helper import FormHelper
|
||
|
from crispy_forms.layout import Layout, HTML, Submit, Column
|
||
|
from django import forms
|
||
|
from django.contrib.auth import authenticate, login
|
||
|
from django.contrib.auth.models import User
|
||
|
from YtManagerApp.views.forms.auth import ExtendedUserCreationForm
|
||
|
from django.urls import reverse_lazy
|
||
|
from YtManagerApp.management.appconfig import global_prefs
|
||
|
|
||
|
logger = logging.getLogger("FirstTimeWizard")
|
||
|
|
||
|
|
||
|
class WelcomeForm(forms.Form):
|
||
|
def __init__(self, *args, **kwargs):
|
||
|
super().__init__(*args, **kwargs)
|
||
|
self.helper = FormHelper()
|
||
|
self.helper.layout = Layout(
|
||
|
Submit('submit', value='Continue')
|
||
|
)
|
||
|
|
||
|
|
||
|
class ApiKeyForm(forms.Form):
|
||
|
api_key = forms.CharField(label="YouTube API Key:")
|
||
|
|
||
|
def __init__(self, *args, **kwargs):
|
||
|
super().__init__(*args, **kwargs)
|
||
|
self.helper = FormHelper()
|
||
|
self.helper.layout = Layout(
|
||
|
'api_key',
|
||
|
Column(
|
||
|
Submit('submit', value='Continue'),
|
||
|
HTML('<a href="{% url \'first_time_2\' %}" class="btn">Skip</a>')
|
||
|
)
|
||
|
)
|
||
|
|
||
|
|
||
|
class UserCreationForm(ExtendedUserCreationForm):
|
||
|
form_action = reverse_lazy('first_time_2')
|
||
|
|
||
|
|
||
|
class PickAdminUserForm(forms.Form):
|
||
|
admin_user = forms.ModelChoiceField(
|
||
|
User.objects.order_by('username'),
|
||
|
label='User to promote to admin',
|
||
|
required=True)
|
||
|
|
||
|
def __init__(self, *args, **kwargs):
|
||
|
super().__init__(*args, **kwargs)
|
||
|
self.helper = FormHelper()
|
||
|
self.helper.layout = Layout(
|
||
|
'admin_user',
|
||
|
Column(
|
||
|
Submit('submit', value='Continue'),
|
||
|
HTML('<a href="{% url \'first_time_2\' %}®ister=1" class="btn">Register a new admin user</a>')
|
||
|
)
|
||
|
)
|
||
|
|
||
|
|
||
|
class ServerConfigForm(forms.Form):
|
||
|
|
||
|
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
|
||
|
)
|
||
|
|
||
|
auto_download = forms.BooleanField(
|
||
|
label="Download videos automatically",
|
||
|
required=False
|
||
|
)
|
||
|
|
||
|
download_location = forms.CharField(
|
||
|
label="Download location",
|
||
|
help_text="Location on the server where videos are downloaded.",
|
||
|
required=True
|
||
|
)
|
||
|
|
||
|
def __init__(self, *args, **kwargs):
|
||
|
super().__init__(*args, **kwargs)
|
||
|
self.helper = FormHelper()
|
||
|
self.helper.layout = Layout(
|
||
|
HTML('<h3>Server settings</h3>'),
|
||
|
'sync_schedule',
|
||
|
'allow_registrations',
|
||
|
HTML('<h3>User settings</h3>'),
|
||
|
'auto_download',
|
||
|
'download_location',
|
||
|
Submit('submit', value='Continue'),
|
||
|
)
|
||
|
|
||
|
|
||
|
class DoneForm(forms.Form):
|
||
|
def __init__(self, *args, **kwargs):
|
||
|
super().__init__(*args, **kwargs)
|
||
|
self.helper = FormHelper()
|
||
|
self.helper.layout = Layout(
|
||
|
Submit('submit', value='Finish')
|
||
|
)
|