mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2025-01-08 16:25:27 +00:00
commit
c2fb076add
2 changed files with 24 additions and 1 deletions
|
@ -218,7 +218,8 @@ class Status(OrderedCollectionPageMixin, BookWyrmModel):
|
|||
"""certain types of status aren't editable"""
|
||||
# first, the standard raise
|
||||
super().raise_not_editable(viewer)
|
||||
if isinstance(self, (GeneratedNote, ReviewRating)):
|
||||
# if it's an edit (not a create) you can only edit content statuses
|
||||
if self.id and isinstance(self, (GeneratedNote, ReviewRating)):
|
||||
raise PermissionDenied()
|
||||
|
||||
@classmethod
|
||||
|
|
|
@ -76,6 +76,28 @@ class StatusViews(TestCase):
|
|||
self.assertEqual(status.book, self.book)
|
||||
self.assertIsNone(status.edited_date)
|
||||
|
||||
def test_create_status_rating(self, *_):
|
||||
"""create a status"""
|
||||
view = views.CreateStatus.as_view()
|
||||
form = forms.RatingForm(
|
||||
{
|
||||
"user": self.local_user.id,
|
||||
"rating": 4,
|
||||
"book": self.book.id,
|
||||
"privacy": "public",
|
||||
}
|
||||
)
|
||||
request = self.factory.post("", form.data)
|
||||
request.user = self.local_user
|
||||
|
||||
view(request, "rating")
|
||||
|
||||
status = models.ReviewRating.objects.get()
|
||||
self.assertEqual(status.user, self.local_user)
|
||||
self.assertEqual(status.book, self.book)
|
||||
self.assertEqual(status.rating, 4.0)
|
||||
self.assertIsNone(status.edited_date)
|
||||
|
||||
def test_create_status_wrong_user(self, *_):
|
||||
"""You can't compose statuses for someone else"""
|
||||
view = views.CreateStatus.as_view()
|
||||
|
|
Loading…
Reference in a new issue