예제 #1
0
class FakeModelCRA(Model):
    collection = Collection("fake_model_cr_a")
    verbose_name = "fake model for simple field creation"
    id = fields.IntegerField()

    req_field = fields.IntegerField(required=True)
    not_req_field = fields.IntegerField()
예제 #2
0
class FakeModelB(Model):
    collection = Collection("fake_model_b")
    verbose_name = "fake model b"

    id = fields.IntegerField()

    meeting_id = fields.RelationField(
        to={Collection("meeting"): "fake_model_b_ids"},
        required=True,
    )

    fake_model_a_oo = fields.RelationField(
        to={Collection("fake_model_a"): "fake_model_b_oo"})
    fake_model_a_mo = fields.RelationListField(
        to={Collection("fake_model_a"): "fake_model_b_om"})
    fake_model_a_mm = fields.RelationListField(
        to={Collection("fake_model_a"): "fake_model_b_mm"})
    fake_model_a_generic_oo = fields.GenericRelationField(
        to={Collection("fake_model_a"): "fake_model_b_generic_oo"}, )
    fake_model_a_generic_mo = fields.GenericRelationListField(
        to={Collection("fake_model_a"): "fake_model_b_generic_om"}, )
    fake_model_a_generic_mm = fields.GenericRelationListField(
        to={Collection("fake_model_a"): "fake_model_b_generic_mm"}, )

    structured_relation_field = fields.RelationField(
        to={Collection("fake_model_a"): "fake_model_b_$_ids"}, )

    fake_model_c_ids = fields.RelationListField(
        to={Collection("fake_model_c"): "foreign_key_field"}, )
예제 #3
0
class FakeModelEFB(Model):
    collection = Collection("fake_model_ef_b")
    verbose_name = "fake model for equal field check b"
    id = fields.IntegerField()

    reference_field = fields.RelationField(to=Collection("fake_model_ef_a"),
                                           related_name="b_id")

    c_id = fields.RelationField(
        to=Collection("fake_model_ef_c"),
        related_name="b_id",
        equal_fields="reference_field",
    )
    c_ids = fields.RelationListField(
        to=Collection("fake_model_ef_c"),
        related_name="b_ids",
        equal_fields="reference_field",
    )
    c_generic_id = fields.GenericRelationField(
        to=[Collection("fake_model_ef_c")],
        related_name="b_generic_id",
        equal_fields="reference_field",
    )
    c_generic_ids = fields.GenericRelationListField(
        to=[Collection("fake_model_ef_c")],
        related_name="b_generic_ids",
        equal_fields="reference_field",
    )
예제 #4
0
class FakeModelEFA(Model):
    collection = Collection("fake_model_ef_a")
    verbose_name = "fake model for equal field check a"
    id = fields.IntegerField()

    b_id = fields.RelationField(
        to={Collection("fake_model_ef_b"): "meeting_id"}, )
    c_id = fields.RelationField(
        to={Collection("fake_model_ef_c"): "meeting_id"}, )
예제 #5
0
class FakeModelURA(Model):
    collection = Collection("fake_model_ur_a")
    verbose_name = "fake model for cascade update a"
    id = fields.IntegerField()

    fake_model_ur_b_id = fields.RelationField(
        to={Collection("fake_model_ur_b"): "fake_model_ur_a_id"}, )
    fake_model_ur_b_required_id = fields.RelationField(
        to={Collection("fake_model_ur_b"): "fake_model_ur_a_required_id"}, )
예제 #6
0
class FakeModelCRD(Model):
    collection = Collection("fake_model_cr_d")
    verbose_name = "fake model for create relation d"
    id = fields.IntegerField()

    name = fields.CharField()
    fake_model_cr_c_ids = fields.RelationListField(
        to={Collection("fake_model_cr_c"): "fake_model_cr_d_id"},
        required=True)
예제 #7
0
class FakeModel(Model):
    """
    Fake Model for testing purposes.
    """

    collection = Collection("fake_model")
    verbose_name = "fake_model"

    id = fields.IntegerField(required=True)
    read_only = fields.IntegerField(read_only=True)
    text = fields.CharField(
        required=True, constraints={"description": "The text of this fake model."}
    )
    fake_model_2_ids = fields.RelationListField(
        to={Collection("fake_model_2"): "relation_field"}
    )
    fake_model_2_generic_ids = fields.GenericRelationListField(
        to={Collection("fake_model_2"): "generic_relation_field"}
    )
