forked from mirrors/bookwyrm
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',
|
'origin_id',
|
||||||
'created_date',
|
'created_date',
|
||||||
'updated_date',
|
'updated_date',
|
||||||
|
'edition_rank',
|
||||||
|
|
||||||
'authors',# TODO
|
'authors',# TODO
|
||||||
'parent_work',
|
'parent_work',
|
||||||
|
|
|
@ -149,6 +149,7 @@ def get_mentions(status, user):
|
||||||
|
|
||||||
@register.filter(name='status_preview_name')
|
@register.filter(name='status_preview_name')
|
||||||
def get_status_preview_name(obj):
|
def get_status_preview_name(obj):
|
||||||
|
''' text snippet with book context for a status '''
|
||||||
name = obj.__class__.__name__.lower()
|
name = obj.__class__.__name__.lower()
|
||||||
if name == 'review':
|
if name == 'review':
|
||||||
return '%s of <em>%s</em>' % (name, obj.book.title)
|
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')
|
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):
|
def test_switch_edition(self):
|
||||||
''' updates user's relationships to a book '''
|
''' updates user's relationships to a book '''
|
||||||
work = models.Work.objects.create(title='test work')
|
work = models.Work.objects.create(title='test work')
|
||||||
|
|
Loading…
Reference in a new issue