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

Issue:
Rename html to templates folder, use subfolder
I load Weblate from my virtual. This works great, three suggestions to make it even better:
- Weblate's template folder should be called `templates` so it's automatically picked up by Django (saves me the trouble of having to use the `TEMPLATE_DIRS` variable)
- More blocks in templates to override. For example, blocks inside the navbar's and tools' dropdown elements would make it easier to add links to non-weblate pages without having to override the whole `index.html`/`project.html` files. On the login page it would be nice to have a block in the right column for custom elements. F.E.:

``` html
{% extends "weblate/index.html" %}
{% block tools_menu %}
    <li>My custom first link</li>
    {{ block.super }}
    <li>My custom last link</li>
{% endblock %}
```
- The templates should be inside a subfolder, fe `weblate/templates/weblate/index.html`. This way it's clear when I'm overriding a template where it originally came from.



Discussion:
The html name comes from old Django, where it was default. I've never bothered to change it :-). All changes you suggest seem okay to me...


Resolving patch:
diff --git a/weblate/settings_example.py b/weblate/settings_example.py
--- a/weblate/settings_example.py
+++ b/weblate/settings_example.py
@@ -177,9 +177,6 @@
 TEMPLATES = [
     {
         'BACKEND': 'django.template.backends.django.DjangoTemplates',
-        'DIRS': [
-            os.path.join(BASE_DIR, 'html'),
-        ],
         'OPTIONS': {
             'context_processors': [
                 'django.contrib.auth.context_processors.auth',


Test patch:
Repository: WeblateOrg/weblate

Issue:
Provide example hooks in pip installations
### Steps to reproduce
1. `pip install Weblate`
2. `ls path/to/site-packages/weblate`

### Actual behaviour
Example hooks are missing. We have to download the examples manually and copy them where we want on the server.

### Expected behaviour
Example hooks should be in site-packages, packaged as data inside Weblate package. This would allow to use examples, even when Weblate is installed using pip.


Discussion:
True, we have workaround for this in the Docker (see https://github.com/WeblateOrg/docker/issues/18), but handling this at packaging level is better approach. Patches are welcome :-).

Resolving patch:
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -32,6 +32,11 @@
 with open('requirements.txt') as requirements:
     REQUIRES = requirements.read().splitlines()
 
+DATA_FILES = [
+    ('share/weblate/' + root, [os.path.join(root, f) for f in files])
+    for root, dirs, files in os.walk('examples')
+]
+
 setup(
     name='Weblate',
     version='2.14',
@@ -120,4 +125,5 @@
         'httpretty',
     ),
     test_suite='runtests.runtests',
+    data_files=DATA_FILES,
 )


Test patch:
Repository: WeblateOrg/weblate

Issue:
POST/PUT screenshots via API
## Given

- We run selenium and protractor to generate screenshots of our testscases.
- We embrace all translated strings in those screenshots with a red box, identification is done using the translation-key as an identifier in html code. 

After running our CI pipeline i have a build artifact containing all screenshots. 

## Idea

So this is a feature request about uploading build artifacts zip-file or each screenshot separately to Weblate using the REST API.


Discussion:
I have (read only) API almost ready, I should polish it and publish, so that somebody can implement upload on top of that...
cool, i'm happy to contribute some stuff here. When are you going to merge the readonly API?
In few minutes ;-)
It's now there: https://docs.weblate.org/en/latest/api.html#screeenshots
@nijel i looked into that and adding Update is pretty simple. I was wondering how to add new screenshots, but the current `ScreenshotSerializer` does not support this. Any reason why you skipped `ModelSerializer` of `django_restframework` and implemented your own ones?

If i'm gonna to refactor this, it would be a pretty heavy change, but i'd suggest to discuss it before you introduce the Screenshot API in a release. Are you available on IRC?

Resolving patch:
diff --git a/weblate/api/views.py b/weblate/api/views.py
--- a/weblate/api/views.py
+++ b/weblate/api/views.py
@@ -31,6 +31,7 @@
 from rest_framework.exceptions import ParseError
 from rest_framework.response import Response
 from rest_framework.reverse import reverse
+from rest_framework.status import HTTP_204_NO_CONTENT
 from rest_framework.utils import formatting
 
 from weblate.api.serializers import (
@@ -577,8 +578,10 @@ def file(self, request, **kwargs):
         if 'file' not in request.data:
             raise ParseError('Missing file parameter')
 
-        # No uploads for now
-        raise PermissionDenied()
+        obj.image = request.data['file']
+        if 'name' in request.data:
+            obj.image = request.data['name']
+        return HttpResponse(status=HTTP_204_NO_CONTENT)
 
 
 class ChangeViewSet(viewsets.ReadOnlyModelViewSet):


Test patch:
diff --git a/weblate/api/tests.py b/weblate/api/tests.py
--- a/weblate/api/tests.py
+++ b/weblate/api/tests.py
@@ -616,6 +616,25 @@ def test_download(self):
             response, b'PNG',
         )
 
+    def test_upload(self):
+        self.authenticate()
+        Screenshot.objects.update(file=None)
+
+        with open(TEST_SCREENSHOT, 'rb') as fp:
+            response = self.client.post(
+                reverse(
+                    'api:screenshot-file',
+                    kwargs={
+                        'pk': Screenshot.objects.all()[0].pk,
+                    }
+                ),
+                {
+                    'file': fp,
+                }
+            )
+        self.assertEqual(response.status_code, 204)
+        self.assertContains(Screenshot.objects.all()[0].file, b'PNG')
+
 
 class ChangeAPITest(APIBaseTest):
     def test_list_changes(self):
Repository: WeblateOrg/weblate

Issue:
File download is outdated
### Steps to reproduce
1. Edit string.
2. Donwload original translation file (without conversion).

### Actual behaviour
The file does not have recent changes.

### Expected behaviour
All changes should be reflected.

### Server configuration
Current master



Discussion:
This is outcome of pushing changes to the file on commit. Probably we should force writing changes on file download.

Resolving patch:
diff --git a/weblate/trans/views/helper.py b/weblate/trans/views/helper.py
--- a/weblate/trans/views/helper.py
+++ b/weblate/trans/views/helper.py
@@ -123,6 +123,10 @@ def download_translation_file(translation, fmt=None):
             )
         )
 
+    # Force flushing pending units
+    author = translation.get_last_author(True)
+    translation.update_units(author)
+
     srcfilename = translation.get_filename()
 
     # Construct file name (do not use real filename as it is usually not


Test patch:
diff --git a/weblate/trans/tests/test_files.py b/weblate/trans/tests/test_files.py
--- a/weblate/trans/tests/test_files.py
+++ b/weblate/trans/tests/test_files.py
@@ -360,6 +360,7 @@ def test_export(self):
             )
         )
         self.assertContains(response, 'Weblate Hello World 2016')
