diff --git a/.env.dev.example b/.env.dev.example index 0036e607d..df6f9b58f 100644 --- a/.env.dev.example +++ b/.env.dev.example @@ -13,16 +13,10 @@ DEFAULT_LANGUAGE="English" ## Leave unset to allow all hosts # ALLOWED_HOSTS="localhost,127.0.0.1,[::1]" -OL_URL=https://openlibrary.org - -## Database backend to use. -## Default is postgres, sqlite is for dev quickstart only (NOT production!!!) -BOOKWYRM_DATABASE_BACKEND=postgres - MEDIA_ROOT=images/ POSTGRES_PORT=5432 -POSTGRES_PASSWORD=securedbpassword123 +POSTGRES_PASSWORD=securedbypassword123 POSTGRES_USER=fedireads POSTGRES_DB=fedireads POSTGRES_HOST=db @@ -47,6 +41,3 @@ EMAIL_HOST_USER=mail@your.domain.here EMAIL_HOST_PASSWORD=emailpassword123 EMAIL_USE_TLS=true EMAIL_USE_SSL=false - -# Set this to true when initializing certbot for domain, false when not -CERTBOT_INIT=false diff --git a/.env.prod.example b/.env.prod.example index e950b2d52..4a7c87b68 100644 --- a/.env.prod.example +++ b/.env.prod.example @@ -13,16 +13,10 @@ DEFAULT_LANGUAGE="English" ## Leave unset to allow all hosts # ALLOWED_HOSTS="localhost,127.0.0.1,[::1]" -OL_URL=https://openlibrary.org - -## Database backend to use. -## Default is postgres, sqlite is for dev quickstart only (NOT production!!!) -BOOKWYRM_DATABASE_BACKEND=postgres - MEDIA_ROOT=images/ POSTGRES_PORT=5432 -POSTGRES_PASSWORD=securedbpassword123 +POSTGRES_PASSWORD=securedbypassword123 POSTGRES_USER=fedireads POSTGRES_DB=fedireads POSTGRES_HOST=db diff --git a/.github/workflows/django-tests.yml b/.github/workflows/django-tests.yml index 75c1c4b41..f9159efe1 100644 --- a/.github/workflows/django-tests.yml +++ b/.github/workflows/django-tests.yml @@ -50,7 +50,6 @@ jobs: SECRET_KEY: beepbeep DEBUG: true DOMAIN: your.domain.here - OL_URL: https://openlibrary.org BOOKWYRM_DATABASE_BACKEND: postgres MEDIA_ROOT: images/ POSTGRES_PASSWORD: hunter2 diff --git a/bookwyrm/forms.py b/bookwyrm/forms.py index 25b72a119..4931805fb 100644 --- a/bookwyrm/forms.py +++ b/bookwyrm/forms.py @@ -150,6 +150,12 @@ class LimitedEditUserForm(CustomForm): help_texts = {f: None for f in fields} +class DeleteUserForm(CustomForm): + class Meta: + model = models.User + fields = ["password"] + + class UserGroupForm(CustomForm): class Meta: model = models.User diff --git a/bookwyrm/models/import_job.py b/bookwyrm/models/import_job.py index c8130af26..f29938469 100644 --- a/bookwyrm/models/import_job.py +++ b/bookwyrm/models/import_job.py @@ -75,7 +75,12 @@ class ImportItem(models.Model): def resolve(self): """try various ways to lookup a book""" - self.book = self.get_book_from_isbn() or self.get_book_from_title_author() + if self.isbn: + self.book = self.get_book_from_isbn() + else: + # don't fall back on title/author search is isbn is present. + # you're too likely to mismatch + self.get_book_from_title_author() def get_book_from_isbn(self): """search by isbn""" diff --git a/bookwyrm/settings.py b/bookwyrm/settings.py index 48e02b67b..00c3d0237 100644 --- a/bookwyrm/settings.py +++ b/bookwyrm/settings.py @@ -52,7 +52,6 @@ SECRET_KEY = env("SECRET_KEY") DEBUG = env.bool("DEBUG", True) ALLOWED_HOSTS = env.list("ALLOWED_HOSTS", ["*"]) -OL_URL = env("OL_URL") # Application definition @@ -114,10 +113,8 @@ STREAMS = ["home", "local", "federated"] # Database # https://docs.djangoproject.com/en/3.2/ref/settings/#databases -BOOKWYRM_DATABASE_BACKEND = env("BOOKWYRM_DATABASE_BACKEND", "postgres") - -BOOKWYRM_DBS = { - "postgres": { +DATABASES = { + "default": { "ENGINE": "django.db.backends.postgresql_psycopg2", "NAME": env("POSTGRES_DB", "fedireads"), "USER": env("POSTGRES_USER", "fedireads"), @@ -127,8 +124,6 @@ BOOKWYRM_DBS = { }, } -DATABASES = {"default": BOOKWYRM_DBS[BOOKWYRM_DATABASE_BACKEND]} - LOGIN_URL = "/login/" AUTH_USER_MODEL = "bookwyrm.User" @@ -136,6 +131,7 @@ AUTH_USER_MODEL = "bookwyrm.User" # Password validation # https://docs.djangoproject.com/en/3.2/ref/settings/#auth-password-validators +# pylint: disable=line-too-long AUTH_PASSWORD_VALIDATORS = [ { "NAME": "django.contrib.auth.password_validation.UserAttributeSimilarityValidator", diff --git a/bookwyrm/static/js/bookwyrm.js b/bookwyrm/static/js/bookwyrm.js index 598dd93ac..e43ed134b 100644 --- a/bookwyrm/static/js/bookwyrm.js +++ b/bookwyrm/static/js/bookwyrm.js @@ -3,7 +3,7 @@ let BookWyrm = new class { constructor() { - this.MAX_FILE_SIZE_BYTES = 10 * 1000000 + this.MAX_FILE_SIZE_BYTES = 10 * 1000000; this.initOnDOMLoaded(); this.initReccuringTasks(); this.initEventListeners(); @@ -45,14 +45,14 @@ let BookWyrm = new class { * Execute code once the DOM is loaded. */ initOnDOMLoaded() { - const bookwyrm = this + const bookwyrm = this; window.addEventListener('DOMContentLoaded', function() { document.querySelectorAll('.tab-group') .forEach(tabs => new TabGroup(tabs)); document.querySelectorAll('input[type="file"]').forEach( bookwyrm.disableIfTooLarge.bind(bookwyrm) - ) + ); }); } @@ -138,6 +138,7 @@ let BookWyrm = new class { * @return {undefined} */ toggleAction(event) { + event.preventDefault(); let trigger = event.currentTarget; let pressed = trigger.getAttribute('aria-pressed') === 'false'; let targetId = trigger.dataset.controls; @@ -182,6 +183,8 @@ let BookWyrm = new class { if (focus) { this.toggleFocus(focus); } + + return false; } /** @@ -298,25 +301,25 @@ let BookWyrm = new class { } disableIfTooLarge(eventOrElement) { - const { addRemoveClass, MAX_FILE_SIZE_BYTES } = this - const element = eventOrElement.currentTarget || eventOrElement + const { addRemoveClass, MAX_FILE_SIZE_BYTES } = this; + const element = eventOrElement.currentTarget || eventOrElement; - const submits = element.form.querySelectorAll('[type="submit"]') - const warns = element.parentElement.querySelectorAll('.file-too-big') + const submits = element.form.querySelectorAll('[type="submit"]'); + const warns = element.parentElement.querySelectorAll('.file-too-big'); const isTooBig = element.files && element.files[0] && - element.files[0].size > MAX_FILE_SIZE_BYTES + element.files[0].size > MAX_FILE_SIZE_BYTES; if (isTooBig) { - submits.forEach(submitter => submitter.disabled = true) + submits.forEach(submitter => submitter.disabled = true); warns.forEach( sib => addRemoveClass(sib, 'is-hidden', false) - ) + ); } else { - submits.forEach(submitter => submitter.disabled = false) + submits.forEach(submitter => submitter.disabled = false); warns.forEach( sib => addRemoveClass(sib, 'is-hidden', true) - ) + ); } } -} +}(); diff --git a/bookwyrm/static/js/localstorage.js b/bookwyrm/static/js/localstorage.js index 059557799..b485ed7ea 100644 --- a/bookwyrm/static/js/localstorage.js +++ b/bookwyrm/static/js/localstorage.js @@ -17,7 +17,7 @@ let LocalStorageTools = new class { * @return {undefined} */ updateDisplay(event) { - // used in set reading goal + // Used in set reading goal let key = event.target.dataset.id; let value = event.target.dataset.value; @@ -34,10 +34,10 @@ let LocalStorageTools = new class { * @return {undefined} */ setDisplay(node) { - // used in set reading goal + // Used in set reading goal let key = node.dataset.hide; let value = window.localStorage.getItem(key); BookWyrm.addRemoveClass(node, 'is-hidden', value); } -} +}(); diff --git a/bookwyrm/templates/book/book.html b/bookwyrm/templates/book/book.html index af2230200..a48120e94 100644 --- a/bookwyrm/templates/book/book.html +++ b/bookwyrm/templates/book/book.html @@ -20,8 +20,7 @@ - ({{ book.series }} - {% if book.series_number %} #{{ book.series_number }}{% endif %}) + ({{ book.series }}{% if book.series_number %} #{{ book.series_number }}{% endif %})
{% endif %} diff --git a/bookwyrm/templates/components/modal.html b/bookwyrm/templates/components/modal.html index 74dcadacd..b29ff8d91 100644 --- a/bookwyrm/templates/components/modal.html +++ b/bookwyrm/templates/components/modal.html @@ -1,7 +1,7 @@ {% load i18n %}