本文整理汇总了Python中mozillians.groups.models.Group.search方法的典型用法代码示例。如果您正苦于以下问题:Python Group.search方法的具体用法?Python Group.search怎么用?Python Group.search使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mozillians.groups.models.Group
的用法示例。
在下文中一共展示了Group.search方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_search_distict_results
# 需要导入模块: from mozillians.groups.models import Group [as 别名]
# 或者: from mozillians.groups.models.Group import search [as 别名]
def test_search_distict_results(self):
group_1 = GroupFactory.create(name='automation', visible=True)
GroupAliasFactory.create(alias=group_1, name='automation development')
GroupAliasFactory.create(alias=group_1, name='automation services')
results = Group.search('automation')
eq_(len(results), 1)
eq_(results[0], group_1)
示例2: search
# 需要导入模块: from mozillians.groups.models import Group [as 别名]
# 或者: from mozillians.groups.models.Group import search [as 别名]
def search(request):
num_pages = 0
limit = None
people = []
show_pagination = False
form = forms.SearchForm(request.GET)
groups = None
curated_groups = None
if form.is_valid():
query = form.cleaned_data.get('q', u'')
limit = form.cleaned_data['limit']
include_non_vouched = form.cleaned_data['include_non_vouched']
page = request.GET.get('page', 1)
curated_groups = Group.get_curated()
public = not (request.user.is_authenticated()
and request.user.userprofile.is_vouched)
profiles = UserProfile.search(query, public=public,
include_non_vouched=include_non_vouched)
if not public:
groups = Group.search(query)
paginator = Paginator(profiles, limit)
try:
people = paginator.page(page)
except PageNotAnInteger:
people = paginator.page(1)
except EmptyPage:
people = paginator.page(paginator.num_pages)
if profiles.count() == 1 and not groups:
return redirect('phonebook:profile_view', people[0].user.username)
if paginator.count > forms.PAGINATION_LIMIT:
show_pagination = True
num_pages = len(people.paginator.page_range)
d = dict(people=people,
search_form=form,
limit=limit,
show_pagination=show_pagination,
num_pages=num_pages,
groups=groups,
curated_groups=curated_groups)
if request.is_ajax():
return render(request, 'search_ajax.html', d)
return render(request, 'phonebook/search.html', d)
示例3: betasearch
# 需要导入模块: from mozillians.groups.models import Group [as 别名]
# 或者: from mozillians.groups.models.Group import search [as 别名]
def betasearch(request):
"""This view is for researching new search and data filtering
options. It will eventually replace the 'search' view.
This view is behind the 'betasearch' waffle flag.
"""
limit = None
people = []
show_pagination = False
form = forms.SearchForm(request.GET)
groups = None
functional_areas = None
if form.is_valid():
query = form.cleaned_data.get('q', u'')
limit = form.cleaned_data['limit']
include_non_vouched = form.cleaned_data['include_non_vouched']
page = request.GET.get('page', 1)
functional_areas = Group.get_functional_areas()
public = not (request.user.is_authenticated()
and request.user.userprofile.is_vouched)
profiles = UserProfile.search(query, public=public,
include_non_vouched=include_non_vouched)
if not public:
groups = Group.search(query)
paginator = Paginator(profiles, limit)
try:
people = paginator.page(page)
except PageNotAnInteger:
people = paginator.page(1)
except EmptyPage:
people = paginator.page(paginator.num_pages)
if profiles.count() == 1 and not groups:
return redirect('phonebook:profile_view', people[0].user.username)
show_pagination = paginator.count > settings.ITEMS_PER_PAGE
d = dict(people=people,
search_form=form,
limit=limit,
show_pagination=show_pagination,
groups=groups,
functional_areas=functional_areas)
return render(request, 'phonebook/betasearch.html', d)
示例4: search
# 需要导入模块: from mozillians.groups.models import Group [as 别名]
# 或者: from mozillians.groups.models.Group import search [as 别名]
def search(request):
limit = None
people = []
show_pagination = False
form = forms.SearchForm(request.GET)
groups = None
curated_groups = None
if form.is_valid():
query = form.cleaned_data.get("q", u"")
limit = form.cleaned_data["limit"]
include_non_vouched = form.cleaned_data["include_non_vouched"]
page = request.GET.get("page", 1)
curated_groups = Group.get_curated()
public = not (request.user.is_authenticated() and request.user.userprofile.is_vouched)
profiles = UserProfile.search(query, public=public, include_non_vouched=include_non_vouched)
if not public:
groups = Group.search(query)
paginator = Paginator(profiles, limit)
try:
people = paginator.page(page)
except PageNotAnInteger:
people = paginator.page(1)
except EmptyPage:
people = paginator.page(paginator.num_pages)
if profiles.count() == 1 and not groups:
return redirect("phonebook:profile_view", people[0].user.username)
show_pagination = paginator.count > settings.ITEMS_PER_PAGE
d = dict(
people=people,
search_form=form,
limit=limit,
show_pagination=show_pagination,
groups=groups,
curated_groups=curated_groups,
)
if request.is_ajax():
return render(request, "search_ajax.html", d)
return render(request, "phonebook/search.html", d)
示例5: test_search_matches_alias
# 需要导入模块: from mozillians.groups.models import Group [as 别名]
# 或者: from mozillians.groups.models.Group import search [as 别名]
def test_search_matches_alias(self):
group_1 = GroupFactory.create(name='lalo', visible=True)
GroupAliasFactory.create(alias=group_1, name='foo')
eq_(set(Group.search('foo')), set([group_1]))
示例6: test_search_no_query
# 需要导入模块: from mozillians.groups.models import Group [as 别名]
# 或者: from mozillians.groups.models.Group import search [as 别名]
def test_search_no_query(self):
eq_(len(Group.search('invalid')), 0)
示例7: test_search_case_insensitive
# 需要导入模块: from mozillians.groups.models import Group [as 别名]
# 或者: from mozillians.groups.models.Group import search [as 别名]
def test_search_case_insensitive(self):
group = GroupFactory.create(visible=True)
query = 'GROUP'
eq_(set(Group.search(query)), set([group]))
示例8: test_search
# 需要导入模块: from mozillians.groups.models import Group [as 别名]
# 或者: from mozillians.groups.models.Group import search [as 别名]
def test_search(self):
group = GroupFactory.create(visible=True)
GroupFactory.create(visible=False)
eq_(set(Group.search(group.name)), set([group]))
eq_(set(Group.search('roup'.format(group.name))), set([group]))
示例9: test_search_include_all
# 需要导入模块: from mozillians.groups.models import Group [as 别名]
# 或者: from mozillians.groups.models.Group import search [as 别名]
def test_search_include_all(self):
"""Test Group searching not limited to auto_complete_only."""
group_1 = GroupFactory.create(name='lola', auto_complete=True)
group_2 = GroupFactory.create(name='lolo', auto_complete=False)
eq_(set(Group.search('lo', auto_complete_only=False)),
set([group_1, group_2]))