blob: 5a47ed41a3b6177f524ec126dc779f1641b1cfb5 [file] [log] [blame]
# Copyright 2016 The Chromium Authors. All rights reserved.
# Use of this source code is govered by a BSD-style
# license that can be found in the LICENSE file or at
"""Classes that implement an admin utility to re-index issues in bulk."""
import logging
import urllib
import settings
from framework import permissions
from framework import servlet
from framework import urls
from services import tracker_fulltext
class IssueReindex(servlet.Servlet):
"""IssueReindex shows a form to request that issues be indexed."""
_PAGE_TEMPLATE = 'tracker/issue-reindex-page.ezt'
def AssertBasePermission(self, mr):
"""Check whether the user has any permission to visit this page.
mr: commonly used info parsed from the request.
super(IssueReindex, self).AssertBasePermission(mr)
if not self.CheckPerm(mr, permissions.EDIT_PROJECT):
raise permissions.PermissionException(
'You are not allowed to administer this project')
def GatherPageData(self, mr):
"""Build up a dictionary of data values to use when rendering the page.
mr: commonly used info parsed from the request.
Dict of values used by EZT for rendering the page.
return {
# start and num are already passed to the template.
'issue_tab_mode': None,
'auto_submit': mr.auto_submit,
'page_perms': self.MakePagePerms(mr, None, permissions.CREATE_ISSUE),
def ProcessFormData(self, mr, post_data):
"""Process a posted issue reindex form.
mr: commonly used info parsed from the request.
post_data: HTML form data from the request.
String URL to redirect the user to after processing. The URL will contain
a new start that is auto-incremented using the specified num value.
start = max(0, int(post_data['start']))
num = max(0, min(settings.max_artifact_search_results_per_page,
issues =
mr.cnxn, mr.project_id, range(start, start + num))'got %d issues to index', len(issues))
if issues:
mr.cnxn, issues,,,
# Make the browser keep submitting the form, if the user wants that,
# and we have not run out of issues to process.
auto_submit = issues and ('auto_submit' in post_data)
query_map = {
'start': start + num, # auto-increment start.
'num': num,
'auto_submit': bool(auto_submit),
return '/p/%s%s?%s' % (mr.project_name, urls.ISSUE_REINDEX,