prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  Priority column is missing
  Since the column reordering we've lost the priority column in the vfolders table
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `pootle/apps/virtualfolder/views.py`
  Content:
  ```
  1 # -*- coding: utf-8 -*-
  2 #
  3 # Copyright (C) Pootle contributors.
  4 #
  5 # This file is a part of the Pootle project. It is distributed under the GPL3
  6 # or later license. See the LICENSE file for a copy of the license and the
  7 # AUTHORS file for copyright and authorship information.
  8 
  9 from django import forms
  10 from django.http import Http404
  11 from django.shortcuts import get_object_or_404
  12 from django.urls import reverse
  13 from django.utils.functional import cached_property
  14 
  15 from pootle.core.browser import get_table_headings
  16 from pootle.core.delegate import search_backend
  17 from pootle.core.exceptions import Http400
  18 from pootle.core.http import JsonResponse
  19 from pootle.core.url_helpers import get_path_parts, split_pootle_path
  20 from pootle.i18n.gettext import ugettext as _
  21 from pootle_misc.util import ajax_required
  22 from pootle_store.forms import UnitSearchForm
  23 from pootle_store.unit.results import GroupedResults
  24 from pootle_translationproject.views import TPTranslateView
  25 
  26 from .delegate import vfolders_data_tool
  27 from .models import VirtualFolder
  28 
  29 
  30 def make_vfolder_dict(context, vf, stats):
  31     lang_code, proj_code = split_pootle_path(context.pootle_path)[:2]
  32     base_url = reverse(
  33         "pootle-vfolder-tp-translate",
  34         kwargs=dict(
  35             vfolder_name=vf,
  36             language_code=lang_code,
  37             project_code=proj_code))
  38     return {
  39         'href_translate': base_url,
  40         'title': stats["title"],
  41         'code': vf,
  42         'priority': stats.get("priority"),
  43         'is_grayed': not stats["isVisible"],
  44         'stats': stats,
  45         'icon': 'vfolder'}
  46 
  47 
  48 class VFolderTPTranslateView(TPTranslateView):
  49     display_vfolder_priority = False
  50 
  51     @cached_property
  52     def check_data(self):
  53         return self.vfolders_data_view.vfolder_data_tool.get_checks(
  54             user=self.request.user).get(self.vfolder_pk, {})
  55 
  56     @cached_property
  57     def vfolder(self):
  58         return VirtualFolder.objects.get(name=self.kwargs["vfolder_name"])
  59 
  60     @property
  61     def vfolder_pk(self):
  62         return self.vfolder.pk
  63 
  64     def get_context_data(self, *args, **kwargs):
  65         ctx = super(
  66             VFolderTPTranslateView,
  67             self).get_context_data(*args, **kwargs)
  68         ctx["unit_api_root"] = reverse(
  69             "vfolder-pootle-xhr-units",
  70             kwargs=dict(vfolder_name=self.vfolder.name))
  71         ctx["resource_path"] = (
  72             "/".join(
  73                 ["++vfolder",
  74                  self.vfolder.name,
  75                  self.object.pootle_path.replace(self.ctx_path, "")]))
  76         ctx["resource_path_parts"] = get_path_parts(ctx["resource_path"])
  77         return ctx
  78 
  79 
  80 @ajax_required
  81 def get_vfolder_units(request, **kwargs):
  82     """Gets source and target texts and its metadata.
  83 
  84     :return: A JSON-encoded string containing the source and target texts
  85         grouped by the store they belong to.
  86 
  87         The optional `count` GET parameter defines the chunk size to
  88         consider. The user's preference will be used by default.
  89 
  90         When the `initial` GET parameter is present, a sorted list of
  91         the result set ids will be returned too.
  92     """
  93     search_form = UnitSearchForm(request.GET, user=request.user)
  94 
  95     vfolder = get_object_or_404(
  96         VirtualFolder,
  97         name=kwargs.get("vfolder_name"))
  98 
  99     if not search_form.is_valid():
  100         errors = search_form.errors.as_data()
  101         if "path" in errors:
  102             for error in errors["path"]:
  103                 if error.code == "max_length":
  104                     raise Http400(_('Path too long.'))
  105                 elif error.code == "required":
  106                     raise Http400(_('Arguments missing.'))
  107         raise Http404(forms.ValidationError(search_form.errors).messages)
  108 
  109     search_form.cleaned_data["vfolder"] = vfolder
  110     backend = search_backend.get(VirtualFolder)(
  111         request.user, **search_form.cleaned_data)
  112     total, start, end, units_qs = backend.search()
  113     return JsonResponse(
  114         {'start': start,
  115          'end': end,
  116          'total': total,
  117          'unitGroups': GroupedResults(units_qs).data})
  118 
  119 
  120 class VFoldersDataView(object):
  121 
  122     _table_fields = (
  123         'name', 'progress', 'activity',
  124         'total', 'need-translation',
  125         'suggestions', 'critical')
  126 
  127     def __init__(self, context, user, has_admin_access=False):
  128         self.context = context
  129         self.user = user
  130         self.has_admin_access = has_admin_access
  131 
  132     @property
  133     def vfolder_data_tool(self):
  134         return vfolders_data_tool.get(self.context.__class__)(self.context)
  135 
  136     @property
  137     def table_fields(self):
  138         fields = self._table_fields
  139         if self.has_admin_access:
  140             fields += ('last-updated', )
  141         return fields
  142 
  143     @cached_property
  144     def table_data(self):
  145         ctx = {}
  146         if len(self.all_stats) > 0:
  147             ctx.update({
  148                 'children': {
  149                     'id': 'vfolders',
  150                     'fields': self.table_fields,
  151                     'headings': get_table_headings(self.table_fields),
  152                     'rows': self.table_items}})
  153         return ctx
  154 
  155     @cached_property
  156     def all_stats(self):
  157         return self.vfolder_data_tool.get_stats(user=self.user)
  158 
  159     @cached_property
  160     def stats(self):
  161         return dict(children=self.all_stats)
  162 
  163     @property
  164     def table_items(self):
  165         return [
  166             make_vfolder_dict(self.context, *vf)
  167             for vf
  168             in self.all_stats.items()]
  169 
  170     @cached_property
  171     def has_data(self):
  172         return (
  173             self.vfolder_data_tool.all_stat_data.exists()
  174             if self.vfolder_data_tool.show_all_to(self.user)
  175             else self.vfolder_data_tool.stat_data.exists())
  176
  ```
  --- END FILES ---
  
  Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.
  
  Here is an example:
  
  ```diff
  diff --git a/examples/server_async.py b/examples/server_async.py
  --- a/examples/server_async.py
  +++ b/examples/server_async.py
  @@ -313,4 +313,4 @@
   
   
   if __name__ == "__main__":
  -    asyncio.run(run_async_server("."), debug=True)
  +    asyncio.run(run_async_server(), debug=True)
  diff --git a/examples/server_sync.py b/examples/server_sync.py
  --- a/examples/server_sync.py
  +++ b/examples/server_sync.py
  @@ -313,5 +313,5 @@
   
   
   if __name__ == "__main__":
  -    server = run_sync_server(".")
  +    server = run_sync_server()
       server.shutdown()
  
  ```
  
