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


Python Organization.all方法代码示例

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


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

示例1: dispatch

# 需要导入模块: from organization import Organization [as 别名]
# 或者: from organization.Organization import all [as 别名]
    def dispatch(self, *args, **kwargs):
        " All requests must have valid, in-date activation codes. "

        self.page_blocks = page_db.get_page_block_dict()

        self.activation_code = self.request.get('code')
        if not self.activation_code:
            self.abort(404)

        # lookup org by activation code
        orgs_by_code = Organization.all() \
            .filter('activation_code', self.activation_code)
        if orgs_by_code.count() != 1:
            self.abort(404)
        self.org_by_code = orgs_by_code[0]

        # send response if already activated
        if self.org_by_code.is_active:
            self.render(
                already_activated_template,
                org=self.org_by_code
            )
            return

        # send response if too late
        if self.org_by_code.activate_by < datetime.datetime.utcnow():
            self.render(
                activation_too_late_template,
                org=self.org_by_code
            )
            return

        # continue handling request
        super(ActivationHandler, self).dispatch(*args, **kwargs)
开发者ID:DuaneNClark,项目名称:crisiscleanup,代码行数:36,代码来源:activation_handler.py

示例2: organizations

# 需要导入模块: from organization import Organization [as 别名]
# 或者: from organization.Organization import all [as 别名]
  def organizations(self):
      """
      Active, verified organizations related to this incident.

      Handles current and legacy incident/s properties.
      """
      from organization import Organization  # avoid circular import

      # lookup using new incidents field
      orgs = list(
          Organization.all().filter('incidents', self.key())
              .filter('org_verified', True)
              .filter('is_active', True)
      )

      # build list of id and look for global admin
      org_ids = set()
      seen_global_admin = False
      for org in orgs:
          if org.is_global_admin:
              seen_global_admin = True
          org_id = org.key().id()
          if org_id not in org_ids:
              org_ids.add(org_id)

      # check legacy incident field
      legacy_field_orgs = Organization.all().filter('incident', self.key()) \
          .filter('org_verified', True) \
          .filter('is_active', True)
      for org in legacy_field_orgs:
          if org.key().id() not in org_ids:
              orgs.append(org)

      # prepend global admin if not encountered
      if not seen_global_admin:
          orgs = (
              list(Organization.all().filter('name', 'Admin')) +
              orgs
          )
      return orgs
开发者ID:DuaneNClark,项目名称:crisiscleanup,代码行数:42,代码来源:event_db.py

示例3: create_work_order_search_form

# 需要导入模块: from organization import Organization [as 别名]
# 或者: from organization.Organization import all [as 别名]
def create_work_order_search_form(events, work_types, limiting_event=None):
    events_by_recency = sorted(events, key=lambda event: event.key().id(), reverse=True)

    # determine orgs and work types to include
    if limiting_event:
        if limiting_event.key() not in [e.key() for e in events]:
            raise Exception("Event %s unavailable" % limiting_event)
        orgs = Organization.all().filter('incidents', limiting_event.key())
        work_types = [
            site.work_type for site
            in Query(Site, projection=['work_type'], distinct=True) \
                .filter('event', limiting_event.key())
            if site.work_type in work_types
        ]
    else:
        orgs = Organization.all().filter('incidents in', [event for event in events])

    class WorkOrderSearchForm(Form):

        def __init__(self, *args, **kwargs):
            super(WorkOrderSearchForm, self).__init__(*args, **kwargs)
            self.offset.data = 0  # offset set by the form should always be 0

        offset = HiddenField(default="0")
        order = HiddenField()
        event = SelectField(
            choices=[
                (e.key(), e.name) for e in events_by_recency
            ],
            default=events_by_recency[0].key()
        )
        query = TextField("Search")
        reporting_org = SelectField(
            choices=[('', '')] + [
                (org.key(), org.name) for org in orgs
            ],
            default=''
        )
        claiming_org = SelectField(
            choices=[('', '')] + [
                (org.key(), org.name) for org in orgs
            ],
            default=''
        )
        work_type = SelectField(
            choices=[('', '')] + [
                (work_type, work_type) for work_type in work_types
            ],
            default=''
        )
        status = SelectField(
            choices=[('', '')] + [
                (s, s) for s in Site.status.choices
            ],
            default=''
        )
        per_page = SelectField(
            choices=[
                (n, n) for n in [10, 50, 100, 250]
            ],
            coerce=int,
            default=10
        )

    return WorkOrderSearchForm
开发者ID:DuaneNClark,项目名称:crisiscleanup,代码行数:67,代码来源:admin_view_work_orders_handler.py


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