diff --git a/bookwyrm/models/base_model.py b/bookwyrm/models/base_model.py index aa174a143..3a2d758b7 100644 --- a/bookwyrm/models/base_model.py +++ b/bookwyrm/models/base_model.py @@ -76,6 +76,10 @@ class BookWyrmModel(models.Model): and self.mention_users.filter(id=viewer.id).first() ): return True + +# TODO: if privacy is direct and the object is a group and viewer is a member of the group +# then return True + return False diff --git a/bookwyrm/models/group.py b/bookwyrm/models/group.py index c1aa2d707..6810779cc 100644 --- a/bookwyrm/models/group.py +++ b/bookwyrm/models/group.py @@ -12,7 +12,7 @@ class Group(BookWyrmModel): """A group of users""" name = fields.CharField(max_length=100) - manager = fields.ForeignKey( + user = fields.ForeignKey( "User", on_delete=models.PROTECT) description = fields.TextField(blank=True, null=True) privacy = fields.PrivacyField() diff --git a/bookwyrm/models/list.py b/bookwyrm/models/list.py index 75f34b9e8..7ea33a8b6 100644 --- a/bookwyrm/models/list.py +++ b/bookwyrm/models/list.py @@ -36,9 +36,10 @@ class List(OrderedCollectionMixin, BookWyrmModel): ) group = models.ForeignKey( "Group", - on_delete=models.CASCADE, + on_delete=models.PROTECT, default=None, - blank=True + blank=True, + null=True, ) books = models.ManyToManyField( "Edition", diff --git a/bookwyrm/templates/groups/created_text.html b/bookwyrm/templates/groups/created_text.html index e7409942a..5e6ce513d 100644 --- a/bookwyrm/templates/groups/created_text.html +++ b/bookwyrm/templates/groups/created_text.html @@ -1,6 +1,6 @@ {% load i18n %} {% spaceless %} -{% blocktrans with username=group.manager.display_name path=group.manager.local_path %}Managed by {{ username }}{% endblocktrans %} +{% blocktrans with username=group.user.display_name path=group.user.local_path %}Managed by {{ username }}{% endblocktrans %} {% endspaceless %} diff --git a/bookwyrm/templates/groups/form.html b/bookwyrm/templates/groups/form.html index f764db6f9..c47cbbc4d 100644 --- a/bookwyrm/templates/groups/form.html +++ b/bookwyrm/templates/groups/form.html @@ -5,7 +5,7 @@
- +
@@ -20,9 +20,9 @@
- +
diff --git a/bookwyrm/templates/groups/layout.html b/bookwyrm/templates/groups/layout.html index 03a957d0a..f558f169a 100644 --- a/bookwyrm/templates/groups/layout.html +++ b/bookwyrm/templates/groups/layout.html @@ -12,7 +12,7 @@

- {% if request.user == group.manager %} + {% if request.user == group.user %} {% trans "Edit group" as button_text %} {% include 'snippets/toggle/open_button.html' with text=button_text icon_with_text="pencil" controls_text="edit_group" focus="edit_group_header" %} {% endif %} diff --git a/bookwyrm/templates/groups/members.html b/bookwyrm/templates/groups/members.html index 80dab21c9..df5f1602a 100644 --- a/bookwyrm/templates/groups/members.html +++ b/bookwyrm/templates/groups/members.html @@ -38,7 +38,7 @@ {{ member.display_name|truncatechars:10 }} @{{ member|username|truncatechars:8 }} - {% if group.manager == member %} + {% if group.user == member %} Manager diff --git a/bookwyrm/templates/groups/user_groups.html b/bookwyrm/templates/groups/user_groups.html index 9c48a8429..5239a3657 100644 --- a/bookwyrm/templates/groups/user_groups.html +++ b/bookwyrm/templates/groups/user_groups.html @@ -8,7 +8,7 @@

- {{ group.name }} {% include 'snippets/privacy-icons.html' with item=group %} + {{ group.name }} {% include 'snippets/privacy-icons.html' with item=group %}

{% if request.user.is_authenticated and request.user|saved:list %}
diff --git a/bookwyrm/templates/snippets/add_to_group_button.html b/bookwyrm/templates/snippets/add_to_group_button.html index f533af6ea..cc394684c 100644 --- a/bookwyrm/templates/snippets/add_to_group_button.html +++ b/bookwyrm/templates/snippets/add_to_group_button.html @@ -1,5 +1,5 @@ {% load i18n %} -{% if request.user == user or not request.user == group.manager or not request.user.is_authenticated %} +{% if request.user == user or not request.user == group.user or not request.user.is_authenticated %} {% elif user in request.user.blocks.all %} {% include 'snippets/block_button.html' with blocks=True %} diff --git a/bookwyrm/templates/user/groups.html b/bookwyrm/templates/user/groups.html index 912d5ec3d..1a5940728 100644 --- a/bookwyrm/templates/user/groups.html +++ b/bookwyrm/templates/user/groups.html @@ -24,7 +24,7 @@ {% block panel %}
-