Example #1
0
class Membership(models.Model):
    # Table Column Fields
    membership_country = models.ForeignKey(Country, models.CASCADE)
    date_joined = models.DateTimeField(default=datetime.datetime.now)
    invite_reason = models.CharField(max_length=64, null=True)
    person_id = models.IntegerField()
    group_id = models.IntegerField()

    # Relation Fields
    person = models.ForeignObject(
        Person,
        from_fields=['membership_country', 'person_id'],
        to_fields=['person_country_id', 'id'],
        on_delete=models.CASCADE,
    )
    group = models.ForeignObject(
        Group,
        from_fields=['membership_country', 'group_id'],
        to_fields=['group_country', 'id'],
        on_delete=models.CASCADE,
    )

    class Meta:
        ordering = ('date_joined', 'invite_reason')

    def __str__(self):
        return "%s is a member of %s" % (self.person.name, self.group.name)
Example #2
0
class Friendship(models.Model):
    # Table Column Fields
    from_friend_country = models.ForeignKey(Country,
                                            models.CASCADE,
                                            related_name="from_friend_country")
    from_friend_id = models.IntegerField()
    to_friend_country_id = models.IntegerField()
    to_friend_id = models.IntegerField()

    # Relation Fields
    from_friend = models.ForeignObject(
        Person,
        on_delete=models.CASCADE,
        from_fields=['from_friend_country', 'from_friend_id'],
        to_fields=['person_country_id', 'id'],
        related_name='from_friend')

    to_friend_country = models.ForeignObject(
        Country,
        from_fields=['to_friend_country_id'],
        to_fields=['id'],
        related_name='to_friend_country',
        on_delete=models.CASCADE,
    )

    to_friend = models.ForeignObject(
        Person,
        from_fields=['to_friend_country_id', 'to_friend_id'],
        to_fields=['person_country_id', 'id'],
        related_name='to_friend',
        on_delete=models.CASCADE,
    )
Example #3
0
class Friendship(models.Model):
    # Table Column Fields
    from_friend_country = models.ForeignKey(Country,
                                            models.CASCADE,
                                            related_name="from_friend_country")
    from_friend_id = models.IntegerField()
    to_friend_country_id = models.IntegerField()
    to_friend_id = models.IntegerField()

    # Relation Fields
    from_friend = models.ForeignObject(
        Person,
        on_delete=models.CASCADE,
        from_fields=["from_friend_country", "from_friend_id"],
        to_fields=["person_country_id", "id"],
        related_name="from_friend",
    )

    to_friend_country = models.ForeignObject(
        Country,
        from_fields=["to_friend_country_id"],
        to_fields=["id"],
        related_name="to_friend_country",
        on_delete=models.CASCADE,
    )

    to_friend = models.ForeignObject(
        Person,
        from_fields=["to_friend_country_id", "to_friend_id"],
        to_fields=["person_country_id", "id"],
        related_name="to_friend",
        on_delete=models.CASCADE,
    )
Example #4
0
class Membership(models.Model):
    # Table Column Fields
    membership_country = models.ForeignKey(Country, models.CASCADE)
    date_joined = models.DateTimeField(default=datetime.datetime.now)
    invite_reason = models.CharField(max_length=64, null=True)
    person_id = models.IntegerField()
    group_id = models.IntegerField(blank=True, null=True)

    # Relation Fields
    person = models.ForeignObject(
        Person,
        from_fields=["person_id", "membership_country"],
        to_fields=["id", "person_country_id"],
        on_delete=models.CASCADE,
    )
    group = models.ForeignObject(
        Group,
        from_fields=["group_id", "membership_country"],
        to_fields=["id", "group_country"],
        on_delete=models.CASCADE,
    )

    class Meta:
        ordering = ("date_joined", "invite_reason")

    def __str__(self):
        group_name = self.group.name if self.group_id else "NULL"
        return "%s is a member of %s" % (self.person.name, group_name)
Example #5
0
class Person(BasePerson):
    # DATA fields
    data_inherited = models.CharField(max_length=10)
    fk_inherited = models.ForeignKey(Relation, related_name='fk_concrete_rel')

    # M2M Fields
    m2m_inherited = models.ManyToManyField(Relation,
                                           related_name='m2m_concrete_rel')
    friends_inherited = models.ManyToManyField('self',
                                               related_name='friends_concrete',
                                               symmetrical=True)
    following_inherited = models.ManyToManyField(
        'self', related_name='followers_concrete', symmetrical=False)

    # VIRTUAL fields
    data_not_concrete_inherited = models.ForeignObject(
        Relation,
        from_fields=['model_non_concrete_id'],
        to_fields=['id'],
        related_name='fo_concrete_rel',
    )

    # GFK fields
    content_type_concrete = models.ForeignKey(ContentType, related_name='+')
    object_id_concrete = models.PositiveIntegerField()
    content_object_concrete = GenericForeignKey('content_type_concrete',
                                                'object_id_concrete')

    # GR fields
    generic_relation_concrete = GenericRelation(Relation)
        class MMembership(models.Model):
            person_country_id = models.IntegerField()
            person_city_id = models.IntegerField()

            person = models.ForeignObject(Person,
                from_fields=['person_country_id', 'person_city_id'],
                to_fields=['country_id', 'city_id'])
