You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@allura.apache.org by br...@apache.org on 2014/09/19 22:04:15 UTC
[01/26] git commit: [#7589] ticket:622 Make User indexable
Repository: allura
Updated Branches:
refs/heads/master 3edcba7f0 -> a9883cd23
[#7589] ticket:622 Make User indexable
Project: http://git-wip-us.apache.org/repos/asf/allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/allura/commit/55be3103
Tree: http://git-wip-us.apache.org/repos/asf/allura/tree/55be3103
Diff: http://git-wip-us.apache.org/repos/asf/allura/diff/55be3103
Branch: refs/heads/master
Commit: 55be3103b7a57a57d8379db18eda2d0cc7547e7c
Parents: 3edcba7
Author: Igor Bondarenko <je...@gmail.com>
Authored: Mon Aug 4 14:16:46 2014 +0300
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Fri Sep 19 19:35:37 2014 +0000
----------------------------------------------------------------------
Allura/allura/lib/plugin.py | 8 ++++++++
Allura/allura/model/auth.py | 38 ++++++++++++++++++++++++++++++++++++--
2 files changed, 44 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/allura/blob/55be3103/Allura/allura/lib/plugin.py
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/plugin.py b/Allura/allura/lib/plugin.py
index 8537f63..ccdf62c 100644
--- a/Allura/allura/lib/plugin.py
+++ b/Allura/allura/lib/plugin.py
@@ -284,6 +284,10 @@ class AuthenticationProvider(object):
return True
return False
+ def index_user(self, user):
+ """Put here additional fields for user index in SOLR."""
+ return {}
+
class LocalAuthenticationProvider(AuthenticationProvider):
@@ -374,6 +378,10 @@ class LocalAuthenticationProvider(AuthenticationProvider):
d = datetime.utcfromtimestamp(calendar.timegm(d.utctimetuple()))
return d
+ def index_user(self, user):
+ fields = super(LocalAuthenticationProvider, self).index_user(user)
+ return dict(user_registration_date_dt=self.user_registration_date(user), **fields)
+
def ldap_conn(who=None, cred=None):
'''
http://git-wip-us.apache.org/repos/asf/allura/blob/55be3103/Allura/allura/model/auth.py
----------------------------------------------------------------------
diff --git a/Allura/allura/model/auth.py b/Allura/allura/model/auth.py
index 827c6fc..9ceb341 100644
--- a/Allura/allura/model/auth.py
+++ b/Allura/allura/model/auth.py
@@ -46,6 +46,7 @@ import allura.tasks.mail_tasks
from allura.lib import helpers as h
from allura.lib import plugin
from allura.lib.decorators import memoize
+from allura.lib.search import SearchIndexable
from .session import main_orm_session, main_doc_session
from .session import project_orm_session
@@ -210,7 +211,7 @@ class FieldPropertyDisplayName(FieldProperty):
return display_name
-class User(MappedClass, ActivityNode, ActivityObject):
+class User(MappedClass, ActivityNode, ActivityObject, SearchIndexable):
SALT_LEN = 8
class __mongometa__:
@@ -219,6 +220,8 @@ class User(MappedClass, ActivityNode, ActivityObject):
indexes = ['tool_data.sfx.userid', 'tool_data.AuthPasswordReset.hash']
unique_indexes = ['username']
+ type_s = 'User'
+
_id = FieldProperty(S.ObjectId)
sfx_userid = FieldProperty(S.Deprecated)
username = FieldProperty(str)
@@ -227,7 +230,7 @@ class User(MappedClass, ActivityNode, ActivityObject):
last_password_updated = FieldProperty(datetime)
projects = FieldProperty(S.Deprecated)
# full mount point: prefs dict
- tool_preferences = FieldProperty({str: {str: None}})
+ tool_preferences = FieldProperty(S.Deprecated)
tool_data = FieldProperty({str: {str: None}}) # entry point: prefs dict
disabled = FieldProperty(bool, if_missing=False)
@@ -280,6 +283,37 @@ class User(MappedClass, ActivityNode, ActivityObject):
session_ip=str,
session_ua=str))
+ def index(self):
+ provider = plugin.AuthenticationProvider.get(None) # no need in request here
+ localization = '%s/%s' % (
+ self.get_pref('localization')['country'],
+ self.get_pref('localization')['city'])
+ fields = dict(
+ id=self.index_id(),
+ title='User %s' % self.username,
+ type_s=self.type_s,
+ username_s=self.username,
+ email_addresses=self.email_addresses,
+ last_password_updated_dt=self.last_password_updated,
+ disabled_b=self.disabled,
+ results_per_page_i=self.get_pref('results_per_page'),
+ email_address_s=self.get_pref('email_address'),
+ email_format_s=self.get_pref('email_format'),
+ disable_user_messages_b=self.get_pref('disable_user_messages'),
+ display_name_s=self.get_pref('display_name'),
+ sex_s=self.get_pref('sex'),
+ birthday_dt=self.get_pref('birthday'),
+ localization_s=localization,
+ timezone_s=self.get_pref('timezone'),
+ socialnetworks=self.get_pref('socialnetworks'),
+ telnumbers=self.get_pref('telnumbers'),
+ skypeaccount_s=self.get_pref('skypeaccount'),
+ webpages=self.get_pref('webpages'),
+ skills=self.get_skills(),
+ last_access=self.last_access,
+ )
+ return dict(provider.index_user(self), **fields)
+
def track_login(self, req):
user_ip = req.headers.get('X_FORWARDED_FOR', req.remote_addr)
user_agent = req.headers.get('User-Agent')
[24/26] git commit: [#7656] ticket:654 Fix tests
Posted by br...@apache.org.
[#7656] ticket:654 Fix tests
Project: http://git-wip-us.apache.org/repos/asf/allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/allura/commit/1b7aea66
Tree: http://git-wip-us.apache.org/repos/asf/allura/tree/1b7aea66
Diff: http://git-wip-us.apache.org/repos/asf/allura/diff/1b7aea66
Branch: refs/heads/master
Commit: 1b7aea66bbf5fa86080d9fd4c6206be879238634
Parents: 74965ec
Author: Igor Bondarenko <je...@gmail.com>
Authored: Thu Sep 18 09:40:49 2014 +0300
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Fri Sep 19 19:35:42 2014 +0000
----------------------------------------------------------------------
Allura/allura/tests/functional/test_site_admin.py | 16 +++++++++-------
1 file changed, 9 insertions(+), 7 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/allura/blob/1b7aea66/Allura/allura/tests/functional/test_site_admin.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tests/functional/test_site_admin.py b/Allura/allura/tests/functional/test_site_admin.py
index c8b3bad..5b0a9b0 100644
--- a/Allura/allura/tests/functional/test_site_admin.py
+++ b/Allura/allura/tests/functional/test_site_admin.py
@@ -167,8 +167,9 @@ class TestSiteAdmin(TestController):
assert json.loads(r.body)['doc'] == 'test_task doc string'
@patch('allura.model.auth.request')
- def test_users(self, request):
- request.url = 'http://host.domain/path/'
+ @patch('allura.lib.helpers.request')
+ def test_users(self, req1, req2):
+ req1.url = req2.url = 'http://host.domain/path/'
c.user = M.User.by_username('test-user-1')
h.auditlog_user('test activity user 1')
h.auditlog_user('test activity user 2', user=M.User.by_username('test-user-2'))
@@ -255,13 +256,13 @@ class TestProjectsSearch(TestController):
@patch('allura.controllers.site_admin.search')
def test_additional_fields(self, search):
search.site_admin_search.return_value = self.TEST_HIT
- with h.push_config(config, **{'search.project.additional_fields': 'private, url'}):
+ with h.push_config(config, **{'search.project.additional_search_fields': 'private, url',
+ 'search.project.additional_display_fields': 'url'}):
r = self.app.get('/nf/admin/search_projects?q=fake&f=shortname')
options = [o['value'] for o in r.html.findAll('option')]
assert_equal(options, ['shortname', 'name', 'private', 'url', '__custom__'])
ths = [th.text for th in r.html.findAll('th')]
- assert_equal(ths, ['Short name', 'Full name', 'Registered', 'Deleted?',
- 'private', 'url', 'Details'])
+ assert_equal(ths, ['Short name', 'Full name', 'Registered', 'Deleted?', 'url', 'Details'])
class TestUsersSearch(TestController):
@@ -308,13 +309,14 @@ class TestUsersSearch(TestController):
@patch('allura.controllers.site_admin.search')
def test_additional_fields(self, search):
search.site_admin_search.return_value = self.TEST_HIT
- with h.push_config(config, **{'search.user.additional_fields': 'email_addresses, url'}):
+ with h.push_config(config, **{'search.user.additional_search_fields': 'email_addresses, url',
+ 'search.user.additional_display_fields': 'url'}):
r = self.app.get('/nf/admin/search_users?q=fake&f=username')
options = [o['value'] for o in r.html.findAll('option')]
assert_equal(options, ['username', 'display_name', 'email_addresses', 'url', '__custom__'])
ths = [th.text for th in r.html.findAll('th')]
assert_equal(ths, ['Username', 'Display name', 'Email', 'Registered',
- 'Disabled?', 'email_addresses', 'url', 'Details'])
+ 'Disabled?', 'url', 'Details'])
@task
[09/26] git commit: [#7656] ticket:648 Refactor projects search form
to something more generic
Posted by br...@apache.org.
[#7656] ticket:648 Refactor projects search form to something more generic
Project: http://git-wip-us.apache.org/repos/asf/allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/allura/commit/1371cc37
Tree: http://git-wip-us.apache.org/repos/asf/allura/tree/1371cc37
Diff: http://git-wip-us.apache.org/repos/asf/allura/diff/1371cc37
Branch: refs/heads/master
Commit: 1371cc37f49ba4412ee5eca27513516fd4dd9463
Parents: 638807a
Author: Igor Bondarenko <je...@gmail.com>
Authored: Tue Sep 9 13:00:11 2014 +0300
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Fri Sep 19 19:35:39 2014 +0000
----------------------------------------------------------------------
Allura/allura/controllers/site_admin.py | 6 ++++--
Allura/allura/lib/widgets/forms.py | 15 +++++++--------
.../allura/templates/site_admin_search_projects.html | 2 +-
3 files changed, 12 insertions(+), 11 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/allura/blob/1371cc37/Allura/allura/controllers/site_admin.py
----------------------------------------------------------------------
diff --git a/Allura/allura/controllers/site_admin.py b/Allura/allura/controllers/site_admin.py
index bf7076e..5913411 100644
--- a/Allura/allura/controllers/site_admin.py
+++ b/Allura/allura/controllers/site_admin.py
@@ -54,7 +54,7 @@ class W:
page_list = ffw.PageList()
page_size = ffw.PageSize()
audit = AuditLog()
- search_projects_form = forms.SearchProjectsForm()
+ admin_search_form = forms.AdminSearchForm
class SiteAdminController(object):
@@ -296,7 +296,9 @@ class SiteAdminController(object):
limit=validators.Int(if_invalid=None),
page=validators.Int(if_empty=0, if_invalid=0)))
def search_projects(self, q=None, f=None, page=0, limit=None, **kw):
- c.search_projects_form = W.search_projects_form
+ fields = [('shortname', 'shortname'), ('name', 'full name')]
+ fields.extend(aslist(tg.config.get('search.project.additional_fields'), ','))
+ c.search_form = W.admin_search_form(fields)
c.page_list = W.page_list
c.page_size = W.page_size
count = 0
http://git-wip-us.apache.org/repos/asf/allura/blob/1371cc37/Allura/allura/lib/widgets/forms.py
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/widgets/forms.py b/Allura/allura/lib/widgets/forms.py
index 794f926..0d25079 100644
--- a/Allura/allura/lib/widgets/forms.py
+++ b/Allura/allura/lib/widgets/forms.py
@@ -1081,21 +1081,20 @@ class AwardGrantForm(ForgeForm):
]
-class SearchProjectsForm(ForgeForm):
+class AdminSearchForm(ForgeForm):
defaults = dict(
ForgeForm.defaults,
action='',
method='get',
submit_text=None)
+ def __init__(self, fields, *args, **kw):
+ super(AdminSearchForm, self).__init__(*args, **kw)
+ self._fields = fields
+
@property
def fields(self):
- add_fields = aslist(tg.config.get('search.project.additional_fields'), ',')
- search_fields = [
- ew.Option(py_value='shortname', label='shortname'),
- ew.Option(py_value='name', label='full name'),
- ]
- search_fields.extend([ew.Option(py_value=f, label=f) for f in add_fields])
+ search_fields = [ew.Option(py_value=v, label=l) for v, l in self._fields]
search_fields.append(ew.Option(py_value='__custom__', label='custom query'))
return [
ew.RowField(fields=[
@@ -1114,7 +1113,7 @@ class SearchProjectsForm(ForgeForm):
])]
def context_for(self, field):
- ctx = super(SearchProjectsForm, self).context_for(field)
+ ctx = super(AdminSearchForm, self).context_for(field)
if field.name is None and not ctx.get('value'):
# RowField does not pass context down to the children :(
render_ctx = ew_core.widget_context.render_context
http://git-wip-us.apache.org/repos/asf/allura/blob/1371cc37/Allura/allura/templates/site_admin_search_projects.html
----------------------------------------------------------------------
diff --git a/Allura/allura/templates/site_admin_search_projects.html b/Allura/allura/templates/site_admin_search_projects.html
index 73f30eb..a6e6b02 100644
--- a/Allura/allura/templates/site_admin_search_projects.html
+++ b/Allura/allura/templates/site_admin_search_projects.html
@@ -23,7 +23,7 @@
{% block content %}
<div class="grid-19">
- {{ c.search_projects_form.display(q=q, f=f) }}
+ {{ c.search_form.display(q=q, f=f) }}
</div>
{% if projects %}
[08/26] git commit: [#7656] ticket:648 Refactor controller & template
to reuse as much as we can
Posted by br...@apache.org.
[#7656] ticket:648 Refactor controller & template to reuse as much as we can
Project: http://git-wip-us.apache.org/repos/asf/allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/allura/commit/9440e40f
Tree: http://git-wip-us.apache.org/repos/asf/allura/tree/9440e40f
Diff: http://git-wip-us.apache.org/repos/asf/allura/diff/9440e40f
Branch: refs/heads/master
Commit: 9440e40fbb0b817a86566e7ffb62dd3db254abf4
Parents: 04b0016
Author: Igor Bondarenko <je...@gmail.com>
Authored: Tue Sep 9 14:09:55 2014 +0300
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Fri Sep 19 19:35:39 2014 +0000
----------------------------------------------------------------------
Allura/allura/controllers/site_admin.py | 74 ++++++++++++--------
Allura/allura/templates/site_admin_search.html | 49 +++++++++++++
.../templates/site_admin_search_projects.html | 74 --------------------
.../site_admin_search_projects_results.html | 27 +++++++
.../templates/site_admin_search_users.html | 25 -------
.../site_admin_search_users_results.html | 7 ++
6 files changed, 126 insertions(+), 130 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/allura/blob/9440e40f/Allura/allura/controllers/site_admin.py
----------------------------------------------------------------------
diff --git a/Allura/allura/controllers/site_admin.py b/Allura/allura/controllers/site_admin.py
index 5913411..b19b84b 100644
--- a/Allura/allura/controllers/site_admin.py
+++ b/Allura/allura/controllers/site_admin.py
@@ -290,41 +290,35 @@ class SiteAdminController(object):
flash('Can not add comment "%s" for user %s' % (comment, user))
redirect(request.referer)
- @without_trailing_slash
- @expose('jinja:allura:templates/site_admin_search_projects.html')
- @validate(validators=dict(q=validators.UnicodeString(if_empty=None),
- limit=validators.Int(if_invalid=None),
- page=validators.Int(if_empty=0, if_invalid=0)))
- def search_projects(self, q=None, f=None, page=0, limit=None, **kw):
- fields = [('shortname', 'shortname'), ('name', 'full name')]
- fields.extend(aslist(tg.config.get('search.project.additional_fields'), ','))
- c.search_form = W.admin_search_form(fields)
+ def _search(self, model, fields, add_fields, q=None, f=None, page=0, limit=None, **kw):
+ all_fields = fields + [(fld, fld) for fld in add_fields]
+ c.search_form = W.admin_search_form(all_fields)
c.page_list = W.page_list
c.page_size = W.page_size
count = 0
- projects = []
+ objects = []
limit, page, start = g.handle_paging(limit, page, default=25)
if q:
- match = search.search_projects(q, f, rows=limit, start=start)
+ match = search.site_admin_search(model, q, f, rows=limit, start=start)
if match:
count = match.hits
- projects = match.docs
- pids = [bson.ObjectId(p['id'].split('#')[1]) for p in projects]
- mongo_projects = {}
- for p in M.Project.query.find({'_id': {'$in': pids}}):
- mongo_projects[str(p._id)] = p
-
- for i in range(len(projects)):
- p = projects[i]
- _id = p['id'].split('#')[1]
- p['project'] = mongo_projects.get(_id)
- # Some projects can be deleted, but still have index in solr, should skip those
- projects = [p for p in projects if p.get('project')]
-
- def convert_fields(p):
+ objects = match.docs
+ ids = [bson.ObjectId(obj['id'].split('#')[1]) for obj in objects]
+ mongo_objects = {}
+ for obj in model.query.find({'_id': {'$in': ids}}):
+ mongo_objects[str(obj._id)] = obj
+
+ for i in range(len(objects)):
+ obj = objects[i]
+ _id = obj['id'].split('#')[1]
+ obj['object'] = mongo_objects.get(_id)
+ # Some objects can be deleted, but still have index in solr, should skip those
+ objects = [obj for obj in objects if obj.get('object')]
+
+ def convert_fields(obj):
# throw the type away (e.g. '_s' from 'url_s')
result = {}
- for k,v in p.iteritems():
+ for k,v in obj.iteritems():
name = k.rsplit('_', 1)
if len(name) == 2:
name = name[0]
@@ -336,21 +330,39 @@ class SiteAdminController(object):
return {
'q': q,
'f': f,
- 'projects': map(convert_fields, projects),
+ 'objects': map(convert_fields, objects),
'count': count,
'page': page,
'limit': limit,
- 'additional_fields': aslist(config.get('search.project.additional_fields'), ','),
- 'provider': ProjectRegistrationProvider.get(),
+ 'fields': fields,
+ 'additional_fields': add_fields,
+ 'type_s': model.type_s,
}
@without_trailing_slash
- @expose('jinja:allura:templates/site_admin_search_users.html')
+ @expose('jinja:allura:templates/site_admin_search.html')
+ @validate(validators=dict(q=validators.UnicodeString(if_empty=None),
+ limit=validators.Int(if_invalid=None),
+ page=validators.Int(if_empty=0, if_invalid=0)))
+ def search_projects(self, q=None, f=None, page=0, limit=None, **kw):
+ fields = [('shortname', 'shortname'), ('name', 'full name')]
+ add_fields = aslist(tg.config.get('search.project.additional_fields'), ',')
+ r = self._search(M.Project, fields, add_fields, q, f, page, limit, **kw)
+ r['search_results_template'] = 'allura:templates/site_admin_search_projects_results.html'
+ r['provider'] = ProjectRegistrationProvider.get()
+ return r
+
+ @without_trailing_slash
+ @expose('jinja:allura:templates/site_admin_search.html')
@validate(validators=dict(q=validators.UnicodeString(if_empty=None),
limit=validators.Int(if_invalid=None),
page=validators.Int(if_empty=0, if_invalid=0)))
def search_users(self, q=None, f=None, page=0, limit=None, **kw):
- return {}
+ fields = []
+ add_fields = aslist(tg.config.get('search.user.additional_fields'), ',')
+ r = self._search(M.User, fields, add_fields, q, f, page, limit, **kw)
+ r['search_results_template'] = 'allura:templates/site_admin_search_users_results.html'
+ return r
class TaskManagerController(object):
http://git-wip-us.apache.org/repos/asf/allura/blob/9440e40f/Allura/allura/templates/site_admin_search.html
----------------------------------------------------------------------
diff --git a/Allura/allura/templates/site_admin_search.html b/Allura/allura/templates/site_admin_search.html
new file mode 100644
index 0000000..685f65b
--- /dev/null
+++ b/Allura/allura/templates/site_admin_search.html
@@ -0,0 +1,49 @@
+{#-
+ 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.
+-#}
+{% extends 'allura:templates/site_admin.html' %}
+
+{% block title %}Search {{ type_s }}s{% endblock %}
+{% block header %}Search {{ type_s }}s{% endblock %}
+
+{% block content %}
+ <div class="grid-19">
+ {{ c.search_form.display(q=q, f=f) }}
+ </div>
+
+ {% if objects %}
+ <table>
+ {% include search_results_template %}
+ </table>
+ {% endif %}
+
+ <div class="grid-19">
+ {{c.page_list.display(limit=limit, page=page, count=count)}}
+ {{c.page_size.display(limit=limit, page=page, count=count)}}
+ </div>
+{% endblock %}
+
+{% block extra_css %}
+<style>
+ table { clear: both; }
+ table th {
+ text-align: left;
+ padding: 5px 10px;
+ }
+</style>
+{% endblock %}
http://git-wip-us.apache.org/repos/asf/allura/blob/9440e40f/Allura/allura/templates/site_admin_search_projects.html
----------------------------------------------------------------------
diff --git a/Allura/allura/templates/site_admin_search_projects.html b/Allura/allura/templates/site_admin_search_projects.html
deleted file mode 100644
index a6e6b02..0000000
--- a/Allura/allura/templates/site_admin_search_projects.html
+++ /dev/null
@@ -1,74 +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.
--#}
-{% extends 'allura:templates/site_admin.html' %}
-
-{% block title %}Search Projects{% endblock %}
-{% block header %}Search Projects{% endblock %}
-
-{% block content %}
- <div class="grid-19">
- {{ c.search_form.display(q=q, f=f) }}
- </div>
-
- {% if projects %}
- <table>
- <tr>
- <th>Short name</th>
- <th>Full name</th>
- <th>Registered</th>
- <th>Deleted?</th>
- {% for field in additional_fields %}
- <th>{{ field }}</th>
- {% endfor %}
- <th>Details</th>
- </tr>
- {% for p in projects %}
- <tr>
- <td><a href="{{ p['url'] }}">{{ p['shortname'] }}</a></td>
- <td>{{ p['name'] }}</td>
- <td>{{ h.ago_string(p['registration']) }}</td>
- <td>{{ p['deleted'] }}</td>
- {% for field in additional_fields %}
- <td>{{ p[field] }}</td>
- {% endfor %}
- <td>
- {% for url, label in provider.details_links(p['project']) %}
- <a href="{{ url }}">{{ label }}</a><br>
- {% endfor %}
- </td>
- </tr>
- {% endfor %}
- </table>
- {% endif %}
-
- <div class="grid-19">
- {{c.page_list.display(limit=limit, page=page, count=count)}}
- {{c.page_size.display(limit=limit, page=page, count=count)}}
- </div>
-{% endblock %}
-
-{% block extra_css %}
-<style>
- table { clear: both; }
- table th {
- text-align: left;
- padding: 5px 10px;
- }
-</style>
-{% endblock %}
http://git-wip-us.apache.org/repos/asf/allura/blob/9440e40f/Allura/allura/templates/site_admin_search_projects_results.html
----------------------------------------------------------------------
diff --git a/Allura/allura/templates/site_admin_search_projects_results.html b/Allura/allura/templates/site_admin_search_projects_results.html
new file mode 100644
index 0000000..622e9a6
--- /dev/null
+++ b/Allura/allura/templates/site_admin_search_projects_results.html
@@ -0,0 +1,27 @@
+<tr>
+ <th>Short name</th>
+ <th>Full name</th>
+ <th>Registered</th>
+ <th>Deleted?</th>
+ {% for field in additional_fields %}
+ <th>{{ field }}</th>
+ {% endfor %}
+ <th>Details</th>
+</tr>
+
+{% for p in objects %}
+<tr>
+ <td><a href="{{ p['url'] }}">{{ p['shortname'] }}</a></td>
+ <td>{{ p['name'] }}</td>
+ <td>{{ h.ago_string(p['registration']) }}</td>
+ <td>{{ p['deleted'] }}</td>
+ {% for field in additional_fields %}
+ <td>{{ p[field] }}</td>
+ {% endfor %}
+ <td>
+ {% for url, label in provider.details_links(p['object']) %}
+ <a href="{{ url }}">{{ label }}</a><br>
+ {% endfor %}
+ </td>
+</tr>
+{% endfor %}
http://git-wip-us.apache.org/repos/asf/allura/blob/9440e40f/Allura/allura/templates/site_admin_search_users.html
----------------------------------------------------------------------
diff --git a/Allura/allura/templates/site_admin_search_users.html b/Allura/allura/templates/site_admin_search_users.html
deleted file mode 100644
index ec18e90..0000000
--- a/Allura/allura/templates/site_admin_search_users.html
+++ /dev/null
@@ -1,25 +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.
--#}
-{% extends 'allura:templates/site_admin.html' %}
-
-{% block title %}Search Users{% endblock %}
-{% block header %}Search Users{% endblock %}
-
-{% block content %}
-{% endblock %}
http://git-wip-us.apache.org/repos/asf/allura/blob/9440e40f/Allura/allura/templates/site_admin_search_users_results.html
----------------------------------------------------------------------
diff --git a/Allura/allura/templates/site_admin_search_users_results.html b/Allura/allura/templates/site_admin_search_users_results.html
new file mode 100644
index 0000000..b73c5c4
--- /dev/null
+++ b/Allura/allura/templates/site_admin_search_users_results.html
@@ -0,0 +1,7 @@
+<tr>
+</tr>
+
+{% for user in objects %}
+<tr>
+</tr>
+{% endfor %}
[16/26] git commit: [#7656] ticket:648 Fix test failing due to
refactoring
Posted by br...@apache.org.
[#7656] ticket:648 Fix test failing due to refactoring
Project: http://git-wip-us.apache.org/repos/asf/allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/allura/commit/2ff64b83
Tree: http://git-wip-us.apache.org/repos/asf/allura/tree/2ff64b83
Diff: http://git-wip-us.apache.org/repos/asf/allura/diff/2ff64b83
Branch: refs/heads/master
Commit: 2ff64b83cdd9f2033a0182724228cf06f872ed81
Parents: 0f6a2d6
Author: Igor Bondarenko <je...@gmail.com>
Authored: Tue Sep 9 16:29:25 2014 +0300
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Fri Sep 19 19:35:40 2014 +0000
----------------------------------------------------------------------
Allura/allura/tests/functional/test_site_admin.py | 4 ++--
Allura/allura/tests/model/test_auth.py | 2 +-
Allura/allura/tests/unit/test_solr.py | 9 +++++----
3 files changed, 8 insertions(+), 7 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/allura/blob/2ff64b83/Allura/allura/tests/functional/test_site_admin.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tests/functional/test_site_admin.py b/Allura/allura/tests/functional/test_site_admin.py
index b7ae16a..9503b7e 100644
--- a/Allura/allura/tests/functional/test_site_admin.py
+++ b/Allura/allura/tests/functional/test_site_admin.py
@@ -244,7 +244,7 @@ class TestProjectsSearch(TestController):
@patch('allura.controllers.site_admin.search')
def test_default_fields(self, search):
- search.search_projects.return_value = self.TEST_HIT
+ search.site_admin_search.return_value = self.TEST_HIT
r = self.app.get('/nf/admin/search_projects?q=fake&f=shortname')
options = [o['value'] for o in r.html.findAll('option')]
assert_equal(options, ['shortname', 'name', '__custom__'])
@@ -253,7 +253,7 @@ class TestProjectsSearch(TestController):
@patch('allura.controllers.site_admin.search')
def test_additional_fields(self, search):
- search.search_projects.return_value = self.TEST_HIT
+ search.site_admin_search.return_value = self.TEST_HIT
with h.push_config(config, **{'search.project.additional_fields': 'private, url'}):
r = self.app.get('/nf/admin/search_projects?q=fake&f=shortname')
options = [o['value'] for o in r.html.findAll('option')]
http://git-wip-us.apache.org/repos/asf/allura/blob/2ff64b83/Allura/allura/tests/model/test_auth.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tests/model/test_auth.py b/Allura/allura/tests/model/test_auth.py
index 4660510..75cf5a2 100644
--- a/Allura/allura/tests/model/test_auth.py
+++ b/Allura/allura/tests/model/test_auth.py
@@ -295,7 +295,7 @@ def test_user_index():
assert_in('results_per_page_i', idx)
assert_in('email_format_s', idx)
assert_in('disable_user_messages_b', idx)
- assert_equal(idx['display_name_s'], 'Test Admin')
+ assert_equal(idx['display_name_t'], 'Test Admin')
assert_equal(idx['sex_s'], 'Unknown')
assert_in('birthdate_dt', idx)
assert_in('localization_s', idx)
http://git-wip-us.apache.org/repos/asf/allura/blob/2ff64b83/Allura/allura/tests/unit/test_solr.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tests/unit/test_solr.py b/Allura/allura/tests/unit/test_solr.py
index 7e104d1..8b237cc 100644
--- a/Allura/allura/tests/unit/test_solr.py
+++ b/Allura/allura/tests/unit/test_solr.py
@@ -92,15 +92,16 @@ class TestSolr(unittest.TestCase):
solr.query_server.search.assert_called_once_with('bar', kw='kw')
@mock.patch('allura.lib.search.search')
- def test_search_projects(self, search):
- from allura.lib.search import search_projects
+ def test_site_admin_search(self, search):
+ from allura.lib.search import site_admin_search
+ from allura.model import Project
fq = ['type_s:Project']
- search_projects('test', 'shortname', rows=25)
+ site_admin_search(Project, 'test', 'shortname', rows=25)
search.assert_called_once_with(
'shortname_s:"test"', fq=fq, ignore_errors=False, rows=25)
search.reset_mock()
- search_projects('shortname:test || shortname:test2', '__custom__')
+ site_admin_search(Project, 'shortname:test || shortname:test2', '__custom__')
search.assert_called_once_with(
'shortname_s:test || shortname_s:test2', fq=fq, ignore_errors=False)
[19/26] git commit: [#7656] ticket:648 Add tests for user search
Posted by br...@apache.org.
[#7656] ticket:648 Add tests for user search
Project: http://git-wip-us.apache.org/repos/asf/allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/allura/commit/de6b7753
Tree: http://git-wip-us.apache.org/repos/asf/allura/tree/de6b7753
Diff: http://git-wip-us.apache.org/repos/asf/allura/diff/de6b7753
Branch: refs/heads/master
Commit: de6b775338ab101239be4067b780f89ee6a3ce33
Parents: 2ff64b8
Author: Igor Bondarenko <je...@gmail.com>
Authored: Tue Sep 9 16:54:56 2014 +0300
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Fri Sep 19 19:35:41 2014 +0000
----------------------------------------------------------------------
.../allura/tests/functional/test_site_admin.py | 58 +++++++++++++++++++-
Allura/allura/tests/unit/test_solr.py | 13 ++++-
2 files changed, 68 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/allura/blob/de6b7753/Allura/allura/tests/functional/test_site_admin.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tests/functional/test_site_admin.py b/Allura/allura/tests/functional/test_site_admin.py
index 9503b7e..c8b3bad 100644
--- a/Allura/allura/tests/functional/test_site_admin.py
+++ b/Allura/allura/tests/functional/test_site_admin.py
@@ -233,10 +233,11 @@ class TestProjectsSearch(TestController):
def setUp(self):
super(TestProjectsSearch, self).setUp()
# Create project that matches TEST_HIT id
- p = M.Project.query.get(_id=ObjectId('53ccf6e8100d2b0741746e9f'))
+ _id = ObjectId('53ccf6e8100d2b0741746e9f')
+ p = M.Project.query.get(_id=_id)
if not p:
M.Project(
- _id=ObjectId('53ccf6e8100d2b0741746e9f'),
+ _id=_id,
neighborhood_id=M.Neighborhood.query.get(url_prefix='/u/')._id,
shortname='test-project',
)
@@ -263,6 +264,59 @@ class TestProjectsSearch(TestController):
'private', 'url', 'Details'])
+class TestUsersSearch(TestController):
+
+ TEST_HIT = MagicMock(hits=1, docs=[{
+ '_version_': 1478773871277506560,
+ 'disabled_b': False,
+ 'display_name_t': 'Darth Vader',
+ 'id': 'allura/model/auth/User#540efdf2100d2b1483155d39',
+ 'last_access_login_date_dt': '2014-09-09T13:17:40.176Z',
+ 'last_access_login_ip_s': '10.0.2.2',
+ 'last_access_login_ua_t': 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/37.0.2062.94 Safari/537.36',
+ 'last_access_session_date_dt': '2014-09-09T13:17:40.33Z',
+ 'last_access_session_ip_s': '10.0.2.2',
+ 'last_access_session_ua_t': 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/37.0.2062.94 Safari/537.36',
+ 'last_password_updated_dt': '2014-09-09T13:17:38.857Z',
+ 'localization_s': 'None/None',
+ 'sex_s': 'Unknown',
+ 'title': ['User darth'],
+ 'type_s': 'User',
+ 'url_s': '/u/darth/',
+ 'user_registration_date_dt': '2014-09-09T13:17:38Z',
+ 'username_s': 'darth'}])
+
+ def setUp(self):
+ super(TestUsersSearch, self).setUp()
+ # Create user that matches TEST_HIT id
+ _id = ObjectId('540efdf2100d2b1483155d39')
+ u = M.User.query.get(_id=_id)
+ if not u:
+ M.User(_id=_id, username='darth')
+ ThreadLocalORMSession().flush_all()
+
+ @patch('allura.controllers.site_admin.search')
+ def test_default_fields(self, search):
+ search.site_admin_search.return_value = self.TEST_HIT
+ r = self.app.get('/nf/admin/search_users?q=fake&f=username')
+ options = [o['value'] for o in r.html.findAll('option')]
+ assert_equal(options, ['username', 'display_name', '__custom__'])
+ ths = [th.text for th in r.html.findAll('th')]
+ assert_equal(ths, ['Username', 'Display name', 'Email', 'Registered',
+ 'Disabled?', 'Details'])
+
+ @patch('allura.controllers.site_admin.search')
+ def test_additional_fields(self, search):
+ search.site_admin_search.return_value = self.TEST_HIT
+ with h.push_config(config, **{'search.user.additional_fields': 'email_addresses, url'}):
+ r = self.app.get('/nf/admin/search_users?q=fake&f=username')
+ options = [o['value'] for o in r.html.findAll('option')]
+ assert_equal(options, ['username', 'display_name', 'email_addresses', 'url', '__custom__'])
+ ths = [th.text for th in r.html.findAll('th')]
+ assert_equal(ths, ['Username', 'Display name', 'Email', 'Registered',
+ 'Disabled?', 'email_addresses', 'url', 'Details'])
+
+
@task
def test_task(*args, **kw):
"""test_task doc string"""
http://git-wip-us.apache.org/repos/asf/allura/blob/de6b7753/Allura/allura/tests/unit/test_solr.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tests/unit/test_solr.py b/Allura/allura/tests/unit/test_solr.py
index 8b237cc..dfe71c7 100644
--- a/Allura/allura/tests/unit/test_solr.py
+++ b/Allura/allura/tests/unit/test_solr.py
@@ -94,7 +94,7 @@ class TestSolr(unittest.TestCase):
@mock.patch('allura.lib.search.search')
def test_site_admin_search(self, search):
from allura.lib.search import site_admin_search
- from allura.model import Project
+ from allura.model import Project, User
fq = ['type_s:Project']
site_admin_search(Project, 'test', 'shortname', rows=25)
search.assert_called_once_with(
@@ -105,6 +105,17 @@ class TestSolr(unittest.TestCase):
search.assert_called_once_with(
'shortname_s:test || shortname_s:test2', fq=fq, ignore_errors=False)
+ fq = ['type_s:User']
+ search.reset_mock()
+ site_admin_search(User, 'test-user', 'username', rows=25)
+ search.assert_called_once_with(
+ 'username_s:"test-user"', fq=fq, ignore_errors=False, rows=25)
+
+ search.reset_mock()
+ site_admin_search(User, 'username:admin1 || username:root', '__custom__')
+ search.assert_called_once_with(
+ 'username_s:admin1 || username_s:root', fq=fq, ignore_errors=False)
+
class TestSearchIndexable(unittest.TestCase):
[15/26] git commit: [#7656] ticket:648 Display search results and
small fixes
Posted by br...@apache.org.
[#7656] ticket:648 Display search results and small fixes
Project: http://git-wip-us.apache.org/repos/asf/allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/allura/commit/caf12ce1
Tree: http://git-wip-us.apache.org/repos/asf/allura/tree/caf12ce1
Diff: http://git-wip-us.apache.org/repos/asf/allura/diff/caf12ce1
Branch: refs/heads/master
Commit: caf12ce1dbbcdddd37ba3b34e3f8326897aff4b9
Parents: 097c850
Author: Igor Bondarenko <je...@gmail.com>
Authored: Tue Sep 9 15:59:14 2014 +0300
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Fri Sep 19 19:35:40 2014 +0000
----------------------------------------------------------------------
Allura/allura/controllers/site_admin.py | 3 ++-
Allura/allura/lib/plugin.py | 10 ++++++++
Allura/allura/model/auth.py | 3 ++-
.../site_admin_search_users_results.html | 24 +++++++++++++++++++-
4 files changed, 37 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/allura/blob/caf12ce1/Allura/allura/controllers/site_admin.py
----------------------------------------------------------------------
diff --git a/Allura/allura/controllers/site_admin.py b/Allura/allura/controllers/site_admin.py
index 40c69f2..b6fecd7 100644
--- a/Allura/allura/controllers/site_admin.py
+++ b/Allura/allura/controllers/site_admin.py
@@ -34,7 +34,7 @@ from allura.app import SitemapEntry
from allura.lib import helpers as h
from allura.lib import validators as v
from allura.lib.decorators import require_post
-from allura.lib.plugin import SiteAdminExtension, ProjectRegistrationProvider
+from allura.lib.plugin import SiteAdminExtension, ProjectRegistrationProvider, AuthenticationProvider
from allura.lib import search
from allura.lib.security import require_access
from allura.lib.widgets import form_fields as ffw
@@ -362,6 +362,7 @@ class SiteAdminController(object):
add_fields = aslist(tg.config.get('search.user.additional_fields'), ',')
r = self._search(M.User, fields, add_fields, q, f, page, limit, **kw)
r['search_results_template'] = 'allura:templates/site_admin_search_users_results.html'
+ r['provider'] = AuthenticationProvider.get(request)
return r
http://git-wip-us.apache.org/repos/asf/allura/blob/caf12ce1/Allura/allura/lib/plugin.py
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/plugin.py b/Allura/allura/lib/plugin.py
index ccdf62c..78aae92 100644
--- a/Allura/allura/lib/plugin.py
+++ b/Allura/allura/lib/plugin.py
@@ -288,6 +288,16 @@ class AuthenticationProvider(object):
"""Put here additional fields for user index in SOLR."""
return {}
+ def details_links(self, user):
+ '''Return list of pairs (url, label) with details
+ about the user.
+ Links will show up at admin user search page.
+ '''
+ return [
+ (user.url(), 'Public profile'),
+ ('/nf/admin/user/%s' % user.username, 'Details/Edit'),
+ ]
+
class LocalAuthenticationProvider(AuthenticationProvider):
http://git-wip-us.apache.org/repos/asf/allura/blob/caf12ce1/Allura/allura/model/auth.py
----------------------------------------------------------------------
diff --git a/Allura/allura/model/auth.py b/Allura/allura/model/auth.py
index 6cca818..7f99866 100644
--- a/Allura/allura/model/auth.py
+++ b/Allura/allura/model/auth.py
@@ -293,6 +293,7 @@ class User(MappedClass, ActivityNode, ActivityObject, SearchIndexable):
fields = dict(
id=self.index_id(),
title='User %s' % self.username,
+ url_s=self.url(),
type_s=self.type_s,
username_s=self.username,
email_addresses_t=' '.join(self.email_addresses),
@@ -311,7 +312,7 @@ class User(MappedClass, ActivityNode, ActivityObject, SearchIndexable):
telnumbers_t=' '.join(self.get_pref('telnumbers')),
skypeaccount_s=self.get_pref('skypeaccount'),
webpages_t=' '.join(self.get_pref('webpages')),
- skills_t=' '.join([s['skill'].fullpath for s in self.get_skills()]),
+ skills_t=' '.join([s['skill'].fullpath for s in self.get_skills() if s.get('skill')]),
last_access_login_date_dt=self.last_access['login_date'],
last_access_login_ip_s=self.last_access['login_ip'],
last_access_login_ua_t=self.last_access['login_ua'],
http://git-wip-us.apache.org/repos/asf/allura/blob/caf12ce1/Allura/allura/templates/site_admin_search_users_results.html
----------------------------------------------------------------------
diff --git a/Allura/allura/templates/site_admin_search_users_results.html b/Allura/allura/templates/site_admin_search_users_results.html
index b73c5c4..ce9a8d0 100644
--- a/Allura/allura/templates/site_admin_search_users_results.html
+++ b/Allura/allura/templates/site_admin_search_users_results.html
@@ -1,7 +1,29 @@
<tr>
+ <th>Username</th>
+ <th>Display name</th>
+ <th>Email</th>
+ <th>Registered</th>
+ <th>Disabled?</th>
+ {% for field in additional_fields %}
+ <th>{{ field }}</th>
+ {% endfor %}
+ <th>Details</th>
</tr>
-{% for user in objects %}
+{% for u in objects %}
<tr>
+ <td><a href="{{ u['url'] }}">{{ u['username'] }}</a></td>
+ <td>{{ u['display_name'] }}</td>
+ <td>{{ u['object'].get_pref('email_address') }}</td>
+ <td>{{ provider.user_registration_date(u['object']) }}</td>
+ <td>{{ u['disabled'] }}</td>
+ {% for field in additional_fields %}
+ <td>{{ u[field] }}</td>
+ {% endfor %}
+ <td>
+ {% for url, label in provider.details_links(u['object']) %}
+ <a href="{{ url }}">{{ label }}</a><br>
+ {% endfor %}
+ </td>
</tr>
{% endfor %}
[14/26] git commit: [#7656] ticket:648 Format registration date
Posted by br...@apache.org.
[#7656] ticket:648 Format registration date
Project: http://git-wip-us.apache.org/repos/asf/allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/allura/commit/0f6a2d61
Tree: http://git-wip-us.apache.org/repos/asf/allura/tree/0f6a2d61
Diff: http://git-wip-us.apache.org/repos/asf/allura/diff/0f6a2d61
Branch: refs/heads/master
Commit: 0f6a2d617bce23b4540cafd1512ad28f41e27f7a
Parents: caf12ce
Author: Igor Bondarenko <je...@gmail.com>
Authored: Tue Sep 9 16:18:48 2014 +0300
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Fri Sep 19 19:35:40 2014 +0000
----------------------------------------------------------------------
Allura/allura/templates/site_admin_search_users_results.html | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/allura/blob/0f6a2d61/Allura/allura/templates/site_admin_search_users_results.html
----------------------------------------------------------------------
diff --git a/Allura/allura/templates/site_admin_search_users_results.html b/Allura/allura/templates/site_admin_search_users_results.html
index ce9a8d0..9e986ab 100644
--- a/Allura/allura/templates/site_admin_search_users_results.html
+++ b/Allura/allura/templates/site_admin_search_users_results.html
@@ -15,7 +15,7 @@
<td><a href="{{ u['url'] }}">{{ u['username'] }}</a></td>
<td>{{ u['display_name'] }}</td>
<td>{{ u['object'].get_pref('email_address') }}</td>
- <td>{{ provider.user_registration_date(u['object']) }}</td>
+ <td>{{ h.ago(provider.user_registration_date(u['object']).replace(tzinfo=None)) }}</td>
<td>{{ u['disabled'] }}</td>
{% for field in additional_fields %}
<td>{{ u[field] }}</td>
[04/26] git commit: [#7589] ticket:622 Tasks for indexing users
Posted by br...@apache.org.
[#7589] ticket:622 Tasks for indexing users
Project: http://git-wip-us.apache.org/repos/asf/allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/allura/commit/5bec5b7c
Tree: http://git-wip-us.apache.org/repos/asf/allura/tree/5bec5b7c
Diff: http://git-wip-us.apache.org/repos/asf/allura/diff/5bec5b7c
Branch: refs/heads/master
Commit: 5bec5b7c16ef4a90f274a4ad4bd95895e77ab6b6
Parents: 55be310
Author: Igor Bondarenko <je...@gmail.com>
Authored: Mon Aug 4 14:50:18 2014 +0300
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Fri Sep 19 19:35:38 2014 +0000
----------------------------------------------------------------------
Allura/allura/model/session.py | 4 +++-
Allura/allura/tasks/index_tasks.py | 12 ++++++++++++
2 files changed, 15 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/allura/blob/5bec5b7c/Allura/allura/model/session.py
----------------------------------------------------------------------
diff --git a/Allura/allura/model/session.py b/Allura/allura/model/session.py
index 8e0f551..eb1f4ba 100644
--- a/Allura/allura/model/session.py
+++ b/Allura/allura/model/session.py
@@ -68,7 +68,9 @@ class IndexerSessionExtension(ManagedSessionExtension):
TASKS = {
'allura.model.project.Project': {'add': index_tasks.add_projects,
- 'del': index_tasks.del_projects}
+ 'del': index_tasks.del_projects},
+ 'allura.model.auth.User': {'add': index_tasks.add_users,
+ 'del': index_tasks.del_users},
}
def _objects_by_types(self, obj_list):
http://git-wip-us.apache.org/repos/asf/allura/blob/5bec5b7c/Allura/allura/tasks/index_tasks.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tasks/index_tasks.py b/Allura/allura/tasks/index_tasks.py
index 3f02cef..c9e853d 100644
--- a/Allura/allura/tasks/index_tasks.py
+++ b/Allura/allura/tasks/index_tasks.py
@@ -57,6 +57,18 @@ def del_projects(project_solr_ids):
@task
+def add_users(user_ids):
+ from allura.model import User
+ users = User.query.find(dict(_id={'$in': user_ids})).all()
+ __add_objects(users)
+
+
+@task
+def del_users(user_solr_ids):
+ __del_objects(user_solr_ids)
+
+
+@task
def add_artifacts(ref_ids, update_solr=True, update_refs=True, solr_hosts=None):
'''
Add the referenced artifacts to SOLR and shortlinks.
[07/26] git commit: [#7656] ticket:648 Get rid of specific search
functions, which aren't used now
Posted by br...@apache.org.
[#7656] ticket:648 Get rid of specific search functions, which aren't used now
Project: http://git-wip-us.apache.org/repos/asf/allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/allura/commit/cd86a181
Tree: http://git-wip-us.apache.org/repos/asf/allura/tree/cd86a181
Diff: http://git-wip-us.apache.org/repos/asf/allura/diff/cd86a181
Branch: refs/heads/master
Commit: cd86a181286a329dc90150d7795f259293009369
Parents: 9440e40
Author: Igor Bondarenko <je...@gmail.com>
Authored: Tue Sep 9 14:10:44 2014 +0300
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Fri Sep 19 19:35:39 2014 +0000
----------------------------------------------------------------------
Allura/allura/lib/search.py | 10 ----------
1 file changed, 10 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/allura/blob/cd86a181/Allura/allura/lib/search.py
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/search.py b/Allura/allura/lib/search.py
index f4f177a..1c3ba8a 100644
--- a/Allura/allura/lib/search.py
+++ b/Allura/allura/lib/search.py
@@ -180,8 +180,6 @@ def search_artifact(atype, q, history=False, rows=10, short_timeout=False, filte
def site_admin_search(model, q, field, **kw):
"""Performs SOLR search for a given model.
- Probably you should not use it directly. Use one of the specific functions below.
-
Raises SearchError if SOLR returns an error.
"""
# first, grab a object and get the fields that it indexes
@@ -198,14 +196,6 @@ def site_admin_search(model, q, field, **kw):
fq = [u'type_s:%s' % model.type_s]
return search(q, fq=fq, ignore_errors=False, **kw)
-def search_projects(q, field, **kw):
- from allura.model import Project
- return site_admin_search(Project, q, field, **kw)
-
-def search_users(q, field, **kw):
- from allura.model import User
- return site_admin_search(User, q, field, **kw)
-
def search_app(q='', fq=None, app=True, **kw):
"""Helper for app/project search.
[05/26] git commit: [#7589] ticket:622 Add command to reindex all
users
Posted by br...@apache.org.
[#7589] ticket:622 Add command to reindex all users
Project: http://git-wip-us.apache.org/repos/asf/allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/allura/commit/73ed47ca
Tree: http://git-wip-us.apache.org/repos/asf/allura/tree/73ed47ca
Diff: http://git-wip-us.apache.org/repos/asf/allura/diff/73ed47ca
Branch: refs/heads/master
Commit: 73ed47ca418279a3fae7aaebfecde63670723475
Parents: 9103e20
Author: Igor Bondarenko <je...@gmail.com>
Authored: Mon Aug 4 17:16:51 2014 +0300
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Fri Sep 19 19:35:38 2014 +0000
----------------------------------------------------------------------
Allura/allura/scripts/reindex_users.py | 89 +++++++++++++++++++++++++++++
1 file changed, 89 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/allura/blob/73ed47ca/Allura/allura/scripts/reindex_users.py
----------------------------------------------------------------------
diff --git a/Allura/allura/scripts/reindex_users.py b/Allura/allura/scripts/reindex_users.py
new file mode 100644
index 0000000..8a0762b
--- /dev/null
+++ b/Allura/allura/scripts/reindex_users.py
@@ -0,0 +1,89 @@
+# 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.
+
+import argparse
+import logging
+
+from pymongo.errors import InvalidDocument
+
+from allura.scripts import ScriptTask
+from allura import model as M
+from allura.tasks.index_tasks import add_users
+from allura.lib.utils import chunked_find, chunked_list
+from allura.lib.exceptions import CompoundError
+
+
+log = logging.getLogger(__name__)
+
+
+class ReindexUsers(ScriptTask):
+
+ @classmethod
+ def execute(cls, options):
+ for chunk in chunked_find(M.User, {}):
+ user_ids = []
+ for u in chunk:
+ log.info('Reindex user %s', u.username)
+ if options.dry_run:
+ continue
+ user_ids.append(u._id)
+ try:
+ for chunk in chunked_list(user_ids, options.max_chunk):
+ if options.tasks:
+ cls._post_add_users(chunk)
+ else:
+ add_users(chunk)
+ except CompoundError, err:
+ log.exception('Error indexing users:\n%r', err)
+ log.error('%s', err.format_error())
+ M.main_orm_session.flush()
+ M.main_orm_session.clear()
+ log.info('Reindex %s', 'queued' if options.tasks else 'done')
+
+ @classmethod
+ def _post_add_users(cls, chunk):
+ """
+ Post task, recursively splitting and re-posting if the resulting
+ mongo document is too large.
+ """
+ try:
+ add_users.post(chunk)
+ except InvalidDocument as e:
+ # there are many types of InvalidDocument, only recurse if its
+ # expected to help
+ if e.args[0].startswith('BSON document too large'):
+ cls._post_add_users(chunk[:len(chunk) // 2])
+ cls._post_add_users(chunk[len(chunk) // 2:])
+ else:
+ raise
+
+ @classmethod
+ def parser(cls):
+ parser = argparse.ArgumentParser(description='Reindex all users')
+ parser.add_argument('--dry-run', action='store_true', dest='dry_run',
+ default=False, help='Log names of projects that would be reindexed, '
+ 'but do not perform the actual reindex.')
+ parser.add_argument('--tasks', action='store_true', dest='tasks',
+ help='Run each individual index operation as a background task.')
+ parser.add_argument(
+ '--max-chunk', dest='max_chunk', type=int, default=100 * 1000,
+ help='Max number of artifacts to index in one Solr update command')
+ return parser
+
+
+if __name__ == '__main__':
+ ReindexUsers.main()
[03/26] git commit: [#7589] ticket:622 Fix field types/appearance in
the index
Posted by br...@apache.org.
[#7589] ticket:622 Fix field types/appearance in the index
Project: http://git-wip-us.apache.org/repos/asf/allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/allura/commit/6c9a86d6
Tree: http://git-wip-us.apache.org/repos/asf/allura/tree/6c9a86d6
Diff: http://git-wip-us.apache.org/repos/asf/allura/diff/6c9a86d6
Branch: refs/heads/master
Commit: 6c9a86d6fec8977283c9030bffae01b461d01b8c
Parents: 5bec5b7
Author: Igor Bondarenko <je...@gmail.com>
Authored: Mon Aug 4 15:19:22 2014 +0300
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Fri Sep 19 19:35:38 2014 +0000
----------------------------------------------------------------------
Allura/allura/model/auth.py | 21 ++++++++++++++-------
1 file changed, 14 insertions(+), 7 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/allura/blob/6c9a86d6/Allura/allura/model/auth.py
----------------------------------------------------------------------
diff --git a/Allura/allura/model/auth.py b/Allura/allura/model/auth.py
index 9ceb341..0f04f6b 100644
--- a/Allura/allura/model/auth.py
+++ b/Allura/allura/model/auth.py
@@ -288,12 +288,14 @@ class User(MappedClass, ActivityNode, ActivityObject, SearchIndexable):
localization = '%s/%s' % (
self.get_pref('localization')['country'],
self.get_pref('localization')['city'])
+ socialnetworks = ' '.join(['%s: %s' % (n['socialnetwork'], n['accounturl'])
+ for n in self.get_pref('socialnetworks')])
fields = dict(
id=self.index_id(),
title='User %s' % self.username,
type_s=self.type_s,
username_s=self.username,
- email_addresses=self.email_addresses,
+ email_addresses_t=' '.join(self.email_addresses),
last_password_updated_dt=self.last_password_updated,
disabled_b=self.disabled,
results_per_page_i=self.get_pref('results_per_page'),
@@ -302,15 +304,20 @@ class User(MappedClass, ActivityNode, ActivityObject, SearchIndexable):
disable_user_messages_b=self.get_pref('disable_user_messages'),
display_name_s=self.get_pref('display_name'),
sex_s=self.get_pref('sex'),
- birthday_dt=self.get_pref('birthday'),
+ birthdate_dt=self.get_pref('birthdate'),
localization_s=localization,
timezone_s=self.get_pref('timezone'),
- socialnetworks=self.get_pref('socialnetworks'),
- telnumbers=self.get_pref('telnumbers'),
+ socialnetworks_t=socialnetworks,
+ telnumbers_t=' '.join(self.get_pref('telnumbers')),
skypeaccount_s=self.get_pref('skypeaccount'),
- webpages=self.get_pref('webpages'),
- skills=self.get_skills(),
- last_access=self.last_access,
+ webpages_t=' '.join(self.get_pref('webpages')),
+ skills_t=' '.join([s['skill'].fullpath for s in self.get_skills()]),
+ last_access_login_date_dt=self.last_access['login_date'],
+ last_access_login_ip_s=self.last_access['login_ip'],
+ last_access_login_ua_t=self.last_access['login_ua'],
+ last_access_session_date_dt=self.last_access['session_date'],
+ last_access_session_ip_s=self.last_access['session_ip'],
+ last_access_session_ua_t=self.last_access['session_ua'],
)
return dict(provider.index_user(self), **fields)
[23/26] git commit: [#7656] ticket:654 Split additional_fields
options into additional_search_fields and additional_display_fields
Posted by br...@apache.org.
[#7656] ticket:654 Split additional_fields options into additional_search_fields and additional_display_fields
Project: http://git-wip-us.apache.org/repos/asf/allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/allura/commit/74965ec2
Tree: http://git-wip-us.apache.org/repos/asf/allura/tree/74965ec2
Diff: http://git-wip-us.apache.org/repos/asf/allura/diff/74965ec2
Branch: refs/heads/master
Commit: 74965ec2c811a6731bf6bb052b84ad7c5a228c42
Parents: ab4961f
Author: Aleksey 'LXj' Alekseyev <go...@gmail.com>
Authored: Tue Sep 16 16:42:51 2014 +0300
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Fri Sep 19 19:35:42 2014 +0000
----------------------------------------------------------------------
Allura/allura/controllers/site_admin.py | 8 ++++++--
.../templates/site_admin_search_projects_results.html | 4 ++--
.../allura/templates/site_admin_search_users_results.html | 4 ++--
Allura/development.ini | 9 +++++++--
4 files changed, 17 insertions(+), 8 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/allura/blob/74965ec2/Allura/allura/controllers/site_admin.py
----------------------------------------------------------------------
diff --git a/Allura/allura/controllers/site_admin.py b/Allura/allura/controllers/site_admin.py
index b6fecd7..755c405 100644
--- a/Allura/allura/controllers/site_admin.py
+++ b/Allura/allura/controllers/site_admin.py
@@ -346,9 +346,11 @@ class SiteAdminController(object):
page=validators.Int(if_empty=0, if_invalid=0)))
def search_projects(self, q=None, f=None, page=0, limit=None, **kw):
fields = [('shortname', 'shortname'), ('name', 'full name')]
- add_fields = aslist(tg.config.get('search.project.additional_fields'), ',')
+ add_fields = aslist(tg.config.get('search.project.additional_search_fields'), ',')
r = self._search(M.Project, fields, add_fields, q, f, page, limit, **kw)
r['search_results_template'] = 'allura:templates/site_admin_search_projects_results.html'
+ r['additional_display_fields'] = \
+ aslist(tg.config.get('search.project.additional_display_fields'), ',')
r['provider'] = ProjectRegistrationProvider.get()
return r
@@ -359,9 +361,11 @@ class SiteAdminController(object):
page=validators.Int(if_empty=0, if_invalid=0)))
def search_users(self, q=None, f=None, page=0, limit=None, **kw):
fields = [('username', 'username'), ('display_name', 'display name')]
- add_fields = aslist(tg.config.get('search.user.additional_fields'), ',')
+ add_fields = aslist(tg.config.get('search.user.additional_search_fields'), ',')
r = self._search(M.User, fields, add_fields, q, f, page, limit, **kw)
r['search_results_template'] = 'allura:templates/site_admin_search_users_results.html'
+ r['additional_display_fields'] = \
+ aslist(tg.config.get('search.user.additional_display_fields'), ',')
r['provider'] = AuthenticationProvider.get(request)
return r
http://git-wip-us.apache.org/repos/asf/allura/blob/74965ec2/Allura/allura/templates/site_admin_search_projects_results.html
----------------------------------------------------------------------
diff --git a/Allura/allura/templates/site_admin_search_projects_results.html b/Allura/allura/templates/site_admin_search_projects_results.html
index 5bde5f0..3fedf82 100644
--- a/Allura/allura/templates/site_admin_search_projects_results.html
+++ b/Allura/allura/templates/site_admin_search_projects_results.html
@@ -21,7 +21,7 @@
<th>Full name</th>
<th>Registered</th>
<th>Deleted?</th>
- {% for field in additional_fields %}
+ {% for field in additional_display_fields %}
<th>{{ field }}</th>
{% endfor %}
<th>Details</th>
@@ -33,7 +33,7 @@
<td>{{ p['name'] }}</td>
<td>{{ h.ago_string(p['registration']) }}</td>
<td>{{ p['deleted'] }}</td>
- {% for field in additional_fields %}
+ {% for field in additional_display_fields %}
<td>{{ p[field] }}</td>
{% endfor %}
<td>
http://git-wip-us.apache.org/repos/asf/allura/blob/74965ec2/Allura/allura/templates/site_admin_search_users_results.html
----------------------------------------------------------------------
diff --git a/Allura/allura/templates/site_admin_search_users_results.html b/Allura/allura/templates/site_admin_search_users_results.html
index dc83184..c718b02 100644
--- a/Allura/allura/templates/site_admin_search_users_results.html
+++ b/Allura/allura/templates/site_admin_search_users_results.html
@@ -22,7 +22,7 @@
<th>Email</th>
<th>Registered</th>
<th>Disabled?</th>
- {% for field in additional_fields %}
+ {% for field in additional_display_fields %}
<th>{{ field }}</th>
{% endfor %}
<th>Details</th>
@@ -35,7 +35,7 @@
<td>{{ u['object'].get_pref('email_address') }}</td>
<td>{{ h.ago(provider.user_registration_date(u['object']).replace(tzinfo=None)) }}</td>
<td>{{ u['disabled'] }}</td>
- {% for field in additional_fields %}
+ {% for field in additional_display_fields %}
<td>{{ u[field] }}</td>
{% endfor %}
<td>
http://git-wip-us.apache.org/repos/asf/allura/blob/74965ec2/Allura/development.ini
----------------------------------------------------------------------
diff --git a/Allura/development.ini b/Allura/development.ini
index ab0c114..841714d 100644
--- a/Allura/development.ini
+++ b/Allura/development.ini
@@ -122,8 +122,13 @@ user_prefs_storage.ldap.fields.display_name = cn
# Additional fields for admin project/user search
# Note: whitespace after comma is important!
-# search.project.additional_fields = private, url, title
-# search.user.additional_fields = email_addresses
+# search.project.additional_search_fields = private, url, title
+# search.user.additional_search_fields = email_addresses
+
+# Additional fields to show in the result of admin project/user search
+# Note: whitespace after comma is important!
+# search.project.additional_display_fields = private, url, title
+# search.user.additional_display_fields = email_addresses
# Set the locations of some static resources
# script_name is the path that is handled by the application
[02/26] git commit: [#7656] ticket:648 Add initial stubs for user
search page
Posted by br...@apache.org.
[#7656] ticket:648 Add initial stubs for user search page
Project: http://git-wip-us.apache.org/repos/asf/allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/allura/commit/638807ad
Tree: http://git-wip-us.apache.org/repos/asf/allura/tree/638807ad
Diff: http://git-wip-us.apache.org/repos/asf/allura/diff/638807ad
Branch: refs/heads/master
Commit: 638807ad690eb2f6477ed3884df664eb4478e1fc
Parents: 73ed47c
Author: Igor Bondarenko <je...@gmail.com>
Authored: Tue Sep 9 12:58:18 2014 +0300
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Fri Sep 19 19:35:38 2014 +0000
----------------------------------------------------------------------
Allura/allura/controllers/site_admin.py | 9 +++++++
.../templates/site_admin_search_users.html | 25 ++++++++++++++++++++
2 files changed, 34 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/allura/blob/638807ad/Allura/allura/controllers/site_admin.py
----------------------------------------------------------------------
diff --git a/Allura/allura/controllers/site_admin.py b/Allura/allura/controllers/site_admin.py
index 4a96298..bf7076e 100644
--- a/Allura/allura/controllers/site_admin.py
+++ b/Allura/allura/controllers/site_admin.py
@@ -87,6 +87,7 @@ class SiteAdminController(object):
SitemapEntry('Task Manager', base_url + 'task_manager?state=busy', ui_icon=g.icons['stats']),
SitemapEntry('Users Audit Log', base_url + 'users', ui_icon=g.icons['admin']),
SitemapEntry('Search Projects', base_url + 'search_projects', ui_icon=g.icons['search']),
+ SitemapEntry('Search Users', base_url + 'search_users', ui_icon=g.icons['search']),
]
for ep_name in sorted(g.entry_points['site_admin']):
g.entry_points['site_admin'][ep_name]().update_sidebar_menu(links)
@@ -341,6 +342,14 @@ class SiteAdminController(object):
'provider': ProjectRegistrationProvider.get(),
}
+ @without_trailing_slash
+ @expose('jinja:allura:templates/site_admin_search_users.html')
+ @validate(validators=dict(q=validators.UnicodeString(if_empty=None),
+ limit=validators.Int(if_invalid=None),
+ page=validators.Int(if_empty=0, if_invalid=0)))
+ def search_users(self, q=None, f=None, page=0, limit=None, **kw):
+ return {}
+
class TaskManagerController(object):
http://git-wip-us.apache.org/repos/asf/allura/blob/638807ad/Allura/allura/templates/site_admin_search_users.html
----------------------------------------------------------------------
diff --git a/Allura/allura/templates/site_admin_search_users.html b/Allura/allura/templates/site_admin_search_users.html
new file mode 100644
index 0000000..ec18e90
--- /dev/null
+++ b/Allura/allura/templates/site_admin_search_users.html
@@ -0,0 +1,25 @@
+{#-
+ 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.
+-#}
+{% extends 'allura:templates/site_admin.html' %}
+
+{% block title %}Search Users{% endblock %}
+{% block header %}Search Users{% endblock %}
+
+{% block content %}
+{% endblock %}
[18/26] git commit: [#7656] ticket:654 Updated search test
Posted by br...@apache.org.
[#7656] ticket:654 Updated search test
Project: http://git-wip-us.apache.org/repos/asf/allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/allura/commit/38cd390e
Tree: http://git-wip-us.apache.org/repos/asf/allura/tree/38cd390e
Diff: http://git-wip-us.apache.org/repos/asf/allura/diff/38cd390e
Branch: refs/heads/master
Commit: 38cd390eaef0f5be140fbb7bd668d4e34f750fbd
Parents: fa91db7
Author: Aleksey 'LXj' Alekseyev <go...@gmail.com>
Authored: Sun Sep 14 20:17:08 2014 +0300
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Fri Sep 19 19:35:41 2014 +0000
----------------------------------------------------------------------
Allura/allura/tests/unit/test_solr.py | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/allura/blob/38cd390e/Allura/allura/tests/unit/test_solr.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tests/unit/test_solr.py b/Allura/allura/tests/unit/test_solr.py
index dfe71c7..3d5317c 100644
--- a/Allura/allura/tests/unit/test_solr.py
+++ b/Allura/allura/tests/unit/test_solr.py
@@ -98,7 +98,7 @@ class TestSolr(unittest.TestCase):
fq = ['type_s:Project']
site_admin_search(Project, 'test', 'shortname', rows=25)
search.assert_called_once_with(
- 'shortname_s:"test"', fq=fq, ignore_errors=False, rows=25)
+ 'shortname_s:test', fq=fq, ignore_errors=False, rows=25)
search.reset_mock()
site_admin_search(Project, 'shortname:test || shortname:test2', '__custom__')
@@ -109,7 +109,7 @@ class TestSolr(unittest.TestCase):
search.reset_mock()
site_admin_search(User, 'test-user', 'username', rows=25)
search.assert_called_once_with(
- 'username_s:"test-user"', fq=fq, ignore_errors=False, rows=25)
+ 'username_s:test-user', fq=fq, ignore_errors=False, rows=25)
search.reset_mock()
site_admin_search(User, 'username:admin1 || username:root', '__custom__')
[11/26] git commit: [#7656] ticket:648 Refactor projects search fn to
generic one and add fn for users
Posted by br...@apache.org.
[#7656] ticket:648 Refactor projects search fn to generic one and add fn for users
Project: http://git-wip-us.apache.org/repos/asf/allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/allura/commit/6c7ca9a5
Tree: http://git-wip-us.apache.org/repos/asf/allura/tree/6c7ca9a5
Diff: http://git-wip-us.apache.org/repos/asf/allura/diff/6c7ca9a5
Branch: refs/heads/master
Commit: 6c7ca9a5a10e9210d855d3eefe2413afc305edc0
Parents: 1371cc3
Author: Igor Bondarenko <je...@gmail.com>
Authored: Tue Sep 9 13:08:44 2014 +0300
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Fri Sep 19 19:35:39 2014 +0000
----------------------------------------------------------------------
Allura/allura/lib/search.py | 31 ++++++++++++++++++++-----------
1 file changed, 20 insertions(+), 11 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/allura/blob/6c7ca9a5/Allura/allura/lib/search.py
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/search.py b/Allura/allura/lib/search.py
index c0f45cc..49a3ad5 100644
--- a/Allura/allura/lib/search.py
+++ b/Allura/allura/lib/search.py
@@ -159,26 +159,35 @@ def search_artifact(atype, q, history=False, rows=10, short_timeout=False, filte
return search(q, fq=fq, rows=rows, short_timeout=short_timeout, ignore_errors=False, **kw)
-def search_projects(q, field, **kw):
- """Performs SOLR search for a project.
+def site_admin_search(model, q, field, **kw):
+ """Performs SOLR search for a given model.
+
+ Probably you should not use it directly. Use one of the specific functions below.
Raises SearchError if SOLR returns an error.
"""
- # first, grab a project and get the fields that it indexes
- from allura.model import Project
- p = Project.query.find().first()
- if p is None:
- return # if there are no projects, we won't find anything
- fields = p.index()
+ # first, grab a object and get the fields that it indexes
+ obj = model.query.find().first()
+ if obj is None:
+ return # if there are no objects, we won't find anything
+ fields = obj.index()
if field == '__custom__':
# custom query -> query as is
- q = p.translate_query(q, fields)
+ q = obj.translate_query(q, fields)
else:
# construct query for a specific selected field
- q = p.translate_query(u'%s:"%s"' % (field, q), fields)
- fq = [u'type_s:Project']
+ q = obj.translate_query(u'%s:"%s"' % (field, q), fields)
+ fq = [u'type_s:%s' % model.type_s]
return search(q, fq=fq, ignore_errors=False, **kw)
+def search_projects(q, field, **kw):
+ from allura.model import Project
+ return site_admin_search(Project, q, field, **kw)
+
+def search_users(q, field, **kw):
+ from allura.model import User
+ return site_admin_search(User, q, field, **kw)
+
def search_app(q='', fq=None, app=True, **kw):
"""Helper for app/project search.
[06/26] git commit: [#7589] ticket:622 Test for User.index()
Posted by br...@apache.org.
[#7589] ticket:622 Test for User.index()
Project: http://git-wip-us.apache.org/repos/asf/allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/allura/commit/9103e203
Tree: http://git-wip-us.apache.org/repos/asf/allura/tree/9103e203
Diff: http://git-wip-us.apache.org/repos/asf/allura/diff/9103e203
Branch: refs/heads/master
Commit: 9103e2032b4731587a9e73404e880e752b041d04
Parents: 6c9a86d
Author: Igor Bondarenko <je...@gmail.com>
Authored: Mon Aug 4 15:44:08 2014 +0300
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Fri Sep 19 19:35:38 2014 +0000
----------------------------------------------------------------------
Allura/allura/tests/model/test_auth.py | 36 +++++++++++++++++++++++++++++
1 file changed, 36 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/allura/blob/9103e203/Allura/allura/tests/model/test_auth.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tests/model/test_auth.py b/Allura/allura/tests/model/test_auth.py
index 9c5a74c..4660510 100644
--- a/Allura/allura/tests/model/test_auth.py
+++ b/Allura/allura/tests/model/test_auth.py
@@ -277,3 +277,39 @@ def test_user_track_active():
c.user = M.User.by_username(c.user.username)
assert_equal(c.user.last_access['session_ip'], 'new addr')
assert_equal(c.user.last_access['session_ua'], 'new browser')
+
+
+@with_setup(setUp)
+def test_user_index():
+ c.user.email_addresses = ['email1', 'email2']
+ c.user.set_pref('email_address', 'email2')
+ idx = c.user.index()
+ assert_equal(idx['id'], c.user.index_id())
+ assert_equal(idx['title'], 'User test-admin')
+ assert_equal(idx['type_s'], 'User')
+ assert_equal(idx['username_s'], 'test-admin')
+ assert_equal(idx['email_addresses_t'], 'email1 email2')
+ assert_equal(idx['email_address_s'], 'email2')
+ assert_in('last_password_updated_dt', idx)
+ assert_equal(idx['disabled_b'], False)
+ assert_in('results_per_page_i', idx)
+ assert_in('email_format_s', idx)
+ assert_in('disable_user_messages_b', idx)
+ assert_equal(idx['display_name_s'], 'Test Admin')
+ assert_equal(idx['sex_s'], 'Unknown')
+ assert_in('birthdate_dt', idx)
+ assert_in('localization_s', idx)
+ assert_in('timezone_s', idx)
+ assert_in('socialnetworks_t', idx)
+ assert_in('telnumbers_t', idx)
+ assert_in('skypeaccount_s', idx)
+ assert_in('webpages_t', idx)
+ assert_in('skills_t', idx)
+ assert_in('last_access_login_date_dt', idx)
+ assert_in('last_access_login_ip_s', idx)
+ assert_in('last_access_login_ua_t', idx)
+ assert_in('last_access_session_date_dt', idx)
+ assert_in('last_access_session_ip_s', idx)
+ assert_in('last_access_session_ua_t', idx)
+ # provided bby auth provider
+ assert_in('user_registration_date_dt', idx)
[20/26] git commit: [#7656] ticket:654 Added license information to
new templates
Posted by br...@apache.org.
[#7656] ticket:654 Added license information to new templates
Project: http://git-wip-us.apache.org/repos/asf/allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/allura/commit/c41daca8
Tree: http://git-wip-us.apache.org/repos/asf/allura/tree/c41daca8
Diff: http://git-wip-us.apache.org/repos/asf/allura/diff/c41daca8
Branch: refs/heads/master
Commit: c41daca80ee00eab163ed1d4164ce35f16ffb227
Parents: d317e96
Author: Aleksey 'LXj' Alekseyev <go...@gmail.com>
Authored: Thu Sep 11 19:43:03 2014 +0300
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Fri Sep 19 19:35:41 2014 +0000
----------------------------------------------------------------------
.../site_admin_search_projects_results.html | 18 ++++++++++++++++++
.../site_admin_search_users_results.html | 18 ++++++++++++++++++
2 files changed, 36 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/allura/blob/c41daca8/Allura/allura/templates/site_admin_search_projects_results.html
----------------------------------------------------------------------
diff --git a/Allura/allura/templates/site_admin_search_projects_results.html b/Allura/allura/templates/site_admin_search_projects_results.html
index 622e9a6..5bde5f0 100644
--- a/Allura/allura/templates/site_admin_search_projects_results.html
+++ b/Allura/allura/templates/site_admin_search_projects_results.html
@@ -1,3 +1,21 @@
+{#-
+ 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.
+-#}
<tr>
<th>Short name</th>
<th>Full name</th>
http://git-wip-us.apache.org/repos/asf/allura/blob/c41daca8/Allura/allura/templates/site_admin_search_users_results.html
----------------------------------------------------------------------
diff --git a/Allura/allura/templates/site_admin_search_users_results.html b/Allura/allura/templates/site_admin_search_users_results.html
index 9e986ab..dc83184 100644
--- a/Allura/allura/templates/site_admin_search_users_results.html
+++ b/Allura/allura/templates/site_admin_search_users_results.html
@@ -1,3 +1,21 @@
+{#-
+ 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.
+-#}
<tr>
<th>Username</th>
<th>Display name</th>
[17/26] git commit: [#7656] ticket:654 Removed quotes for search term
Posted by br...@apache.org.
[#7656] ticket:654 Removed quotes for search term
Project: http://git-wip-us.apache.org/repos/asf/allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/allura/commit/fa91db78
Tree: http://git-wip-us.apache.org/repos/asf/allura/tree/fa91db78
Diff: http://git-wip-us.apache.org/repos/asf/allura/diff/fa91db78
Branch: refs/heads/master
Commit: fa91db782659fc4d28e0e44a58cb3eaa5b77bebe
Parents: c41daca
Author: Aleksey 'LXj' Alekseyev <go...@gmail.com>
Authored: Fri Sep 12 16:27:21 2014 +0300
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Fri Sep 19 19:35:41 2014 +0000
----------------------------------------------------------------------
Allura/allura/lib/search.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/allura/blob/fa91db78/Allura/allura/lib/search.py
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/search.py b/Allura/allura/lib/search.py
index 525fab3..9c4a5f3 100644
--- a/Allura/allura/lib/search.py
+++ b/Allura/allura/lib/search.py
@@ -192,7 +192,7 @@ def site_admin_search(model, q, field, **kw):
q = obj.translate_query(q, fields)
else:
# construct query for a specific selected field
- q = obj.translate_query(u'%s:"%s"' % (field, q), fields)
+ q = obj.translate_query(u'%s:%s' % (field, q), fields)
fq = [u'type_s:%s' % model.type_s]
return search(q, fq=fq, ignore_errors=False, **kw)
[12/26] git commit: [#7656] ticket:648 Add default search fields for
user & additional fields examples
Posted by br...@apache.org.
[#7656] ticket:648 Add default search fields for user & additional fields examples
Project: http://git-wip-us.apache.org/repos/asf/allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/allura/commit/097c8505
Tree: http://git-wip-us.apache.org/repos/asf/allura/tree/097c8505
Diff: http://git-wip-us.apache.org/repos/asf/allura/diff/097c8505
Branch: refs/heads/master
Commit: 097c8505abbcd844f6fee227df45f6c9292732cc
Parents: 5029fc0
Author: Igor Bondarenko <je...@gmail.com>
Authored: Tue Sep 9 14:24:39 2014 +0300
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Fri Sep 19 19:35:40 2014 +0000
----------------------------------------------------------------------
Allura/allura/controllers/site_admin.py | 2 +-
Allura/development.ini | 3 ++-
2 files changed, 3 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/allura/blob/097c8505/Allura/allura/controllers/site_admin.py
----------------------------------------------------------------------
diff --git a/Allura/allura/controllers/site_admin.py b/Allura/allura/controllers/site_admin.py
index b19b84b..40c69f2 100644
--- a/Allura/allura/controllers/site_admin.py
+++ b/Allura/allura/controllers/site_admin.py
@@ -358,7 +358,7 @@ class SiteAdminController(object):
limit=validators.Int(if_invalid=None),
page=validators.Int(if_empty=0, if_invalid=0)))
def search_users(self, q=None, f=None, page=0, limit=None, **kw):
- fields = []
+ fields = [('username', 'username'), ('display_name', 'display name')]
add_fields = aslist(tg.config.get('search.user.additional_fields'), ',')
r = self._search(M.User, fields, add_fields, q, f, page, limit, **kw)
r['search_results_template'] = 'allura:templates/site_admin_search_users_results.html'
http://git-wip-us.apache.org/repos/asf/allura/blob/097c8505/Allura/development.ini
----------------------------------------------------------------------
diff --git a/Allura/development.ini b/Allura/development.ini
index 80275d5..ab0c114 100644
--- a/Allura/development.ini
+++ b/Allura/development.ini
@@ -120,9 +120,10 @@ user_prefs_storage.method = local
user_prefs_storage.ldap.fields.display_name = cn
-# Additional fields for admin project search (/nf/admin/search_projects/)
+# Additional fields for admin project/user search
# Note: whitespace after comma is important!
# search.project.additional_fields = private, url, title
+# search.user.additional_fields = email_addresses
# Set the locations of some static resources
# script_name is the path that is handled by the application
[26/26] git commit: [#7656] put hide_left_bar var logic in respective
templates
Posted by br...@apache.org.
[#7656] put hide_left_bar var logic in respective templates
Project: http://git-wip-us.apache.org/repos/asf/allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/allura/commit/a9883cd2
Tree: http://git-wip-us.apache.org/repos/asf/allura/tree/a9883cd2
Diff: http://git-wip-us.apache.org/repos/asf/allura/diff/a9883cd2
Branch: refs/heads/master
Commit: a9883cd2345697df8acdcd6cc8c0b20ad142db64
Parents: 7cb33a4
Author: Dave Brondsema <db...@slashdotmedia.com>
Authored: Fri Sep 19 19:50:42 2014 +0000
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Fri Sep 19 19:50:42 2014 +0000
----------------------------------------------------------------------
Allura/allura/templates/site_admin.html | 4 ----
.../templates/site_admin_new_projects.html | 24 +++++++++++---------
Allura/allura/templates/site_admin_search.html | 1 +
3 files changed, 14 insertions(+), 15 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/allura/blob/a9883cd2/Allura/allura/templates/site_admin.html
----------------------------------------------------------------------
diff --git a/Allura/allura/templates/site_admin.html b/Allura/allura/templates/site_admin.html
index 0256563..3670285 100644
--- a/Allura/allura/templates/site_admin.html
+++ b/Allura/allura/templates/site_admin.html
@@ -19,10 +19,6 @@
{% from 'allura:templates/jinja_master/sidebar_menu.html' import sidebar_item with context %}
-{% set hide_left_bar=False %}
-{% if page in ['new_projects', 'search_results'] %}
- {% set hide_left_bar=True %}
-{% endif %}
{% extends g.theme.master %}
{% block title %}Forge Site Admin{% endblock %}
http://git-wip-us.apache.org/repos/asf/allura/blob/a9883cd2/Allura/allura/templates/site_admin_new_projects.html
----------------------------------------------------------------------
diff --git a/Allura/allura/templates/site_admin_new_projects.html b/Allura/allura/templates/site_admin_new_projects.html
index 995906f..81902d6 100644
--- a/Allura/allura/templates/site_admin_new_projects.html
+++ b/Allura/allura/templates/site_admin_new_projects.html
@@ -16,7 +16,9 @@
specific language governing permissions and limitations
under the License.
-#}
-{% set page="new_projects" %}
+{% set page = "new_projects" %}
+{% set hide_left_bar = True %}
+
{% extends 'allura:templates/site_admin.html' %}
{% macro _paging() %}
@@ -86,20 +88,20 @@
}
th.header {
background-image: url("{{g.forge_static('images/bg.gif')}}");
- cursor: pointer;
- font-weight: bold;
- background-repeat: no-repeat;
- background-position: center left;
- padding-left: 20px;
+ cursor: pointer;
+ font-weight: bold;
+ background-repeat: no-repeat;
+ background-position: center left;
+ padding-left: 20px;
}
- th.headerSortUp {
+ th.headerSortUp {
background-image: url("{{g.forge_static('images/asc.gif')}}");
- background-color: #6bb3fd;
+ background-color: #6bb3fd;
}
- th.headerSortDown {
+ th.headerSortDown {
background-image: url("{{g.forge_static('images/desc.gif')}}");
- background-color: #6bb3fd;
- }
+ background-color: #6bb3fd;
+ }
</style>
{% endblock %}
http://git-wip-us.apache.org/repos/asf/allura/blob/a9883cd2/Allura/allura/templates/site_admin_search.html
----------------------------------------------------------------------
diff --git a/Allura/allura/templates/site_admin_search.html b/Allura/allura/templates/site_admin_search.html
index 7345c4d..108b39b 100644
--- a/Allura/allura/templates/site_admin_search.html
+++ b/Allura/allura/templates/site_admin_search.html
@@ -19,6 +19,7 @@
{% set page_num = page %}
{% set page = 'search_results' %}
+{% set hide_left_bar = True %}
{% extends 'allura:templates/site_admin.html' %}
[13/26] git commit: [#7656] ticket:648 Change display name index type
to allow not strict matches when searching
Posted by br...@apache.org.
[#7656] ticket:648 Change display name index type to allow not strict matches when searching
Project: http://git-wip-us.apache.org/repos/asf/allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/allura/commit/5029fc00
Tree: http://git-wip-us.apache.org/repos/asf/allura/tree/5029fc00
Diff: http://git-wip-us.apache.org/repos/asf/allura/diff/5029fc00
Branch: refs/heads/master
Commit: 5029fc008ece84e1c8cd5270ecc75a3e3145e106
Parents: cd86a18
Author: Igor Bondarenko <je...@gmail.com>
Authored: Tue Sep 9 14:15:41 2014 +0300
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Fri Sep 19 19:35:40 2014 +0000
----------------------------------------------------------------------
Allura/allura/model/auth.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/allura/blob/5029fc00/Allura/allura/model/auth.py
----------------------------------------------------------------------
diff --git a/Allura/allura/model/auth.py b/Allura/allura/model/auth.py
index 0f04f6b..6cca818 100644
--- a/Allura/allura/model/auth.py
+++ b/Allura/allura/model/auth.py
@@ -302,7 +302,7 @@ class User(MappedClass, ActivityNode, ActivityObject, SearchIndexable):
email_address_s=self.get_pref('email_address'),
email_format_s=self.get_pref('email_format'),
disable_user_messages_b=self.get_pref('disable_user_messages'),
- display_name_s=self.get_pref('display_name'),
+ display_name_t=self.get_pref('display_name'),
sex_s=self.get_pref('sex'),
birthdate_dt=self.get_pref('birthdate'),
localization_s=localization,
[10/26] git commit: [#7656] ticket:648 Move translate_query to
SearchIndexable
Posted by br...@apache.org.
[#7656] ticket:648 Move translate_query to SearchIndexable
Project: http://git-wip-us.apache.org/repos/asf/allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/allura/commit/04b0016e
Tree: http://git-wip-us.apache.org/repos/asf/allura/tree/04b0016e
Diff: http://git-wip-us.apache.org/repos/asf/allura/diff/04b0016e
Branch: refs/heads/master
Commit: 04b0016e13186317c238012debf1edf4a57cab8c
Parents: 6c7ca9a
Author: Igor Bondarenko <je...@gmail.com>
Authored: Tue Sep 9 13:15:17 2014 +0300
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Fri Sep 19 19:35:39 2014 +0000
----------------------------------------------------------------------
Allura/allura/lib/search.py | 18 ++++++++++++++++++
Allura/allura/model/artifact.py | 18 ------------------
Allura/allura/model/project.py | 5 -----
3 files changed, 18 insertions(+), 23 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/allura/blob/04b0016e/Allura/allura/lib/search.py
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/search.py b/Allura/allura/lib/search.py
index 49a3ad5..f4f177a 100644
--- a/Allura/allura/lib/search.py
+++ b/Allura/allura/lib/search.py
@@ -100,6 +100,24 @@ class SearchIndexable(object):
doc['text'] = jinja2.Markup.escape(text).striptags()
return doc
+ @classmethod
+ def translate_query(cls, q, fields):
+ """Return a translated Solr query (``q``), where generic field
+ identifiers are replaced by the 'strongly typed' versions defined in
+ ``fields``.
+
+ """
+ # Replace longest fields first to avoid problems when field names have
+ # the same suffixes, but different field types. E.g.:
+ # query 'shortname:test' with fields.keys() == ['name_t', 'shortname_s']
+ # will be translated to 'shortname_t:test', which makes no sense
+ fields = sorted(fields.keys(), key=len, reverse=True)
+ for f in fields:
+ if '_' in f:
+ base, typ = f.rsplit('_', 1)
+ q = q.replace(base + ':', f + ':')
+ return q
+
class SearchError(SolrError):
pass
http://git-wip-us.apache.org/repos/asf/allura/blob/04b0016e/Allura/allura/model/artifact.py
----------------------------------------------------------------------
diff --git a/Allura/allura/model/artifact.py b/Allura/allura/model/artifact.py
index 2639021..ccb6b42 100644
--- a/Allura/allura/model/artifact.py
+++ b/Allura/allura/model/artifact.py
@@ -130,24 +130,6 @@ class Artifact(MappedClass, SearchIndexable):
def attachment_class(cls):
raise NotImplementedError, 'attachment_class'
- @classmethod
- def translate_query(cls, q, fields):
- """Return a translated Solr query (``q``), where generic field
- identifiers are replaced by the 'strongly typed' versions defined in
- ``fields``.
-
- """
- # Replace longest fields first to avoid problems when field names have
- # the same suffixes, but different field types. E.g.:
- # query 'shortname:test' with fields.keys() == ['name_t', 'shortname_s']
- # will be translated to 'shortname_t:test', which makes no sense
- fields = sorted(fields.keys(), key=len, reverse=True)
- for f in fields:
- if '_' in f:
- base, typ = f.rsplit('_', 1)
- q = q.replace(base + ':', f + ':')
- return q
-
@LazyProperty
def ref(self):
"""Return :class:`allura.model.index.ArtifactReference` for this
http://git-wip-us.apache.org/repos/asf/allura/blob/04b0016e/Allura/allura/model/project.py
----------------------------------------------------------------------
diff --git a/Allura/allura/model/project.py b/Allura/allura/model/project.py
index d8c3180..2ecb530 100644
--- a/Allura/allura/model/project.py
+++ b/Allura/allura/model/project.py
@@ -252,11 +252,6 @@ class Project(SearchIndexable, MappedClass, ActivityNode, ActivityObject):
# transient properties
notifications_disabled = False
- @classmethod
- def translate_query(cls, q, fields):
- from .artifact import Artifact
- return Artifact.translate_query(q, fields)
-
@property
def activity_name(self):
return self.name
[22/26] git commit: [#7656] ticket:648 Fix typo
Posted by br...@apache.org.
[#7656] ticket:648 Fix typo
Project: http://git-wip-us.apache.org/repos/asf/allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/allura/commit/d317e962
Tree: http://git-wip-us.apache.org/repos/asf/allura/tree/d317e962
Diff: http://git-wip-us.apache.org/repos/asf/allura/diff/d317e962
Branch: refs/heads/master
Commit: d317e9622e41373169dc9534fa8ed3c526b2e366
Parents: de6b775
Author: Igor Bondarenko <je...@gmail.com>
Authored: Tue Sep 9 16:57:58 2014 +0300
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Fri Sep 19 19:35:41 2014 +0000
----------------------------------------------------------------------
Allura/allura/lib/search.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/allura/blob/d317e962/Allura/allura/lib/search.py
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/search.py b/Allura/allura/lib/search.py
index 1c3ba8a..525fab3 100644
--- a/Allura/allura/lib/search.py
+++ b/Allura/allura/lib/search.py
@@ -182,7 +182,7 @@ def site_admin_search(model, q, field, **kw):
Raises SearchError if SOLR returns an error.
"""
- # first, grab a object and get the fields that it indexes
+ # first, grab an object and get the fields that it indexes
obj = model.query.find().first()
if obj is None:
return # if there are no objects, we won't find anything
[25/26] git commit: [#7656] ticket:654 Small amends to layout
Posted by br...@apache.org.
[#7656] ticket:654 Small amends to layout
Project: http://git-wip-us.apache.org/repos/asf/allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/allura/commit/7cb33a49
Tree: http://git-wip-us.apache.org/repos/asf/allura/tree/7cb33a49
Diff: http://git-wip-us.apache.org/repos/asf/allura/diff/7cb33a49
Branch: refs/heads/master
Commit: 7cb33a498110a04435ca5a0c2c3fbf9c0ee05221
Parents: 1b7aea6
Author: Igor Bondarenko <je...@gmail.com>
Authored: Thu Sep 18 10:02:47 2014 +0300
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Fri Sep 19 19:35:42 2014 +0000
----------------------------------------------------------------------
Allura/allura/lib/widgets/forms.py | 3 ++-
Allura/allura/templates/site_admin_search.html | 11 +++++++----
2 files changed, 9 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/allura/blob/7cb33a49/Allura/allura/lib/widgets/forms.py
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/widgets/forms.py b/Allura/allura/lib/widgets/forms.py
index 0d25079..55700b1 100644
--- a/Allura/allura/lib/widgets/forms.py
+++ b/Allura/allura/lib/widgets/forms.py
@@ -1086,6 +1086,7 @@ class AdminSearchForm(ForgeForm):
ForgeForm.defaults,
action='',
method='get',
+ style='wide',
submit_text=None)
def __init__(self, fields, *args, **kw):
@@ -1102,7 +1103,7 @@ class AdminSearchForm(ForgeForm):
name='f',
show_label=False,
options=search_fields),
- ew.InputField(name='q', show_label=False, attrs={'style': 'width: 500px'}),
+ ew.InputField(name='q', show_label=False, attrs={'style': 'width: 600px'}),
ew.SubmitButton(
show_label=False,
attrs={
http://git-wip-us.apache.org/repos/asf/allura/blob/7cb33a49/Allura/allura/templates/site_admin_search.html
----------------------------------------------------------------------
diff --git a/Allura/allura/templates/site_admin_search.html b/Allura/allura/templates/site_admin_search.html
index b0d86a8..7345c4d 100644
--- a/Allura/allura/templates/site_admin_search.html
+++ b/Allura/allura/templates/site_admin_search.html
@@ -26,9 +26,9 @@
{% block header %}Search {{ type_s }}s{% endblock %}
{% block content %}
- <div class="grid-19"><p><a href="/nf/admin">Back to Site Admin Home</a></p></div>
+ <div class="grid-23"><p><a href="/nf/admin">Back to Site Admin Home</a></p></div>
- <div class="grid-19">
+ <div class="grid-23">
{{ c.search_form.display(q=q, f=f) }}
</div>
@@ -38,7 +38,7 @@
</table>
{% endif %}
- <div class="grid-19">
+ <div class="grid-23">
{{c.page_list.display(limit=limit, page=page_num, count=count)}}
{{c.page_size.display(limit=limit, page=page_num, count=count)}}
</div>
@@ -46,7 +46,10 @@
{% block extra_css %}
<style>
- table { clear: both; }
+ .pad table {
+ clear: both;
+ width: 900px;
+ }
table th {
text-align: left;
padding: 5px 10px;
[21/26] git commit: [#7656] ticket:654 Removed sidebar from search
result pages
Posted by br...@apache.org.
[#7656] ticket:654 Removed sidebar from search result pages
Project: http://git-wip-us.apache.org/repos/asf/allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/allura/commit/ab4961f5
Tree: http://git-wip-us.apache.org/repos/asf/allura/tree/ab4961f5
Diff: http://git-wip-us.apache.org/repos/asf/allura/diff/ab4961f5
Branch: refs/heads/master
Commit: ab4961f58f943fe085980008e233689fdde485d5
Parents: 38cd390
Author: Aleksey 'LXj' Alekseyev <go...@gmail.com>
Authored: Tue Sep 16 16:19:07 2014 +0300
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Fri Sep 19 19:35:41 2014 +0000
----------------------------------------------------------------------
Allura/allura/templates/site_admin.html | 2 +-
Allura/allura/templates/site_admin_search.html | 10 ++++++++--
2 files changed, 9 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/allura/blob/ab4961f5/Allura/allura/templates/site_admin.html
----------------------------------------------------------------------
diff --git a/Allura/allura/templates/site_admin.html b/Allura/allura/templates/site_admin.html
index d83f06e..0256563 100644
--- a/Allura/allura/templates/site_admin.html
+++ b/Allura/allura/templates/site_admin.html
@@ -20,7 +20,7 @@
{% from 'allura:templates/jinja_master/sidebar_menu.html' import sidebar_item with context %}
{% set hide_left_bar=False %}
-{% if page == 'new_projects' %}
+{% if page in ['new_projects', 'search_results'] %}
{% set hide_left_bar=True %}
{% endif %}
{% extends g.theme.master %}
http://git-wip-us.apache.org/repos/asf/allura/blob/ab4961f5/Allura/allura/templates/site_admin_search.html
----------------------------------------------------------------------
diff --git a/Allura/allura/templates/site_admin_search.html b/Allura/allura/templates/site_admin_search.html
index 685f65b..b0d86a8 100644
--- a/Allura/allura/templates/site_admin_search.html
+++ b/Allura/allura/templates/site_admin_search.html
@@ -16,12 +16,18 @@
specific language governing permissions and limitations
under the License.
-#}
+
+{% set page_num = page %}
+{% set page = 'search_results' %}
+
{% extends 'allura:templates/site_admin.html' %}
{% block title %}Search {{ type_s }}s{% endblock %}
{% block header %}Search {{ type_s }}s{% endblock %}
{% block content %}
+ <div class="grid-19"><p><a href="/nf/admin">Back to Site Admin Home</a></p></div>
+
<div class="grid-19">
{{ c.search_form.display(q=q, f=f) }}
</div>
@@ -33,8 +39,8 @@
{% endif %}
<div class="grid-19">
- {{c.page_list.display(limit=limit, page=page, count=count)}}
- {{c.page_size.display(limit=limit, page=page, count=count)}}
+ {{c.page_list.display(limit=limit, page=page_num, count=count)}}
+ {{c.page_size.display(limit=limit, page=page_num, count=count)}}
</div>
{% endblock %}