internlm/SWE-Fixer-Train-110K huggingface dataset:
Repository: translate/pootle

Issue:
Configurable logo url and favicon
It would be nice to have a configurable logo in the config file like you did for the name of pootle site (`POOTLE_TITLE`) instead of creating a custom template or editing the css of the default one.



Discussion:
I add also the feedback to edit the favicon in the config file

@JohnnyKing94 is there any reason why you don't want to override `images/app-32x32.png` and `images/app-64x64.png` using [image customisation](http://docs.translatehouse.org/projects/pootle/en/latest/developers/customization.html#customizing-images)?

Actually i have no problem to edit manually... the only reason why i opened this, it was as a simply feedback... many cms include an user-friendly template customization for editing logos, favicons, og:images, meta descriptions and other things... sometimes if they don't have an appropriate dedicate page on CP, they use config file like you... as i said i don't have any problem to edit manually... it was just a feedback :smile:

this is partly done @JohnnyKing94 - you can now set `POOTLE_CUSTOM_LOGO`
looking at favicons - its a bit more complex, there are several and a config

```html
    <link rel="apple-touch-icon" sizes="180x180" href="/assets/favicon/apple-touch-icon.png">
    <link rel="icon" type="image/png" href="/assets/favicon/favicon-32x32.png" sizes="32x32">
    <link rel="icon" type="image/png" href="/assets/favicon/favicon-16x16.png" sizes="16x16">
    <link rel="manifest" href="/assets/favicon/manifest.json">
    <link rel="mask-icon" href="/assets/favicon/safari-pinned-tab.svg" color="#5bbad5">
    <link rel="shortcut icon" href="/assets/favicon/favicon.ico">
    <meta name="msapplication-config" content="/assets/favicon/browserconfig.xml">
```
im wondering if there is some way we can use an svg and have it resize, rather than lots of diff sized bitmaps
looks like not on svg favicons - altho perhaps for some

http://caniuse.com/#feat=link-icon-svg

Resolving patch:
diff --git a/pootle/apps/pootle_misc/context_processors.py b/pootle/apps/pootle_misc/context_processors.py
--- a/pootle/apps/pootle_misc/context_processors.py
+++ b/pootle/apps/pootle_misc/context_processors.py
@@ -43,6 +43,7 @@ def pootle_context(request):
         'settings': {
             'POOTLE_CUSTOM_LOGO': getattr(settings, "POOTLE_CUSTOM_LOGO", ""),
             'POOTLE_TITLE': settings.POOTLE_TITLE,
+            'POOTLE_FAVICONS_PATH': settings.POOTLE_FAVICONS_PATH,
             'POOTLE_INSTANCE_ID': settings.POOTLE_INSTANCE_ID,
             'POOTLE_CONTACT_ENABLED': (settings.POOTLE_CONTACT_ENABLED and
                                        settings.POOTLE_CONTACT_EMAIL),


Test patch:
Repository: translate/pootle

Issue:
Muted checks don't act muted in Pootle 2.8.0rc6
In Pootle 2.8.0rc5, after translating a string and triggering some warnings (namely, XML tag mismatch), I could mute that check and/or press Ctrl+Enter to navigate to the next string.

With rc6, even if I mute that check for that translation, Ctrl+Enter still flashes that check to me and does NOT take me to the next string, regardless of how many times I press that key combo.



Discussion:
Just validated, this did work in 2.8.0rc5 but doesn't work on master.

Resolving patch:
diff --git a/pootle/apps/pootle_store/views.py b/pootle/apps/pootle_store/views.py
--- a/pootle/apps/pootle_store/views.py
+++ b/pootle/apps/pootle_store/views.py
@@ -690,7 +690,9 @@ def get_context_data(self, *args, **kwargs):
             result = dict(
                 checks=_get_critical_checks_snippet(self.request, form.unit),
                 user_score=self.request.user.public_score,
-                newtargets=[target for target in form.unit.target.strings])
+                newtargets=[target for target in form.unit.target.strings],
+                critical_checks_active=(
+                    form.unit.get_active_critical_qualitychecks().exists()))
             return result
 
 


Test patch:
Repository: translate/pootle

Issue:
Team page is very slow to load
not sure of the cause, but new team page is loading v slowly


Discussion:

