mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2024-12-22 16:16:39 +00:00
Merge pull request #517 from mouse-reeve/fixes-edit-book
Fixes edit book view
This commit is contained in:
commit
8986af42d6
3 changed files with 16 additions and 0 deletions
|
@ -125,6 +125,7 @@ class EditionForm(CustomForm):
|
|||
'origin_id',
|
||||
'created_date',
|
||||
'updated_date',
|
||||
'edition_rank',
|
||||
|
||||
'authors',# TODO
|
||||
'parent_work',
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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')
|
||||
|
|
Loading…
Reference in a new issue