Merge branch 'main' into production

This commit is contained in:
Mouse Reeve 2021-01-12 07:30:49 -08:00
commit c7d6273b3b
3 changed files with 16 additions and 0 deletions

View file

@ -125,6 +125,7 @@ class EditionForm(CustomForm):
'origin_id',
'created_date',
'updated_date',
'edition_rank',
'authors',# TODO
'parent_work',

View file

@ -149,6 +149,7 @@ def get_mentions(status, user):
@register.filter(name='status_preview_name')
def get_status_preview_name(obj):
''' text snippet with book context for a status '''
name = obj.__class__.__name__.lower()
if name == 'review':
return '%s of <em>%s</em>' % (name, obj.book.title)

View file

@ -291,6 +291,20 @@ class ViewActions(TestCase):
self.assertEqual(self.local_user.name, 'New Name')
def test_edit_book(self):
''' lets a user edit a book '''
self.local_user.groups.add(self.group)
form = forms.EditionForm(instance=self.book)
form.data['title'] = 'New Title'
form.data['last_edited_by'] = self.local_user.id
request = self.factory.post('', form.data)
request.user = self.local_user
with patch('bookwyrm.broadcast.broadcast_task.delay'):
actions.edit_book(request, self.book.id)
self.book.refresh_from_db()
self.assertEqual(self.book.title, 'New Title')
def test_switch_edition(self):
''' updates user's relationships to a book '''
work = models.Work.objects.create(title='test work')