forked from mirrors/bookwyrm
Merge pull request #1816 from bookwyrm-social/privacy-translation
Build-in translations to privacy choices dropdown
This commit is contained in:
commit
b2262a5f98
5 changed files with 69 additions and 15 deletions
55
bookwyrm/migrations/0126_auto_20220112_2315.py
Normal file
55
bookwyrm/migrations/0126_auto_20220112_2315.py
Normal file
|
@ -0,0 +1,55 @@
|
||||||
|
# Generated by Django 3.2.10 on 2022-01-12 23:15
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
("bookwyrm", "0125_alter_user_preferred_language"),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name="annualgoal",
|
||||||
|
name="privacy",
|
||||||
|
field=models.CharField(
|
||||||
|
choices=[
|
||||||
|
("public", "Public"),
|
||||||
|
("unlisted", "Unlisted"),
|
||||||
|
("followers", "Followers"),
|
||||||
|
("direct", "Private"),
|
||||||
|
],
|
||||||
|
default="public",
|
||||||
|
max_length=255,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name="importjob",
|
||||||
|
name="privacy",
|
||||||
|
field=models.CharField(
|
||||||
|
choices=[
|
||||||
|
("public", "Public"),
|
||||||
|
("unlisted", "Unlisted"),
|
||||||
|
("followers", "Followers"),
|
||||||
|
("direct", "Private"),
|
||||||
|
],
|
||||||
|
default="public",
|
||||||
|
max_length=255,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name="user",
|
||||||
|
name="default_post_privacy",
|
||||||
|
field=models.CharField(
|
||||||
|
choices=[
|
||||||
|
("public", "Public"),
|
||||||
|
("unlisted", "Unlisted"),
|
||||||
|
("followers", "Followers"),
|
||||||
|
("direct", "Private"),
|
||||||
|
],
|
||||||
|
default="public",
|
||||||
|
max_length=255,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
]
|
|
@ -203,9 +203,12 @@ class UsernameField(ActivitypubFieldMixin, models.CharField):
|
||||||
return value.split("@")[0]
|
return value.split("@")[0]
|
||||||
|
|
||||||
|
|
||||||
PrivacyLevels = models.TextChoices(
|
PrivacyLevels = [
|
||||||
"Privacy", ["public", "unlisted", "followers", "direct"]
|
("public", _("Public")),
|
||||||
)
|
("unlisted", _("Unlisted")),
|
||||||
|
("followers", _("Followers")),
|
||||||
|
("direct", _("Private")),
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
class PrivacyField(ActivitypubFieldMixin, models.CharField):
|
class PrivacyField(ActivitypubFieldMixin, models.CharField):
|
||||||
|
@ -214,9 +217,7 @@ class PrivacyField(ActivitypubFieldMixin, models.CharField):
|
||||||
public = "https://www.w3.org/ns/activitystreams#Public"
|
public = "https://www.w3.org/ns/activitystreams#Public"
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
super().__init__(
|
super().__init__(*args, max_length=255, choices=PrivacyLevels, default="public")
|
||||||
*args, max_length=255, choices=PrivacyLevels.choices, default="public"
|
|
||||||
)
|
|
||||||
|
|
||||||
# pylint: disable=invalid-name
|
# pylint: disable=invalid-name
|
||||||
def set_field_from_activity(self, instance, data, overwrite=True):
|
def set_field_from_activity(self, instance, data, overwrite=True):
|
||||||
|
|
|
@ -40,9 +40,7 @@ class ImportJob(models.Model):
|
||||||
mappings = models.JSONField()
|
mappings = models.JSONField()
|
||||||
complete = models.BooleanField(default=False)
|
complete = models.BooleanField(default=False)
|
||||||
source = models.CharField(max_length=100)
|
source = models.CharField(max_length=100)
|
||||||
privacy = models.CharField(
|
privacy = models.CharField(max_length=255, default="public", choices=PrivacyLevels)
|
||||||
max_length=255, default="public", choices=PrivacyLevels.choices
|
|
||||||
)
|
|
||||||
retry = models.BooleanField(default=False)
|
retry = models.BooleanField(default=False)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
|
|
@ -129,7 +129,7 @@ class User(OrderedCollectionPageMixin, AbstractUser):
|
||||||
related_name="favorite_statuses",
|
related_name="favorite_statuses",
|
||||||
)
|
)
|
||||||
default_post_privacy = models.CharField(
|
default_post_privacy = models.CharField(
|
||||||
max_length=255, default="public", choices=fields.PrivacyLevels.choices
|
max_length=255, default="public", choices=fields.PrivacyLevels
|
||||||
)
|
)
|
||||||
remote_id = fields.RemoteIdField(null=True, unique=True, activitypub_field="id")
|
remote_id = fields.RemoteIdField(null=True, unique=True, activitypub_field="id")
|
||||||
created_date = models.DateTimeField(auto_now_add=True)
|
created_date = models.DateTimeField(auto_now_add=True)
|
||||||
|
@ -427,7 +427,7 @@ class AnnualGoal(BookWyrmModel):
|
||||||
goal = models.IntegerField(validators=[MinValueValidator(1)])
|
goal = models.IntegerField(validators=[MinValueValidator(1)])
|
||||||
year = models.IntegerField(default=get_current_year)
|
year = models.IntegerField(default=get_current_year)
|
||||||
privacy = models.CharField(
|
privacy = models.CharField(
|
||||||
max_length=255, default="public", choices=fields.PrivacyLevels.choices
|
max_length=255, default="public", choices=fields.PrivacyLevels
|
||||||
)
|
)
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
|
|
|
@ -34,26 +34,26 @@
|
||||||
<div class="column">
|
<div class="column">
|
||||||
{{ form.avatar }}
|
{{ form.avatar }}
|
||||||
|
|
||||||
{% include 'snippets/form_errors.html' with errors_list=form.avatar.errors id="desc_avatar" %}
|
{% include 'snippets/form_errors.html' with errors_list=form.avatar.errors id="desc_avatar" %}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="field">
|
<div class="field">
|
||||||
<label class="label" for="id_name">{% trans "Display name:" %}</label>
|
<label class="label" for="id_name">{% trans "Display name:" %}</label>
|
||||||
{{ form.name }}
|
{{ form.name }}
|
||||||
|
|
||||||
{% include 'snippets/form_errors.html' with errors_list=form.name.errors id="desc_name" %}
|
{% include 'snippets/form_errors.html' with errors_list=form.name.errors id="desc_name" %}
|
||||||
</div>
|
</div>
|
||||||
<div class="field">
|
<div class="field">
|
||||||
<label class="label" for="id_summary">{% trans "Summary:" %}</label>
|
<label class="label" for="id_summary">{% trans "Summary:" %}</label>
|
||||||
{{ form.summary }}
|
{{ form.summary }}
|
||||||
|
|
||||||
{% include 'snippets/form_errors.html' with errors_list=form.summary.errors id="desc_summary" %}
|
{% include 'snippets/form_errors.html' with errors_list=form.summary.errors id="desc_summary" %}
|
||||||
</div>
|
</div>
|
||||||
<div class="field">
|
<div class="field">
|
||||||
<label class="label" for="id_email">{% trans "Email address:" %}</label>
|
<label class="label" for="id_email">{% trans "Email address:" %}</label>
|
||||||
{{ form.email }}
|
{{ form.email }}
|
||||||
|
|
||||||
{% include 'snippets/form_errors.html' with errors_list=form.email.errors id="desc_email" %}
|
{% include 'snippets/form_errors.html' with errors_list=form.email.errors id="desc_email" %}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
|
|
Loading…
Reference in a new issue