class FakeModelCDC(Model):
    collection = Collection("fake_model_cd_c")
    verbose_name = "fake model for cascade deletion c"
    id = fields.IntegerField()

    fake_model_cd_a = fields.RelationField(
        to={Collection("fake_model_cd_a"): "fake_model_cd_c"})
    fake_model_cd_b_protected = fields.RelationField(
        to={Collection("fake_model_cd_b"): "fake_model_cd_c_protect"})
    fake_model_cd_b_cascaded = fields.RelationField(
        to={Collection("fake_model_cd_b"): "fake_model_cd_c_cascade"})
예제 #9
0
class FakeModelEFA(Model):
    collection = Collection("fake_model_ef_a")
    verbose_name = "fake model for equal field check a"
    id = fields.IntegerField()

    b_id = fields.RelationField(
        to=Collection("fake_model_ef_b"),
        related_name="reference_field",
    )
    c_id = fields.RelationField(
        to=Collection("fake_model_ef_c"),
        related_name="reference_field",
    )
예제 #10
0
class FakeModelCDA(Model):
    collection = Collection("fake_model_cd_a")
    verbose_name = "fake model for cascade deletion a"
    id = fields.IntegerField()

    fake_model_cd_b = fields.RelationField(
        to=Collection("fake_model_cd_b"),
        related_name="fake_model_cd_a",
        on_delete=fields.OnDelete.CASCADE,
    )
    fake_model_cd_c = fields.RelationField(
        to=Collection("fake_model_cd_c"),
        related_name="fake_model_cd_a",
        on_delete=fields.OnDelete.CASCADE,
    )
예제 #11
0
class FakeModelEFC(Model):
    collection = Collection("fake_model_ef_c")
    verbose_name = "fake model for equal field check c"
    id = fields.IntegerField()

    meeting_id = fields.RelationField(
        to={Collection("fake_model_ef_a"): "c_id"})

    b_id = fields.RelationField(to={Collection("fake_model_ef_b"): "c_id"}, )
    b_ids = fields.RelationListField(
        to={Collection("fake_model_ef_b"): "c_ids"}, )
    b_generic_id = fields.GenericRelationField(
        to={Collection("fake_model_ef_b"): "c_generic_id"}, )
    b_generic_ids = fields.GenericRelationListField(
        to={Collection("fake_model_ef_b"): "c_generic_ids"}, )
예제 #12
0
class FakeModel2(Model):
    """
    Fake model for testing purposes. With relation field.
    """

    collection = Collection("fake_model_2")
    verbose_name = "fake_model_2"

    id = fields.IntegerField(required=True)
    relation_field = fields.RelationField(
        to={Collection("fake_model"): "fake_model_2_ids"},
    )
    generic_relation_field = fields.RelationField(
        to={Collection("fake_model"): "fake_model_2_generic_ids"},
    )
예제 #13
0
class FakeModelC(Model):
    collection = Collection("fake_model_c")
    verbose_name = "fake model c"

    id = fields.IntegerField()

    # nested structured field
    foreign_key_field = fields.RelationField(
        to=Collection("fake_model_b"),
        related_name="fake_model_c_ids",
    )
    structured_relation_field = fields.RelationField(
        to=Collection("fake_model_a"),
        related_name="fake_model_c_$_ids",
        structured_relation=["foreign_key_field", "meeting_id"],
    )
예제 #14
0
class FakeModelC(Model):
    collection = Collection("fake_model_c")
    verbose_name = "fake model c"

    id = fields.IntegerField()

    meeting_id = fields.RelationField(
        to={Collection("meeting"): "fake_model_b_ids"},
        required=True,
    )

    # nested structured field
    foreign_key_field = fields.RelationField(
        to={Collection("fake_model_b"): "fake_model_c_ids"}, )
    structured_relation_field = fields.RelationField(
        to={Collection("fake_model_a"): "fake_model_c_$_ids"}, )
