Adds overview page to setup

This commit is contained in:
Mouse Reeve 2022-02-17 13:01:36 -08:00
parent 1b9688832a
commit f6e2ec02aa
6 changed files with 214 additions and 50 deletions

View file

@ -218,7 +218,6 @@
<p id="status-success-message" class="live-message is-sr-only is-hidden">{% trans "Successfully posted status" %}</p> <p id="status-success-message" class="live-message is-sr-only is-hidden">{% trans "Successfully posted status" %}</p>
<p id="status-error-message" class="live-message notification is-danger p-3 pr-5 pl-5 is-hidden">{% trans "Error posting status" %}</p> <p id="status-error-message" class="live-message notification is-danger p-3 pr-5 pl-5 is-hidden">{% trans "Error posting status" %}</p>
</div> </div>
{% endblock %}
<footer class="footer"> <footer class="footer">
<div class="container"> <div class="container">
@ -255,6 +254,7 @@
</div> </div>
</div> </div>
</footer> </footer>
{% endblock %}
<script> <script>
var csrf_token = '{{ csrf_token }}'; var csrf_token = '{{ csrf_token }}';

View file

@ -2,58 +2,60 @@
{% load i18n %} {% load i18n %}
{% block header %} {% block header %}
<h1 class="title">{% trans "Setup admin user" %}</h1> <h1 class="title">{% trans "Set up BookWyrm" %}</h1>
<div class="subtitle"> <div class="subtitle">
{% trans "Your account a user and an admin" %} {% trans "Your account as a user and an admin" %}
</div> </div>
{% endblock %} {% endblock %}
{% block panel %} {% block panel %}
<div class="columns content"> <div class="block content">
<div class="column is-half"> <h2 class="title is-4">{% trans "Create your account" %}</h2>
<div class="box has-background-primary-light"> <div class="columns">
<h2 class="title is-4">{% trans "Create your account" %}</h2> <div class="column is-half">
<form name="register" method="post" action="{% url 'setup' %}"> <div class="box has-background-primary-light">
<div class="field"> <form name="register" method="post" action="{% url 'setup-admin' %}">
<label class="label" for="id_admin_key"> <div class="field">
{% trans "Admin key:" %} <label class="label" for="id_admin_key">
</label> {% trans "Admin key:" %}
<div class="control"> </label>
<input <div class="control">
type="password" <input
name="admin_key" type="password"
class="input" name="admin_key"
id="id_admin_key" class="input"
aria-describedby="desc_admin_key" id="id_admin_key"
required aria-describedby="desc_admin_key"
> required
<p class="help" id="desc_admin_key"> >
{% blocktrans trimmed %} <p class="help" id="desc_admin_key">
An admin key was created when you installed BookWyrm. {% blocktrans trimmed %}
You can get your admin key by running <code>./bw-dev admin_code</code> from the command line on your server. An admin key was created when you installed BookWyrm.
{% endblocktrans %} You can get your admin key by running <code>./bw-dev admin_code</code> from the command line on your server.
</p> {% endblocktrans %}
</p>
</div>
</div> </div>
</div> {% include 'snippets/register_form.html' %}
{% include 'snippets/register_form.html' %} </form>
</form> </div>
</div>
<div class="column">
<p>
{% blocktrans trimmed %}
As an admin, you'll be able to configure the instance name and information, and moderate your instance.
This means you will have access to private information about your users, and are responsible for responding to reports of bad behavior or spam.
{% endblocktrans %}
</p>
<p>
{% trans "Once the instance is set up, you can promote other users to moderator or admin roles from the admin panel." %}
</p>
<p>
<a href="https://docs.joinbookwyrm.com/moderation.html" target="_blank">
{% trans "Learn more about moderation" %}
</a>
</p>
</div> </div>
</div>
<div class="column">
<p>
{% blocktrans trimmed %}
As an admin, you'll be able to configure the instance name and information, and moderate your instance.
This means you will have access to private information about your users, and are responsible for repsonding to reports of bad behavior or spam.
{% endblocktrans %}
</p>
<p>
{% trans "Once the instance is set up, you can promote other users to moderator or admin roles from the admin panel." %}
</p>
<p>
<a href="https://docs.joinbookwyrm.com/moderation.html" target="_blank">
{% trans "Learn more about moderation" %}
</a>
</p>
</div> </div>
</div> </div>
{% endblock %} {% endblock %}

View file

