Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge main into production Nov24 #71

Open
wants to merge 140 commits into
base: production
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
140 commits
Select commit Hold shift + click to select a range
539a9fa
csv import and export fixes
hughrun Nov 25, 2023
aaa31b4
Add privileges to codeql-analysis.yml
MaggieFero Aug 16, 2023
f0567ed
Bump versions on libraries (#10)
phildini Aug 17, 2023
9e17662
Merge branch 'bookwyrm-social:main' into main
MaggieFero Mar 5, 2024
2dac7c7
fix: requirements.txt to reduce vulnerabilities
snyk-bot Mar 16, 2024
d414b02
Reapplying permission change lost in sync
MaggieFero Mar 16, 2024
981c2a1
Merge branch 'main' into snyk-fix-01d34ee7b28d9adf4c6a25e5bf2cc504
MaggieFero Mar 16, 2024
bcc469f
Remove Pillow version bump from this
MaggieFero Mar 16, 2024
5ad6da4
Another approach to Opentelemetry Version Bump
MaggieFero Mar 16, 2024
8a246a1
Bump version: opentelemetry-sdk to 1.23.0
MaggieFero Mar 16, 2024
52e660c
Remove grpcio pin
MaggieFero Mar 16, 2024
069d6a1
Revert "Remove grpcio pin"
MaggieFero Mar 16, 2024
bea4cb2
Version bump opentelemetry-exporter-otlp-proto-grpc to 1.23.0
MaggieFero Mar 16, 2024
1c5c398
Decrement version: opentelemetry-exporter-otlp-proto-grpc==1.22.0
MaggieFero Mar 16, 2024
ac89c5a
Decrement version: opentelemetry-sdk==1.22.0
MaggieFero Mar 16, 2024
0b399fd
Align opentelemetry-api -sdk and -exporter-otlp-proto-grpc versions
MaggieFero Mar 16, 2024
c06e8b0
Bringing opentelemetry-instrumentation a little closer to current tha…
MaggieFero Mar 17, 2024
6f2baa8
Create phildini-bookwyrm-troubleshooting.md (#50)
MaggieFero Mar 17, 2024
8efc235
Merge branch 'bookwyrm-social:main' into main
MaggieFero Mar 21, 2024
b549408
fix: dev-tools/requirements.txt to reduce vulnerabilities (#51)
MaggieFero Mar 21, 2024
dfb8b96
fix: requirements.txt to reduce vulnerabilities
snyk-bot Apr 17, 2024
33b67ba
Add privileges to codeql-analysis.yml
MaggieFero Aug 16, 2023
4c20182
Bump versions on libraries (#10)
phildini Aug 17, 2023
0371cef
Merge branch 'main' into bookwyrm-social-main
MaggieFero May 13, 2024
ada1994
Merge pull request #57 from phildini/bookwyrm-social-main
MaggieFero May 13, 2024
ecf0bf1
Merge branch 'main' into snyk-fix-5e6d90b557b300b5a8f54932009743df
MaggieFero May 13, 2024
ebefce3
Merge branch 'main' into snyk-fix-01d34ee7b28d9adf4c6a25e5bf2cc504
MaggieFero May 13, 2024
a55c53d
Merge pull request #56 from phildini/snyk-fix-5e6d90b557b300b5a8f5493…
MaggieFero May 13, 2024
f43f5fc
Merge pull request #49 from phildini/snyk-fix-01d34ee7b28d9adf4c6a25e…
MaggieFero May 13, 2024
5596f61
fix: requirements.txt to reduce vulnerabilities
snyk-bot May 21, 2024
ad38779
Merge pull request #59 from phildini/snyk-fix-67318f4c451d377b46c7c09…
MaggieFero May 24, 2024
3f08d6d
Use a simpler query for books to show on the landing page
mouse-reeve Jun 8, 2024
2e67547
Reorganizes PR template a bit
mouse-reeve Jun 8, 2024
261e794
possible fix for #3372 - user export timeouts
hughrun Jun 9, 2024
1d4119e
LOL
hughrun Jun 9, 2024
1a2f434
Fix CSS path prefix when S3 storage is used
lo48576 Jun 12, 2024
37caed7
fix: requirements.txt to reduce vulnerabilities
snyk-bot Jun 19, 2024
3236003
Merge pull request #3378 from hughrun/get-books-for-user
mouse-reeve Jun 23, 2024
e5b260e
Merge branch 'main' into csv
hughrun Jun 29, 2024
06d6360
merge latest changes and add tests
hughrun Jun 30, 2024
1bcf38e
fix: requirements.txt to reduce vulnerabilities
snyk-bot Jul 10, 2024
8a235bc
Bump django from 4.2.11 to 4.2.14
dependabot[bot] Jul 10, 2024
ab30738
Merge pull request #3384 from lo48576/fix/css-path-prefix-with-s3-bac…
BartSchuurmans Jul 14, 2024
b3b8d41
fix: requirements.txt to reduce vulnerabilities
snyk-bot Jul 16, 2024
acc6814
Order user shelf previews by book shelved date
matthewmincher Jul 21, 2024
f6eb4f4
Add test for shelf order
matthewmincher Jul 21, 2024
94dfbbc
fix BookwyrmBooksImporter and tests
hughrun Jul 27, 2024
93c6b76
Merge branch 'main' into csv
hughrun Jul 27, 2024
1608ca6
improve formatting
hughrun Jul 27, 2024
2cdbddc
.pylintrc: use symbolic names for message suppressions
dato Jul 27, 2024
1a0fbac
pylint: upgrade to 3.2.6
dato Jul 27, 2024
81ee5e9
pylint: remove unused global suppressions
dato Jul 27, 2024
0b87aac
pylint: enable `useless-suppression` lint and perform cleanup
dato Jul 27, 2024
8ce2984
Merge pull request #3393 from bookwyrm-social/dependabot/pip/django-4…
mouse-reeve Jul 27, 2024
dc54f28
Type fix
mouse-reeve Jul 27, 2024
300eeac
Merge pull request #3374 from bookwyrm-social/landing-page-books
mouse-reeve Jul 27, 2024
f0e5c33
Merge pull request #3399 from dato/pylint_useless_suppression_cleanup
mouse-reeve Jul 27, 2024
afd44e1
Add an up-to-date sqlparse to requirements.txt
dato Jul 27, 2024
0887651
Actions: run makemigrations check with increased verbosity
dato Jul 27, 2024
eef0551
Merge pull request #3400 from dato/upgrade_sqlparse
mouse-reeve Jul 27, 2024
e41b27e
Merge branch 'main' into pr-template
mouse-reeve Jul 27, 2024
355a607
Merge branch 'main' into pylint3
mouse-reeve Jul 27, 2024
7311526
Merge pull request #3375 from bookwyrm-social/pr-template
mouse-reeve Jul 27, 2024
7f773b3
Merge pull request #3398 from bookwyrm-social/pylint3
mouse-reeve Jul 27, 2024
43577f3
Merge branch 'main' into csv
mouse-reeve Jul 27, 2024
8122214
Add failing test case for comment progress clobbering start_date
dato Jul 28, 2024
041f2fc
edit_readthrough: set start_date/finish_date iff present in request
dato Jul 28, 2024
f4133e0
celerywyrm: allow broker and result backend from the environment
dato Dec 1, 2023
3d28019
Use in-memory backends for Celery in tests and workflows
dato Dec 1, 2023
8aba8ca
merge migration
hughrun Jul 28, 2024
69962bb
Avoid empty <title> in templates
dato Jul 29, 2024
b454358
Bump django from 4.2.14 to 4.2.15
dependabot[bot] Aug 7, 2024
fc33edb
Bump aiohttp from 3.9.4 to 3.10.2
dependabot[bot] Aug 9, 2024
9e73ab0
Merge pull request #3407 from bookwyrm-social/dependabot/pip/django-4…
mouse-reeve Aug 9, 2024
96a2fa5
Merge pull request #3402 from dato/ostatus_no_empty_titles
mouse-reeve Aug 9, 2024
66dd39e
Merge pull request #3151 from dato/celery_inmem
mouse-reeve Aug 9, 2024
95c2798
Merge pull request #3401 from dato/comment_progress_keep_start_date
mouse-reeve Aug 9, 2024
7fc54c5
fixes for bookwyrm csv import
hughrun Aug 10, 2024
2bb77d9
Updated search view to trim leading and trailing whitespace for autho…
timothyjrogers Aug 11, 2024
f68e33f
Added additional test cases for searches with leading and trailing wh…
timothyjrogers Aug 11, 2024
cf753af
Merge pull request #3410 from timothyjrogers/trim-search-whitespace
mouse-reeve Aug 12, 2024
6ec3783
Merge branch 'main' into dependabot/pip/aiohttp-3.10.2
mouse-reeve Aug 12, 2024
cf61279
Narrowed is_authenticated check in verfication_modal to only restrict…
timothyjrogers Aug 13, 2024
7ff1ab9
Merge pull request #3411 from timothyjrogers/fix-link-verification-mo…
mouse-reeve Aug 13, 2024
413c26b
Merge pull request #3135 from hughrun/csv
mouse-reeve Aug 23, 2024
142ed70
Sets edit status header to indicate status type
mouse-reeve Aug 23, 2024
f53bb62
Allow users to hide ratings in the UI
mouse-reeve Aug 23, 2024
6120984
Adds option to show ratings to the user settings panel
mouse-reeve Aug 24, 2024
23471f6
Prettifies javascript
mouse-reeve Aug 24, 2024
c9155bd
Adds migration
mouse-reeve Aug 24, 2024
698a0b1
Adds some unit tests
mouse-reeve Aug 24, 2024
9f5ca7a
Uses workaround for test that fails ~sometimes~
mouse-reeve Aug 26, 2024
bd773f4
Uses much simpler approach to ensuring test result order
mouse-reeve Aug 26, 2024
df607a0
Merge pull request #3419 from bookwyrm-social/test-fix
mouse-reeve Aug 26, 2024
a6912dc
Merge branch 'main' into hide-ratings
mouse-reeve Aug 26, 2024
abb97e6
Merge branch 'main' into edit-status-header
mouse-reeve Aug 26, 2024
23dfe39
Merge pull request #3418 from bookwyrm-social/hide-ratings
hughrun Aug 27, 2024
3555ef9
Merge pull request #3416 from bookwyrm-social/edit-status-header
mouse-reeve Aug 27, 2024
4123478
Merge pull request #3423 from bookwyrm-social/misc-tests
mouse-reeve Aug 28, 2024
904aa6c
Merge pull request #3394 from matthewmincher/feature/user-shelf-previ…
mouse-reeve Aug 28, 2024
80248d3
Convert min_confidence param to string to appease mypy
dato Aug 31, 2024
cbdb59d
Merge pull request #3408 from bookwyrm-social/dependabot/pip/aiohttp-…
mouse-reeve Sep 2, 2024
15ec79d
fix: requirements.txt to reduce vulnerabilities
snyk-bot Sep 3, 2024
ed55e05
add test for resolving users with aliases
hughrun Sep 8, 2024
1a93ba0
check alias with new user data
hughrun Sep 8, 2024
9c89e0f
sign all AP requests
hughrun Sep 8, 2024
c0ce22a
docker-compose 'version' has been deprecated
hughrun Sep 9, 2024
13381b9
Merge pull request #3435 from hughrun/docker-version
mouse-reeve Sep 9, 2024
cfe10fa
update error message
hughrun Sep 9, 2024
a61ca16
Fix post dates being inconsistent
hughrun Sep 14, 2024
dd45823
enable localised dates
hughrun Sep 18, 2024
bee9daf
update tests
hughrun Sep 18, 2024
6745a9a
Add test for #3365 fix (#5)
dato Sep 19, 2024
514c54f
black formatting
hughrun Sep 19, 2024
999829d
Bump django from 4.2.15 to 4.2.16
dependabot[bot] Oct 8, 2024
6143aa6
Fix IntegrityError when creating periodic tasks
Guanchishan Oct 11, 2024
f8650bb
show Wikidata link on author page
Guanchishan Oct 13, 2024
1923db3
Merge pull request #3434 from hughrun/signed_requests
mouse-reeve Oct 17, 2024
f1b0e4b
Merge pull request #3432 from hughrun/3426
mouse-reeve Oct 17, 2024
8594c8c
Updates locales
mouse-reeve Oct 17, 2024
0ccbf8d
Fixes inconsistent wording in source text
mouse-reeve Oct 17, 2024
0a3fc58
Check for wikidata when determining if links are present
mouse-reeve Oct 17, 2024
7ecf3b6
Merge pull request #3451 from Guanchishan/patch-1
mouse-reeve Oct 17, 2024
20026b9
Merge pull request #3454 from Guanchishan/patch-3
mouse-reeve Oct 17, 2024
f2eb3fd
Merge pull request #3458 from bookwyrm-social/update_locales
mouse-reeve Oct 17, 2024
09bbaf0
Merge pull request #3442 from bookwyrm-social/dependabot/pip/django-4…
mouse-reeve Oct 17, 2024
14dba48
Merge pull request #3437 from hughrun/published_date
mouse-reeve Oct 17, 2024
750cedd
fix failing test
hughrun Oct 21, 2024
d16faac
Merge pull request #3460 from hughrun/3426
mouse-reeve Oct 21, 2024
b6350cf
Merge pull request #63 from phildini/snyk-fix-f9ba1cca5dac3fa6217ced0…
MaggieFero Nov 15, 2024
5b2a613
Merge remote-tracking branch 'upstream/main'
phildini Nov 15, 2024
019978b
Merge branch 'main' into snyk-fix-c5dfec6a07a6a9020e6762d9384e1fa9
MaggieFero Nov 15, 2024
c0ca4ec
Merge branch 'main' into snyk-fix-7722961d2dd3f2557b2a4654047227f7
MaggieFero Nov 15, 2024
1e51062
Merge branch 'main' into snyk-fix-677a69233881a32823e8fa43a278626f
MaggieFero Nov 15, 2024
5defe19
Merge pull request #62 from phildini/snyk-fix-c5dfec6a07a6a9020e6762d…
MaggieFero Nov 15, 2024
cf22afe
Merge branch 'main' into snyk-fix-677a69233881a32823e8fa43a278626f
MaggieFero Nov 15, 2024
4e596e4
Merge pull request #65 from phildini/snyk-fix-7722961d2dd3f2557b2a465…
MaggieFero Nov 15, 2024
b562204
Merge branch 'main' into snyk-fix-677a69233881a32823e8fa43a278626f
MaggieFero Nov 15, 2024
cb5603d
Merge pull request #68 from phildini/snyk-fix-677a69233881a32823e8fa4…
MaggieFero Nov 15, 2024
9892bf7
Merge branch 'production' into main
phildini Nov 15, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 24 additions & 34 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -1,35 +1,29 @@
<!--
Thanks for contributing!

Please ensure the name of your PR is written in imperative present tense. For example:

- "fix color contrast on submit buttons"
- "add 'favourite food' value to Author model"
Thanks for contributing! This template has some checkboxes that help keep track of what changes go into a release.

To check (tick) a list item, replace the space between square brackets with an x, like this:

- [x] I have checked the box

You can find more information and tips for BookWyrm contributors at https://docs.joinbookwyrm.com/contributing.html
-->

## Are you finished?

### Linters
## Description
<!--
Please run linters on your code before submitting your PR.
If you miss this step it is likely that the GitHub task runners will fail.
Describe what your pull request does here
-->

- [ ] I have checked my code with `black`, `pylint`, and `mypy`, or `./bw-dev formatters`

### Tests
<!-- Check one -->
<!--
For pull requests that relate or close an issue, please include them
below. We like to follow [Github's guidance on linking issues to pull requests](https://docs.github.com/en/issues/tracking-your-work-with-issues/linking-a-pull-request-to-an-issue).

- [ ] My changes do not need new tests
- [ ] All tests I have added are passing
- [ ] I have written tests but need help to make them pass
- [ ] I have not written tests and need help to write them
For example having the text: "closes #1234" would connect the current pull
request to issue 1234. And when we merge the pull request, Github will
automatically close the issue.
-->

- Related Issue #
- Closes #

## What type of Pull Request is this?
<!-- Check all that apply -->
Expand All @@ -48,21 +42,6 @@ If you miss this step it is likely that the GitHub task runners will fail.

### Details of breaking or configuration changes (if any of above checked)

## Description

<!--
Describe what your pull request does here.

For pull requests that relate or close an issue, please include them
below. We like to follow [Github's guidance on linking issues to pull requests](https://docs.github.com/en/issues/tracking-your-work-with-issues/linking-a-pull-request-to-an-issue).

For example having the text: "closes #1234" would connect the current pull
request to issue 1234. And when we merge the pull request, Github will
automatically close the issue.
-->

- Related Issue #
- Closes #

## Documentation
<!--
Expand All @@ -76,3 +55,14 @@ Our documentation is maintained in a separate repository at https://github.com/b
- [ ] I have created a matching pull request in the Documentation repository
- [ ] I intend to create a matching pull request in the Documentation repository after this PR is merged

<!-- Amazing! Thanks for filling that out. Your PR will need to have passing tests and happy linters before we can merge
You will need to check your code with `black`, `pylint`, and `mypy`, or `./bw-dev formatters`
-->

### Tests
<!-- Check one -->

- [ ] My changes do not need new tests
- [ ] All tests I have added are passing
- [ ] I have written tests but need help to make them pass
- [ ] I have not written tests and need help to write them
2 changes: 1 addition & 1 deletion .github/workflows/python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ jobs:
- name: Set up .env
run: cp .env.example .env
- name: Check migrations up-to-date
run: python ./manage.py makemigrations --check
run: python ./manage.py makemigrations --check -v 3
- name: Run Tests
run: pytest -n 3

Expand Down
14 changes: 13 additions & 1 deletion .pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,19 @@ ignore=migrations
load-plugins=pylint.extensions.no_self_use

[MESSAGES CONTROL]
disable=E1101,E1135,E1136,R0903,R0901,R0902,W0707,W0511,W0406,R0401,R0801,C3001,import-error
disable =
cyclic-import,
duplicate-code,
fixme,
no-member,
raise-missing-from,
too-few-public-methods,
too-many-ancestors,
too-many-instance-attributes,
unnecessary-lambda-assignment,
unsubscriptable-object,
enable =
useless-suppression

[FORMAT]
max-line-length=88
10 changes: 3 additions & 7 deletions bookwyrm/activitypub/base_activity.py
Original file line number Diff line number Diff line change
Expand Up @@ -369,17 +369,13 @@ def resolve_remote_id(

# load the data and create the object
try:
data = get_data(remote_id)
data = get_activitypub_data(remote_id)
except ConnectionError:
logger.info("Could not connect to host for remote_id: %s", remote_id)
return None
except requests.HTTPError as e:
if (e.response is not None) and e.response.status_code == 401:
# This most likely means it's a mastodon with secure fetch enabled.
data = get_activitypub_data(remote_id)
else:
logger.info("Could not connect to host for remote_id: %s", remote_id)
return None
logger.exception("HTTP error - remote_id: %s - error: %s", remote_id, e)
return None
# determine the model implicitly, if not provided
# or if it's a model with subclasses like Status, check again
if not model or hasattr(model.objects, "select_subclasses"):
Expand Down
1 change: 0 additions & 1 deletion bookwyrm/activitypub/book.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ class Edition(Book):
type: str = "Edition"


# pylint: disable=invalid-name
@dataclass(init=False)
class Work(Book):
"""work instance of a book object"""
Expand Down
1 change: 0 additions & 1 deletion bookwyrm/activitypub/ordered_collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ class OrderedCollection(ActivityObject):
type: str = "OrderedCollection"


# pylint: disable=invalid-name
@dataclass(init=False)
class OrderedCollectionPrivate(OrderedCollection):
"""an ordered collection with privacy settings"""
Expand Down
4 changes: 0 additions & 4 deletions bookwyrm/activitypub/verbs.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ def action(self, allow_external_connections=True):
self.object.to_model(allow_external_connections=allow_external_connections)


# pylint: disable=invalid-name
@dataclass(init=False)
class Create(Verb):
"""Create activity"""
Expand All @@ -33,7 +32,6 @@ class Create(Verb):
type: str = "Create"


# pylint: disable=invalid-name
@dataclass(init=False)
class Delete(Verb):
"""Create activity"""
Expand Down Expand Up @@ -63,7 +61,6 @@ def action(self, allow_external_connections=True):
# if we can't find it, we don't need to delete it because we don't have it


# pylint: disable=invalid-name
@dataclass(init=False)
class Update(Verb):
"""Update activity"""
Expand Down Expand Up @@ -227,7 +224,6 @@ def action(self, allow_external_connections=True):
self.to_model(allow_external_connections=allow_external_connections)


# pylint: disable=invalid-name
@dataclass(init=False)
class Announce(Verb):
"""boosting a status"""
Expand Down
2 changes: 1 addition & 1 deletion bookwyrm/activitystreams.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def unread_by_status_type_id(self, user_id):
stream_id = self.stream_id(user_id)
return f"{stream_id}-unread-by-type"

def get_rank(self, obj): # pylint: disable=no-self-use
def get_rank(self, obj):
"""statuses are sorted by date published"""
return obj.published_date.timestamp()

Expand Down
1 change: 0 additions & 1 deletion bookwyrm/apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ class BookwyrmConfig(AppConfig):
name = "bookwyrm"
verbose_name = "BookWyrm"

# pylint: disable=no-self-use
def ready(self):
"""set up OTLP and preview image files, if desired"""
if settings.OTEL_EXPORTER_OTLP_ENDPOINT or settings.OTEL_EXPORTER_CONSOLE:
Expand Down
1 change: 0 additions & 1 deletion bookwyrm/book_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ def search(
...


# pylint: disable=arguments-differ
def search(
query: str,
*,
Expand Down
2 changes: 1 addition & 1 deletion bookwyrm/connectors/abstract_connector.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ async def get_results(
),
"User-Agent": USER_AGENT,
}
params = {"min_confidence": min_confidence}
params = {"min_confidence": str(min_confidence)}
try:
async with session.get(url, headers=headers, params=params) as response:
if not response.ok:
Expand Down
2 changes: 1 addition & 1 deletion bookwyrm/context_processors.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from bookwyrm import models, settings


def site_settings(request): # pylint: disable=unused-argument
def site_settings(request):
"""include the custom info about the site"""
request_protocol = "https://"
if not request.is_secure():
Expand Down
2 changes: 1 addition & 1 deletion bookwyrm/forms/custom_form.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ def __init__(self, *args, **kwargs):
css_classes["number"] = "input"
css_classes["checkbox"] = "checkbox"
css_classes["textarea"] = "textarea"
# pylint: disable=super-with-arguments
super().__init__(*args, **kwargs)
for visible in self.visible_fields():
input_type = ""
if hasattr(visible.field.widget, "input_type"):
input_type = visible.field.widget.input_type
if isinstance(visible.field.widget, Textarea):
Expand Down
1 change: 1 addition & 0 deletions bookwyrm/forms/edit_user.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ class Meta:
"email",
"summary",
"show_goal",
"show_ratings",
"show_suggested_users",
"manually_approves_followers",
"default_post_privacy",
Expand Down
1 change: 0 additions & 1 deletion bookwyrm/forms/landing.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ def infer_username(self):

def add_invalid_password_error(self):
"""We don't want to be too specific about this"""
# pylint: disable=attribute-defined-outside-init
self.non_field_errors = _("Username or password are incorrect")


Expand Down
2 changes: 0 additions & 2 deletions bookwyrm/forms/widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
class ArrayWidget(forms.widgets.TextInput):
"""Inputs for postgres array fields"""

# pylint: disable=unused-argument
# pylint: disable=no-self-use
def value_from_datadict(self, data, files, name):
"""get all values for this name"""
return [i for i in data.getlist(name) if i]
Expand Down
2 changes: 1 addition & 1 deletion bookwyrm/importers/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
""" import classes """

from .importer import Importer
from .bookwyrm_import import BookwyrmImporter
from .bookwyrm_import import BookwyrmImporter, BookwyrmBooksImporter
from .calibre_import import CalibreImporter
from .goodreads_import import GoodreadsImporter
from .librarything_import import LibrarythingImporter
Expand Down
15 changes: 15 additions & 0 deletions bookwyrm/importers/bookwyrm_import.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

from bookwyrm.models import User
from bookwyrm.models.bookwyrm_import_job import BookwyrmImportJob
from . import Importer


class BookwyrmImporter:
Expand All @@ -22,3 +23,17 @@ def process_import(
user=user, archive_file=archive_file, required=required
)
return job


class BookwyrmBooksImporter(Importer):
"""
Handle reading a csv from BookWyrm.
Goodreads is the default importer, we basically just use the same structure
But BookWyrm has additional attributes in the csv
"""

service = "BookWyrm"
row_mappings_guesses = Importer.row_mappings_guesses + [
("shelf_name", ["shelf_name"]),
("review_published", ["review_published"]),
]
38 changes: 27 additions & 11 deletions bookwyrm/importers/importer.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,27 +18,41 @@ class Importer:
row_mappings_guesses = [
("id", ["id", "book id"]),
("title", ["title"]),
("authors", ["author", "authors", "primary author"]),
("isbn_10", ["isbn10", "isbn", "isbn/uid"]),
("isbn_13", ["isbn13", "isbn", "isbns", "isbn/uid"]),
("authors", ["author_text", "author", "authors", "primary author"]),
("isbn_10", ["isbn_10", "isbn10", "isbn", "isbn/uid"]),
("isbn_13", ["isbn_13", "isbn13", "isbn", "isbns", "isbn/uid"]),
("shelf", ["shelf", "exclusive shelf", "read status", "bookshelf"]),
("review_name", ["review name"]),
("review_body", ["my review", "review"]),
("review_name", ["review_name", "review name"]),
("review_body", ["review_content", "my review", "review"]),
("rating", ["my rating", "rating", "star rating"]),
("date_added", ["date added", "entry date", "added"]),
("date_started", ["date started", "started"]),
("date_finished", ["date finished", "last date read", "date read", "finished"]),
(
"date_added",
["shelf_date", "date_added", "date added", "entry date", "added"],
),
("date_started", ["start_date", "date started", "started"]),
(
"date_finished",
["finish_date", "date finished", "last date read", "date read", "finished"],
),
]

# TODO: stopped

date_fields = ["date_added", "date_started", "date_finished"]
shelf_mapping_guesses = {
"to-read": ["to-read", "want to read"],
"read": ["read", "already read"],
"reading": ["currently-reading", "reading", "currently reading"],
}

# pylint: disable=too-many-locals
# pylint: disable=too-many-arguments
def create_job(
self, user: User, csv_file: Iterable[str], include_reviews: bool, privacy: str
self,
user: User,
csv_file: Iterable[str],
include_reviews: bool,
privacy: str,
create_shelves: bool = True,
) -> ImportJob:
"""check over a csv and creates a database entry for the job"""
csv_reader = csv.DictReader(csv_file, delimiter=self.delimiter)
Expand All @@ -55,6 +69,7 @@ def create_job(
job = ImportJob.objects.create(
user=user,
include_reviews=include_reviews,
create_shelves=create_shelves,
privacy=privacy,
mappings=mappings,
source=self.service,
Expand Down Expand Up @@ -114,7 +129,7 @@ def get_shelf(self, normalized_row: dict[str, Optional[str]]) -> Optional[str]:
shelf = [
s for (s, gs) in self.shelf_mapping_guesses.items() if shelf_name in gs
]
return shelf[0] if shelf else None
return shelf[0] if shelf else normalized_row.get("shelf") or None

# pylint: disable=no-self-use
def normalize_row(
Expand Down Expand Up @@ -149,6 +164,7 @@ def create_retry_job(
job = ImportJob.objects.create(
user=user,
include_reviews=original_job.include_reviews,
create_shelves=original_job.create_shelves,
privacy=original_job.privacy,
source=original_job.source,
# TODO: allow users to adjust mappings
Expand Down
2 changes: 1 addition & 1 deletion bookwyrm/importers/librarything_import.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class LibrarythingImporter(Importer):

def normalize_row(
self, entry: dict[str, str], mappings: dict[str, Optional[str]]
) -> dict[str, Optional[str]]: # pylint: disable=no-self-use
) -> dict[str, Optional[str]]:
"""use the dataclass to create the formatted row of data"""
normalized = {
k: _remove_brackets(entry.get(v) if v else None)
Expand Down
2 changes: 1 addition & 1 deletion bookwyrm/lists_stream.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def stream_id(self, user): # pylint: disable=no-self-use
return f"{user}-lists"
return f"{user.id}-lists"

def get_rank(self, obj): # pylint: disable=no-self-use
def get_rank(self, obj):
"""lists are sorted by updated date"""
return obj.updated_date.timestamp()

Expand Down
Loading
Loading