+        self.assertContains(response, 'Nazdar svete!')
         self.assertEqual(
             response['Content-Disposition'],
             'attachment; filename=test-test-cs.po'
Repository: WeblateOrg/weblate

Issue:
Change the pull request title
Is it possible to create pull requests with some other title than "Update from Weblate."?


Discussion:
Right now it is not possible, it's hardcoded:

https://github.com/WeblateOrg/weblate/blob/30b4c118e7c5b9b0e77ce8093129c7c807af3b6f/weblate/vcs/git.py#L550
I think there could be setting for this:

* Add setting default value to `weblate/trans/models/conf.py`
* Add documentation to `docs/admin/config.rst`
* Use it in the vcs (currently `weblate/vcs/git.py`)

Resolving patch:
diff --git a/weblate/trans/models/conf.py b/weblate/trans/models/conf.py
--- a/weblate/trans/models/conf.py
+++ b/weblate/trans/models/conf.py
@@ -182,6 +182,10 @@ class WeblateConf(AppConf):
         'Deleted translation using Weblate ({{ language_name }})\n\n'
     )
 
+    DEFAULT_PULL_MESSAGE = (
+        'Update from Weblate'
+    )
+
     # Billing
     INVOICE_PATH = ''
 
diff --git a/weblate/vcs/git.py b/weblate/vcs/git.py
--- a/weblate/vcs/git.py
+++ b/weblate/vcs/git.py
@@ -548,7 +548,7 @@ def create_pull_request(self, origin_branch, fork_branch):
             '-f',
             '-h', '{0}:{1}'.format(settings.GITHUB_USERNAME, fork_branch),
             '-b', origin_branch,
