当前位置: 首页>>代码示例>>Python>>正文


Python Team.get_by_org方法代码示例

本文整理汇总了Python中corehq.apps.orgs.models.Team.get_by_org方法的典型用法代码示例。如果您正苦于以下问题:Python Team.get_by_org方法的具体用法?Python Team.get_by_org怎么用?Python Team.get_by_org使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在corehq.apps.orgs.models.Team的用法示例。


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

示例1: orgs_team_members

# 需要导入模块: from corehq.apps.orgs.models import Team [as 别名]
# 或者: from corehq.apps.orgs.models.Team import get_by_org [as 别名]
def orgs_team_members(request, org, team_id, template="orgs/orgs_team_members.html"):
    #organization and teams
    organization = Organization.get_by_name(org)
    teams = Team.get_by_org(org)
    current_domains = Domain.get_by_organization(org)

    #check that the team exists
    team = Team.get(team_id)
    if team is None:
        raise Http404("Group %s does not exist" % team_id)

    #inspect the members of the team
    member_ids = team.get_member_ids()
    members = WebUser.view("_all_docs", keys=member_ids, include_docs=True).all()
    members.sort(key=lambda user: user.username)

    #inspect the domains of the team
    domain_names = team.get_domains()
    domains = list()
    for name in domain_names:
        domains.append([Domain.get_by_name(name), team.role_label(domain=name)])

    all_org_domains = Domain.get_by_organization(org)
    non_domains = [domain for domain in all_org_domains if domain.name not in domain_names]

    all_org_member_ids = organization.members
    all_org_members = WebUser.view("_all_docs", keys=all_org_member_ids, include_docs=True).all()
    non_members = [member for member in all_org_members if member.user_id not in member_ids]

    vals = dict(org=organization, team=team, teams=teams, members=members, nonmembers=non_members, domains=current_domains, team_domains=domains, team_nondomains=non_domains)
    return render_to_response(request, template, vals)
开发者ID:mchampanis,项目名称:core-hq,代码行数:33,代码来源:views.py

示例2: clean_team

# 需要导入模块: from corehq.apps.orgs.models import Team [as 别名]
# 或者: from corehq.apps.orgs.models.Team import get_by_org [as 别名]
 def clean_team(self):
     data = self.cleaned_data["team"].strip()
     org_teams = Team.get_by_org(self.org_name)
     for t in org_teams:
         if t.name == data:
             raise forms.ValidationError("A team with that name already exists.")
     return data
开发者ID:nikhilvarma22,项目名称:commcare-hq,代码行数:9,代码来源:forms.py

示例3: base_context

# 需要导入模块: from corehq.apps.orgs.models import Team [as 别名]
# 或者: from corehq.apps.orgs.models.Team import get_by_org [as 别名]
def base_context(request, organization, update_form=None):
    return {
        "org": organization,
        "teams": Team.get_by_org(organization.name),
        "domains": sorted(Domain.get_by_organization(organization.name), key=lambda x: x.name),
        "members": organization.get_members(),
        "admin": request.couch_user.is_org_admin(organization.name) or request.couch_user.is_superuser,
        "update_form_empty": not update_form,
        "update_form": update_form or UpdateOrgInfo(initial={'org_title': organization.title, 'email': organization.email,
                                                            'url': organization.url, 'location': organization.location})
    }
开发者ID:dszafranek,项目名称:commcare-hq,代码行数:13,代码来源:views.py

示例4: orgs_remove_project

# 需要导入模块: from corehq.apps.orgs.models import Team [as 别名]
# 或者: from corehq.apps.orgs.models.Team import get_by_org [as 别名]
def orgs_remove_project(request, org):
    domain = request.POST.get("project_name", None)
    if not domain:
        messages.error(request, "You must specify a project name")
    else:
        domain = Domain.get_by_name(domain)
        domain.organization = None
        domain.save()
        for team in Team.get_by_org(org):
            team.delete_domain_membership(domain.name)
            team.save()
        messages.success(request, render_to_string('orgs/partials/undo_remove_project.html',
                                                   {"org": org, "dom": domain}), extra_tags="html")
    return HttpResponseRedirect(reverse(request.POST.get('redirect_url', 'orgs_landing'), args=(org,)))
开发者ID:dszafranek,项目名称:commcare-hq,代码行数:16,代码来源:views.py

示例5: orgs_add_team

# 需要导入模块: from corehq.apps.orgs.models import Team [as 别名]
# 或者: from corehq.apps.orgs.models.Team import get_by_org [as 别名]
def orgs_add_team(request, org):
    team_name = request.POST.get("team", None)
    if not team_name:
        messages.error(request, 'You must specify a team name')
        return HttpResponseRedirect(reverse('orgs_teams', args=[org]))

    org_teams = Team.get_by_org(org)
    for t in org_teams:
        if t.name == team_name:
            messages.error(request, 'A team with that name already exists.')
            return HttpResponseRedirect(reverse('orgs_teams', args=[org]))

    team = Team(name=team_name, organization=org)
    team.save()
    messages.success(request, "Team Added!")
    return HttpResponseRedirect(reverse('orgs_teams', args=[org]))
开发者ID:dszafranek,项目名称:commcare-hq,代码行数:18,代码来源:views.py

示例6: orgs_landing

# 需要导入模块: from corehq.apps.orgs.models import Team [as 别名]
# 或者: from corehq.apps.orgs.models.Team import get_by_org [as 别名]
def orgs_landing(request, org, template="orgs/orgs_landing.html", form=None, add_form=None, add_member_form=None, add_team_form=None, update_form=None):
    organization = Organization.get_by_name(org)

    reg_form_empty = not form
    add_form_empty = not add_form
    add_member_form_empty = not add_member_form
    add_team_form_empty = not add_team_form
    update_form_empty = not update_form

    reg_form = form or DomainRegistrationForm(initial={'org': organization.name})
    add_form = add_form or AddProjectForm(org)
    add_member_form = add_member_form or AddMemberForm(org)
    add_team_form = add_team_form or AddTeamForm(org)

    update_form = update_form or UpdateOrgInfo(initial={'org_title': organization.title, 'email': organization.email, 'url': organization.url, 'location': organization.location})

    current_teams = Team.get_by_org(org)
    current_domains = Domain.get_by_organization(org)
    members = [WebUser.get_by_user_id(user_id) for user_id in organization.members]
    vals = dict( org=organization, domains=current_domains, reg_form=reg_form,
                 add_form=add_form, reg_form_empty=reg_form_empty, add_form_empty=add_form_empty, update_form=update_form, update_form_empty=update_form_empty, add_member_form=add_member_form, add_member_form_empty=add_member_form_empty, add_team_form=add_team_form, add_team_form_empty=add_team_form_empty, teams=current_teams, members=members)
    return render_to_response(request, template, vals)
开发者ID:mchampanis,项目名称:core-hq,代码行数:24,代码来源:views.py

示例7: orgs_teams

# 需要导入模块: from corehq.apps.orgs.models import Team [as 别名]
# 或者: from corehq.apps.orgs.models.Team import get_by_org [as 别名]
def orgs_teams(request, org, template="orgs/orgs_teams.html"):
    organization = Organization.get_by_name(org)
    teams = Team.get_by_org(org)
    current_domains = Domain.get_by_organization(org)
    vals = dict(org=organization, teams=teams, domains=current_domains)
    return render_to_response(request, template, vals)
开发者ID:mchampanis,项目名称:core-hq,代码行数:8,代码来源:views.py


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