예제 #15
0
class FakeModelCDB(Model):
    collection = Collection("fake_model_cd_b")
    verbose_name = "fake model for cascade deletion b"
    id = fields.IntegerField()

    fake_model_cd_a = fields.RelationField(to=Collection("fake_model_cd_a"),
                                           related_name="fake_model_cd_b")
    fake_model_cd_c_protect = fields.RelationField(
        to=Collection("fake_model_cd_c"),
        related_name="fake_model_cd_b_protected",
        on_delete=fields.OnDelete.PROTECT,
    )
    fake_model_cd_c_cascade = fields.RelationField(
        to=Collection("fake_model_cd_c"),
        related_name="fake_model_cd_b_cascaded",
        on_delete=fields.OnDelete.CASCADE,
    )
예제 #16
0
class FakeModelA(Model):
    collection = Collection("fake_model_a")
    verbose_name = "fake model a"

    id = fields.IntegerField()

    # normal relations
    fake_model_b_oo = fields.RelationField(to=Collection("fake_model_b"),
                                           related_name="fake_model_a_oo")
    fake_model_b_om = fields.RelationField(to=Collection("fake_model_b"),
                                           related_name="fake_model_a_mo")
    fake_model_b_mm = fields.RelationListField(to=Collection("fake_model_b"),
                                               related_name="fake_model_a_mm")

    # generic relations
    fake_model_b_generic_oo = fields.RelationField(
        to=Collection("fake_model_b"),
        related_name="fake_model_a_generic_oo",
        generic_relation=True,
    )
    fake_model_b_generic_om = fields.RelationField(
        to=Collection("fake_model_b"),
        related_name="fake_model_a_generic_mo",
        generic_relation=True,
    )
    fake_model_b_generic_mm = fields.RelationListField(
        to=Collection("fake_model_b"),
        related_name="fake_model_a_generic_mm",
        generic_relation=True,
    )

    # template field / structured relation
    fake_model_b__ids = fields.TemplateRelationListField(
        replacement="meeting_id",
        index=13,
        to=Collection("fake_model_b"),
        related_name="structured_relation_field",
    )
    fake_model_c__ids = fields.TemplateRelationListField(
        replacement="meeting_id",
        index=13,
        to=Collection("fake_model_c"),
        related_name="structured_relation_field",
    )
class FakeModelCDA(Model):
    collection = Collection("fake_model_cd_a")
    verbose_name = "fake model for cascade deletion a"
    id = fields.IntegerField()

    fake_model_cd_b = fields.RelationField(
        to={Collection("fake_model_cd_b"): "fake_model_cd_a"},
        on_delete=fields.OnDelete.CASCADE,
    )
    fake_model_cd_c = fields.RelationField(
        to={Collection("fake_model_cd_c"): "fake_model_cd_a"},
        on_delete=fields.OnDelete.CASCADE,
    )
    fake_model_cd_b_set_null = fields.RelationField(
        to={Collection("fake_model_cd_b"): "fake_model_cd_a_set_null"},
        on_delete=fields.OnDelete.SET_NULL,
    )
    fake_model_cd_b_set_null_required = fields.RelationField(
        to={Collection("fake_model_cd_b"): "fake_model_cd_a_set_null_required"},
        on_delete=fields.OnDelete.SET_NULL,
    )
class FakeModelCDB(Model):
    collection = Collection("fake_model_cd_b")
    verbose_name = "fake model for cascade deletion b"
    id = fields.IntegerField()

    fake_model_cd_a = fields.RelationField(
        to={Collection("fake_model_cd_a"): "fake_model_cd_b"}
    )
    fake_model_cd_c_protect = fields.RelationField(
        to={Collection("fake_model_cd_c"): "fake_model_cd_b_protected"},
        on_delete=fields.OnDelete.PROTECT,
    )
    fake_model_cd_c_cascade = fields.RelationField(
        to={Collection("fake_model_cd_c"): "fake_model_cd_b_cascaded"},
        on_delete=fields.OnDelete.CASCADE,
    )
    fake_model_cd_a_set_null = fields.RelationField(
        to={Collection("fake_model_cd_a"): "fake_model_cd_b_set_null"},
    )
    fake_model_cd_a_set_null_required = fields.RelationField(
        to={Collection("fake_model_cd_a"): "fake_model_cd_b_set_null_required"},
        required=True,
    )
class FakeModelP(Model):
    collection = Collection("fake_model_p")
    verbose_name = "fake model for permissions"
    id = fields.IntegerField()