golden_diff: diff --git a/pootle/apps/virtualfolder/views.py b/pootle/apps/virtualfolder/views.py
  --- a/pootle/apps/virtualfolder/views.py
  +++ b/pootle/apps/virtualfolder/views.py
  @@ -122,7 +122,7 @@
       _table_fields = (
           'name', 'progress', 'activity',
           'total', 'need-translation',
  -        'suggestions', 'critical')
  +        'suggestions', 'critical', 'priority')
   
       def __init__(self, context, user, has_admin_access=False):
           self.context = context
  
verification_info: {"golden_diff": "diff --git a/pootle/apps/virtualfolder/views.py b/pootle/apps/virtualfolder/views.py\n--- a/pootle/apps/virtualfolder/views.py\n+++ b/pootle/apps/virtualfolder/views.py\n@@ -122,7 +122,7 @@\n     _table_fields = (\n         'name', 'progress', 'activity',\n         'total', 'need-translation',\n-        'suggestions', 'critical')\n+        'suggestions', 'critical', 'priority')\n \n     def __init__(self, context, user, has_admin_access=False):\n         self.context = context\n", "issue": "Priority column is missing\nSince the column reordering we've lost the priority column in the vfolders table\n", "before_files": [{"content": "# -*- coding: utf-8 -*-\n#\n# Copyright (C) Pootle contributors.\n#\n# This file is a part of the Pootle project. It is distributed under the GPL3\n# or later license. See the LICENSE file for a copy of the license and the\n# AUTHORS file for copyright and authorship information.\n\nfrom django import forms\nfrom django.http import Http404\nfrom django.shortcuts import get_object_or_404\nfrom django.urls import reverse\nfrom django.utils.functional import cached_property\n\nfrom pootle.core.browser import get_table_headings\nfrom pootle.core.delegate import search_backend\nfrom pootle.core.exceptions import Http400\nfrom pootle.core.http import JsonResponse\nfrom pootle.core.url_helpers import get_path_parts, split_pootle_path\nfrom pootle.i18n.gettext import ugettext as _\nfrom pootle_misc.util import ajax_required\nfrom pootle_store.forms import UnitSearchForm\nfrom pootle_store.unit.results import GroupedResults\nfrom pootle_translationproject.views import TPTranslateView\n\nfrom .delegate import vfolders_data_tool\nfrom .models import VirtualFolder\n\n\ndef make_vfolder_dict(context, vf, stats):\n    lang_code, proj_code = split_pootle_path(context.pootle_path)[:2]\n    base_url = reverse(\n        \"pootle-vfolder-tp-translate\",\n        kwargs=dict(\n            vfolder_name=vf,\n            language_code=lang_code,\n            project_code=proj_code))\n    return {\n        'href_translate': base_url,\n        'title': stats[\"title\"],\n        'code': vf,\n        'priority': stats.get(\"priority\"),\n        'is_grayed': not stats[\"isVisible\"],\n        'stats': stats,\n        'icon': 'vfolder'}\n\n\nclass VFolderTPTranslateView(TPTranslateView):\n    display_vfolder_priority = False\n\n    @cached_property\n    def check_data(self):\n        return self.vfolders_data_view.vfolder_data_tool.get_checks(\n            user=self.request.user).get(self.vfolder_pk, {})\n\n    @cached_property\n    def vfolder(self):\n        return VirtualFolder.objects.get(name=self.kwargs[\"vfolder_name\"])\n\n    @property\n    def vfolder_pk(self):\n        return self.vfolder.pk\n\n    def get_context_data(self, *args, **kwargs):\n        ctx = super(\n            VFolderTPTranslateView,\n            self).get_context_data(*args, **kwargs)\n        ctx[\"unit_api_root\"] = reverse(\n            \"vfolder-pootle-xhr-units\",\n            kwargs=dict(vfolder_name=self.vfolder.name))\n        ctx[\"resource_path\"] = (\n            \"/\".join(\n                [\"++vfolder\",\n                 self.vfolder.name,\n                 self.object.pootle_path.replace(self.ctx_path, \"\")]))\n        ctx[\"resource_path_parts\"] = get_path_parts(ctx[\"resource_path\"])\n        return ctx\n\n\n@ajax_required\ndef get_vfolder_units(request, **kwargs):\n    \"\"\"Gets source and target texts and its metadata.\n\n    :return: A JSON-encoded string containing the source and target texts\n        grouped by the store they belong to.\n\n        The optional `count` GET parameter defines the chunk size to\n        consider. The user's preference will be used by default.\n\n        When the `initial` GET parameter is present, a sorted list of\n        the result set ids will be returned too.\n    \"\"\"\n    search_form = UnitSearchForm(request.GET, user=request.user)\n\n    vfolder = get_object_or_404(\n        VirtualFolder,\n        name=kwargs.get(\"vfolder_name\"))\n\n    if not search_form.is_valid():\n        errors = search_form.errors.as_data()\n        if \"path\" in errors:\n            for error in errors[\"path\"]:\n                if error.code == \"max_length\":\n                    raise Http400(_('Path too long.'))\n                elif error.code == \"required\":\n                    raise Http400(_('Arguments missing.'))\n        raise Http404(forms.ValidationError(search_form.errors).messages)\n\n    search_form.cleaned_data[\"vfolder\"] = vfolder\n    backend = search_backend.get(VirtualFolder)(\n        request.user, **search_form.cleaned_data)\n    total, start, end, units_qs = backend.search()\n    return JsonResponse(\n        {'start': start,\n         'end': end,\n         'total': total,\n         'unitGroups': GroupedResults(units_qs).data})\n\n\nclass VFoldersDataView(object):\n\n    _table_fields = (\n        'name', 'progress', 'activity',\n        'total', 'need-translation',\n        'suggestions', 'critical')\n\n    def __init__(self, context, user, has_admin_access=False):\n        self.context = context\n        self.user = user\n        self.has_admin_access = has_admin_access\n\n    @property\n    def vfolder_data_tool(self):\n        return vfolders_data_tool.get(self.context.__class__)(self.context)\n\n    @property\n    def table_fields(self):\n        fields = self._table_fields\n        if self.has_admin_access:\n            fields += ('last-updated', )\n        return fields\n\n    @cached_property\n    def table_data(self):\n        ctx = {}\n        if len(self.all_stats) > 0:\n            ctx.update({\n                'children': {\n                    'id': 'vfolders',\n                    'fields': self.table_fields,\n                    'headings': get_table_headings(self.table_fields),\n                    'rows': self.table_items}})\n        return ctx\n\n    @cached_property\n    def all_stats(self):\n        return self.vfolder_data_tool.get_stats(user=self.user)\n\n    @cached_property\n    def stats(self):\n        return dict(children=self.all_stats)\n\n    @property\n    def table_items(self):\n        return [\n            make_vfolder_dict(self.context, *vf)\n            for vf\n            in self.all_stats.items()]\n\n    @cached_property\n    def has_data(self):\n        return (\n            self.vfolder_data_tool.all_stat_data.exists()\n            if self.vfolder_data_tool.show_all_to(self.user)\n            else self.vfolder_data_tool.stat_data.exists())\n", "path": "pootle/apps/virtualfolder/views.py"}], "after_files": [{"content": "# -*- coding: utf-8 -*-\n#\n# Copyright (C) Pootle contributors.\n#\n# This file is a part of the Pootle project. It is distributed under the GPL3\n# or later license. See the LICENSE file for a copy of the license and the\n# AUTHORS file for copyright and authorship information.\n\nfrom django import forms\nfrom django.http import Http404\nfrom django.shortcuts import get_object_or_404\nfrom django.urls import reverse\nfrom django.utils.functional import cached_property\n\nfrom pootle.core.browser import get_table_headings\nfrom pootle.core.delegate import search_backend\nfrom pootle.core.exceptions import Http400\nfrom pootle.core.http import JsonResponse\nfrom pootle.core.url_helpers import get_path_parts, split_pootle_path\nfrom pootle.i18n.gettext import ugettext as _\nfrom pootle_misc.util import ajax_required\nfrom pootle_store.forms import UnitSearchForm\nfrom pootle_store.unit.results import GroupedResults\nfrom pootle_translationproject.views import TPTranslateView\n\nfrom .delegate import vfolders_data_tool\nfrom .models import VirtualFolder\n\n\ndef make_vfolder_dict(context, vf, stats):\n    lang_code, proj_code = split_pootle_path(context.pootle_path)[:2]\n    base_url = reverse(\n        \"pootle-vfolder-tp-translate\",\n        kwargs=dict(\n            vfolder_name=vf,\n            language_code=lang_code,\n            project_code=proj_code))\n    return {\n        'href_translate': base_url,\n        'title': stats[\"title\"],\n        'code': vf,\n        'priority': stats.get(\"priority\"),\n        'is_grayed': not stats[\"isVisible\"],\n        'stats': stats,\n        'icon': 'vfolder'}\n\n\nclass VFolderTPTranslateView(TPTranslateView):\n    display_vfolder_priority = False\n\n    @cached_property\n    def check_data(self):\n        return self.vfolders_data_view.vfolder_data_tool.get_checks(\n            user=self.request.user).get(self.vfolder_pk, {})\n\n    @cached_property\n    def vfolder(self):\n        return VirtualFolder.objects.get(name=self.kwargs[\"vfolder_name\"])\n\n    @property\n    def vfolder_pk(self):\n        return self.vfolder.pk\n\n    def get_context_data(self, *args, **kwargs):\n        ctx = super(\n            VFolderTPTranslateView,\n            self).get_context_data(*args, **kwargs)\n        ctx[\"unit_api_root\"] = reverse(\n            \"vfolder-pootle-xhr-units\",\n            kwargs=dict(vfolder_name=self.vfolder.name))\n        ctx[\"resource_path\"] = (\n            \"/\".join(\n                [\"++vfolder\",\n                 self.vfolder.name,\n                 self.object.pootle_path.replace(self.ctx_path, \"\")]))\n        ctx[\"resource_path_parts\"] = get_path_parts(ctx[\"resource_path\"])\n        return ctx\n\n\n@ajax_required\ndef get_vfolder_units(request, **kwargs):\n    \"\"\"Gets source and target texts and its metadata.\n\n    :return: A JSON-encoded string containing the source and target texts\n        grouped by the store they belong to.\n\n        The optional `count` GET parameter defines the chunk size to\n        consider. The user's preference will be used by default.\n\n        When the `initial` GET parameter is present, a sorted list of\n        the result set ids will be returned too.\n    \"\"\"\n    search_form = UnitSearchForm(request.GET, user=request.user)\n\n    vfolder = get_object_or_404(\n        VirtualFolder,\n        name=kwargs.get(\"vfolder_name\"))\n\n    if not search_form.is_valid():\n        errors = search_form.errors.as_data()\n        if \"path\" in errors:\n            for error in errors[\"path\"]:\n                if error.code == \"max_length\":\n                    raise Http400(_('Path too long.'))\n                elif error.code == \"required\":\n                    raise Http400(_('Arguments missing.'))\n        raise Http404(forms.ValidationError(search_form.errors).messages)\n\n    search_form.cleaned_data[\"vfolder\"] = vfolder\n    backend = search_backend.get(VirtualFolder)(\n        request.user, **search_form.cleaned_data)\n    total, start, end, units_qs = backend.search()\n    return JsonResponse(\n        {'start': start,\n         'end': end,\n         'total': total,\n         'unitGroups': GroupedResults(units_qs).data})\n\n\nclass VFoldersDataView(object):\n\n    _table_fields = (\n        'name', 'progress', 'activity',\n        'total', 'need-translation',\n        'suggestions', 'critical', 'priority')\n\n    def __init__(self, context, user, has_admin_access=False):\n        self.context = context\n        self.user = user\n        self.has_admin_access = has_admin_access\n\n    @property\n    def vfolder_data_tool(self):\n        return vfolders_data_tool.get(self.context.__class__)(self.context)\n\n    @property\n    def table_fields(self):\n        fields = self._table_fields\n        if self.has_admin_access:\n            fields += ('last-updated', )\n        return fields\n\n    @cached_property\n    def table_data(self):\n        ctx = {}\n        if len(self.all_stats) > 0:\n            ctx.update({\n                'children': {\n                    'id': 'vfolders',\n                    'fields': self.table_fields,\n                    'headings': get_table_headings(self.table_fields),\n                    'rows': self.table_items}})\n        return ctx\n\n    @cached_property\n    def all_stats(self):\n        return self.vfolder_data_tool.get_stats(user=self.user)\n\n    @cached_property\n    def stats(self):\n        return dict(children=self.all_stats)\n\n    @property\n    def table_items(self):\n        return [\n            make_vfolder_dict(self.context, *vf)\n            for vf\n            in self.all_stats.items()]\n\n    @cached_property\n    def has_data(self):\n        return (\n            self.vfolder_data_tool.all_stat_data.exists()\n            if self.vfolder_data_tool.show_all_to(self.user)\n            else self.vfolder_data_tool.stat_data.exists())\n", "path": "pootle/apps/virtualfolder/views.py"}]}