From 686198472df29ed021ec0c7c77c81d5f9310fbfc Mon Sep 17 00:00:00 2001 From: Hugh Rundle Date: Sun, 26 Sep 2021 15:50:15 +1000 Subject: [PATCH] update group and list models - remove GroupList model - add a group foreign key value to List model - remove reference to lists in Group model --- bookwyrm/models/__init__.py | 2 +- bookwyrm/models/group.py | 14 -------------- bookwyrm/models/list.py | 7 +++++++ 3 files changed, 8 insertions(+), 15 deletions(-) diff --git a/bookwyrm/models/__init__.py b/bookwyrm/models/__init__.py index 2774f081..a4a06eba 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 Group, GroupList, GroupMember +from .group import Group, GroupMember from .import_job import ImportJob, ImportItem diff --git a/bookwyrm/models/group.py b/bookwyrm/models/group.py index 01fdbdd6..c1aa2d70 100644 --- a/bookwyrm/models/group.py +++ b/bookwyrm/models/group.py @@ -16,14 +16,6 @@ class Group(BookWyrmModel): "User", on_delete=models.PROTECT) description = fields.TextField(blank=True, null=True) privacy = fields.PrivacyField() - - lists = models.ManyToManyField( - "List", - symmetrical=False, - through="GroupList", - through_fields=("group", "book_list"), - ) - members = models.ManyToManyField( "User", symmetrical=False, @@ -32,12 +24,6 @@ class Group(BookWyrmModel): related_name="members" ) -class GroupList(BookWyrmModel): - """Lists that group members can edit""" - - group = models.ForeignKey("Group", on_delete=models.CASCADE) - book_list = models.ForeignKey("List", on_delete=models.CASCADE) - class GroupMember(models.Model): """Users who are members of a group""" diff --git a/bookwyrm/models/list.py b/bookwyrm/models/list.py index 49fb5375..b73d7708 100644 --- a/bookwyrm/models/list.py +++ b/bookwyrm/models/list.py @@ -1,4 +1,5 @@ """ make a list of books!! """ +from dataclasses import field from django.apps import apps from django.db import models from django.utils import timezone @@ -16,6 +17,7 @@ CurationType = models.TextChoices( "closed", "open", "curated", + "group" ], ) @@ -32,6 +34,11 @@ class List(OrderedCollectionMixin, BookWyrmModel): curation = fields.CharField( max_length=255, default="closed", choices=CurationType.choices ) + group = models.ForeignKey( + "Group", + on_delete=models.CASCADE, + null=True + ) books = models.ManyToManyField( "Edition", symmetrical=False,