コード例 #1
0
ファイル: program.py プロジェクト: kripsy/Project
        },
        "program_reader": {
            "display_name": "Reader",
            "type": AttributeInfo.Type.USER_ROLE,
            "filter_by": "_filter_by_program_reader",
        },
    }

    @classmethod
    def _filter_by_program_owner(cls, predicate):
        return cls._filter_by_role("ProgramOwner", predicate)

    @classmethod
    def _filter_by_program_editor(cls, predicate):
        return cls._filter_by_role("ProgramEditor", predicate)

    @classmethod
    def _filter_by_program_reader(cls, predicate):
        return cls._filter_by_role("ProgramReader", predicate)

    @classmethod
    def eager_query(cls):
        from sqlalchemy import orm

        query = super(Program, cls).eager_query()
        return cls.eager_inclusions(query, Program._include_links).options(
            orm.subqueryload('audits'))


track_state_for_class(Program)
コード例 #2
0
      'Final',
      'Effective',
      'Ineffective',
      'Launched',
      'Not Launched',
      'In Scope',
      'Not in Scope',
      'Deprecated',
  ]
  __tablename__ = 'clauses'
  _table_plural = 'clauses'
  _aliases = {
      "url": "Clause URL",
      "description": "Text of Clause",
      "directive": None,
  }

  # pylint: disable=invalid-name
  na = deferred(db.Column(db.Boolean, default=False, nullable=False),
                'Clause')
  notes = deferred(db.Column(db.Text), 'Clause')

  _publish_attrs = [
      'na',
      'notes',
  ]
  _sanitize_html = ['notes']
  _include_links = []

track_state_for_class(Clause)
コード例 #3
0
        return value if value in self.VALID_CONCLUSIONS else ""

    @validates("operationally")
    def validate_opperationally(self, key, value):
        # pylint: disable=unused-argument
        return self.validate_conclusion(value)

    @validates("design")
    def validate_design(self, key, value):
        # pylint: disable=unused-argument
        return self.validate_conclusion(value)

    @classmethod
    def _filter_by_related_creators(cls, predicate):
        return cls._get_relate_filter(predicate, "Creator")

    @classmethod
    def _filter_by_related_assessors(cls, predicate):
        return cls._get_relate_filter(predicate, "Assessor")

    @classmethod
    def _filter_by_related_verifiers(cls, predicate):
        return cls._get_relate_filter(predicate, "Verifier")

    @classmethod
    def _ignore_filter(cls, predicate):
        return None


track_state_for_class(Assessment)
コード例 #4
0
ファイル: access_group.py プロジェクト: gaurav46/ggrc-core
# Copyright (C) 2016 Google Inc.
# Licensed under http://www.apache.org/licenses/LICENSE-2.0 <see LICENSE file>

from ggrc import db
from ggrc.models.mixins import BusinessObject, Timeboxed, CustomAttributable
from ggrc.models.object_document import Documentable
from ggrc.models.object_owner import Ownable
from ggrc.models.object_person import Personable
from ggrc.models.relationship import Relatable
from ggrc.models.track_object_state import HasObjectState, track_state_for_class


class AccessGroup(HasObjectState, CustomAttributable, Personable, Documentable,
                  Relatable, Timeboxed, Ownable, BusinessObject, db.Model):
    __tablename__ = 'access_groups'

    _aliases = {"url": "Access Group URL"}


track_state_for_class(AccessGroup)
コード例 #5
0
ファイル: control.py プロジェクト: runt18/ggrc-core
    @classmethod
    def _filter_by_secondary_assessor(cls, predicate):
        return Person.query.filter((Person.id == cls.secondary_assessor_id)
                                   & (predicate(Person.name)
                                      | predicate(Person.email))).exists()

    @classmethod
    def _filter_by_verify_frequency(cls, predicate):
        return Option.query.filter((Option.id == cls.verify_frequency_id)
                                   & predicate(Option.title)).exists()

    @classmethod
    def eager_query(cls):
        from sqlalchemy import orm
        query = super(Control, cls).eager_query()
        return cls.eager_inclusions(query, Control._include_links).options(
            orm.joinedload('directive'),
            orm.joinedload('principal_assessor'),
            orm.joinedload('secondary_assessor'),
        )

    def log_json(self):
        out_json = super(Control, self).log_json()
        # so that event log can refer to deleted directive
        if self.directive:
            out_json["mapped_directive"] = self.directive.display_name
        return out_json


track_state_for_class(Control)
コード例 #6
0
ファイル: system.py プロジェクト: gaurav46/ggrc-core
                                   & predicate(Option.title)).exists()

    @classmethod
    def eager_query(cls):
        from sqlalchemy import orm

        query = super(SystemOrProcess, cls).eager_query()
        return query.options(orm.joinedload('network_zone'))

    @staticmethod
    def _extra_table_args(cls):
        return (db.Index('ix_{}_is_biz_process'.format(cls.__tablename__),
                         'is_biz_process'), )


track_object_state.track_state_for_class(SystemOrProcess)


class System(CustomAttributable, Documentable, Personable, Relatable, Ownable,
             SystemOrProcess):
    __mapper_args__ = {'polymorphic_identity': False}
    _table_plural = 'systems'

    _aliases = {"url": "System URL"}

    @validates('is_biz_process')
    def validates_is_biz_process(self, key, value):
        return False


class Process(CustomAttributable, Documentable, Personable, Relatable, Ownable,
コード例 #7
0
  _publish_attrs = [
      'na',
      'notes',
  ]
  _sanitize_html = ['notes']
  _include_links = []

  @classmethod
  def _filter_by_directive(cls, predicate):
    types = ["Policy", "Regulation", "Standard", "Contract"]
    dst = Relationship.query \
        .filter(
            (Relationship.source_id == cls.id) &
            (Relationship.source_type == cls.__name__) &
            (Relationship.destination_type.in_(types))) \
        .join(Directive, Directive.id == Relationship.destination_id) \
        .filter(predicate(Directive.slug) | predicate(Directive.title)) \
        .exists()
    src = Relationship.query \
        .filter(
            (Relationship.destination_id == cls.id) &
            (Relationship.destination_type == cls.__name__) &
            (Relationship.source_type.in_(types))) \
        .join(Directive, Directive.id == Relationship.source_id) \
        .filter(predicate(Directive.slug) | predicate(Directive.title)) \
        .exists()
    return dst | src


track_state_for_class(Section)
コード例 #8
0
ファイル: product.py プロジェクト: kripsy/Project
      'version',
  ]
  _sanitize_html = ['version', ]
  _aliases = {
      "url": "Product URL",
      "kind": {
          "display_name": "Kind/Type",
          "filter_by": "_filter_by_kind",
      },
  }

  @validates('kind')
  def validate_product_options(self, key, option):
    return validate_option(
        self.__class__.__name__, key, option, 'product_type')

  @classmethod
  def _filter_by_kind(cls, predicate):
    return Option.query.filter(
        (Option.id == cls.kind_id) & predicate(Option.title)
    ).exists()

  @classmethod
  def eager_query(cls):
    from sqlalchemy import orm

    query = super(Product, cls).eager_query()
    return query.options(orm.joinedload('kind'))

track_state_for_class(Product)