mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2024-11-18 15:41:12 +00:00
change group owner from 'manager' to 'user'
This will allow privacy management to use existing code. Some template updates also are for rationalising how groups are created and edited.
This commit is contained in:
parent
2874e52309
commit
f3181690a2
10 changed files with 17 additions and 12 deletions
|
@ -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
|
||||
|
||||
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -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",
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{% load i18n %}
|
||||
{% spaceless %}
|
||||
|
||||
{% blocktrans with username=group.manager.display_name path=group.manager.local_path %}Managed by <a href="{{ path }}">{{ username }}</a>{% endblocktrans %}
|
||||
{% blocktrans with username=group.user.display_name path=group.user.local_path %}Managed by <a href="{{ path }}">{{ username }}</a>{% endblocktrans %}
|
||||
|
||||
{% endspaceless %}
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
<div class="columns">
|
||||
|
||||
<div class="column is-two-thirds">
|
||||
<input type="hidden" name="manager" value="{{ request.user.id }}" />
|
||||
<input type="hidden" name="user" value="{{ request.user.id }}" />
|
||||
<input type="hidden" name="privacy" value="public" />
|
||||
<div class="field">
|
||||
<label class="label" for="id_name">{% trans "Group Name:" %}</label>
|
||||
|
@ -20,9 +20,9 @@
|
|||
<div class="columns is-mobile">
|
||||
<div class="column">
|
||||
<div class="field has-addons">
|
||||
<!-- <div class="control">
|
||||
<div class="control">
|
||||
{% include 'snippets/privacy_select.html' with current=group.privacy %}
|
||||
</div> -->
|
||||
</div>
|
||||
<div class="control">
|
||||
<button type="submit" class="button is-primary">{% trans "Save" %}</button>
|
||||
</div>
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
</p>
|
||||
</div>
|
||||
<div class="column is-narrow is-flex">
|
||||
{% 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 %}
|
||||
|
|
|
@ -38,7 +38,7 @@
|
|||
<span title="{{ member.display_name }}" class="is-block is-6 has-text-weight-bold">{{ member.display_name|truncatechars:10 }}</span>
|
||||
<span title="@{{ member|username }}" class="is-block pb-3">@{{ member|username|truncatechars:8 }}</span>
|
||||
</a>
|
||||
{% if group.manager == member %}
|
||||
{% if group.user == member %}
|
||||
<span class="icon icon-star-full" title="Manager">
|
||||
<span class="is-sr-only">Manager</span>
|
||||
</span>
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
<div class="card is-stretchable">
|
||||
<header class="card-header">
|
||||
<h4 class="card-header-title">
|
||||
<a href="{{ group.local_path }}">{{ group.name }}</a> <span class="subtitle">{% include 'snippets/privacy-icons.html' with item=group %}</span>
|
||||
<a href="/group/{{ group.id }}">{{ group.name }}</a> <span class="subtitle">{% include 'snippets/privacy-icons.html' with item=group %}</span>
|
||||
</h4>
|
||||
{% if request.user.is_authenticated and request.user|saved:list %}
|
||||
<div class="card-header-icon">
|
||||
|
|
|
@ -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 %}
|
||||
<!-- TODO: blocking is irrelevant here, but ...is it? -->
|
||||
{% elif user in request.user.blocks.all %}
|
||||
{% include 'snippets/block_button.html' with blocks=True %}
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
|
||||
{% block panel %}
|
||||
<section class="block">
|
||||
<form name="create-group" method="post" action="{% url 'create-group' %}" class="box is-hidden" id="create_group">
|
||||
<form name="create-group" method="post" action="{% url 'user-groups' request.user.username %}" class="box is-hidden" id="create_group">
|
||||
<header class="columns">
|
||||
<h3 class="title column">{% trans "Create group" %}</h3>
|
||||
<div class="column is-narrow">
|
||||
|
|
Loading…
Reference in a new issue