Adds setup view

This commit is contained in:
Mouse Reeve 2022-02-17 10:02:42 -08:00
parent e9397eaedd
commit c31ec7dbd5
5 changed files with 50 additions and 0 deletions

View file

@ -0,0 +1,24 @@
# Generated by Django 3.2.12 on 2022-02-17 17:08
from django.db import migrations, models
import uuid
class Migration(migrations.Migration):
dependencies = [
("bookwyrm", "0135_auto_20220217_1624"),
]
operations = [
migrations.AddField(
model_name="sitesettings",
name="admin_code",
field=models.CharField(default=uuid.uuid4, max_length=50),
),
migrations.AddField(
model_name="sitesettings",
name="install_mode",
field=models.BooleanField(default=False),
),
]

View file

@ -1,6 +1,7 @@
""" the particulars for this instance of BookWyrm """ """ the particulars for this instance of BookWyrm """
import datetime import datetime
from urllib.parse import urljoin from urllib.parse import urljoin
import uuid
from django.db import models, IntegrityError from django.db import models, IntegrityError
from django.dispatch import receiver from django.dispatch import receiver
@ -24,6 +25,10 @@ class SiteSettings(models.Model):
instance_description = models.TextField(default="This instance has no description.") instance_description = models.TextField(default="This instance has no description.")
instance_short_description = models.CharField(max_length=255, blank=True, null=True) instance_short_description = models.CharField(max_length=255, blank=True, null=True)
# admin setup options
install_mode = models.BooleanField(default=False)
admin_code = models.CharField(max_length=50, default=uuid.uuid4)
# about page # about page
registration_closed_text = models.TextField( registration_closed_text = models.TextField(
default="We aren't taking new users at this time. You can find an open " default="We aren't taking new users at this time. You can find an open "

View file

@ -58,6 +58,8 @@ urlpatterns = [
views.get_unread_status_string, views.get_unread_status_string,
name="stream-updates", name="stream-updates",
), ),
# instance setup
re_path(r"^setup/?$", views.CreateAdmin.as_view(), name="setup-admin"),
# authentication # authentication
re_path(r"^login/?$", views.Login.as_view(), name="login"), re_path(r"^login/?$", views.Login.as_view(), name="login"),
re_path(r"^login/(?P<confirmed>confirmed)/?$", views.Login.as_view(), name="login"), re_path(r"^login/(?P<confirmed>confirmed)/?$", views.Login.as_view(), name="login"),

View file

@ -113,6 +113,7 @@ from .reading import ReadingStatus
from .report import Report from .report import Report
from .rss_feed import RssFeed from .rss_feed import RssFeed
from .search import Search from .search import Search
from .setup import CreateAdmin
from .status import CreateStatus, EditStatus, DeleteStatus, update_progress from .status import CreateStatus, EditStatus, DeleteStatus, update_progress
from .status import edit_readthrough from .status import edit_readthrough
from .updates import get_notification_count, get_unread_status_string from .updates import get_notification_count, get_unread_status_string

18
bookwyrm/views/setup.py Normal file
View file

@ -0,0 +1,18 @@
""" Installation wizard 🧙 """
from django.template.response import TemplateResponse
from django.utils.decorators import method_decorator
from django.views import View
from bookwyrm import emailing, forms, models
# pylint: disable= no-self-use
class CreateAdmin(View):
"""manage things like the instance name"""
def get(self, request):
"""Create admin user"""
data = {
"register_form": forms.RegisterForm()
}
return TemplateResponse(request, "setup/admin.html", data)