Exemple #1
0
    def _clone(self, source_object):
        """Clone audit and all relevant attributes.

    Keeps the internals of actual audit cloning and everything that is related
    to audit itself (auditors, audit firm, context setting,
    custom attribute values, etc.)
    """
        from ggrc_basic_permissions import create_audit_context

        data = {
            "title": source_object.generate_attribute("title"),
            "description": source_object.description,
            "audit_firm": source_object.audit_firm,
            "start_date": source_object.start_date,
            "end_date": source_object.end_date,
            "program": source_object.program,
            "status": source_object.VALID_STATES[0],
            "report_start_date": source_object.report_start_date,
            "report_end_date": source_object.report_end_date,
            "contact": source_object.contact
        }

        self.update_attrs(data)
        db.session.flush()

        create_audit_context(self)
        self._clone_auditors(source_object)
        self.clone_custom_attribute_values(source_object)
Exemple #2
0
  def _clone(self, source_object):
    """Clone audit and all relevant attributes.

    Keeps the internals of actual audit cloning and everything that is related
    to audit itself (auditors, audit firm, context setting,
    custom attribute values, etc.)
    """
    from ggrc_basic_permissions import create_audit_context

    data = {
        "title": source_object.generate_attribute("title"),
        "description": source_object.description,
        "audit_firm": source_object.audit_firm,
        "start_date": source_object.start_date,
        "end_date": source_object.end_date,
        "program": source_object.program,
        "status": source_object.VALID_STATES[0],
        "report_start_date": source_object.report_start_date,
        "report_end_date": source_object.report_end_date,
        "contact": source_object.contact
    }

    self.update_attrs(data)
    db.session.flush()

    create_audit_context(self)
    self._clone_auditors(source_object)
    self.clone_custom_attribute_values(source_object)
Exemple #3
0
    def _clone(self, source_object):
        """Clone audit and all relevant attributes.

    Keeps the internals of actual audit cloning and everything that is related
    to audit itself (auditors, audit firm, context setting,
    custom attribute values, etc.)
    """

        # NOTE. Currently this function is called from Restful.collection_posted
        # hook. The following operations are performed:
        # 1) create new object, call json_create(), where attributes will be set
        #    with value validation
        # 2) current function is called from(Restful.collection_posted
        #    which overrides some attributes, attribute validator for these
        #    attributes are called
        # So, validation for those attrs are called twice!
        # One corner case of this behavior is validation of field "title".
        # title cannot be None, and because title validation is performed before
        # this function, API request MUST contain non-empty title in dict,
        # however the value will be overridden and re-validated in this function!

        from ggrc_basic_permissions import create_audit_context
        data = {
            "title": source_object.generate_attribute("title"),
            "description": source_object.description,
            "audit_firm": source_object.audit_firm,
            "start_date": source_object.start_date,
            "end_date": source_object.end_date,
            "last_deprecated_date": source_object.last_deprecated_date,
            "program": source_object.program,
            "status": source_object.VALID_STATES[0],
            "report_start_date": source_object.report_start_date,
            "report_end_date": source_object.report_end_date
        }

        self.update_attrs(data)
        db.session.flush()

        create_audit_context(self)
        self.clone_acls(source_object)
        self.clone_custom_attribute_values(source_object)
Exemple #4
0
  def _clone(self, source_object):
    """Clone audit and all relevant attributes.

    Keeps the internals of actual audit cloning and everything that is related
    to audit itself (auditors, audit firm, context setting,
    custom attribute values, etc.)
    """

    # NOTE. Currently this function is called from Restful.collection_posted
    # hook. The following operations are performed:
    # 1) create new object, call json_create(), where attributes will be set
    #    with value validation
    # 2) current function is called from(Restful.collection_posted
    #    which overrides some attributes, attribute validator for these
    #    attributes are called
    # So, validation for those attrs are called twice!
    # One corner case of this behavior is validation of field "title".
    # title cannot be None, and because title validation is performed before
    # this function, API request MUST contain non-empty title in dict,
    # however the value will be overridden and re-validated in this function!

    from ggrc_basic_permissions import create_audit_context
    data = {
        "title": source_object.generate_attribute("title"),
        "description": source_object.description,
        "audit_firm": source_object.audit_firm,
        "start_date": source_object.start_date,
        "end_date": source_object.end_date,
        "last_deprecated_date": source_object.last_deprecated_date,
        "program": source_object.program,
        "status": source_object.VALID_STATES[0],
        "report_start_date": source_object.report_start_date,
        "report_end_date": source_object.report_end_date
    }

    self.update_attrs(data)
    db.session.flush()

    create_audit_context(self)
    self.clone_acls(source_object)
    self.clone_custom_attribute_values(source_object)