Ejemplo n.º 1
0
    def add_m2m_table(self, app_label, proj_sig):
        app_sig = proj_sig[app_label]
        model_sig = app_sig[self.model_name]

        model = MockModel(proj_sig, app_label, self.model_name, model_sig)

        field = create_field(proj_sig, self.field_name, self.field_type,
                             self.field_attrs, model)

        related_app_label, related_model_name = self.field_attrs['related_model'].split('.')
        related_sig = proj_sig[related_app_label][related_model_name]
        related_model = MockModel(proj_sig, related_app_label, related_model_name, related_sig)
        related = MockRelated(related_model, model, field)

        if hasattr(field, '_get_m2m_column_name'):
            # Django < 1.2
            field.m2m_column_name = curry(field._get_m2m_column_name, related)
            field.m2m_reverse_name = curry(field._get_m2m_reverse_name, related)
        else:
            # Django >= 1.2
            field.m2m_column_name = curry(field._get_m2m_attr,
                                          related, 'column')
            field.m2m_reverse_name = curry(field._get_m2m_reverse_attr,
                                           related, 'column')

        sql_statements = evolver.add_m2m_table(model, field)

        return sql_statements
Ejemplo n.º 2
0
    def add_m2m_table(self, app_label, proj_sig):
        app_sig = proj_sig[app_label]
        model_sig = app_sig[self.model_name]

        model = MockModel(proj_sig, app_label, self.model_name, model_sig)
        field = create_field(proj_sig, self.field_name, self.field_type, self.field_attrs)
        field.m2m_db_table = curry(field._get_m2m_db_table, model._meta)

        related_app_label, related_model_name = self.field_attrs['related_model'].split('.')
        related_sig = proj_sig[related_app_label][related_model_name]
        related_model = MockModel(proj_sig, related_app_label, related_model_name, related_sig)
        related = MockRelated(related_model, model, field)

        field.m2m_column_name = curry(field._get_m2m_column_name, related)
        field.m2m_reverse_name = curry(field._get_m2m_reverse_name, related)

        sql_statements = evolver.add_m2m_table(model, field)

        return sql_statements
Ejemplo n.º 3
0
    def add_m2m_table(self, app_label, proj_sig):
        app_sig = proj_sig[app_label]
        model_sig = app_sig[self.model_name]

        model = MockModel(proj_sig, app_label, self.model_name, model_sig)
        field = create_field(proj_sig, self.field_name, self.field_type,
                             self.field_attrs)
        field.m2m_db_table = curry(field._get_m2m_db_table, model._meta)

        related_app_label, related_model_name = self.field_attrs[
            'related_model'].split('.')
        related_sig = proj_sig[related_app_label][related_model_name]
        related_model = MockModel(proj_sig, related_app_label,
                                  related_model_name, related_sig)
        related = MockRelated(related_model, model, field)

        field.m2m_column_name = curry(field._get_m2m_column_name, related)
        field.m2m_reverse_name = curry(field._get_m2m_reverse_name, related)

        sql_statements = evolver.add_m2m_table(model, field)

        return sql_statements