mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2024-11-26 11:31:08 +00:00
Python formatting
This commit is contained in:
parent
5caac46c31
commit
0d88794f46
2 changed files with 10 additions and 10 deletions
|
@ -47,9 +47,9 @@ class UpdateViews(TestCase):
|
||||||
request = self.factory.get("")
|
request = self.factory.get("")
|
||||||
request.user = self.local_user
|
request.user = self.local_user
|
||||||
|
|
||||||
with patch('bookwyrm.activitystreams.ActivityStream.get_unread_count') as mock:
|
with patch("bookwyrm.activitystreams.ActivityStream.get_unread_count") as mock:
|
||||||
mock.return_value = 3
|
mock.return_value = 3
|
||||||
result = views.get_unread_status_count(request, 'home')
|
result = views.get_unread_status_count(request, "home")
|
||||||
|
|
||||||
self.assertIsInstance(result, JsonResponse)
|
self.assertIsInstance(result, JsonResponse)
|
||||||
data = json.loads(result.getvalue())
|
data = json.loads(result.getvalue())
|
||||||
|
|
|
@ -4,14 +4,16 @@ from django.http import JsonResponse
|
||||||
|
|
||||||
from bookwyrm import activitystreams
|
from bookwyrm import activitystreams
|
||||||
|
|
||||||
|
|
||||||
@login_required
|
@login_required
|
||||||
def get_notification_count(request):
|
def get_notification_count(request):
|
||||||
""" any notifications waiting? """
|
""" any notifications waiting? """
|
||||||
return JsonResponse({
|
return JsonResponse(
|
||||||
"count": request.user.notification_set.filter(
|
{
|
||||||
read=False
|
"count": request.user.notification_set.filter(read=False).count(),
|
||||||
).count(),
|
}
|
||||||
})
|
)
|
||||||
|
|
||||||
|
|
||||||
@login_required
|
@login_required
|
||||||
def get_unread_status_count(request, stream):
|
def get_unread_status_count(request, stream):
|
||||||
|
@ -19,6 +21,4 @@ def get_unread_status_count(request, stream):
|
||||||
stream = activitystreams.streams.get(stream)
|
stream = activitystreams.streams.get(stream)
|
||||||
if not stream:
|
if not stream:
|
||||||
return JsonResponse({})
|
return JsonResponse({})
|
||||||
return JsonResponse({
|
return JsonResponse({"count": stream.get_unread_count(request.user)})
|
||||||
"count": stream.get_unread_count(request.user)
|
|
||||||
})
|
|
||||||
|
|
Loading…
Reference in a new issue