mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2024-12-16 13:16:33 +00:00
emblacken files
Wouldn't it be great if I just remembered to run Black before every commit?
This commit is contained in:
parent
b3cc9e5b75
commit
252ff0d689
4 changed files with 22 additions and 10 deletions
|
@ -7,6 +7,7 @@ from .base_model import BookWyrmModel
|
|||
from . import fields
|
||||
from .relationship import UserBlocks
|
||||
|
||||
|
||||
class Group(BookWyrmModel):
|
||||
"""A group of users"""
|
||||
|
||||
|
@ -36,6 +37,7 @@ class Group(BookWyrmModel):
|
|||
|
||||
return queryset.exclude(~Q(memberships__user=viewer), privacy="direct")
|
||||
|
||||
|
||||
class GroupMember(models.Model):
|
||||
"""Users who are members of a group"""
|
||||
|
||||
|
|
|
@ -79,7 +79,9 @@ class List(OrderedCollectionMixin, BookWyrmModel):
|
|||
|
||||
return queryset.exclude(
|
||||
~Q( # user isn't following and it isn't their own status and they are not a group member
|
||||
Q(user__followers=viewer) | Q(user=viewer) | Q(group__memberships__user=viewer)
|
||||
Q(user__followers=viewer)
|
||||
| Q(user=viewer)
|
||||
| Q(group__memberships__user=viewer)
|
||||
),
|
||||
privacy="followers", # and the status (of the list) is followers only
|
||||
)
|
||||
|
@ -89,10 +91,10 @@ class List(OrderedCollectionMixin, BookWyrmModel):
|
|||
"""Override filter for "direct" privacy level to allow group members to see the existence of group lists"""
|
||||
|
||||
return queryset.exclude(
|
||||
~Q( # user not self and not in the group if this is a group list
|
||||
Q(user=viewer) | Q(group__memberships__user=viewer)
|
||||
),
|
||||
privacy="direct"
|
||||
~Q( # user not self and not in the group if this is a group list
|
||||
Q(user=viewer) | Q(group__memberships__user=viewer)
|
||||
),
|
||||
privacy="direct",
|
||||
)
|
||||
|
||||
@classmethod
|
||||
|
|
|
@ -72,7 +72,7 @@ class GroupViews(TestCase):
|
|||
view = views.FindUsers.as_view()
|
||||
request = self.factory.get("")
|
||||
request.user = self.local_user
|
||||
result = view(request,group_id=999)
|
||||
result = view(request, group_id=999)
|
||||
self.assertIsInstance(result, TemplateResponse)
|
||||
validate_html(result.render())
|
||||
self.assertEqual(result.status_code, 200)
|
||||
|
@ -85,7 +85,7 @@ class GroupViews(TestCase):
|
|||
"name": "Updated Group",
|
||||
"privacy": "private",
|
||||
"description": "Test description",
|
||||
"user": self.local_user
|
||||
"user": self.local_user,
|
||||
}
|
||||
request = self.factory.post("", group_fields)
|
||||
request.user = self.local_user
|
||||
|
|
|
@ -25,7 +25,11 @@ class Group(View):
|
|||
|
||||
group = get_object_or_404(models.Group, id=group_id)
|
||||
group.raise_visible_to_user(request.user)
|
||||
lists = models.List.privacy_filter(request.user).filter(group=group).order_by("-updated_date")
|
||||
lists = (
|
||||
models.List.privacy_filter(request.user)
|
||||
.filter(group=group)
|
||||
.order_by("-updated_date")
|
||||
)
|
||||
|
||||
data = {
|
||||
"group": group,
|
||||
|
@ -53,7 +57,11 @@ class UserGroups(View):
|
|||
def get(self, request, username):
|
||||
"""display a group"""
|
||||
user = get_user_from_username(request.user, username)
|
||||
groups = models.Group.privacy_filter(request.user).filter(memberships__user=user).order_by("-updated_date")
|
||||
groups = (
|
||||
models.Group.privacy_filter(request.user)
|
||||
.filter(memberships__user=user)
|
||||
.order_by("-updated_date")
|
||||
)
|
||||
paginated = Paginator(groups, 12)
|
||||
|
||||
data = {
|
||||
|
@ -164,7 +172,7 @@ def remove_member(request):
|
|||
return HttpResponseBadRequest()
|
||||
|
||||
# you can't be removed from your own group
|
||||
if request.POST["user"]== group.user:
|
||||
if request.POST["user"] == group.user:
|
||||
return HttpResponseBadRequest()
|
||||
|
||||
is_member = models.GroupMember.objects.filter(group=group, user=user).exists()
|
||||
|
|
Loading…
Reference in a new issue