Example #7
0
class Person(BasePerson):
    # DATA fields
    data_inherited = models.CharField(max_length=10)
    fk_inherited = models.ForeignKey(
        Relation, models.CASCADE, related_name="fk_concrete_rel"
    )

    # M2M Fields
    m2m_inherited = models.ManyToManyField(Relation, related_name="m2m_concrete_rel")
    friends_inherited = models.ManyToManyField("self", symmetrical=True)
    following_inherited = models.ManyToManyField(
        "self", related_name="followers_concrete", symmetrical=False
    )

    # VIRTUAL fields
    data_not_concrete_inherited = models.ForeignObject(
        Relation,
        on_delete=models.CASCADE,
        from_fields=["model_non_concrete_id"],
        to_fields=["id"],
        related_name="fo_concrete_rel",
    )

    # GFK fields
    content_type_concrete = models.ForeignKey(
        ContentType, models.CASCADE, related_name="+"
    )
    object_id_concrete = models.PositiveIntegerField()
    content_object_concrete = GenericForeignKey(
        "content_type_concrete", "object_id_concrete"
    )

    # GR fields
    generic_relation_concrete = GenericRelation(Relation)
Example #8
0
class Migration(migrations.Migration):

    dependencies = [
        ('machines', '0038_auto_20200403_2157'),
        ('spareparts', '0011_auto_20200404_0250'),
    ]

    operations = [
        migrations.AddField(
            model_name='spareparts',
            name='Serial',
            field=models.CharField(blank=True,
                                   default='',
                                   max_length=100,
                                   null=True),
        ),
        migrations.AddField(
            model_name='spareparts',
            name='Εταιρεία',
            field=models.CharField(blank=True,
                                   default='',
                                   max_length=100,
                                   null=True),
        ),
        migrations.AlterField(
            model_name='spareparts',
            name='ΜΗΧΑΝΗΜΑ',
            field=models.ForeignObject(
                from_fields=('ΜΗΧΑΝΗΜΑ', 'Serial'),
                on_delete=django.db.models.deletion.PROTECT,
                to='machines.Machines',
                to_fields=('Εταιρεία', 'Serial')),
        ),
    ]
Example #9
0
class AbstractPerson(models.Model):
    # DATA fields
    data_abstract = models.CharField(max_length=10)
    fk_abstract = models.ForeignKey(Relation, related_name='fk_abstract_rel')

    # M2M fields
    m2m_abstract = models.ManyToManyField(Relation,
                                          related_name='m2m_abstract_rel')
    friends_abstract = models.ManyToManyField('self',
                                              related_name='friends_abstract',
                                              symmetrical=True)
    following_abstract = models.ManyToManyField(
        'self', related_name='followers_abstract', symmetrical=False)

    # VIRTUAL fields
    data_not_concrete_abstract = models.ForeignObject(
        Relation,
        from_fields=['abstract_non_concrete_id'],
        to_fields=['id'],
        related_name='fo_abstract_rel',
    )

    # GFK fields
    content_type_abstract = models.ForeignKey(ContentType, related_name='+')
    object_id_abstract = models.PositiveIntegerField()
    content_object_abstract = GenericForeignKey('content_type_abstract',
                                                'object_id_abstract')

    # GR fields
    generic_relation_abstract = GenericRelation(Relation)

    class Meta:
        abstract = True
Example #10
0
class BasePerson(AbstractPerson):
    # DATA fields
    data_base = models.CharField(max_length=10)
    fk_base = models.ForeignKey(Relation,
                                models.CASCADE,
                                related_name='fk_base_rel')

    # M2M fields
    m2m_base = models.ManyToManyField(Relation, related_name='m2m_base_rel')
    friends_base = models.ManyToManyField('self',
                                          related_name='friends_base',
                                          symmetrical=True)
    following_base = models.ManyToManyField('self',
                                            related_name='followers_base',
                                            symmetrical=False)

    # VIRTUAL fields
    data_not_concrete_base = models.ForeignObject(
        Relation,
        on_delete=models.CASCADE,
        from_fields=['base_non_concrete_id'],
        to_fields=['id'],
        related_name='fo_base_rel',
    )

    # GFK fields
    content_type_base = models.ForeignKey(ContentType,
                                          models.CASCADE,
                                          related_name='+')
    object_id_base = models.PositiveIntegerField()
    content_object_base = GenericForeignKey('content_type_base',
                                            'object_id_base')

    # GR fields
    generic_relation_base = GenericRelation(Relation)
