forked from mirrors/bookwyrm
Add user default privacy setting to the privacy_select and user preferences
This commit is contained in:
parent
7b749d6476
commit
73c30e8c9a
5 changed files with 34 additions and 6 deletions
|
@ -103,7 +103,7 @@ class EditUserForm(CustomForm):
|
||||||
class Meta:
|
class Meta:
|
||||||
model = models.User
|
model = models.User
|
||||||
fields = [
|
fields = [
|
||||||
'avatar', 'name', 'email', 'summary', 'manually_approves_followers'
|
'avatar', 'name', 'email', 'summary', 'manually_approves_followers', 'default_post_privacy'
|
||||||
]
|
]
|
||||||
help_texts = {f: None for f in fields}
|
help_texts = {f: None for f in fields}
|
||||||
|
|
||||||
|
|
18
bookwyrm/migrations/0046_user_default_post_privacy.py
Normal file
18
bookwyrm/migrations/0046_user_default_post_privacy.py
Normal 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),
|
||||||
|
),
|
||||||
|
]
|
|
@ -22,7 +22,6 @@ from .base_model import BookWyrmModel
|
||||||
from .federated_server import FederatedServer
|
from .federated_server import FederatedServer
|
||||||
from . import fields, Review
|
from . import fields, Review
|
||||||
|
|
||||||
|
|
||||||
class User(OrderedCollectionPageMixin, AbstractUser):
|
class User(OrderedCollectionPageMixin, AbstractUser):
|
||||||
''' a user who wants to read books '''
|
''' a user who wants to read books '''
|
||||||
username = fields.UsernameField()
|
username = fields.UsernameField()
|
||||||
|
@ -91,6 +90,11 @@ class User(OrderedCollectionPageMixin, AbstractUser):
|
||||||
through_fields=('user', 'status'),
|
through_fields=('user', 'status'),
|
||||||
related_name='favorite_statuses'
|
related_name='favorite_statuses'
|
||||||
)
|
)
|
||||||
|
default_post_privacy = models.CharField(
|
||||||
|
max_length=255,
|
||||||
|
default='public',
|
||||||
|
choices=fields.PrivacyLevels.choices
|
||||||
|
)
|
||||||
remote_id = fields.RemoteIdField(
|
remote_id = fields.RemoteIdField(
|
||||||
null=True, unique=True, activitypub_field='id')
|
null=True, unique=True, activitypub_field='id')
|
||||||
created_date = models.DateTimeField(auto_now_add=True)
|
created_date = models.DateTimeField(auto_now_add=True)
|
||||||
|
|
|
@ -43,6 +43,12 @@ Edit Profile
|
||||||
{{ form.manually_approves_followers }}
|
{{ form.manually_approves_followers }}
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="block">
|
||||||
|
<label class="label" for="id_default_post_privacy">
|
||||||
|
Default post privacy:
|
||||||
|
{{form.default_post_privacy}}
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
<button class="button is-primary" type="submit">Save</button>
|
<button class="button is-primary" type="submit">Save</button>
|
||||||
</form>
|
</form>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
|
@ -5,16 +5,16 @@
|
||||||
<label class="is-sr-only" for="privacy-{{ uuid }}">Post privacy</label>
|
<label class="is-sr-only" for="privacy-{{ uuid }}">Post privacy</label>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<select name="privacy" id="privacy-{{ uuid }}">
|
<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 %}>
|
||||||
Public
|
Public
|
||||||
</option>
|
</option>
|
||||||
<option value="unlisted" {% if current == 'unlisted' %}selected{% endif %}>
|
<option value="unlisted" {% if user.default_post_privacy == 'unlisted' or current == 'unlisted' %}selected{% endif %}>
|
||||||
Unlisted
|
Unlisted
|
||||||
</option>
|
</option>
|
||||||
<option value="followers" {% if current == 'followers' %}selected{% endif %}>
|
<option value="followers" {% if user.default_post_privacy == 'followers' or current == 'followers' %}selected{% endif %}>
|
||||||
Followers
|
Followers
|
||||||
</option>
|
</option>
|
||||||
<option value="direct" {% if current == 'direct' %}selected{% endif %}>
|
<option value="direct" {% if user.default_post_privacy == 'direct' or current == 'direct' %}selected{% endif %}>
|
||||||
Private
|
Private
|
||||||
</option>
|
</option>
|
||||||
</select>
|
</select>
|
||||||
|
|
Loading…
Reference in a new issue