This is an automated email from the ASF dual-hosted git repository. asf-gitbox-commits pushed a commit to branch cc/11102-part2b in repository https://gitbox.apache.org/repos/asf/allura.git
commit e075d270e66ed9008ef7d15bb344cb7f09f858c3 Author: Carlos Cruz <[email protected]> AuthorDate: Fri Apr 24 12:37:36 2026 -0600 Remove dead ProjectUserSelect code --- Allura/allura/controllers/project.py | 22 ------------ Allura/allura/lib/widgets/form_fields.py | 39 ---------------------- .../templates/widgets/project_user_select.html | 21 ------------ Allura/allura/tests/functional/test_home.py | 19 ----------- .../forgetracker/tests/functional/test_root.py | 2 +- 5 files changed, 1 insertion(+), 102 deletions(-) diff --git a/Allura/allura/controllers/project.py b/Allura/allura/controllers/project.py index cf521e59c..23d0d1e74 100644 --- a/Allura/allura/controllers/project.py +++ b/Allura/allura/controllers/project.py @@ -42,7 +42,6 @@ from allura.controllers.feed import FeedArgs, FeedController from allura.controllers.rest import nbhd_lookup_first_path from allura.lib.security import require_access -from allura.lib.security import RoleCache from allura.lib.widgets import forms as ff from allura.lib.widgets import form_fields as ffw from allura.lib.widgets import project_list as plw @@ -448,27 +447,6 @@ def user_icon(self, **kw): default_image_url = g.forge_static('images/user.png') redirect(default_image_url) - @expose('json:') - def user_search(self, term='', **kw): - if len(term) < 3: - raise exc.HTTPBadRequest('"term" param must be at least length 3') - named_roles = RoleCache( - g.credentials, - g.credentials.project_roles(project_id=c.project.root_project._id).named) - users = M.User.query.find({ - '_id': {'$in': named_roles.userids_that_reach}, - 'display_name': re.compile(r'(?i)%s' % re.escape(term)), - 'disabled': False, - 'pending': False, - }).sort('username').limit(10).all() - return dict( - users=[ - dict( - label='{} ({})'.format(u.get_pref('display_name'), u.username), - value=u.username, - id=u.username) - for u in users]) - @expose('json:') def users(self, **kw): users = c.project.users() diff --git a/Allura/allura/lib/widgets/form_fields.py b/Allura/allura/lib/widgets/form_fields.py index 95d04311e..c4fa3cd29 100644 --- a/Allura/allura/lib/widgets/form_fields.py +++ b/Allura/allura/lib/widgets/form_fields.py @@ -102,45 +102,6 @@ def resources(self): ''' % dict(url=c.app.url)) -class ProjectUserSelect(ew.InputField): - template = 'jinja:allura:templates/widgets/project_user_select.html' - defaults = dict( - ew.InputField.defaults, - name=None, - value=None, - show_label=True, - className=None) - - def __init__(self, **kw): - super().__init__(**kw) - if not isinstance(self.value, list): - self.value = [self.value] - - def from_python(self, value, state=None): - return value - - def resources(self): - yield from super().resources() - yield ew.JSLink('allura/js/jquery-ui.min.js', location='body_top_js') - yield ew.CSSLink('css/autocomplete.css') # customized in [6b78ed] so we can't just use jquery-ui.min.css - yield onready(''' - $('input.project_user_select').autocomplete({ - source: function (request, response) { - $.ajax({ - url: "%suser_search", - dataType: "json", - data: { - term: request.term - }, - success: function (data) { - response(data.users); - } - }); - }, - minLength: 2 - });''' % c.project.url()) - - class ProjectUserCombo(ew.SingleSelectField): template = 'jinja:allura:templates/widgets/project_user_combo.html' diff --git a/Allura/allura/templates/widgets/project_user_select.html b/Allura/allura/templates/widgets/project_user_select.html deleted file mode 100644 index 23c434703..000000000 --- a/Allura/allura/templates/widgets/project_user_select.html +++ /dev/null @@ -1,21 +0,0 @@ -{#- - Licensed to the Apache Software Foundation (ASF) under one - or more contributor license agreements. See the NOTICE file - distributed with this work for additional information - regarding copyright ownership. The ASF licenses this file - to you under the Apache License, Version 2.0 (the - "License"); you may not use this file except in compliance - with the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, - software distributed under the License is distributed on an - "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - KIND, either express or implied. See the License for the - specific language governing permissions and limitations - under the License. --#} -<div> - <input type="text" id="{{id}}" name="{{name}}" class="ui-autocomplete-input project_user_select{{className and ' %s' % className or ''}}" value="{{value and value.username or value or ''}}"/> -</div> diff --git a/Allura/allura/tests/functional/test_home.py b/Allura/allura/tests/functional/test_home.py index 8f4047320..34a4531db 100644 --- a/Allura/allura/tests/functional/test_home.py +++ b/Allura/allura/tests/functional/test_home.py @@ -163,25 +163,6 @@ def test_user_icon(self): r = self.app.get('/u/test-admin/user_icon') assert r.content_type == 'image/png' - def test_user_search(self): - r = self.app.get('/p/test/user_search?term=test', status=200) - j = json.loads(r.text) - assert j['users'][0]['id'].startswith('test') - - def test_user_search_for_disabled_user(self): - user = M.User.by_username('test-admin') - user.disabled = True - ThreadLocalODMSession.flush_all() - r = self.app.get('/p/test/user_search?term=test', status=200) - j = json.loads(r.text) - assert j == {'users': []} - - def test_user_search_noparam(self): - self.app.get('/p/test/user_search', status=400) - - def test_user_search_shortparam(self): - self.app.get('/p/test/user_search?term=ad', status=400) - def test_users(self): r = self.app.get('/p/test/users', status=200) j = json.loads(r.text) diff --git a/ForgeTracker/forgetracker/tests/functional/test_root.py b/ForgeTracker/forgetracker/tests/functional/test_root.py index 528a81a77..b2a57b524 100644 --- a/ForgeTracker/forgetracker/tests/functional/test_root.py +++ b/ForgeTracker/forgetracker/tests/functional/test_root.py @@ -270,7 +270,7 @@ def test_deleted_ticket_visibility(self): class TestFunctionalController(TrackerTestController): def test_bad_ticket_number(self): - self.app.get('/bugs/input.project_user_select', status=404) + self.app.get('/bugs/not-a-ticket', status=404) def test_invalid_ticket(self): self.app.get('/bugs/2/', status=404)