@ -0,0 +1,130 @@
{% extends 'setup/layout.html' %}
{% load i18n %}
{% block header %}
<h1 class="title">{% trans "Instance Configuration" %}</h1>
<div class="subtitle">
{% trans "Make sure everything looks right before proceeding" %}
</div>
{% endblock %}
{% block panel %}
<div class="block content">
{% if warnings.debug %}
<div class="notification is-danger is-flex is-align-items-start">
<span class="icon icon-warning is-size-4 pr-3" aria-hidden="true"></span>
<span>
{% blocktrans trimmed %}
You are running BookWyrm in <strong>debug</strong> mode.
This should <strong>never</strong> be used in a production environment.
{% endblocktrans %}
</span>
</div>
{% endif %}
<div class="columns">
<div class="column is-half is-flex is-flex-direction-column">
<h2 class="title is-4">{% trans "Settings" %}</h2>
<div class="notification is-flex-grow-1">
<dl>
<dt class="is-pulled-left mr-5 has-text-weight-bold">
{% trans "Instance domain:" %}
</dt>
<dd>
{{ info.domain }}
</dd>
<dt class="is-pulled-left mr-5 has-text-weight-bold">
{% trans "Protocol:" %}
</dt>
<dd>
{% if info.use_https %}
<span class="tag is-success">https</span>
{% else %}
<span class="tag is-danger">http</span>
{% endif %}
</dd>
<dt class="is-pulled-left mr-5 has-text-weight-bold">
{% trans "Software version:" %}
</dt>
<dd>
{{ info.version }}
</dd>
<dt class="is-pulled-left mr-5 has-text-weight-bold">
{% trans "Using S3:" %}
</dt>
<dd>
{{ info.use_s3|yesno }}
</dd>
</dl>
</div>
</div>
<div class="column is-half is-flex is-flex-direction-column">
<h2 class="title is-4">{% trans "Display" %}</h2>
<div class="notification is-flex-grow-1">
<dl>
<dt class="is-pulled-left mr-5 has-text-weight-bold">
{% trans "Default interface language:" %}
</dt>
<dd>
{{ info.language }}
</dd>
<dt class="is-pulled-left mr-5 has-text-weight-bold">
{% trans "Email sender:" %}
</dt>
<dd>
{{ info.email_sender }}
</dd>
<dt class="is-pulled-left mr-5 has-text-weight-bold">
{% trans "Enable preview images" %}
</dt>
<dd>
{{ info.preview_images|yesno }}
</dd>
<dt class="is-pulled-left mr-5 has-text-weight-bold">
{% trans "Enable image thumbnails" %}
</dt>
<dd>
{{ info.thumbnails|yesno }}
</dd>
</dl>
</div>
</div>
</div>
</div>
<div class="block content">
<h2 class="title is-4">{% trans "Does everything look right?" %}</h2>
<p class="subtitle help">
{% blocktrans trimmed %}
This is your last change to set your domain and protocol.
{% endblocktrans %}
</p>
<div class="box">
<div class="control">
<a class="button is-primary" href="{% url 'setup-admin' %}">
<span class="icon icon-check" aria-hidden="true"></span>
<span>{% trans "Continue" %}</span>
</a>
</div>
<p>
{% blocktrans trimmed %}
You can change your instance settings in the <code>.env</code> file on your server.
{% endblocktrans %}
<a href="https://docs.joinbookwyrm.com/installing-in-production.html" target="_blank">
{% trans "View installation instructions" %}
</a>
</p>
</div>
</div>
{% endblock %}

View file

@ -59,7 +59,8 @@ urlpatterns = [
name="stream-updates", name="stream-updates",
), ),
# instance setup # instance setup
re_path(r"^setup/?$", views.CreateAdmin.as_view(), name="setup"), re_path(r"^setup/?$", views.InstanceConfig.as_view(), name="setup"),
re_path(r"^setup/admin?$", 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,7 +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 .setup import InstanceConfig, 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

View file

@ -8,10 +8,41 @@ from django.template.response import TemplateResponse
from django.views import View from django.views import View
from bookwyrm import forms, models from bookwyrm import forms, models
from bookwyrm.settings import DOMAIN from bookwyrm import settings
# pylint: disable= no-self-use # pylint: disable= no-self-use
class InstanceConfig(View):
"""make sure the instance looks correct before adding any data"""
def get(self, request):
"""Check out this cool instance"""
# only allow this view when an instance is being configured
site = models.SiteSettings.objects.get()
if not site.install_mode:
raise PermissionDenied()
# check for possible problems with the instance configuration
warnings = {}
warnings["debug"] = settings.DEBUG
warnings["protocol_in_domain"] = settings.DOMAIN.startswith("http")
data = {
"warnings": warnings,
"info": {
"domain": settings.DOMAIN,
"version": settings.VERSION,
"use_https": settings.USE_HTTPS,
"language": settings.LANGUAGE_CODE,
"use_s3": settings.USE_S3,
"email_sender": f"{settings.EMAIL_SENDER_NAME}@{settings.EMAIL_SENDER_DOMAIN}",
"preview_images": settings.ENABLE_PREVIEW_IMAGES,
"thumbnails": settings.ENABLE_THUMBNAIL_GENERATION,
},
}
return TemplateResponse(request, "setup/config.html", data)
class CreateAdmin(View): class CreateAdmin(View):
"""manage things like the instance name""" """manage things like the instance name"""
@ -39,7 +70,7 @@ class CreateAdmin(View):
return TemplateResponse(request, "setup/admin.html", data) return TemplateResponse(request, "setup/admin.html", data)
localname = form.data["localname"].strip() localname = form.data["localname"].strip()
username = f"{localname}@{DOMAIN}" username = f"{localname}@{settings.DOMAIN}"
user = models.User.objects.create_superuser( user = models.User.objects.create_superuser(
username, username,