Example #11
0
class Property(models.Model):
    leased = models.BooleanField(default=True)
    residential = 'Residential property'
    commercial = 'Commercial property'
    res_or_com = models.Field.choices(
        (residential, 'Residential property')(commercial,
                                              'Commercial property'))
    address = models.CharField(max_length=300)
    tenant = models.ForeignObject(parent_link='Tenant')
Example #12
0
class ObjectPropertiesData(models.Model):
    properties_fk = models.ForeignKey(ObjectProperties, on_delete=models.CASCADE)
    intake_fk = models.ForeignObject(Object, on_delete=models.CASCADE)
    data_int = models.SmallIntegerField()
    data_bitint = models.BigIntegerField()
    data_float = models.FloatField()
    data_datetime = models.DateTimeField()
    data_string = models.CharField(max_length=250)
    created = models.ForeignKey(User, on_delete=models.CASCADE)
    created_by = models.ForeignKey(User, on_delete=models.CASCADE)
class Freebie(models.Model):
    gift_product = models.ForeignKey(Product, models.CASCADE)
    stock_id = models.IntegerField(blank=True, null=True)

    stock = models.ForeignObject(
        Stock,
        from_fields=['stock_id', 'gift_product'],
        to_fields=['id', 'product'],
        on_delete=models.CASCADE,
    )
Example #14
0
class Contact(models.Model):
    company_code = models.CharField(max_length=1)
    customer_code = models.IntegerField()
    customer = models.ForeignObject(
        Customer,
        models.CASCADE,
        related_name="contacts",
        to_fields=["customer_id", "company"],
        from_fields=["customer_code", "company_code"],
    )
Example #15
0
class Contact(models.Model):
    company_code = models.CharField(max_length=1)
    customer_code = models.IntegerField()
    customer = models.ForeignObject(
        Customer,
        models.CASCADE,
        related_name='contacts',
        to_fields=['customer_id', 'company'],
        from_fields=['customer_code', 'company_code'],
    )
class ListaDividas(models.Model):
    id = models.AutoField(primary_key=True)
    dividas = [
        models.ForeignObject(to='DadosDividas',
                             on_delete=models.CASCADE,
                             from_fields=['dividas'],
                             to_fields=['id'])
    ]

    def __str__(self):
        return self.id
Example #17
0
 class Child(models.Model):
     a = models.PositiveIntegerField()
     b = models.PositiveIntegerField()
     value = models.CharField(max_length=255)
     parent = models.ForeignObject(
         Parent,
         on_delete=models.SET_NULL,
         from_fields=('a', 'b'),
         to_fields=('a', 'b'),
         related_name='children',
     )
Example #18
0
 class Child(models.Model):
     a = models.PositiveIntegerField()
     b = models.PositiveIntegerField()
     c = models.PositiveIntegerField()
     d = models.CharField(max_length=255)
     parent = models.ForeignObject(
         Parent,
         on_delete=models.SET_NULL,
         from_fields=("a", "b", "c"),
         to_fields=("a", "b", "c"),
         related_name="children",
     )
Example #19
0
class Person(models.Model):
    # Table Column Fields
    name = models.CharField(max_length=128)
    person_country_id = models.IntegerField()

    # Relation Fields
    person_country = models.ForeignObject(
        Country, from_fields=['person_country_id'], to_fields=['id'])
    friends = models.ManyToManyField('self', through='Friendship', symmetrical=False)

    class Meta:
        ordering = ('name',)

    def __str__(self):
        return self.name
Example #20
0
class Customer(models.Model):
    company = models.CharField(max_length=1)
    customer_id = models.IntegerField()
    address = models.ForeignObject(
        Address,
        models.CASCADE,
        null=True,
        # order mismatches the Contact ForeignObject.
        from_fields=['company', 'customer_id'],
        to_fields=['company', 'customer_id'],
    )

    class Meta:
        unique_together = [
            ('company', 'customer_id'),
        ]