-            '-m', 'Update from Weblate.',
+            '-m', settings.DEFAULT_PULL_MESSAGE,
         ]
         self.execute(cmd)
 


Test patch:
Repository: WeblateOrg/weblate

Issue:
copy to clipboard
Can you add "Copy to Clipboard" button for source strings.

![image 1](https://user-images.githubusercontent.com/7031346/50376812-dd6c6000-0623-11e9-9f26-288353ea3e10.jpg)


Discussion:

Resolving patch:
diff --git a/weblate/trans/templatetags/translations.py b/weblate/trans/templatetags/translations.py
--- a/weblate/trans/templatetags/translations.py
+++ b/weblate/trans/templatetags/translations.py
@@ -196,6 +196,9 @@ def format_translation(value, language, plural=None, diff=None,
         # HTML escape
         value = escape(force_text(raw_value))
 
+        # Content of the Copy to clipboard button
+        copy = value
+
         # Format diff if there is any
         value = fmt_diff(value, diff, idx)
 
@@ -222,12 +225,13 @@ def format_translation(value, language, plural=None, diff=None,
         # Join paragraphs
         content = mark_safe(newline.join(paras))
 
-        parts.append({'title': title, 'content': content})
+        parts.append({'title': title, 'content': content, 'copy': copy})
 
     return {
         'simple': simple,
         'items': parts,
         'language': language,
+        'unit': unit,
     }
 
 


Test patch:
Repository: WeblateOrg/weblate

Issue:
Ability to disable auto update
For Tails we are using Weblate with a set of scripts to integrate Weblate into the rest of our infrastructure [1]. Therefore the `update-remotes` cronjob should not be run. Currently we use a broken git url to make sure, that Weblate can't update the repository on it's own. But it is quite annoying to see always the alerts:

    The VCS repository has many changes compared to the upstream. Please merge the changes manually or set up push to automate this.
    --- 
    Weblate could not fetch upstream changes when updating the repository.

I searched around to lean about celery, but I haven't found a way to disable task, that's why  I think it needs to be supported by Weblate itself. If it is possible to disable cronjobs outside touching the Weblate code I would also be happy. 

[1] https://git.tails.boum.org/puppet-tails/tree/files/weblate/scripts/cron.sh

<bountysource-plugin>

---
Want to back this issue? **[Post a bounty on it!](https://www.bountysource.com/issues/86133717-ability-to-disable-celery-jobs?utm_campaign=plugin&utm_content=tracker%2F253393&utm_medium=issues&utm_source=github)** We accept bounties via [Bountysource](https://www.bountysource.com/?utm_campaign=plugin&utm_content=tracker%2F253393&utm_medium=issues&utm_source=github).
</bountysource-plugin>


Discussion:
The task is currently hardcoded:

https://github.com/WeblateOrg/weblate/blob/d75addfd133b91767733910d0ba0d19e0ce40409/weblate/trans/tasks.py#L375-L377

But it could certainly be made configurable. We already do this for backups:

https://github.com/WeblateOrg/weblate/blob/d75addfd133b91767733910d0ba0d19e0ce40409/weblate/utils/tasks.py#L97-L100

It was introduced in 1d093bc2795fc22ed658bd2dc74938afa545cb49
There already is [AUTO_UPDATE](https://docs.weblate.org/en/latest/admin/config.html#auto-update) setting which configures whether local repos should be updated. Maybe we should have one setting for all that instead of adding another one. Tentative choices: 

* `none` - no daily updates at all
* `remote` (also accept False for backwards compatibility) - update remotes
*  `full` (also accept True for backwards compatibility) - update remote and merge working copy

Resolving patch:
diff --git a/weblate/trans/tasks.py b/weblate/trans/tasks.py
--- a/weblate/trans/tasks.py
+++ b/weblate/trans/tasks.py
@@ -67,8 +67,7 @@ def perform_update(cls, pk, auto=False):
             obj = Project.objects.get(pk=pk)
         else:
             obj = Component.objects.get(pk=pk)
-
-        if not auto or settings.AUTO_UPDATE:
+        if settings.AUTO_UPDATE in ("full", True) or not auto:
             obj.do_update()
         else:
             obj.update_remote_branch()
@@ -228,6 +227,10 @@ def cleanup_suggestions():
 def update_remotes():
     """Update all remote branches (without attempt to merge)."""
     non_linked = Component.objects.with_repo()
+
+    if settings.AUTO_UPDATE not in ("full", "remote", True, False):
+        return
+
     for component in non_linked.iterator():
         perform_update.delay("Component", component.pk, auto=True)
 


Test patch:
Repository: WeblateOrg/weblate

Issue:
Unchanged check should honor placeholders
**Is your feature request related to a problem? Please describe.**
It is possible to define placeholders using [`placeholder:` flag](https://docs.weblate.org/en/latest/admin/checks.html#customizing-behavior). The [Unchanged translation check](https://docs.weblate.org/en/latest/user/checks.html#unchanged-translation) should deal with those correctly.

**Describe the solution you'd like**
The check strip custom placeholders from the string similarly like we do with format strings:

https://github.com/WeblateOrg/weblate/blob/ddfbd298a31a95229fa4487cfb2a5a4878da7b2b/weblate/checks/same.py#L107-L137

**Additional context**

Getting `placeholder:` flag value:

https://github.com/WeblateOrg/weblate/blob/256fa9370edc90c2404df6178d1daa002d441e2f/weblate/checks/base.py#L179

Building regexp for placeholders:

https://github.com/WeblateOrg/weblate/blob/256fa9370edc90c2404df6178d1daa002d441e2f/weblate/checks/placeholders.py#L57 

<bountysource-plugin>

---
Want to back this issue? **[Post a bounty on it!](https://www.bountysource.com/issues/88807457-unchanged-check-should-honor-placeholders?utm_campaign=plugin&utm_content=tracker%2F253393&utm_medium=issues&utm_source=github)** We accept bounties via [Bountysource](https://www.bountysource.com/?utm_campaign=plugin&utm_content=tracker%2F253393&utm_medium=issues&utm_source=github).
</bountysource-plugin>


Discussion:

Resolving patch:
diff --git a/weblate/checks/same.py b/weblate/checks/same.py
--- a/weblate/checks/same.py
+++ b/weblate/checks/same.py
@@ -140,6 +140,17 @@ def test_word(word):
     return len(word) <= 2 or word in SAME_BLACKLIST or word in LANGUAGES
 
 
+def strip_placeholders(msg, unit):
+
+    return re.sub(
+        "|".join(
+            re.escape(param) for param in unit.all_flags.get_value("placeholders")
+        ),
+        "",
+        msg,
+    )
+
+
 class SameCheck(TargetCheck):
     """Check for not translated entries."""
 
@@ -169,6 +180,10 @@ def should_ignore(self, source, unit):
         # Strip format strings
         stripped = strip_string(source, unit.all_flags)
 
+        # Strip placeholder strings
+        if "placeholders" in unit.all_flags:
+            stripped = strip_placeholders(stripped, unit)
+
         # Ignore strings which don't contain any string to translate
         # or just single letter (usually unit or something like that)
         # or are whole uppercase (abbreviations)


Test patch:
diff --git a/weblate/checks/tests/test_same_checks.py b/weblate/checks/tests/test_same_checks.py
--- a/weblate/checks/tests/test_same_checks.py
+++ b/weblate/checks/tests/test_same_checks.py
@@ -215,3 +215,7 @@ def test_same_uppercase(self):
         self.do_test(False, ("RMS", "RMS", ""))
         self.do_test(False, ("<primary>RMS</primary>", "<primary>RMS</primary>", ""))
         self.do_test(True, ("Who is RMS?", "Who is RMS?", ""))
+
+    def test_same_placeholders(self):
+        self.do_test(True, ("%location%", "%location%", ""))
+        self.do_test(False, ("%location%", "%location%.", "placeholders:%location%"))
Repository: WeblateOrg/weblate

Issue:
Search / Criteria"Exact" overwrites 'Add" button
The search is a great feature (quick to fill, powerfull  - with advanced criterias - and results are fast and reliable) but I have noticed an issue in the layout : "Exact" (which seems to be an untranslatable string yet) overwrite the "Add" button (at least in french, the full french label is "Ajouter"); see:  ![Search](https://user-images.githubusercontent.com/1452146/78504660-e0368a00-776e-11ea-9ede-ce77263e4107.jpg)

page https://hosted.weblate.org/projects/weblate/master/#search 



Discussion:
@SaptakS Can you please take a look at this?
It's not translatable only because strings were not yet extracted, but it's properly marked for translation. But I've added context to the string in 5fa8327280.
@nijel on it.

Resolving patch:
diff --git a/weblate/utils/search.py b/weblate/utils/search.py
--- a/weblate/utils/search.py
+++ b/weblate/utils/search.py
@@ -69,8 +69,8 @@ class Exact(whoosh.query.Term):
     pass
 
 
-class ExactPlugin(QuotePlugin):
-    """Exact match plugin with quotes to specify an exact term."""
+class ExactPlugin(whoosh.qparser.TaggingPlugin):
+    """Exact match plugin to specify an exact term."""
 
     class ExactNode(whoosh.qparser.syntax.TextNode):
         qclass = Exact
@@ -78,7 +78,7 @@ class ExactNode(whoosh.qparser.syntax.TextNode):
         def r(self):
             return "Exact %r" % self.text
 
-    expr = r"\=(^|(?<=\W))['\"](?P<text>.*?)['\"](?=\s|\]|[)}]|$)"
+    expr = r"\=(^|(?<=\W))(['\"]?)(?P<text>.*?)\2(?=\s|\]|[)}]|$)"
     nodetype = ExactNode
 
 


Test patch:
diff --git a/weblate/utils/tests/test_search.py b/weblate/utils/tests/test_search.py
--- a/weblate/utils/tests/test_search.py
+++ b/weblate/utils/tests/test_search.py
@@ -94,7 +94,7 @@ def test_exact(self):
         self.assert_query("source:='hello'", Q(source__iexact="hello"))
         self.assert_query('source:="hello world"', Q(source__iexact="hello world"))
         self.assert_query("source:='hello world'", Q(source__iexact="hello world"))
-        self.assert_query("source:=hello", Q(source__substring="=hello"))
+        self.assert_query("source:=hello", Q(source__iexact="hello"))
 
     def test_regex(self):
         self.assert_query('source:r"^hello"', Q(source__regex="^hello"))
Repository: WeblateOrg/weblate

Issue:
Subversion svn+ssh protocol doesn't use ssh key
Subversion protocol svn+shh doesn't try the publickey method

I've tried to use the url like we use it in other svn clients, eg:
svn+ssh://username@svnserver.example.com/repository/

Weblate connects to the svn server via ssh, but doesn't try to use the ssh key (publickey method):
```
debug1: Client protocol version 2.0; client software version OpenSSH_7.9p1 Debian-10+deb10u2
debug1: match: OpenSSH_7.9p1 Debian-10+deb10u2 pat OpenSSH* compat 0x04000000
debug1: Local version string SSH-2.0-OpenSSH_7.9p1 Debian-10+deb10u1
debug1: permanently_set_uid: 106/65534 [preauth]
debug1: list_hostkey_types: rsa-sha2-512,rsa-sha2-256,ssh-rsa,ecdsa-sha2-nistp256,ssh-ed25519 [preauth]
debug1: SSH2_MSG_KEXINIT sent [preauth]
debug1: SSH2_MSG_KEXINIT received [preauth]
debug1: kex: algorithm: curve25519-sha256 [preauth]
debug1: kex: host key algorithm: ecdsa-sha2-nistp256 [preauth]
debug1: kex: client->server cipher: chacha20-poly1305@openssh.com MAC: <implicit> compression: none [preauth]
debug1: kex: server->client cipher: chacha20-poly1305@openssh.com MAC: <implicit> compression: none [preauth]
debug1: expecting SSH2_MSG_KEX_ECDH_INIT [preauth]
debug1: rekey after 134217728 blocks [preauth]
debug1: SSH2_MSG_NEWKEYS sent [preauth]
debug1: expecting SSH2_MSG_NEWKEYS [preauth]
debug1: SSH2_MSG_NEWKEYS received [preauth]
debug1: rekey after 134217728 blocks [preauth]
debug1: KEX done [preauth]
debug1: userauth-request for user username service ssh-connection method none [preauth]
debug1: attempt 0 failures 0 [preauth]
debug1: PAM: initializing for "username"
debug1: PAM: setting PAM_RHOST to "10.10.50.121"
debug1: PAM: setting PAM_TTY to "ssh"
debug1: userauth-request for user username service ssh-connection method password [preauth]
debug1: attempt 1 failures 0 [preauth]
Failed none for username from 10.10.50.121 port 44768 ssh2
debug1: userauth-request for user username service ssh-connection method password [preauth]
```
This is only when I set the Version control System as "Subversion" in the "Add new translation component" dialog. When I set i to "Git", the ssh connection proceeds with publickey method.
`debug1: userauth-request for user progwart service ssh-connection method publickey [preauth]`

What am I setting wrong? Seems like a bug to me, but I'm not sure.


Discussion:

Resolving patch:
diff --git a/weblate/vcs/base.py b/weblate/vcs/base.py
--- a/weblate/vcs/base.py
+++ b/weblate/vcs/base.py
@@ -142,7 +142,11 @@ def resolve_symlinks(self, path):
     def _getenv():
         """Generate environment for process execution."""
         return get_clean_env(
-            {"GIT_SSH": SSH_WRAPPER.filename, "GIT_TERMINAL_PROMPT": "0"}
+            {
+                "GIT_SSH": SSH_WRAPPER.filename,
+                "GIT_TERMINAL_PROMPT": "0",
+                "SVN_SSH": SSH_WRAPPER.filename,
+            }
         )
 
     @classmethod


Test patch:
Repository: WeblateOrg/weblate

Issue:
Add ``has:context`` search type
**Is your feature request related to a problem? Please describe.**
Sometimes I want to see all messages with context no matter which context really are.

**Describe the solution you'd like**
Add search type ``has:context`` similar to existing ``has:plural`` or ``has:comment``. Search with this type should find all messages which have settled context (has ``msgctxt`` field in po-file).



Discussion:
The has lookup is defined here:

https://github.com/WeblateOrg/weblate/blob/2c412409550d26b231423b752d8dca45f674b7bc/weblate/utils/search.py#L251-L269

Resolving patch:
diff --git a/weblate/trans/filter.py b/weblate/trans/filter.py
--- a/weblate/trans/filter.py
+++ b/weblate/trans/filter.py
@@ -37,6 +37,7 @@ def full_list(self):
             ("suggestions", _("Strings with suggestions"), "has:suggestion"),
             ("shapings", _("Strings with shapings"), "has:shaping"),
             ("labels", _("Strings with labels"), "has:label"),
+            ("context", _("Strings with context"), "has:context"),
             (
                 "nosuggestions",
                 _("Strings needing action without suggestions"),
diff --git a/weblate/utils/search.py b/weblate/utils/search.py
--- a/weblate/utils/search.py
+++ b/weblate/utils/search.py
@@ -265,6 +265,8 @@ def has_sql(text):
         return Q(shaping__isnull=False)
     if text == "label":
         return Q(labels__isnull=False)
+    if text == "context":
+        return ~Q(context="")
 
     raise ValueError("Unsupported has lookup: {}".format(text))
 


Test patch:
diff --git a/weblate/utils/tests/test_search.py b/weblate/utils/tests/test_search.py
--- a/weblate/utils/tests/test_search.py
+++ b/weblate/utils/tests/test_search.py
@@ -209,6 +209,7 @@ def test_has(self):
         self.assert_query("has:translation", Q(state__gte=STATE_TRANSLATED))
         self.assert_query("has:shaping", Q(shaping__isnull=False))
         self.assert_query("has:label", Q(labels__isnull=False))
+        self.assert_query("has:context", ~Q(context=""))
 
     def test_is(self):
         self.assert_query("is:pending", Q(pending=True))