diff --git a/bookwyrm/management/commands/admin_code.py b/bookwyrm/management/commands/admin_code.py new file mode 100644 index 000000000..73531109a --- /dev/null +++ b/bookwyrm/management/commands/admin_code.py @@ -0,0 +1,18 @@ +""" Get your admin code to allow install """ +from django.core.management.base import BaseCommand + +from bookwyrm import models + +def get_admin_code(): + """get that code""" + return models.SiteSettings.objects.get().admin_code + +class Command(BaseCommand): + """command-line options""" + + help = "Gets admin code for configuring BookWyrm" + + # pylint: disable=unused-argument + def handle(self, *args, **options): + """execute init""" + self.stdout.write(get_admin_code()) diff --git a/bookwyrm/management/commands/generate_preview_images.py b/bookwyrm/management/commands/generate_preview_images.py index df2186238..0454e5e51 100644 --- a/bookwyrm/management/commands/generate_preview_images.py +++ b/bookwyrm/management/commands/generate_preview_images.py @@ -10,7 +10,9 @@ class Command(BaseCommand): help = "Generate preview images" + # pylint: disable=no-self-use def add_arguments(self, parser): + """options for how the command is run""" parser.add_argument( "--all", "-a", @@ -38,6 +40,7 @@ class Command(BaseCommand): preview_images.generate_site_preview_image_task.delay() self.stdout.write(" OK 🖼") + # pylint: disable=consider-using-f-string if options["all"]: # Users users = models.User.objects.filter( diff --git a/bookwyrm/templates/setup/admin.html b/bookwyrm/templates/setup/admin.html index 713577d5e..8bba55a8d 100644 --- a/bookwyrm/templates/setup/admin.html +++ b/bookwyrm/templates/setup/admin.html @@ -30,7 +30,7 @@

{% blocktrans trimmed %} An admin key was created when you installed BookWyrm. - You can get your admin key by running ./bw-dev admin-code from the command line on your server. + You can get your admin key by running ./bw-dev admin_code from the command line on your server. {% endblocktrans %}

diff --git a/bw-dev b/bw-dev index 04d14ba0a..478754cbe 100755 --- a/bw-dev +++ b/bw-dev @@ -197,6 +197,9 @@ case "$CMD" in --endpoint-url ${AWS_S3_ENDPOINT_URL}\ --cors-configuration file:///bw/$config_file" "$@" ;; + admin_code) + runweb python manage.py admin_code + ;; runweb) runweb "$@" ;; diff --git a/complete_bwdev.sh b/complete_bwdev.sh index 6dd574541..52d755333 100644 --- a/complete_bwdev.sh +++ b/complete_bwdev.sh @@ -30,4 +30,5 @@ generate_thumbnails generate_preview_images copy_media_to_s3 set_cors_to_s3 +admin_code runweb" -o bashdefault -o default bw-dev