add option default not sharing mastodon

This commit is contained in:
Your Name 2023-02-12 08:49:10 -05:00 committed by Henri Dickson
parent 26eddd848a
commit 6b87154005
6 changed files with 30 additions and 4 deletions

View file

@ -25,7 +25,7 @@
<textarea name="text" cols="40" rows="10" placeholder="超过360字部分实例可能无法显示" maxlength="360" id="id_text">{% if comment.text %}{{ comment.text }}{% endif %}</textarea>
<div class="mark-modal__share-checkbox float-right">
<label for="id_share_to_mastodon"><input type="checkbox" name="share_to_mastodon" id="id_share_to_mastodon" value="1" checked>分享到联邦网络</label>
<label for="id_share_to_mastodon"><input type="checkbox" name="share_to_mastodon" id="id_share_to_mastodon" value="1" {%if not request.user.preference.default_no_share %}checked{% endif %}>分享到联邦网络</label>
</div>
<div class="mark-modal__option">

View file

@ -45,7 +45,7 @@
</div>
<div class="mark-modal__share-checkbox float-right">
<label for="id_share_to_mastodon"><input type="checkbox" name="share_to_mastodon" id="id_share_to_mastodon" value="1" checked>分享到联邦网络</label>
<label for="id_share_to_mastodon"><input type="checkbox" name="share_to_mastodon" id="id_share_to_mastodon" value="1" {%if not request.user.preference.default_no_share %}checked{% endif %}>分享到联邦网络</label>
</div>
<div class="mark-modal__option">

View file

@ -38,6 +38,7 @@ def preferences(request):
preference = request.user.get_preference()
if request.method == "POST":
preference.default_visibility = int(request.POST.get("default_visibility"))
preference.default_no_share = bool(request.POST.get("default_no_share"))
preference.classic_homepage = bool(request.POST.get("classic_homepage"))
preference.mastodon_publish_public = bool(
request.POST.get("mastodon_publish_public")
@ -49,6 +50,7 @@ def preferences(request):
preference.save(
update_fields=[
"default_visibility",
"default_no_share",
"classic_homepage",
"mastodon_publish_public",
"mastodon_append_tag",

View file

@ -0,0 +1,17 @@
# Generated by Django 3.2.16 on 2023-02-12 13:43
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("users", "0001_initial"),
]
operations = [
migrations.AddField(
model_name="preference",
name="default_no_share",
field=models.BooleanField(default=False),
),
]

View file

@ -214,6 +214,7 @@ class Preference(models.Model):
import_status = models.JSONField(
blank=True, null=True, encoder=DjangoJSONEncoder, default=dict
)
default_no_share = models.BooleanField(default=False)
default_visibility = models.PositiveSmallIntegerField(default=0)
classic_homepage = models.BooleanField(null=False, default=False)
mastodon_publish_public = models.BooleanField(null=False, default=False)

View file

@ -69,8 +69,8 @@
<div class="import-panel__body">
<span>{% trans '在联邦网络上以公开方式分享的帖文是否发布到公共时间轴上:' %}</span>
<div class="import-panel__checkbox import-panel__checkbox--last">
<input type="checkbox" name="mastodon_publish_public" id="visibility" {%if request.user.preference.mastodon_publish_public %}checked{% endif %}>
<label for="visibility">{% trans '选中时为public未选中时为unlisted' %}</label>
<input type="checkbox" name="mastodon_publish_public" id="mastodon_publish_public" {%if request.user.preference.mastodon_publish_public %}checked{% endif %}>
<label for="mastodon_publish_public">{% trans '选中时为public未选中时为unlisted' %}</label>
</div>
<br><br>
<span>{% trans '在联邦网络上分享帖文时附加标签:' %}</span>
@ -78,6 +78,12 @@
<input name="mastodon_append_tag" id="tag" placeholder="#我的书影音" value="{{ request.user.preference.mastodon_append_tag }}" >
<label for="tag">{% trans '输入标签文字会被添加到帖文结尾' %}</label>
</div>
<br>
<span>{% trans '默认不分享到联邦网络:' %}</span>
<div class="import-panel__checkbox import-panel__checkbox--last">
<input type="checkbox" name="default_no_share" id="default_no_share" {%if request.user.preference.default_no_share %}checked{% endif %}>
<label for="default_no_share">标记默认分享到联邦网络,除非选中此项</label>
</div>
</div>
</div>
</div>