本文整理汇总了Python中mozillians.groups.models.Group.get_curated方法的典型用法代码示例。如果您正苦于以下问题:Python Group.get_curated方法的具体用法?Python Group.get_curated怎么用?Python Group.get_curated使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mozillians.groups.models.Group
的用法示例。
在下文中一共展示了Group.get_curated方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_get_curated
# 需要导入模块: from mozillians.groups.models import Group [as 别名]
# 或者: from mozillians.groups.models.Group import get_curated [as 别名]
def test_get_curated(self):
GroupFactory.create()
GroupFactory.create()
user_1 = UserFactory.create()
user_2 = UserFactory.create()
cgroup_1 = GroupFactory.create(steward=user_1.userprofile)
cgroup_2 = GroupFactory.create(steward=user_2.userprofile)
eq_(set(Group.get_curated()), set([cgroup_1, cgroup_2]))
示例2: home
# 需要导入模块: from mozillians.groups.models import Group [as 别名]
# 或者: from mozillians.groups.models.Group import get_curated [as 别名]
def home(request):
if request.user.is_authenticated():
profile = request.user.get_profile()
my_groups = profile.groups.exclude(steward=None).order_by("name")
curated_groups = Group.get_curated()
data = dict(groups=my_groups, curated_groups=curated_groups)
return render(request, "phonebook/home.html", data)
else:
return render(request, "phonebook/home.html")
示例3: search
# 需要导入模块: from mozillians.groups.models import Group [as 别名]
# 或者: from mozillians.groups.models.Group import get_curated [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)
示例4: search
# 需要导入模块: from mozillians.groups.models import Group [as 别名]
# 或者: from mozillians.groups.models.Group import get_curated [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: index_functional_areas
# 需要导入模块: from mozillians.groups.models import Group [as 别名]
# 或者: from mozillians.groups.models.Group import get_curated [as 别名]
def index_functional_areas(request):
"""Lists all curated groups."""
query = Group.get_curated()
template = 'groups/index_areas.html'
return _list_groups(request, template, query)