1
0
mirror of https://github.com/netbox-community/netbox.git synced 2024-05-10 07:54:54 +00:00

10300 initial translation support use gettext

This commit is contained in:
Arthur
2022-11-03 11:58:26 -07:00
committed by Jeremy Stretch
parent 2cc2d2cc37
commit 6eba5d4d96
67 changed files with 1192 additions and 1134 deletions

View File

@@ -12,6 +12,7 @@ from django.http import HttpResponse, QueryDict
from django.urls import reverse
from django.utils import timezone
from django.utils.formats import date_format
from django.utils.translation import gettext as _
from rest_framework.utils.encoders import JSONEncoder
import django_rq
@@ -51,7 +52,7 @@ class Webhook(ExportTemplatesMixin, WebhooksMixin, ChangeLoggedModel):
related_name='webhooks',
verbose_name='Object types',
limit_choices_to=FeatureQuery('webhooks'),
help_text="The object(s) to which this Webhook applies."
help_text=_("The object(s) to which this Webhook applies.")
)
name = models.CharField(
max_length=150,
@@ -59,21 +60,21 @@ class Webhook(ExportTemplatesMixin, WebhooksMixin, ChangeLoggedModel):
)
type_create = models.BooleanField(
default=False,
help_text="Call this webhook when a matching object is created."
help_text=_("Call this webhook when a matching object is created.")
)
type_update = models.BooleanField(
default=False,
help_text="Call this webhook when a matching object is updated."
help_text=_("Call this webhook when a matching object is updated.")
)
type_delete = models.BooleanField(
default=False,
help_text="Call this webhook when a matching object is deleted."
help_text=_("Call this webhook when a matching object is deleted.")
)
payload_url = models.CharField(
max_length=500,
verbose_name='URL',
help_text='This URL will be called using the HTTP method defined when the webhook is called. '
'Jinja2 template processing is supported with the same context as the request body.'
help_text=_('This URL will be called using the HTTP method defined when the webhook is called. '
'Jinja2 template processing is supported with the same context as the request body.')
)
enabled = models.BooleanField(
default=True
@@ -88,46 +89,46 @@ class Webhook(ExportTemplatesMixin, WebhooksMixin, ChangeLoggedModel):
max_length=100,
default=HTTP_CONTENT_TYPE_JSON,
verbose_name='HTTP content type',
help_text='The complete list of official content types is available '
'<a href="https://www.iana.org/assignments/media-types/media-types.xhtml">here</a>.'
help_text=_('The complete list of official content types is available '
'<a href="https://www.iana.org/assignments/media-types/media-types.xhtml">here</a>.')
)
additional_headers = models.TextField(
blank=True,
help_text="User-supplied HTTP headers to be sent with the request in addition to the HTTP content type. "
"Headers should be defined in the format <code>Name: Value</code>. Jinja2 template processing is "
"supported with the same context as the request body (below)."
help_text=_("User-supplied HTTP headers to be sent with the request in addition to the HTTP content type. "
"Headers should be defined in the format <code>Name: Value</code>. Jinja2 template processing is "
"supported with the same context as the request body (below).")
)
body_template = models.TextField(
blank=True,
help_text='Jinja2 template for a custom request body. If blank, a JSON object representing the change will be '
'included. Available context data includes: <code>event</code>, <code>model</code>, '
'<code>timestamp</code>, <code>username</code>, <code>request_id</code>, and <code>data</code>.'
help_text=_('Jinja2 template for a custom request body. If blank, a JSON object representing the change will be '
'included. Available context data includes: <code>event</code>, <code>model</code>, '
'<code>timestamp</code>, <code>username</code>, <code>request_id</code>, and <code>data</code>.')
)
secret = models.CharField(
max_length=255,
blank=True,
help_text="When provided, the request will include a 'X-Hook-Signature' "
"header containing a HMAC hex digest of the payload body using "
"the secret as the key. The secret is not transmitted in "
"the request."
help_text=_("When provided, the request will include a 'X-Hook-Signature' "
"header containing a HMAC hex digest of the payload body using "
"the secret as the key. The secret is not transmitted in "
"the request.")
)
conditions = models.JSONField(
blank=True,
null=True,
help_text="A set of conditions which determine whether the webhook will be generated."
help_text=_("A set of conditions which determine whether the webhook will be generated.")
)
ssl_verification = models.BooleanField(
default=True,
verbose_name='SSL verification',
help_text="Enable SSL certificate verification. Disable with caution!"
help_text=_("Enable SSL certificate verification. Disable with caution!")
)
ca_file_path = models.CharField(
max_length=4096,
null=True,
blank=True,
verbose_name='CA File Path',
help_text='The specific CA certificate file to use for SSL verification. '
'Leave blank to use the system defaults.'
help_text=_('The specific CA certificate file to use for SSL verification. '
'Leave blank to use the system defaults.')
)
class Meta:
@@ -201,7 +202,7 @@ class CustomLink(CloningMixin, ExportTemplatesMixin, WebhooksMixin, ChangeLogged
content_types = models.ManyToManyField(
to=ContentType,
related_name='custom_links',
help_text='The object type(s) to which this link applies.'
help_text=_('The object type(s) to which this link applies.')
)
name = models.CharField(
max_length=100,
@@ -211,11 +212,11 @@ class CustomLink(CloningMixin, ExportTemplatesMixin, WebhooksMixin, ChangeLogged
default=True
)
link_text = models.TextField(
help_text="Jinja2 template code for link text"
help_text=_("Jinja2 template code for link text")
)
link_url = models.TextField(
verbose_name='Link URL',
help_text="Jinja2 template code for link URL"
help_text=_("Jinja2 template code for link URL")
)
weight = models.PositiveSmallIntegerField(
default=100
@@ -223,17 +224,17 @@ class CustomLink(CloningMixin, ExportTemplatesMixin, WebhooksMixin, ChangeLogged
group_name = models.CharField(
max_length=50,
blank=True,
help_text="Links with the same group will appear as a dropdown menu"
help_text=_("Links with the same group will appear as a dropdown menu")
)
button_class = models.CharField(
max_length=30,
choices=CustomLinkButtonClassChoices,
default=CustomLinkButtonClassChoices.DEFAULT,
help_text="The class of the first link in a group will be used for the dropdown button"
help_text=_("The class of the first link in a group will be used for the dropdown button")
)
new_window = models.BooleanField(
default=False,
help_text="Force link to open in a new window"
help_text=_("Force link to open in a new window")
)
clone_fields = (
@@ -272,7 +273,7 @@ class ExportTemplate(ExportTemplatesMixin, WebhooksMixin, ChangeLoggedModel):
content_types = models.ManyToManyField(
to=ContentType,
related_name='export_templates',
help_text='The object type(s) to which this template applies.'
help_text=_('The object type(s) to which this template applies.')
)
name = models.CharField(
max_length=100
@@ -282,23 +283,23 @@ class ExportTemplate(ExportTemplatesMixin, WebhooksMixin, ChangeLoggedModel):
blank=True
)
template_code = models.TextField(
help_text='Jinja2 template code. The list of objects being exported is passed as a context variable named '
'<code>queryset</code>.'
help_text=_('Jinja2 template code. The list of objects being exported is passed as a context variable named '
'<code>queryset</code>.')
)
mime_type = models.CharField(
max_length=50,
blank=True,
verbose_name='MIME type',
help_text='Defaults to <code>text/plain</code>'
help_text=_('Defaults to <code>text/plain</code>')
)
file_extension = models.CharField(
max_length=15,
blank=True,
help_text='Extension to append to the rendered filename'
help_text=_('Extension to append to the rendered filename')
)
as_attachment = models.BooleanField(
default=True,
help_text="Download file as attachment"
help_text=_("Download file as attachment")
)
class Meta:
@@ -358,7 +359,7 @@ class SavedFilter(CloningMixin, ExportTemplatesMixin, WebhooksMixin, ChangeLogge
content_types = models.ManyToManyField(
to=ContentType,
related_name='saved_filters',
help_text='The object type(s) to which this filter applies.'
help_text=_('The object type(s) to which this filter applies.')
)
name = models.CharField(
max_length=100,
@@ -553,7 +554,7 @@ class JobResult(models.Model):
related_name='job_results',
verbose_name='Object types',
limit_choices_to=FeatureQuery('job_results'),
help_text="The object type to which this job result applies",
help_text=_("The object type to which this job result applies"),
on_delete=models.CASCADE,
)
created = models.DateTimeField(