Merge branch '253-user-post-privacy-v2' of https://github.com/ibrand/bookwyrm into ibrand-253-user-post-privacy-v2

This commit is contained in:
Mouse Reeve 2021-08-04 10:44:30 -07:00
commit 63c8301eb9
5 changed files with 34 additions and 5 deletions

View file

@ -132,6 +132,7 @@ class EditUserForm(CustomForm):
"summary",
"show_goal",
"manually_approves_followers",
"default_post_privacy",
"discoverable",
"preferred_timezone",
]

View file

@ -0,0 +1,18 @@
# Generated by Django 3.0.7 on 2021-02-14 00:39
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('bookwyrm', '0045_auto_20210210_2114'),
]
operations = [
migrations.AddField(
model_name='user',
name='default_post_privacy',
field=models.CharField(choices=[('public', 'Public'), ('unlisted', 'Unlisted'), ('followers', 'Followers'), ('direct', 'Direct')], default='public', max_length=255),
),
]

View file

@ -26,7 +26,6 @@ from .base_model import BookWyrmModel, DeactivationReason
from .federated_server import FederatedServer
from . import fields, Review
class User(OrderedCollectionPageMixin, AbstractUser):
"""a user who wants to read books"""
@ -105,6 +104,11 @@ class User(OrderedCollectionPageMixin, AbstractUser):
through_fields=("user", "status"),
related_name="favorite_statuses",
)
default_post_privacy = models.CharField(
max_length=255,
default='public',
choices=fields.PrivacyLevels.choices
)
remote_id = fields.RemoteIdField(null=True, unique=True, activitypub_field="id")
created_date = models.DateTimeField(auto_now_add=True)
updated_date = models.DateTimeField(auto_now=True)

View file

@ -53,6 +53,12 @@
{{ form.manually_approves_followers }}
</label>
</div>
<div class="block">
<label class="label" for="id_default_post_privacy">
{% trans "Default post privacy:" %}
{{ form.default_post_privacy }}
</label>
</div>
<div class="block">
<label class="checkbox label" for="id_discoverable">
{% trans "Show this account in suggested users:" %}

View file

@ -6,16 +6,16 @@
<label class="is-sr-only" for="privacy-{{ uuid }}">{% trans "Post privacy" %}</label>
{% endif %}
<select name="privacy" id="privacy-{{ uuid }}">
<option value="public" {% if not current or current == 'public' %}selected{% endif %}>
<option value="public" {% if user.default_post_privacy == 'public' or current == 'public' %}selected{% endif %}>
{% trans "Public" %}
</option>
<option value="unlisted" {% if current == 'unlisted' %}selected{% endif %}>
<option value="unlisted" {% if user.default_post_privacy == 'unlisted' or current == 'unlisted' %}selected{% endif %}>
{% trans "Unlisted" %}
</option>
<option value="followers" {% if current == 'followers' %}selected{% endif %}>
<option value="followers" {% if user.default_post_privacy == 'followers' or current == 'followers' %}selected{% endif %}>
{% trans "Followers" %}
</option>
<option value="direct" {% if current == 'direct' %}selected{% endif %}>
<option value="direct" {% if user.default_post_privacy == 'direct' or current == 'direct' %}selected{% endif %}>
{% trans "Private" %}
</option>
</select>