Resolving patch:
diff --git a/pootle/apps/pootle_language/views.py b/pootle/apps/pootle_language/views.py
--- a/pootle/apps/pootle_language/views.py
+++ b/pootle/apps/pootle_language/views.py
@@ -302,11 +302,9 @@ def get_context_data(self, **kwargs):
             if k in stats:
                 stats[k + "_display"] = formatter.number(stats[k])
         context["stats"] = stats
-        context["suggestions"] = form.language_team.suggestions
-        suggestions_count = 0
-        if context["suggestions"]:
-            suggestions_count = context["suggestions"].count()
-        context["suggestions_display"] = formatter.number(suggestions_count)
+        context["suggestions"] = form.language_team.suggestions.count()
+        context["suggestions_display"] = formatter.number(
+            context["suggestions"])
         context["language"] = self.language
         context["page"] = "admin-team"
         context["browse_url"] = reverse(


Test patch:
diff --git a/tests/pootle_language/views.py b/tests/pootle_language/views.py
--- a/tests/pootle_language/views.py
+++ b/tests/pootle_language/views.py
@@ -135,9 +135,8 @@ def test_view_language_team_admin(client, language0, request_users):
                 include_children=False,
                 user=user)))
     assert (
-        list(response.context["suggestions"])
-        == list(
-            response.context["form"].language_team.suggestions))
+        response.context["suggestions"]
+        == response.context["form"].language_team.suggestions.count())
     assert response.context["language"] == language0
     if user in team.admins:
         team.remove_member(user)
Repository: translate/pootle

Issue:
Documentation not clear regarding setting up ElasticSearch as TM
There are some points missing in the Documentation regarding using ElasticSearch as a TM.

