From a399694bbb09526868dcc48cf8942b4e627ab41f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20=C4=8Ciha=C5=99?= Date: Fri, 15 Nov 2024 08:41:19 +0100 Subject: [PATCH] feat: expose component locked state in component API This makes it easier to obtain lock state. --- docs/api.rst | 1 + docs/changes.rst | 1 + weblate/api/serializers.py | 2 ++ 3 files changed, 4 insertions(+) diff --git a/docs/api.rst b/docs/api.rst index 9f6d5c13d898..1a5c8301db45 100644 --- a/docs/api.rst +++ b/docs/api.rst @@ -1297,6 +1297,7 @@ Components :>json string suggestion_voting: :ref:`component-suggestion_voting` :>json string suggestion_autoaccept: :ref:`component-suggestion_autoaccept` :>json string push_on_commit: :ref:`component-push_on_commit` + :>json bool locked: Whether component is locked, this field is read-only; see :http:get:`/api/components/(string:project)/(string:component)/lock/` :>json string commit_pending_age: :ref:`component-commit_pending_age` :>json string auto_lock_error: :ref:`component-auto_lock_error` :>json string language_regex: :ref:`component-language_regex` diff --git a/docs/changes.rst b/docs/changes.rst index a389bde629a6..a74406266771 100644 --- a/docs/changes.rst +++ b/docs/changes.rst @@ -11,6 +11,7 @@ Not yet released. * A shortcut to duplicate a component is now available directly in the menu (:guilabel:`Manage` → :guilabel:`Duplicate Component`) * Included username when generating :ref:`credits`. * :ref:`bulk-edit` shows a preview of matched strings. +* :http:get:`/api/components/(string:project)/(string:component)/` exposes component lock state. **Bug fixes** diff --git a/weblate/api/serializers.py b/weblate/api/serializers.py index d4ce6175a570..2227d2b24b1f 100644 --- a/weblate/api/serializers.py +++ b/weblate/api/serializers.py @@ -496,6 +496,7 @@ class ComponentSerializer(RemovableSerializer[Component]): push_branch = LinkedField( required=False, allow_blank=True, max_length=BRANCH_LENGTH ) + locked = serializers.BooleanField(read_only=True) serializer_url_field = MultiFieldHyperlinkedIdentityField @@ -595,6 +596,7 @@ class Meta: "disable_autoshare", "category", "linked_component", + "locked", ) extra_kwargs = { "url": {