本文整理汇总了Python中mozillians.groups.models.Group.get_functional_areas方法的典型用法代码示例。如果您正苦于以下问题:Python Group.get_functional_areas方法的具体用法?Python Group.get_functional_areas怎么用?Python Group.get_functional_areas使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mozillians.groups.models.Group
的用法示例。
在下文中一共展示了Group.get_functional_areas方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_get_functional_areas
# 需要导入模块: from mozillians.groups.models import Group [as 别名]
# 或者: from mozillians.groups.models.Group import get_functional_areas [as 别名]
def test_get_functional_areas(self):
GroupFactory.create()
GroupFactory.create()
UserFactory.create()
UserFactory.create()
cgroup_1 = GroupFactory.create(functional_area=True)
GroupFactory.create(functional_area=False)
eq_(set(Group.get_functional_areas()), set([cgroup_1]))
示例2: get_context_data
# 需要导入模块: from mozillians.groups.models import Group [as 别名]
# 或者: from mozillians.groups.models.Group import get_functional_areas [as 别名]
def get_context_data(self, **kwargs):
"""Override method to pass more context data in the template."""
context_data = super(PhonebookSearchView, self).get_context_data(**kwargs)
context_data['functional_areas'] = Group.get_functional_areas()
context_data['show_pagination'] = context_data['is_paginated']
context_data['search_form'] = context_data['form']
context_data['country'] = self.kwargs.get('country')
context_data['region'] = self.kwargs.get('region')
context_data['city'] = self.kwargs.get('city')
return context_data
示例3: betasearch
# 需要导入模块: from mozillians.groups.models import Group [as 别名]
# 或者: from mozillians.groups.models.Group import get_functional_areas [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 get_functional_areas [as 别名]
def search(request):
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/search.html", d)
示例5: index_functional_areas
# 需要导入模块: from mozillians.groups.models import Group [as 别名]
# 或者: from mozillians.groups.models.Group import get_functional_areas [as 别名]
def index_functional_areas(request):
"""Lists all functional areas."""
query = Group.get_functional_areas()
template = 'groups/index_areas.html'
return _list_groups(request, template, query)