• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python models.Group类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中mozillians.groups.models.Group的典型用法代码示例。如果您正苦于以下问题:Python Group类的具体用法?Python Group怎么用?Python Group使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了Group类的19个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: group_add_edit

def group_add_edit(request, url=None):
    """
    Add or edit a group.  (If a url is passed in, we're editing.)
    """

    profile = request.user.userprofile
    if url:
        # Get the group to edit
        group = get_object_or_404(Group, url=url)
        # Only a group curator or an admin is allowed to edit a group
        is_curator = profile == group.curator
        if not (is_curator or request.user.is_superuser):
            messages.error(request, _('You must be a curator or an admin to edit a group'))
            return redirect(reverse('groups:show_group', args=[group.url]))
    else:
        group = Group(curator=profile)

    form_class = SuperuserGroupForm if request.user.is_superuser else GroupForm

    form = form_class(request.POST or None, instance=group)
    if form.is_valid():
        group = form.save()
        # Ensure curator is in the group when it's created
        if profile == group.curator and not group.has_member(profile):
            group.add_member(profile)
        return redirect(reverse('groups:show_group', args=[group.url]))

    context = {
        'form': form,
        'creating': url is None,
        'group': group if url else None,
    }
    return render(request, 'groups/add_edit.html', context)
开发者ID:CodeBreaker24,项目名称:mozillians,代码行数:33,代码来源:views.py


示例2: search

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)
开发者ID:SudeepSrinivas,项目名称:mozillians,代码行数:51,代码来源:views.py


示例3: betasearch

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)
开发者ID:maheshkkumar,项目名称:mozillians,代码行数:49,代码来源:views.py


示例4: test_search_distict_results

 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)
开发者ID:Acidburn0zzz,项目名称:mozillians,代码行数:7,代码来源:test_models.py


示例5: index_groups

def index_groups(request):
    """Lists all public groups (in use) on Mozillians."""
    # Omit functional areas, invisible groups, and groups with
    # no vouched members
    query = Group.get_non_functional_areas(members__is_vouched=True)
    template = 'groups/index_groups.html'
    return _list_groups(request, template, query)
开发者ID:anukin,项目名称:mozillians,代码行数:7,代码来源:views.py


示例6: search

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)
开发者ID:rahulrrixe,项目名称:mozillians,代码行数:47,代码来源:views.py


示例7: test_get_functional_areas

 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]))
开发者ID:Acidburn0zzz,项目名称:mozillians,代码行数:8,代码来源:test_models.py


示例8: test_get_curated

 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]))
开发者ID:Narrator,项目名称:mozillians,代码行数:8,代码来源:test_models.py


示例9: index_groups

def index_groups(request):
    """Lists all public groups (in use) on Mozillians.

    Doesn't list functional areas, invisible groups, and groups with
    no vouched members
    """
    query = Group.get_non_functional_areas()
    template = 'groups/index_groups.html'
    return _list_groups(request, template, query)
开发者ID:CDees,项目名称:mozillians,代码行数:9,代码来源:views.py


示例10: home

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")
开发者ID:erinversfeld,项目名称:mozillians-new,代码行数:9,代码来源:views.py


示例11: get_context_data

 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
开发者ID:johngian,项目名称:mozillians,代码行数:10,代码来源:views.py


示例12: index_groups

def index_groups(request):
    """Lists all public groups (in use) on Mozillians.

    Doesn't list functional areas, invisible groups, and groups with
    no vouched members
    """

    group_form = forms.CreateGroupForm(request.POST or None)
    if group_form.is_valid():
        group = group_form.save()
        group.curators.add(request.user.userprofile)
        return redirect(reverse('groups:group_edit', args=[group.url]))

    query = Group.get_non_functional_areas()
    template = 'groups/index_groups.html'
    context = {
        'group_form': group_form
    }
    return _list_groups(request, template, query, context)
开发者ID:ppapadeas,项目名称:mozillians,代码行数:19,代码来源:views.py


示例13: test_search

    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]))
开发者ID:Acidburn0zzz,项目名称:mozillians,代码行数:6,代码来源:test_models.py


示例14: index_functional_areas

def index_functional_areas(request):
    """Lists all curated groups."""
    query = Group.get_curated()
    template = "groups/areas.html"
    return _list_groups(request, template, query)
开发者ID:prafullakiran,项目名称:mozillians,代码行数:5,代码来源:views.py


示例15: test_search_matches_alias

 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]))
开发者ID:Acidburn0zzz,项目名称:mozillians,代码行数:4,代码来源:test_models.py


示例16: test_search_no_query

 def test_search_no_query(self):
     eq_(len(Group.search('invalid')), 0)
开发者ID:Acidburn0zzz,项目名称:mozillians,代码行数:2,代码来源:test_models.py


示例17: test_search_case_insensitive

 def test_search_case_insensitive(self):
     group = GroupFactory.create(visible=True)
     query = 'GROUP'
     eq_(set(Group.search(query)), set([group]))
开发者ID:Acidburn0zzz,项目名称:mozillians,代码行数:4,代码来源:test_models.py


示例18: index_functional_areas

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)
开发者ID:CodeBreaker24,项目名称:mozillians,代码行数:5,代码来源:views.py


示例19: test_search_include_all

 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]))
开发者ID:Narrator,项目名称:mozillians,代码行数:6,代码来源:test_models.py



注:本文中的mozillians.groups.models.Group类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python tests.GroupAliasFactory类代码示例发布时间:2022-05-27
下一篇:
Python tests.CountryFactory类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap