internlm/SWE-Fixer-Train-110K huggingface dataset:
Repository: WeblateOrg/weblate

Issue:
FieldError: Cannot resolve keyword 'max_labels_name' into field. Choices are: change, check, comment, content...
Error when sorting by label. Apparently, the tests do not cover this well as it's broken without tests failing.

Sentry Issue: [WEBLATE-3WE](https://sentry.io/organizations/weblate/issues/1674410274/?referrer=github_integration)

```
FieldError: Cannot resolve keyword 'max_labels_name' into field. Choices are: change, check, comment, content_hash, context, extra_context, extra_flags, flags, id, id_hash, labels, location, note, num_words, original_state, pending, position, previous_source, priority, screenshots, shaping, shaping_id, source, state, suggestion, target, timestamp, translation, translation_id
(12 additional frame(s) were not displayed)
...
  File "django/db/models/sql/compiler.py", line 342, in get_order_by
    field, self.query.get_meta(), default_order=asc))
  File "django/db/models/sql/compiler.py", line 720, in find_ordering_name
    field, targets, alias, joins, path, opts, transform_function = self._setup_joins(pieces, opts, alias)
  File "django/db/models/sql/compiler.py", line 755, in _setup_joins
    field, targets, opts, joins, path, transform_function = self.query.setup_joins(pieces, opts, alias)
  File "django/db/models/sql/query.py", line 1568, in setup_joins
    names[:pivot], opts, allow_many, fail_on_missing=True,
  File "django/db/models/sql/query.py", line 1484, in names_to_path
    "Choices are: %s" % (name, ", ".join(available)))
```


Discussion:
This happens when reversing ordering by label, @SaptakS can you please take a look?
Checking.

Resolving patch:
diff --git a/weblate/trans/models/unit.py b/weblate/trans/models/unit.py
--- a/weblate/trans/models/unit.py
+++ b/weblate/trans/models/unit.py
@@ -150,7 +150,7 @@ def order_by_request(self, form_data):
                 sort_list.append(choice)
         if not sort_list:
             return self.order()
-        if "max_labels_name" in sort_list:
+        if "max_labels_name" in sort_list or "-max_labels_name" in sort_list:
             return self.annotate(max_labels_name=Max("labels__name")).order_by(
                 *sort_list
             )


Test patch:
diff --git a/weblate/trans/tests/test_models.py b/weblate/trans/tests/test_models.py
--- a/weblate/trans/tests/test_models.py
+++ b/weblate/trans/tests/test_models.py
@@ -380,7 +380,11 @@ def test_order_by_request(self):
             ordered_unit = Unit.objects.filter(
                 translation__language_code="cs"
             ).order_by_request({"sort_by": order_option})
+            ordered_desc_unit = Unit.objects.filter(
+                translation__language_code="cs"
+            ).order_by_request({"sort_by": "-{}".format(order_option)})
             self.assertEqual(len(ordered_unit), 4)
+            self.assertEqual(len(ordered_desc_unit), 4)
 
         # check sorting with multiple options work
         multiple_ordered_unit = Unit.objects.filter(
Repository: WeblateOrg/weblate

Issue:
The ability to disassociate components from a component-list via the API
**Is your feature request related to a problem? Please describe.**

I am able to associate component(s) with a component list via the API but not disassociate.

**Describe the solution you'd like**

DELETE method available at `/api/component-lists/<list-name>/components/<component-id>/`

This action should disassociate the component with the component-list.

**Describe alternatives you've considered**

I have checked the REST API docs and there does not seem to be a valid way to do this.




Discussion:
FYI - this is related to https://github.com/WeblateOrg/weblate/issues/3291 

Resolving patch:
diff --git a/weblate/api/views.py b/weblate/api/views.py
--- a/weblate/api/views.py
+++ b/weblate/api/views.py
@@ -1128,6 +1128,25 @@ def components(self, request, **kwargs):
 
         return Response(serializer.data, status=status.HTTP_200_OK)
 
+    @action(
+        detail=True,
+        methods=["delete"],
+        url_path="components/(?P<component_slug>[^/.]+)",
+    )
+    def delete_components(self, request, slug, component_slug):
+        obj = self.get_object()
+        self.perm_check(request)
+
+        try:
+            component = Component.objects.get(slug=component_slug)
+        except (Component.DoesNotExist, ValueError) as error:
+            return Response(
+                data={"result": "Unsuccessful", "detail": force_str(error)},
+                status=status.HTTP_400_BAD_REQUEST,
+            )
+        obj.components.remove(component)
+        return Response(status=status.HTTP_204_NO_CONTENT)
+
 
 class Metrics(APIView):
     """Metrics view for monitoring."""


Test patch:
diff --git a/weblate/api/tests.py b/weblate/api/tests.py
--- a/weblate/api/tests.py
+++ b/weblate/api/tests.py
@@ -1657,6 +1657,37 @@ def test_add_component(self):
             request={"component_id": self.component.pk},
         )
 
+    def test_remove_component(self):
+        self.do_request(
+            "api:componentlist-delete-components",
+            kwargs={
+                "slug": ComponentList.objects.get().slug,
+                "component_slug": self.component.slug,
+            },
+            method="delete",
+            code=403,
+        )
+        self.do_request(
+            "api:componentlist-delete-components",
+            kwargs={
+                "slug": ComponentList.objects.get().slug,
+                "component_slug": "invalid",
+            },
+            method="delete",
+            superuser=True,
+            code=400,
+        )
+        self.do_request(
+            "api:componentlist-delete-components",
+            kwargs={
+                "slug": ComponentList.objects.get().slug,
+                "component_slug": self.component.slug,
+            },
+            method="delete",
+            superuser=True,
+            code=204,
+        )
+
     def test_put(self):
         self.do_request(
             "api:componentlist-detail",
Repository: WeblateOrg/weblate

Issue:
migrations fail for database name containing "-"
**Describe the bug**
  Applying memory.0007_use_trigram...Traceback (most recent call last):
  File "/usr/lib/python3.6/site-packages/django/db/backends/utils.py", line 84, in _execute
    return self.cursor.execute(sql, params)
psycopg2.errors.SyntaxError: syntax error at or near "-"
LINE 1: ALTER DATABASE weblate-staging SET pg_trgm.similarity_thresh...
                              ^
**To Reproduce**
Set the database name to "weblate-staging"

I worked around this by changing of
ALTER DATABASE {} SET
to
ALTER DATABASE \"{}\" SET
in 0007_use_trigram.py and 0008_adjust_similarity.py.

weblate-4.1.1


Discussion:
Weblate 4.2 has changed this to role based, see bbf6f11e21dabfee760725b2ebb32fe84e8180f6 and #3940, but the problem could exist there as well.

Resolving patch:
diff --git a/weblate/memory/migrations/0008_adjust_similarity.py b/weblate/memory/migrations/0008_adjust_similarity.py
--- a/weblate/memory/migrations/0008_adjust_similarity.py
+++ b/weblate/memory/migrations/0008_adjust_similarity.py
@@ -15,7 +15,7 @@ def update_index(apps, schema_editor):
 
     schema_editor.execute(
         "ALTER ROLE {} SET pg_trgm.similarity_threshold = 0.5".format(
-            schema_editor.connection.settings_dict["USER"]
+            schema_editor.quote_name(schema_editor.connection.settings_dict["USER"])
         )
     )
 


Test patch:
Repository: WeblateOrg/weblate

Issue:
Auth provider title and image override do not work for auth providers with '-' in it
**Describe the issue**

The new feature to override the name and image for an auth provider (introduced in 159ae591e91e7c2065ede9c39f14d743f5ab07e5) does not work for auth providers with '-' in them. 

<!--
A clear and concise description of the problem you are facing.
-->

**I already tried**

Describe the steps you tried to solve the problem yourself.

- [x] I've read and searched [the docs](https://docs.weblate.org/) and did not find the answer there.
      If you didn’t try already, try to search there what you wrote above.

**To Reproduce the issue**

Steps to reproduce the behavior:

1. Add an auth to your settings - e.g. `SOCIAL_AUTH_AZUREAD_TENANT_OAUTH2_KEY`
2. Set the title and image override (`SOCIAL_AUTH_AZUREAD_TENANT_OAUTH2_TITLE` and `SOCIAL_AUTH_AZUREAD_TENANT_OAUTH2_IMAGE`)
3. Go to the login page
4. The title and image are not overriden

**Expected behavior**

The title and image should be overridden. 



Discussion:

Resolving patch:
diff --git a/weblate/accounts/templatetags/authnames.py b/weblate/accounts/templatetags/authnames.py
--- a/weblate/accounts/templatetags/authnames.py
+++ b/weblate/accounts/templatetags/authnames.py
@@ -72,8 +72,8 @@ def get_auth_params(auth: str):
 
     # Settings override
     settings_params = {
-        "name": f"SOCIAL_AUTH_{auth.upper()}_TITLE",
-        "image": f"SOCIAL_AUTH_{auth.upper()}_IMAGE",
+        "name": f"SOCIAL_AUTH_{auth.upper().replace('-','_')}_TITLE",
+        "image": f"SOCIAL_AUTH_{auth.upper().replace('-','_')}_IMAGE",
     }
     for target, source in settings_params.items():
         value = getattr(settings, source, None)


Test patch:
Repository: WeblateOrg/weblate

Issue:
Update to Source Sans 3 v. 3.046
Weblate currently uses Source Sans _Pro_ [v. 3.6.0](https://github.com/WeblateOrg/weblate/pull/2998), but newer versions of the font are called Source Sans _3_ and [the latest release](https://github.com/adobe-fonts/source-sans/releases/tag/3.046R) has a lower version number, weirdly (@adobe-fonts, you did make a mess here! :/). This will need CSS changes to update the font name.


Discussion:
Apparently, we're using https://yarnpkg.com/package/source-sans-pro which has been renamed to https://yarnpkg.com/package/source-sans. That's why we don't follow the updates...

Resolving patch:
diff --git a/weblate/trans/widgets.py b/weblate/trans/widgets.py
--- a/weblate/trans/widgets.py
+++ b/weblate/trans/widgets.py
@@ -155,8 +155,8 @@ def get_column_width(self, surface, columns):
 
     def get_column_fonts(self):
         return [
-            Pango.FontDescription(f"Source Sans Pro {self.font_size * 1.5}"),
-            Pango.FontDescription(f"Source Sans Pro {self.font_size}"),
+            Pango.FontDescription(f"Source Sans 3 {self.font_size * 1.5}"),
+            Pango.FontDescription(f"Source Sans 3 {self.font_size}"),
         ]
 
     def render_additional(self, ctx):
@@ -307,8 +307,8 @@ def get_column_width(self, surface, columns):
 
     def get_column_fonts(self):
         return [
-            Pango.FontDescription(f"Source Sans Pro {42}"),
-            Pango.FontDescription(f"Source Sans Pro {18}"),
+            Pango.FontDescription(f"Source Sans 3 {42}"),
+            Pango.FontDescription(f"Source Sans 3 {18}"),
         ]
 
     def get_name(self) -> str:
@@ -321,7 +321,7 @@ def get_title(self, name: str, suffix: str = "") -> str:
     def render_additional(self, ctx):
         ctx.move_to(280, 170)
         layout = PangoCairo.create_layout(ctx)
-        layout.set_font_description(Pango.FontDescription(f"Source Sans Pro {52}"))
+        layout.set_font_description(Pango.FontDescription(f"Source Sans 3 {52}"))
         name = self.get_name()
         layout.set_markup(self.get_title(name))
 


Test patch:
diff --git a/weblate/trans/tests/test_selenium.py b/weblate/trans/tests/test_selenium.py
--- a/weblate/trans/tests/test_selenium.py
+++ b/weblate/trans/tests/test_selenium.py
@@ -75,7 +75,7 @@
     "vendor",
     "font-source",
     "TTF",
-    "SourceSansPro-Bold.ttf",
+    "SourceSans3-Bold.ttf",
 )
 
 
@@ -1052,7 +1052,7 @@ def test_fonts(self):
 
         # Create group
         Select(self.driver.find_element(By.ID, "id_group_font")).select_by_visible_text(
-            "Source Sans Pro Bold"
+            "Source Sans 3 Bold"
         )
         element = self.driver.find_element(By.ID, "id_group_name")
         element.send_keys("default-font")
Repository: WeblateOrg/weblate

Issue:
Adjust DEFAULT_PULL_MESSAGE in docker compose
### Describe the issue

I'd like to adjust [`DEFAULT_PULL_MESSAGE`](https://docs.weblate.org/en/weblate-4.10.1/admin/config.html?highlight=pull%20request#default-pull-message) in my docker compose setup.

This is currently not possible and not documented in https://docs.weblate.org/en/weblate-4.10.1/admin/install/docker.html?highlight=pull%20request#docker-environment-variables.

### I already tried

- [X] I've read and searched [the documentation](https://docs.weblate.org/).
- [X] I've searched for similar issues in this repository.

### Steps to reproduce the behavior

_No response_

### Expected behavior

_No response_

### Screenshots

_No response_

### Exception traceback

_No response_

### Additional context

_No response_


Discussion:
This issue looks more like a support question than an issue. We strive to answer these reasonably fast, but [purchasing the support subscription](https://weblate.org/support/) is not only more responsible and faster for your business but also makes Weblate stronger.

In case your question is already answered, [making a donation](https://weblate.org/donate/) is the right way to say thank you!
This issue seems to be a good fit for newbie contributors. You are welcome to contribute to Weblate! Don't hesitate to ask any questions you would have while implementing this.

You can learn about how to get started in our [contributors documentation](https://docs.weblate.org/en/latest/contributing/index.html).
I've since had some time to experiment with this. I've tried setting `WEBLATE_DEFAULT_PULL_MESSAGE` in my docker compose setup and the pull request message is still on its default value.

I've therefore taken a look at the code and found these parts for `WEBLATE_GITHUB_USERNAME` etc.:

https://github.com/WeblateOrg/weblate/blob/c32f48f6dd7aace61a7c1446d63592fd544a4e5b/weblate/settings_docker.py#L229-L242

I suppose adding `WEBLATE_DEFAULT_PULL_MESSAGE` would be sufficcient to implement this feature. I will try and open up a PR later, though I don't have the time to test in real world right now. I will also update the [documentation](https://github.com/WeblateOrg/weblate/blob/efacbf5d7e36c7207e985744639564e7edfc2fbb/docs/admin/install/docker.rst#L640).

How long do you suppose the review process will take for such a small addition? Would it be useful to build and deploy my own image to for the time being until a new release is made? 

Resolving patch:
diff --git a/weblate/settings_docker.py b/weblate/settings_docker.py
--- a/weblate/settings_docker.py
+++ b/weblate/settings_docker.py
@@ -241,6 +241,10 @@
 PAGURE_USERNAME = os.environ.get("WEBLATE_PAGURE_USERNAME")
 PAGURE_TOKEN = os.environ.get("WEBLATE_PAGURE_TOKEN")
 
+# Default pull request message.
+# Please see the documentation for more details.
+DEFAULT_PULL_MESSAGE = os.environ.get("WEBLATE_DEFAULT_PULL_MESSAGE")
+
 # Authentication configuration
 AUTHENTICATION_BACKENDS = ()
 


Test patch:
Repository: WeblateOrg/weblate

Issue:
Analysis issues do not link to content
This is the e-mail I got about QR Code Generator/Translations
"
'Expecting property name enclosed in double quotes: line 2 column 3 (char 4)'

Erroneous file

src/_locales/en/messages.json"

Would expect link to source and respective Weblate section here.


Discussion:
In this case Weblate failed to parse the file, so the content is not in Weblate and it has to be fixed in the VCS directly. Suggestions to improve the mail are of course welcome.
@nijel I was thinking the e-mail could link to the file in the VCS.
Which in this case is "https://github.com/rugk/offline-qr-code/blob/master/src/_locales/en/messages.json"

It could quote what the offending property name is.
Unfortunately there is no detailed information from the parser, so this is best error message we can provide.

Link to the VCS should be doable if project has set repository web browser, what is unfortunately not the case for most non Gettext projects...
Link to the file should be easy to add since 4b2e079b80103364292464b585186943b7172890 does this in the UI.
This issue seems to be a good fit for newbie contributors. You are welcome to contribute to Weblate! Don't hesitate to ask any questions you would have while implementing this.

You can learn about how to get started in our [contributors documentation](https://docs.weblate.org/en/latest/contributing/index.html).
After going through the mentioned commit and the code, I found that, here => https://github.com/WeblateOrg/weblate/blob/main/weblate/templates/mail/parse_error.html, we parse the error and send it in the mail.

I made some changes in the template to test but I am not able to reproduce the issue. Can you please point me to the views code or where the mail is using this template? Thanks
This is triggered in case the file in the repository cannot be parsed.

In the debug mode, you can also render individual change events directly without going through e-mail when browsing history by clicking on the bell icon.

Resolving patch:
diff --git a/weblate/accounts/notifications.py b/weblate/accounts/notifications.py
--- a/weblate/accounts/notifications.py
+++ b/weblate/accounts/notifications.py
@@ -472,6 +472,16 @@ class ParseErrorNotification(Notification):
     verbose = _("Parse error")
     template_name = "parse_error"
 
+    def get_context(
+        self, change=None, subscription=None, extracontext=None, changes=None
+    ):
+        context = super().get_context(change, subscription, extracontext, changes)
+        if change:
+            context["details"]["filelink"] = change.component.get_repoweb_link(
+                change.details.get("filename"), "1"
+            )
+        return context
+
 
 @register_notification
 class NewStringNotificaton(Notification):


Test patch:
Repository: WeblateOrg/weblate

Issue:
Maintainers not able to add Punjabi translations
### Describe the issue

The Punjabi language is used in both Pakistan and India, but with different writing systems. The locales available for this in Weblate are `pa_PK` and `pa` respectively. (This is the same as how the Android locales are set up for this.) I have been translating applications for both scripts, which is easier to do together. However, `pa_PK` is not on the list of languages to choose from in the menu for adding a new translation, which says only a basic list of languages is included. For context, Punjabi is the 10th most spoken language in the world, and the majority of speakers live in Pakistan where it is the most widely apoken language. The language selection menu even includes ancient languages but does not have this option, it is odd that it is omitted entirely.

I have tried requesting adding it manually to maintainers, but here the maintainer of F-Droid suggests this may be a bug with Weblate since Android supports this locale but they were not able to add it on their hostes Weblate instance: https://gitlab.com/fdroid/admin/-/issues/342

In the meantime, I have been using the "und" Undetermined language code to store these translationa, but this puts a burden on project maintainers to manually export these and include them under the `pa_PK` locale when the Weblate application is supposed to be able to do this.

### I already tried

- [X] I've read and searched [the documentation](https://docs.weblate.org/).
- [X] I've searched for similar issues in this repository.

### Steps to reproduce the behavior

1. Click "+" to add "Punjabi (Pakistan)"
2. Error appears saying project maintainer needs to add support for this
3. Project maintainer is not able to do this

### Expected behavior

Ability to translate projects on Weblate to Punjabi.

### Screenshots

Screenshots in the linked Gitlab issue re: F-Droid

### Exception traceback

_No response_

### How do you run Weblate?

weblate.org service

### Weblate versions

_No response_

### Weblate deploy checks

_No response_

### Additional context

_No response_


Discussion:

Resolving patch:
diff --git a/weblate/lang/data.py b/weblate/lang/data.py
--- a/weblate/lang/data.py
+++ b/weblate/lang/data.py
@@ -24,7 +24,15 @@
 
 NO_CODE_LANGUAGES = {lang[0] for lang in languages.LANGUAGES}
 
-UNDERSCORE_EXCEPTIONS = {"nb_NO", "zh_Hant", "zh_Hans", "be_Latn", "ro_MD", "pt_BR"}
+UNDERSCORE_EXCEPTIONS = {
+    "nb_NO",
+    "zh_Hant",
+    "zh_Hans",
+    "be_Latn",
+    "ro_MD",
+    "pt_BR",
+    "pa_PK",
+}
 AT_EXCEPTIONS = {"ca@valencia"}
 
 


Test patch:
Repository: WeblateOrg/weblate

Issue:
component.py does not set timeout in WeblateLock
### Describe the issue

I'm getting irregular errors like these when I stress the API a little bit on a slightly overloaded system:

The API call is `POST` `translations/project/component/language/file/`.
The response is:
`{"file":"Lock could not be acquired in 1"}`

Should the lock timeout really be the default 1 here? All other calls to the constructor of `WeblateLock` use a timeout of 120.

### I already tried

- [X] I've read and searched [the documentation](https://docs.weblate.org/).
- [X] I've searched for similar issues in this repository.

### Steps to reproduce the behavior

_No response_

### Expected behavior

_No response_

### Screenshots

_No response_

### Exception traceback

_No response_

### How do you run Weblate?

Docker container

### Weblate versions

_No response_

### Weblate deploy checks

_No response_

### Additional context

_No response_


Discussion:
The timeout really needs to be way shorter here, but maybe it could be longer than the default 1 second.

But looking at the code I think the locking is no longer needed for the regular upload as it now uses standard translate API and that one does not need locking.

Resolving patch:
diff --git a/weblate/trans/models/translation.py b/weblate/trans/models/translation.py
--- a/weblate/trans/models/translation.py
+++ b/weblate/trans/models/translation.py
@@ -1239,11 +1239,8 @@ def handle_upload(  # noqa: C901
 
             if method in ("translate", "fuzzy", "approve"):
                 # Merge on units level
-                with component.lock:
-                    return self.merge_translations(
-                        request, store, conflicts, method, fuzzy
-                    )
-            elif method == "add":
+                return self.merge_translations(request, store, conflicts, method, fuzzy)
+            if method == "add":
                 with component.lock:
                     return self.handle_add_upload(request, store, fuzzy=fuzzy)
 


Test patch: