From 60738011a2a6c4ae6f1c2143c7bdde503cbdf2fb Mon Sep 17 00:00:00 2001 From: Mouse Reeve <mousereeve@riseup.net> Date: Sun, 20 Dec 2020 12:09:19 -0800 Subject: [PATCH] user's name and bio field are optional get it together, mouse --- bookwyrm/activitypub/person.py | 4 ++-- .../migrations/0027_auto_20201220_2007.py | 24 +++++++++++++++++++ bookwyrm/models/user.py | 4 ++-- bookwyrm/view_actions.py | 6 +++-- 4 files changed, 32 insertions(+), 6 deletions(-) create mode 100644 bookwyrm/migrations/0027_auto_20201220_2007.py diff --git a/bookwyrm/activitypub/person.py b/bookwyrm/activitypub/person.py index 88349c02c..7e7d027eb 100644 --- a/bookwyrm/activitypub/person.py +++ b/bookwyrm/activitypub/person.py @@ -18,13 +18,13 @@ class PublicKey(ActivityObject): class Person(ActivityObject): ''' actor activitypub json ''' preferredUsername: str - name: str inbox: str outbox: str followers: str - summary: str publicKey: PublicKey endpoints: Dict + name: str = None + summary: str = None icon: Image = field(default_factory=lambda: {}) bookwyrmUser: bool = False manuallyApprovesFollowers: str = False diff --git a/bookwyrm/migrations/0027_auto_20201220_2007.py b/bookwyrm/migrations/0027_auto_20201220_2007.py new file mode 100644 index 000000000..a3ad4dda3 --- /dev/null +++ b/bookwyrm/migrations/0027_auto_20201220_2007.py @@ -0,0 +1,24 @@ +# Generated by Django 3.0.7 on 2020-12-20 20:07 + +import bookwyrm.models.fields +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('bookwyrm', '0026_status_content_warning'), + ] + + operations = [ + migrations.AlterField( + model_name='user', + name='name', + field=bookwyrm.models.fields.CharField(blank=True, max_length=100, null=True), + ), + migrations.AlterField( + model_name='user', + name='summary', + field=bookwyrm.models.fields.HtmlField(blank=True, null=True), + ), + ] diff --git a/bookwyrm/models/user.py b/bookwyrm/models/user.py index ce50fc092..654bc811b 100644 --- a/bookwyrm/models/user.py +++ b/bookwyrm/models/user.py @@ -42,7 +42,7 @@ class User(OrderedCollectionPageMixin, AbstractUser): blank=True, ) outbox = fields.RemoteIdField(unique=True) - summary = fields.HtmlField(default='') + summary = fields.HtmlField(null=True, blank=True) local = models.BooleanField(default=False) bookwyrm_user = fields.BooleanField(default=True) localname = models.CharField( @@ -51,7 +51,7 @@ class User(OrderedCollectionPageMixin, AbstractUser): unique=True ) # name is your display name, which you can change at will - name = fields.CharField(max_length=100, default='') + name = fields.CharField(max_length=100, null=True, blank=True) avatar = fields.ImageField( upload_to='avatars/', blank=True, null=True, activitypub_field='icon', alt_field='alt_text') diff --git a/bookwyrm/view_actions.py b/bookwyrm/view_actions.py index 1df1dcbaf..5fd8cff39 100644 --- a/bookwyrm/view_actions.py +++ b/bookwyrm/view_actions.py @@ -208,7 +208,7 @@ def edit_profile(request): ContentFile(output.getvalue()) ) - request.user.summary = form.data['summary'] + request.user.summary = outgoing.to_markdown(form.data['summary']) request.user.manually_approves_followers = \ form.cleaned_data['manually_approves_followers'] request.user.save() @@ -244,7 +244,9 @@ def edit_book(request, book_id): 'form': form } return TemplateResponse(request, 'edit_book.html', data) - form.save() + book = form.save(commit=False) + book.description = outgoing.to_markown(book.description) + book.save() outgoing.handle_update_book(request.user, book) return redirect('/book/%s' % book.id)