revert name change for Group, GroupMember
these were named as BookwyrmGroup and BookwyrmGroupMember due to a misunderstanding about related_name and a dodgy development environment. This naming makes more sense.
This commit is contained in:
@ -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
|
||||
|
||||
|
@ -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
|
||||
|
@ -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,
|
||||
|
@ -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)
|
||||
|
@ -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"""
|
||||
|
Reference in New Issue
Block a user