diff --git a/bookwyrm/forms.py b/bookwyrm/forms.py
index 290e01877..ffb7581e5 100644
--- a/bookwyrm/forms.py
+++ b/bookwyrm/forms.py
@@ -297,7 +297,7 @@ class ListForm(CustomForm):
class GroupForm(CustomForm):
class Meta:
- model = models.BookwyrmGroup
+ model = models.Group
fields = ["user", "privacy", "name", "description"]
class ReportForm(CustomForm):
diff --git a/bookwyrm/models/__init__.py b/bookwyrm/models/__init__.py
index 7ac41f1b9..c5ea44e0a 100644
--- a/bookwyrm/models/__init__.py
+++ b/bookwyrm/models/__init__.py
@@ -21,7 +21,7 @@ from .relationship import UserFollows, UserFollowRequest, UserBlocks
from .report import Report, ReportComment
from .federated_server import FederatedServer
-from .group import BookwyrmGroup, BookwyrmGroupMember, GroupMemberInvitation
+from .group import Group, GroupMember, GroupMemberInvitation
from .import_job import ImportJob, ImportItem
diff --git a/bookwyrm/models/group.py b/bookwyrm/models/group.py
index dbded1154..2d60ae2de 100644
--- a/bookwyrm/models/group.py
+++ b/bookwyrm/models/group.py
@@ -8,7 +8,7 @@ from . import fields
from .relationship import UserBlocks
# from .user import User
-class BookwyrmGroup(BookWyrmModel):
+class Group(BookWyrmModel):
"""A group of users"""
name = fields.CharField(max_length=100)
@@ -17,12 +17,12 @@ class BookwyrmGroup(BookWyrmModel):
description = fields.TextField(blank=True, null=True)
privacy = fields.PrivacyField()
-class BookwyrmGroupMember(models.Model):
+class GroupMember(models.Model):
"""Users who are members of a group"""
created_date = models.DateTimeField(auto_now_add=True)
updated_date = models.DateTimeField(auto_now=True)
group = models.ForeignKey(
- "BookwyrmGroup",
+ "Group",
on_delete=models.CASCADE,
related_name="memberships"
)
@@ -53,7 +53,7 @@ class BookwyrmGroupMember(models.Model):
)
).exists():
raise IntegrityError()
- # accepts and requests are handled by the BookwyrmGroupInvitation model
+ # accepts and requests are handled by the GroupInvitation model
super().save(*args, **kwargs)
@classmethod
@@ -74,7 +74,7 @@ class GroupMemberInvitation(models.Model):
"""adding a user to a group requires manual confirmation"""
created_date = models.DateTimeField(auto_now_add=True)
group = models.ForeignKey(
- "BookwyrmGroup",
+ "Group",
on_delete=models.CASCADE,
related_name="user_invitations"
)
@@ -94,7 +94,7 @@ class GroupMemberInvitation(models.Model):
"""make sure the membership doesn't already exist"""
# if there's an invitation for a membership that already exists, accept it
# without changing the local database state
- if BookwyrmGroupMember.objects.filter(
+ if GroupMember.objects.filter(
user=self.user,
group=self.group
).exists():
@@ -131,7 +131,7 @@ class GroupMemberInvitation(models.Model):
"""turn this request into the real deal"""
with transaction.atomic():
- BookwyrmGroupMember.from_request(self)
+ GroupMember.from_request(self)
model = apps.get_model("bookwyrm.Notification", require_ready=True)
# tell the group owner
diff --git a/bookwyrm/models/list.py b/bookwyrm/models/list.py
index 498026326..43f5265d0 100644
--- a/bookwyrm/models/list.py
+++ b/bookwyrm/models/list.py
@@ -35,7 +35,7 @@ class List(OrderedCollectionMixin, BookWyrmModel):
max_length=255, default="closed", choices=CurationType.choices
)
group = models.ForeignKey(
- "BookwyrmGroup",
+ "Group",
on_delete=models.PROTECT,
default=None,
blank=True,
diff --git a/bookwyrm/models/notification.py b/bookwyrm/models/notification.py
index a2ddb8747..0cae7790c 100644
--- a/bookwyrm/models/notification.py
+++ b/bookwyrm/models/notification.py
@@ -23,7 +23,7 @@ class Notification(BookWyrmModel):
"User", on_delete=models.CASCADE, null=True, related_name="related_group_member"
)
related_group = models.ForeignKey(
- "BookwyrmGroup", on_delete=models.CASCADE, null=True, related_name="notifications"
+ "Group", on_delete=models.CASCADE, null=True, related_name="notifications"
)
related_status = models.ForeignKey("Status", on_delete=models.CASCADE, null=True)
related_import = models.ForeignKey("ImportJob", on_delete=models.CASCADE, null=True)
diff --git a/bookwyrm/models/user.py b/bookwyrm/models/user.py
index 0e1397949..637baa6ee 100644
--- a/bookwyrm/models/user.py
+++ b/bookwyrm/models/user.py
@@ -143,11 +143,6 @@ class User(OrderedCollectionPageMixin, AbstractUser):
property_fields = [("following_link", "following")]
field_tracker = FieldTracker(fields=["name", "avatar"])
- # @property
- # def bookwyrm_groups(self):
- # group_ids = bookwyrm_group_membership.values_list("user", flat=True)
- # return BookwyrmGroup.objects.in_bulk(group_ids).values()
-
@property
def confirmation_link(self):
"""helper for generating confirmation links"""
diff --git a/bookwyrm/templates/groups/suggested_users.html b/bookwyrm/templates/groups/suggested_users.html
index 75dfe491c..54ec861db 100644
--- a/bookwyrm/templates/groups/suggested_users.html
+++ b/bookwyrm/templates/groups/suggested_users.html
@@ -37,6 +37,6 @@
{% endfor %}
{% else %}
- No potential members found for "{{ query }}"
+
No potential members found for "{{ query }}"
{% endif %}
diff --git a/bookwyrm/templatetags/bookwyrm_group_tags.py b/bookwyrm/templatetags/bookwyrm_group_tags.py
index 81c4a4b94..eabca2b41 100644
--- a/bookwyrm/templatetags/bookwyrm_group_tags.py
+++ b/bookwyrm/templatetags/bookwyrm_group_tags.py
@@ -10,13 +10,13 @@ register = template.Library()
def has_groups(user):
"""whether or not the user has a pending invitation to join this group"""
- return models.BookwyrmGroupMember.objects.filter(user=user).exists()
+ return models.GroupMember.objects.filter(user=user).exists()
@register.filter(name="is_member")
def is_member(group, user):
"""whether or not the user is a member of this group"""
- return models.BookwyrmGroupMember.objects.filter(group=group,user=user).exists()
+ return models.GroupMember.objects.filter(group=group,user=user).exists()
@register.filter(name="is_invited")
def is_invited(group, user):
diff --git a/bookwyrm/urls.py b/bookwyrm/urls.py
index 3e1d35266..834f95be9 100644
--- a/bookwyrm/urls.py
+++ b/bookwyrm/urls.py
@@ -253,7 +253,7 @@ urlpatterns = [
re_path(r"^hide-suggestions/?$", views.hide_suggestions, name="hide-suggestions"),
# groups
re_path(rf"{USER_PATH}/groups/?$", views.UserGroups.as_view(), name="user-groups"),
- re_path(r"^group/(?P\d+)(.json)?/?$", views.BookwyrmGroup.as_view(), name="group"),
+ re_path(r"^group/(?P\d+)(.json)?/?$", views.Group.as_view(), name="group"),
re_path(r"^group/(?P\d+)/add-users/?$", views.FindUsers.as_view(), name="group-find-users"),
re_path(r"^add-group-member/?$", views.invite_member, name="invite-group-member"),
re_path(r"^remove-group-member/?$", views.remove_member, name="remove-group-member"),
diff --git a/bookwyrm/views/__init__.py b/bookwyrm/views/__init__.py
index 930fdfcd9..4bdfb6ed6 100644
--- a/bookwyrm/views/__init__.py
+++ b/bookwyrm/views/__init__.py
@@ -32,7 +32,7 @@ from .follow import follow, unfollow
from .follow import accept_follow_request, delete_follow_request
from .get_started import GetStartedBooks, GetStartedProfile, GetStartedUsers
from .goal import Goal, hide_goal
-from .group import BookwyrmGroup, UserGroups, FindUsers, invite_member, remove_member, accept_membership, reject_membership
+from .group import Group, UserGroups, FindUsers, invite_member, remove_member, accept_membership, reject_membership
from .import_data import Import, ImportStatus
from .inbox import Inbox
from .interaction import Favorite, Unfavorite, Boost, Unboost
diff --git a/bookwyrm/views/group.py b/bookwyrm/views/group.py
index b8c45a4da..373811655 100644
--- a/bookwyrm/views/group.py
+++ b/bookwyrm/views/group.py
@@ -18,13 +18,13 @@ from .helpers import privacy_filter
from .helpers import get_user_from_username
from bookwyrm.settings import DOMAIN
-class BookwyrmGroup(View):
+class Group(View):
"""group page"""
def get(self, request, group_id):
"""display a group"""
- group = get_object_or_404(models.BookwyrmGroup, id=group_id)
+ group = get_object_or_404(models.Group, id=group_id)
lists = models.List.objects.filter(group=group).order_by("-updated_date")
lists = privacy_filter(request.user, lists)
@@ -43,7 +43,7 @@ class BookwyrmGroup(View):
@method_decorator(login_required, name="dispatch")
def post(self, request, group_id):
"""edit a group"""
- user_group = get_object_or_404(models.BookwyrmGroup, id=group_id)
+ user_group = get_object_or_404(models.Group, id=group_id)
form = forms.GroupForm(request.POST, instance=user_group)
if not form.is_valid():
return redirect("group", user_group.id)
@@ -57,7 +57,7 @@ class UserGroups(View):
def get(self, request, username):
"""display a group"""
user = get_user_from_username(request.user, username)
- memberships = models.BookwyrmGroupMember.objects.filter(user=user).all()
+ memberships = models.GroupMember.objects.filter(user=user).all()
paginated = Paginator(memberships, 12)
data = {
@@ -78,7 +78,7 @@ class UserGroups(View):
return redirect(request.user.local_path + "groups")
group = form.save()
# add the creator as a group member
- models.BookwyrmGroupMember.objects.create(group=group, user=request.user)
+ models.GroupMember.objects.create(group=group, user=request.user)
return redirect("group", group.id)
@method_decorator(login_required, name="dispatch")
@@ -89,7 +89,7 @@ class FindUsers(View):
def get(self, request, group_id):
"""basic profile info"""
query = request.GET.get("query")
- group = models.BookwyrmGroup.objects.get(id=group_id)
+ group = models.Group.objects.get(id=group_id)
user_results = (
models.User.viewer_aware_objects(request.user)
.exclude(memberships__in=group.memberships.all()) # don't suggest users who are already members
@@ -112,7 +112,7 @@ class FindUsers(View):
request.user
)
- group = get_object_or_404(models.BookwyrmGroup, id=group_id)
+ group = get_object_or_404(models.Group, id=group_id)
if not group:
return HttpResponseBadRequest()
@@ -133,7 +133,7 @@ class FindUsers(View):
def invite_member(request):
"""invite a member to the group"""
- group = get_object_or_404(models.BookwyrmGroup, id=request.POST.get("group"))
+ group = get_object_or_404(models.Group, id=request.POST.get("group"))
if not group:
return HttpResponseBadRequest()
@@ -160,7 +160,7 @@ def invite_member(request):
def remove_member(request):
"""remove a member from the group"""
- group = get_object_or_404(models.BookwyrmGroup, id=request.POST.get("group"))
+ group = get_object_or_404(models.Group, id=request.POST.get("group"))
if not group:
return HttpResponseBadRequest()
@@ -168,7 +168,7 @@ def remove_member(request):
if not user:
return HttpResponseBadRequest()
- is_member = models.BookwyrmGroupMember.objects.filter(group=group,user=user).exists()
+ is_member = models.GroupMember.objects.filter(group=group,user=user).exists()
is_invited = models.GroupMemberInvitation.objects.filter(group=group,user=user).exists()
if is_invited:
@@ -186,13 +186,13 @@ def remove_member(request):
if is_member:
try:
- membership = models.BookwyrmGroupMember.objects.get(group=group,user=user)
+ membership = models.GroupMember.objects.get(group=group,user=user)
membership.delete()
except IntegrityError:
pass
- memberships = models.BookwyrmGroupMember.objects.filter(group=group)
+ memberships = models.GroupMember.objects.filter(group=group)
model = apps.get_model("bookwyrm.Notification", require_ready=True)
notification_type = "LEAVE" if "self_removal" in request.POST and request.POST["self_removal"] else "REMOVE"
# let the other members know about it
@@ -221,7 +221,7 @@ def remove_member(request):
def accept_membership(request):
"""accept an invitation to join a group"""
- group = models.BookwyrmGroup.objects.get(id=request.POST["group"])
+ group = models.Group.objects.get(id=request.POST["group"])
if not group:
return HttpResponseBadRequest()
@@ -242,7 +242,7 @@ def accept_membership(request):
def reject_membership(request):
"""reject an invitation to join a group"""
- group = models.BookwyrmGroup.objects.get(id=request.POST["group"])
+ group = models.Group.objects.get(id=request.POST["group"])
if not group:
return HttpResponseBadRequest()
diff --git a/bookwyrm/views/user.py b/bookwyrm/views/user.py
index 562c49335..f711a7798 100644
--- a/bookwyrm/views/user.py
+++ b/bookwyrm/views/user.py
@@ -140,7 +140,7 @@ class Groups(View):
user = get_user_from_username(request.user, username)
paginated = Paginator(
- models.BookwyrmGroup.memberships.filter(user=user)
+ models.Group.memberships.filter(user=user)
)
data = {
"user": user,