Example #21
0
class AbstractPerson(models.Model):
    # DATA fields
    data_abstract = models.CharField(max_length=10)
    fk_abstract = models.ForeignKey(
        Relation, models.CASCADE, related_name="fk_abstract_rel"
    )

    # M2M fields
    m2m_abstract = models.ManyToManyField(Relation, related_name="m2m_abstract_rel")
    friends_abstract = models.ManyToManyField("self", symmetrical=True)
    following_abstract = models.ManyToManyField(
        "self", related_name="followers_abstract", symmetrical=False
    )

    # VIRTUAL fields
    data_not_concrete_abstract = models.ForeignObject(
        Relation,
        on_delete=models.CASCADE,
        from_fields=["abstract_non_concrete_id"],
        to_fields=["id"],
        related_name="fo_abstract_rel",
    )

    # GFK fields
    content_type_abstract = models.ForeignKey(
        ContentType, models.CASCADE, related_name="+"
    )
    object_id_abstract = models.PositiveIntegerField()
    content_object_abstract = GenericForeignKey(
        "content_type_abstract", "object_id_abstract"
    )

    # GR fields
    generic_relation_abstract = GenericRelation(Relation)

    class Meta:
        abstract = True

    @property
    def test_property(self):
        return 1

    test_instance_only_descriptor = InstanceOnlyDescriptor()
Example #22
0
class AllFieldsModel(models.Model):
    big_integer = models.BigIntegerField()
    binary = models.BinaryField()
    boolean = models.BooleanField(default=False)
    char = models.CharField(max_length=10)
    date = models.DateField()
    datetime = models.DateTimeField()
    decimal = models.DecimalField(decimal_places=2, max_digits=2)
    duration = models.DurationField()
    email = models.EmailField()
    file_path = models.FilePathField()
    floatf = models.FloatField()
    integer = models.IntegerField()
    generic_ip = models.GenericIPAddressField()
    null_boolean = models.NullBooleanField()
    positive_integer = models.PositiveIntegerField()
    positive_small_integer = models.PositiveSmallIntegerField()
    slug = models.SlugField()
    small_integer = models.SmallIntegerField()
    text = models.TextField()
    time = models.TimeField()
    url = models.URLField()
    uuid = models.UUIDField()

    fo = models.ForeignObject(
        'self',
        on_delete=models.CASCADE,
        from_fields=['positive_integer'],
        to_fields=['id'],
        related_name='reverse'
    )
    fk = models.ForeignKey(
        'self',
        models.CASCADE,
        related_name='reverse2'
    )
    m2m = models.ManyToManyField('self')
    oto = models.OneToOneField('self', models.CASCADE)

    object_id = models.PositiveIntegerField()
    content_type = models.ForeignKey(ContentType, models.CASCADE)
    gfk = GenericForeignKey()
    gr = GenericRelation(DataModel)
Example #23
0
class Person(models.Model):
    # Table Column Fields
    name = models.CharField(max_length=128)
    person_country_id = models.IntegerField()

    # Relation Fields
    person_country = models.ForeignObject(Country,
                                          from_fields=["person_country_id"],
                                          to_fields=["id"],
                                          on_delete=models.CASCADE)
    friends = models.ManyToManyField("self",
                                     through="Friendship",
                                     symmetrical=False)

    class Meta:
        ordering = ("name", )

    def __str__(self):
        return self.name
Example #24
0
class Hs4_cpy(models.Model):
    class Meta:
        db_table = DB_PREFIX + "observatory_hs4_cpy"
        managed = False

    country = models.ForeignKey(Country)
    product = models.ForeignKey(Hs4)
    year = models.PositiveSmallIntegerField(max_length=4)
    export_value = models.FloatField(null=True)
    import_value = models.FloatField(null=True)
    export_rca = models.FloatField(null=True)
    distance = models.FloatField(null=True)
    opp_gain = models.FloatField(null=True)

    product_year = models.ForeignObject(Hs4_py, ('product', 'year'),
                                        ('product', 'year'))

    def __unicode__(self):
        return "CPY: %s.%s.%d" % (self.country.name, self.product.code,
                                  self.year)
Example #25
0
class Article(DBAdapterModel):
    article_id = models.BigAutoField(primary_key=True)
    name = models.CharField(max_length=30)
    text = models.TextField(null=True, help_text='Article description')
    active = models.NullBooleanField()
    author = models.ForeignKey(
        Author,
        on_delete=models.CASCADE,
        null=True,
        db_index=False,
        db_column='written_by',
    )
    tag = models.ForeignKey(
        Tag,
        on_delete=models.CASCADE,
        null=True,
        db_index=True,
        db_column='tag',
    )
    # Virtual fields
    liked_by = models.ManyToManyField(
        Person,
        related_name='liked_articles',
        through='tests.ArticleLike',
        through_fields=['article', 'person'],
    )
    post = models.ForeignObject(
        Post,
        on_delete=models.DO_NOTHING,
        from_fields=['name'],
        to_fields=['name'],
    )

    class Meta:
        db_table = 'tbl_article'
        unique_together = ['author', 'name']
Example #26
0
class LeasePayment(models.Model):
    paid = models.FloatField()
    lease_contract = models.ForeignObject(parent_link='LeaseContract')
    total = lease_contract.rent - paid