Ejemplo n.º 1
0
Archivo: columns.py Proyecto: gltn/stdm
    def __init__(self, *args, **kwargs):
        # Reset bounds
        kwargs['minimum'] = 0
        kwargs['maximum'] = self.SQL_MAX

        IntegerColumn.__init__(self, *args, **kwargs)

        # Added in version 1.7
        self._on_update_action = None
        self._on_delete_action = None

        self.entity_relation = kwargs.pop('entity_relation',
                                          EntityRelation(self.entity.profile))

        self.entity_relation.child_column = self.name
        self.entity_relation.child = self.entity

        # If the entity relation is valid then add it right away to the profile
        if self.entity_relation.valid()[0]:
            self.profile.add_entity_relation(self.entity_relation)

        # Map referential actions
        self.ref_actions = {
            self.CASCADE: 'CASCADE',
            self.NO_ACTION: 'NO ACTION',
            self.SET_NULL: 'SET NULL',
            self.SET_DEFAULT: 'SET DEFAULT'
        }

        # Set default cascade options
        self.on_update_action = ForeignKeyColumn.NO_ACTION
        self.on_delete_action = ForeignKeyColumn.SET_NULL
Ejemplo n.º 2
0
 def create_entity_relation(self, **kwargs):
     """
     Creates a new instances of an EntityRelation object.
     :param kwargs: Arguments sent to the EntityRelation constructor.
     :returns: Instance of an EntityRelation object
     :rtype: EntityRelation
     """
     return EntityRelation(self, **kwargs)
Ejemplo n.º 3
0
    def add_values(self):
        """
        Construct an EntityRelation instance from form fields
        """
        er_fields = {}
        er_fields['parent'] = str(self.cboPrimaryEntity.currentText())
        er_fields['parent_column'] = str(self.cboPrimaryUKey.currentText())
        er_fields['display_columns'] = self.display_columns()
        er_fields['child'] = self.entity
        er_fields['child_column'] = self.column_name

        self._entity_relation = EntityRelation(self.profile, **er_fields)
Ejemplo n.º 4
0
 def admin_spatial_unit_property(self):
     """
     Sets entity relation property used when creating column of type
     ADMIN_SPATIAL_UNIT
     """
     er_fields = {}
     er_fields['parent'] = self.entity
     er_fields['parent_column'] = None
     er_fields['display_columns'] = []
     er_fields['child'] = None
     er_fields['child_column'] = None
     self.form_fields['entity_relation'] = EntityRelation(self.profile, **er_fields)
Ejemplo n.º 5
0
    def add_values(self):
        """
        Construct an EntityRelation instance
        """
        lookup_name = unicode(self.cboPrimaryEntity.currentText())
        self._lookup_name = lookup_name

        er_fields = {}
        er_fields['parent'] = lookup_name
        er_fields['parent_column'] = None
        er_fields['display_columns'] = []
        er_fields['child'] = None
        er_fields['child_column'] = None
        self._entity_relation = EntityRelation(self._profile, **er_fields)
Ejemplo n.º 6
0
    def __init__(self, *args, **kwargs):
        #Reset bounds
        kwargs['minimum'] = 0
        kwargs['maximum'] = self.SQL_MAX

        IntegerColumn.__init__(self, *args, **kwargs)

        self.entity_relation = kwargs.pop('entity_relation',
                                          EntityRelation(self.entity.profile))

        self.entity_relation.child_column = self.name
        self.entity_relation.child = self.entity

        #If the entity relation is valid then add it right away to the profile
        if self.entity_relation.valid()[0]:
            self.profile.add_entity_relation(self.entity_relation)