
from ggrc import db
from .mixins import (
    deferred, BusinessObject, Timeboxed, CustomAttributable, TestPlanned
)
from .object_document import Documentable
from .object_owner import Ownable
from .object_person import Personable
from .relationship import Relatable
from .track_object_state import HasObjectState, track_state_for_class
from ggrc.models.reflection import PublishOnly


class ControlAssessment(HasObjectState, TestPlanned, CustomAttributable,
                        Documentable, Personable, Timeboxed, Ownable,
                        Relatable, BusinessObject, db.Model):
  __tablename__ = 'control_assessments'

  design = deferred(db.Column(db.String), 'ControlAssessment')
  operationally = deferred(db.Column(db.String), 'ControlAssessment')

  control_id = db.Column(db.Integer, db.ForeignKey('controls.id'))
  control = db.relationship('Control', foreign_keys=[control_id])

  # REST properties
  _publish_attrs = [
      'design',
      'operationally',
      'control'
  ]

track_state_for_class(ControlAssessment)


from ggrc import db
from .mixins import (
    deferred, BusinessObject, Timeboxed, CustomAttributable, TestPlanned
)
from .object_document import Documentable
from .object_owner import Ownable
from .object_person import Personable
from .relationship import Relatable
from .track_object_state import HasObjectState, track_state_for_class
from ggrc.models.reflection import PublishOnly


class ControlAssessment(HasObjectState, TestPlanned, CustomAttributable,
                        Documentable, Personable, Timeboxed, Ownable,
                        Relatable, BusinessObject, db.Model):
  __tablename__ = 'control_assessments'

  design = deferred(db.Column(db.String), 'ControlAssessment')
  operationally = deferred(db.Column(db.String), 'ControlAssessment')

  control_id = db.Column(db.Integer, db.ForeignKey('controls.id'))
  control = db.relationship('Control', foreign_keys=[control_id])

  audit = {}  # we add this for the sake of client side error checking

  # REST properties
  _publish_attrs = [
      'design',
      'operationally',
      'control',
      PublishOnly('audit')
  ]

track_state_for_class(ControlAssessment)

Fix edit control assessment modal
Fix edit control assessment modal

This works, because our client side verification checks only if the
audit attr exists.

ref: core-1643

  
  from ggrc import db
  from .mixins import (
      deferred, BusinessObject, Timeboxed, CustomAttributable, TestPlanned
  )
  from .object_document import Documentable
  from .object_owner import Ownable
  from .object_person import Personable
  from .relationship import Relatable
  from .track_object_state import HasObjectState, track_state_for_class
  from ggrc.models.reflection import PublishOnly
  
  
  class ControlAssessment(HasObjectState, TestPlanned, CustomAttributable,
                          Documentable, Personable, Timeboxed, Ownable,
                          Relatable, BusinessObject, db.Model):
    __tablename__ = 'control_assessments'
  
    design = deferred(db.Column(db.String), 'ControlAssessment')
    operationally = deferred(db.Column(db.String), 'ControlAssessment')
  
    control_id = db.Column(db.Integer, db.ForeignKey('controls.id'))
    control = db.relationship('Control', foreign_keys=[control_id])
  
+   audit = {}  # we add this for the sake of client side error checking
+ 
    # REST properties
    _publish_attrs = [
        'design',
        'operationally',
-       'control'
+       'control',
+       PublishOnly('audit')
    ]
  
  track_state_for_class(ControlAssessment)
  
Fix edit control assessment modal
## Code Before:

from ggrc import db
from .mixins import (
    deferred, BusinessObject, Timeboxed, CustomAttributable, TestPlanned
)
from .object_document import Documentable
from .object_owner import Ownable
from .object_person import Personable
from .relationship import Relatable
from .track_object_state import HasObjectState, track_state_for_class
from ggrc.models.reflection import PublishOnly


class ControlAssessment(HasObjectState, TestPlanned, CustomAttributable,
                        Documentable, Personable, Timeboxed, Ownable,
                        Relatable, BusinessObject, db.Model):
  __tablename__ = 'control_assessments'

  design = deferred(db.Column(db.String), 'ControlAssessment')
  operationally = deferred(db.Column(db.String), 'ControlAssessment')

  control_id = db.Column(db.Integer, db.ForeignKey('controls.id'))
  control = db.relationship('Control', foreign_keys=[control_id])

  # REST properties
  _publish_attrs = [
      'design',
      'operationally',
      'control'
  ]

track_state_for_class(ControlAssessment)

## Instruction:
Fix edit control assessment modal
## Code After:

from ggrc import db
from .mixins import (
    deferred, BusinessObject, Timeboxed, CustomAttributable, TestPlanned
)
from .object_document import Documentable
from .object_owner import Ownable
from .object_person import Personable
from .relationship import Relatable
from .track_object_state import HasObjectState, track_state_for_class
from ggrc.models.reflection import PublishOnly


class ControlAssessment(HasObjectState, TestPlanned, CustomAttributable,
                        Documentable, Personable, Timeboxed, Ownable,
                        Relatable, BusinessObject, db.Model):
  __tablename__ = 'control_assessments'

  design = deferred(db.Column(db.String), 'ControlAssessment')
  operationally = deferred(db.Column(db.String), 'ControlAssessment')

  control_id = db.Column(db.Integer, db.ForeignKey('controls.id'))
  control = db.relationship('Control', foreign_keys=[control_id])

  audit = {}  # we add this for the sake of client side error checking

  # REST properties
  _publish_attrs = [
      'design',
      'operationally',
      'control',
      PublishOnly('audit')
  ]

track_state_for_class(ControlAssessment)