Main Problem is, that it only works with ElasticSearch 1.7.x, which is superseded by ElasticSearch 2.x. And only downloadable via past releases (https://www.elastic.co/downloads/past-releases/elasticsearch-1-7-5)

Another problem i've encountered is the documentation states you need to run update `pootle update_tmserver` once to setup your local installation.  But this command failed for me, regardless if the index exists or not.
Running `pootle update_tmserver --rebuild` actually worked. So my suggesting is either update the documentation or probably better, do a rebuild automatically if the index does not exist.



Discussion:
Just a note on versions:
- Elasticsearch 2.4.1 is the upstream stable 
- Elasticsearch is currently limited to <2.0 as the API changes.  And thus the Python package is also similarly limited.
- Travis has Elasticsearch v1.4.0 installed, installing newer ones would hammer the test environment ito speed as we need to download and install that package.
- Ubuntu/Debian are released with 1.7.3 in 16.04LTS (Xenial).  Nothing was packaged before that.

So my current position, lets leave things on the 1.7.x range and simply improve the docs where that isn't clear to someone setting up Elasticsearch based TM.


Resolving patch:
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -427,6 +427,13 @@ def replace_urls():
 # Pootle FS plugins
 extras_require['git'] = parse_requirements('requirements/_pootle_fs_git.txt')
 dependency_links += parse_dependency_links('requirements/_pootle_fs_git.txt')
+# Elasticsearch
+extras_require['es1'] = parse_requirements('requirements/_es_1.txt')
+dependency_links += parse_dependency_links('requirements/_es_1.txt')
+extras_require['es2'] = parse_requirements('requirements/_es_2.txt')
+dependency_links += parse_dependency_links('requirements/_es_2.txt')
+extras_require['es5'] = parse_requirements('requirements/_es_5.txt')
+dependency_links += parse_dependency_links('requirements/_es_5.txt')
 # Testing
 extras_require['travis'] = parse_requirements('requirements/travis.txt',
                                               recurse=True)


Test patch:
Repository: translate/pootle

Issue:
Running `calculate_checks` without a project specified runs same checks for all projects
It seems that running `pootle calculate_checks` uses same checks for all projects, regardless of per-project settings.
This caused quite a headache for me by seemingly using the `standard` checks on a project with `reduced` checks specified.


Discussion:
the problem appears to be with teechecker https://github.com/translate/translate/blob/master/translate/filters/checks.py#L579

Resolving patch:
diff --git a/pootle/apps/pootle_checks/utils.py b/pootle/apps/pootle_checks/utils.py
--- a/pootle/apps/pootle_checks/utils.py
+++ b/pootle/apps/pootle_checks/utils.py
@@ -298,7 +298,7 @@ def update_translated(self):
             if self.translation_project is not None:
                 # if TP is set then manually add TP.id to the Unit value dict
                 unit[tp_key] = self.translation_project.id
-            elif checker is None:
+            else:
                 checker = self.get_checker(unit[tp_key])
             if checker and self.update_translated_unit(unit, checker=checker):
                 updated_count += 1


Test patch:
Repository: translate/pootle

Issue:
pootle/runner.py fails when undefined env var "VIRTUAL_ENV"
# Steps to reproduce:

Install Pootle as a collection of docker containers, using [1drop/pootle](https://github.com/1drop/pootle) (and with [these changes to install 2.8.0](https://github.com/boite/pootle/commit/0eeb0a85cb58cb7f9767273772e76ed17a7a947b)):-

    $ docker-compose up -d

# Result:

    Step 18/24 : RUN pootle collectstatic --noinput --clear
     ---> Running in 8fd1a6b297b3
    Traceback (most recent call last):
      File "/usr/local/bin/pootle", line 7, in <module>
        from pootle.runner import main
      File "/usr/local/lib/python2.7/dist-packages/pootle/runner.py", line 37, in <module>
        VENV_SETTINGS_PATH = os.path.join(os.environ["VIRTUAL_ENV"], "pootle.conf")
      File "/usr/lib/python2.7/UserDict.py", line 40, in __getitem__
        raise KeyError(key)
    KeyError: 'VIRTUAL_ENV'

# Environment:

The Pootle installation made by the 1drop/pootle container isn't into a virtualenv and so `VIRTUAL_ENV` is undefined.


Discussion:

Resolving patch:
diff --git a/pootle/runner.py b/pootle/runner.py
--- a/pootle/runner.py
+++ b/pootle/runner.py
@@ -34,7 +34,10 @@
 #: Default path for the settings file
 SYSTEM_SETTINGS_PATH = os.path.join('/etc', 'pootle', 'pootle.conf')
 HOME_SETTINGS_PATH = os.path.join('~', '.pootle', 'pootle.conf')
-VENV_SETTINGS_PATH = os.path.join(os.environ["VIRTUAL_ENV"], "pootle.conf")
+if "VIRTUAL_ENV" in os.environ:
+    VENV_SETTINGS_PATH = os.path.join(os.environ["VIRTUAL_ENV"], "pootle.conf")
+else:
+    VENV_SETTINGS_PATH = ""
 DEFAULT_SETTINGS_PATH = ":".join(
     [SYSTEM_SETTINGS_PATH,
      HOME_SETTINGS_PATH,
@@ -146,7 +149,7 @@ def init_command(parser, args):
                               u"Not used with sqlite."))
 
     args, remainder_ = parser.parse_known_args(args)
-    config_path = args.config or VENV_SETTINGS_PATH
+    config_path = args.config or VENV_SETTINGS_PATH or HOME_SETTINGS_PATH
 
     if os.path.exists(config_path):
         resp = None
@@ -243,7 +246,7 @@ def configure_app(project, config_paths, django_settings_module, runner_name):
         logger.error(
             u"Configuration file does not exist at %(config_path)r. "
             u"Use '%(runner_name)s init' to initialize the configuration file.",
-            dict(config_path=VENV_SETTINGS_PATH,
+            dict(config_path=VENV_SETTINGS_PATH or HOME_SETTINGS_PATH,
                  runner_name=runner_name))
         sys.exit(1)
     os.environ.setdefault(settings_envvar, ":".join(_config_paths))


Test patch:
Repository: translate/pootle

Issue:
Empty file cant sync in pootle fs
if for some reason a file is empty - theres no way to get pootle fs to fill it again. All seems to work but it remains empty


Discussion:

Resolving patch:
diff --git a/pootle/apps/pootle_fs/files.py b/pootle/apps/pootle_fs/files.py
--- a/pootle/apps/pootle_fs/files.py
+++ b/pootle/apps/pootle_fs/files.py
@@ -202,7 +202,8 @@ def deserialize(self, create=False):
                     self.store.syncer.file_class(f)
                     if self.store and self.store.syncer.file_class
                     else getclass(f)(f.read()))
-            return store_file
+            if store_file.units:
+                return store_file
         if self.store_exists:
             return self.store.deserialize(self.store.serialize())
 


Test patch:
Repository: translate/pootle

Issue:
Add unit constraint on Submission
atm there is unit is not required on submission although it actually is.

im also not clear whether the store field is necessary as it can be accessed through unit and not all submissions seem to have it

i propose to 
- add migration to delete submissions with no unit
- add constraint on unit
- possibly remove Submission.store and related clear up



Discussion:
It is worth checking if `Submission.store` is needed.

need to check scorelog


Resolving patch:
diff --git a/pootle/apps/pootle_statistics/migrations/0014_submission_unit_notnull.py b/pootle/apps/pootle_statistics/migrations/0014_submission_unit_notnull.py
new file mode 100644
--- /dev/null
+++ b/pootle/apps/pootle_statistics/migrations/0014_submission_unit_notnull.py
@@ -0,0 +1,21 @@
+# -*- coding: utf-8 -*-
+# Generated by Django 1.10.7 on 2017-09-06 08:52
+from __future__ import unicode_literals
+
+from django.db import migrations, models
+import django.db.models.deletion
+
+
+class Migration(migrations.Migration):
+
+    dependencies = [
+        ('pootle_statistics', '0013_remove_extra_indeces'),
+    ]
+
+    operations = [
+        migrations.AlterField(
+            model_name='submission',
+            name='unit',
+            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='pootle_store.Unit'),
+        ),
+    ]
diff --git a/pootle/apps/pootle_statistics/models.py b/pootle/apps/pootle_statistics/models.py
--- a/pootle/apps/pootle_statistics/models.py
+++ b/pootle/apps/pootle_statistics/models.py
@@ -165,8 +165,10 @@ class Meta(object):
     suggestion = models.ForeignKey('pootle_store.Suggestion', blank=True,
                                    null=True, db_index=True,
                                    on_delete=models.CASCADE)
-    unit = models.ForeignKey('pootle_store.Unit', blank=True, null=True,
-                             db_index=True, on_delete=models.CASCADE)
+    unit = models.ForeignKey(
+        'pootle_store.Unit',
+        db_index=True,
+        on_delete=models.CASCADE)
     quality_check = models.ForeignKey('pootle_store.QualityCheck', blank=True,
                                       null=True, db_index=True,
                                       on_delete=models.CASCADE)


Test patch:
Repository: translate/pootle

Issue:
Add defaults for new project creation
when you create a new project it should probably set some defaults, in particular

- fs_type = localfs
- fs_url = settings.POOTLE_TRANSLATION_DIRECTORY + project.code

ref #6633 



Discussion:

Resolving patch:
diff --git a/pootle/apps/pootle_project/models.py b/pootle/apps/pootle_project/models.py
--- a/pootle/apps/pootle_project/models.py
+++ b/pootle/apps/pootle_project/models.py
@@ -66,6 +66,12 @@ def create(self, *args, **kwargs):
         project = super(ProjectManager, self).create(*args, **kwargs)
         for filetype in filetypes:
             project.filetypes.add(filetype)
+        project.config["pootle_fs.fs_type"] = kwargs.pop("fs_type", "localfs")
+        project.config["pootle_fs.fs_url"] = kwargs.pop(
+            "fs_url",
+            os.path.join(
+                settings.POOTLE_TRANSLATION_DIRECTORY,
+                project.code))
         return project
 
     def get_or_create(self, *args, **kwargs):


Test patch:
diff --git a/tests/pootle_project/models.py b/tests/pootle_project/models.py
new file mode 100644
--- /dev/null
+++ b/tests/pootle_project/models.py
@@ -0,0 +1,27 @@
+# -*- coding: utf-8 -*-
+#
+# Copyright (C) Pootle contributors.
+#
+# This file is a part of the Pootle project. It is distributed under the GPL3
+# or later license. See the LICENSE file for a copy of the license and the
+# AUTHORS file for copyright and authorship information.
+
+import os
+
+import pytest
+
+from pootle_project.models import Project
+
+
+@pytest.mark.django_db
+def test_project_create_defaults(settings, english):
+    foo0 = Project.objects.create(
+        code="foo0",
+        fullname="Project Foo 0",
+        source_language=english)
+    assert foo0.config["pootle_fs.fs_type"] == "localfs"
+    assert (
+        foo0.config["pootle_fs.fs_url"]
+        == os.path.join(
+            settings.POOTLE_TRANSLATION_DIRECTORY,
+            foo0.code))
Repository: translate/pootle

Issue:
BUG UI about silencing checks
Despite I silenced the critical errors, if I reload the page, I keep seeing the red alert on the unit.
![](https://i.imgur.com/t0Lysid.jpg)


Discussion:
What are the exact steps you followed? I mean something like:

- Go to unit with critical checks
- Mute all checks
- Background is still red despite all checks silenced
- I go to the unit with critical checks
-  I mute the check
- The red alert disappears
- I try to reload the page of that unit
- The red alert appears again
Which Pootle version are you using?
Pootle 2.9.0b2
@JohnnyKing94 seems like the issue is just with the red background. I can repro, and the check stays muted, doesnt block etc, but as you said the background appears again red. I'll see if i can fix...

Resolving patch:
diff --git a/pootle/apps/pootle_store/views.py b/pootle/apps/pootle_store/views.py
--- a/pootle/apps/pootle_store/views.py
+++ b/pootle/apps/pootle_store/views.py
@@ -486,6 +486,11 @@ def get_context_data(self, *args, **kwargs):
         accepted_suggestion = None
         if latest_target_submission is not None:
             accepted_suggestion = latest_target_submission.suggestion
+        critical_checks = list(self.object.get_critical_qualitychecks())
+        failing_checks = any(
+            not check.false_positive
+            for check
+            in critical_checks)
         return {
             'unit': self.object,
             'accepted_suggestion': accepted_suggestion,
@@ -522,8 +527,8 @@ def get_context_data(self, *args, **kwargs):
             'suggestions': suggestions,
             'suggestions_dict': {x.id: dict(id=x.id, target=x.target.strings)
                                  for x in suggestions},
-            "critical_checks": list(
-                self.object.get_critical_qualitychecks()),
+            "failing_checks": failing_checks,
+            "critical_checks": critical_checks,
             "warning_checks": list(
                 self.object.get_warning_qualitychecks()),
             "terms": self.object.get_terminology()}


Test patch:
diff --git a/tests/views/get_edit_unit.py b/tests/views/get_edit_unit.py
--- a/tests/views/get_edit_unit.py
+++ b/tests/views/get_edit_unit.py
@@ -93,3 +93,8 @@ def test_get_edit_unit(project0_nongnu, get_edit_unit, client,
     assert (
         response.context["terms"]
         == unit.get_terminology())
+    failing_checks = any(
+        not check.false_positive
+        for check
+        in list(unit.get_warning_qualitychecks()))
+    assert response.context["failing_checks"] == failing_checks
Repository: translate/pootle

Issue:
Use XHR for user select2 widgets
on a site with a lot of users the admin widgets are very slow and unnecessarily push a full list of users



Discussion:

Resolving patch:
diff --git a/pootle/apps/pootle_app/views/admin/permissions.py b/pootle/apps/pootle_app/views/admin/permissions.py
--- a/pootle/apps/pootle_app/views/admin/permissions.py
+++ b/pootle/apps/pootle_app/views/admin/permissions.py
@@ -8,11 +8,13 @@
 
 from django import forms
 from django.contrib.auth import get_user_model
+from django.urls import reverse
 
 from pootle.core.decorators import get_object_or_404
 from pootle.core.exceptions import Http400
 from pootle.core.views.admin import PootleAdminFormView
 from pootle.core.views.mixins import PootleJSONMixin
+from pootle.core.views.widgets import RemoteSelectWidget
 from pootle.i18n.gettext import ugettext as _
 from pootle_app.forms import PermissionsUsersSearchForm
 from pootle_app.models import Directory
@@ -89,10 +91,11 @@ class Meta(object):
             choice_groups=choice_groups,
             queryset=User.objects.all(),
             required=True,
-            widget=forms.Select(attrs={
-                'class': 'js-select2 select2-username',
-            }),
-        )
+            widget=RemoteSelectWidget(
+                attrs={
+                    "data-s2-placeholder": _("Search for users to add"),
+                    'class': ('js-select2-remote select2-username '
+                              'js-s2-new-members')}))
         positive_permissions = PermissionFormField(
             label=_('Add Permissions'),
             queryset=positive_permissions_qs,
@@ -115,6 +118,10 @@ class Meta(object):
         def __init__(self, *args, **kwargs):
             super(PermissionSetForm, self).__init__(*args, **kwargs)
 
+            self.fields["user"].widget.attrs["data-select2-url"] = reverse(
+                "pootle-permissions-users",
+                kwargs=dict(directory=current_directory.pk))
+
             # Don't display extra negative permissions field where they
             # are not applicable
             if language is not None:


Test patch: