emblacken files

Wouldn't it be great if I just remembered to run Black before every commit?
This commit is contained in:
Hugh Rundle 2021-10-09 22:15:24 +11:00
parent b3cc9e5b75
commit 252ff0d689
4 changed files with 22 additions and 10 deletions

View file

@ -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"""

View file

@ -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
)
@ -92,7 +94,7 @@ class List(OrderedCollectionMixin, BookWyrmModel):
~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"
privacy="direct",
)
@classmethod

View file

@ -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

View file

@ -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 = {