Ejemplo n.º 1
0
    def test_create_class_structure(self):

        self.assertTrue(get_model("test.NewDynamicType") is None)

        dynClass = type("NewDynamicType", (Model, ), {
            '__module__': "test",
            'text': fields.CharField()
        })

        self.assertTrue(get_model("test.NewDynamicType") is not None)

        dynClass2 = type(
            "NewDynamicType2", (Model, ), {
                '__module__': "test",
                'text': fields.CharField(),
                'name': related.OneOf("test.NewDynamicType")
            })
        a = dynClass2()

        a.test = 'Hello'
        a.name = dynClass(
        )  # note that we to create a class, think about how we have to create these
        a.name.test = "Hello again"

        self.assertEquals('Hello', a.test)
        self.assertEquals('Hello again', a.name.test)

        meta = dynClass2._meta.describe()
        print meta
class Mymodel(Model):
    #     mymodel = related.OneOf('Mymodel')
    id = fields.CharField(blank=False,
                          null=False,
                          max_length=36,
                          auto_created=True)
    site = fields.CharField(max_length=40, blank=True, null=True)
    name = fields.CharField(max_length=40)
    rootCategories = related.ListOf('Mymodel')
Ejemplo n.º 3
0
    def test_create_class(self):
        dynClass = type("test.DynamicType", (Model, ), {
            '__module__': "test",
            'text': fields.CharField()
        })
        a = dynClass()
        a.test = 'Hello'

        self.assertEquals('Hello', a.test)
Ejemplo n.º 4
0
class Restaurant(Model):
    name = fields.CharField(max_length=20,
                            blank=False,
                            null=False,
                            verbose_name={
                                "nl": "Naam",
                                "de": "Name",
                                "en": "Name"
                            })
class AbstractBaseClass(Model):
    id = fields.CharField(max_length=30)

    class Meta:
        abstract = True
import prepare_settings

from unittest import TestCase, main

from django_documents.documents import Model
from django_documents import fields, related
from types import StringType

charField = fields.CharField(max_length=3)


class ListOfCharFields(Model):
    names = related.ListOf(StringType)


class ChoicesTest(TestCase):
    def testLanguagedChoices(self):
        loc = ListOfCharFields()
        loc.names = ["hello"]


if __name__ == '__main__':
    main()
class ModelWithOneOffField(persistentmodels.Model):
    name = fields.CharField()
    oneOf = related.OneOf(ModelWithAllBaseFields)
Ejemplo n.º 8
0
class Address(Model):
    street = fields.CharField(max_length=30, null=False, blank=False)
    zipcode = fields.CharField(max_length=10, null=False, blank=False)
Ejemplo n.º 9
0
class Duck(persistentmodels.Model):
    name = fields.CharField()
Ejemplo n.º 10
0
class Address(documents.Model):
    street = fields.CharField()
    localityName = fields.CharField()
Ejemplo n.º 11
0
class ToValidate(Model):
    name = fields.CharField(max_length=300, null=False, blank=False)
    child = related.OneOf(ToValidateChild, null=False)
Ejemplo n.º 12
0
class ModelA(Model):

    char = fields.CharField()
    integer = fields.IntegerField()
class ModelWithListOffStringType(persistentmodels.Model):
    name = fields.CharField()
    listOfString = related.ListOf(types.StringType)
class Party(persistentmodels.Model):
    name = fields.CharField()
    name2 = fields.CharField()
    contactInfo = related.OneOf(ContactInfo)
class ContactInfo(persistentmodels.Model):
    email = fields.CharField()
class ModelWithMapModelWithAllBaseFields(persistentmodels.Model):
    name = fields.CharField()
    mapOf = related.MapOf(ModelWithAllBaseFields)
class ModelWithMapOffStringType(persistentmodels.Model):
    name = fields.CharField()
    mapOf = related.MapOf(types.StringType)
class ModelWithListModelWithAllBaseFields(persistentmodels.Model):
    name = fields.CharField()
    listOf = related.ListOf(ModelWithAllBaseFields)
Ejemplo n.º 19
0
class Image(documents.Model):
    url = fields.CharField()
class DataAspectClass(DataAspect):
    name = fields.CharField()
Ejemplo n.º 21
0
class ToValidateChild(Model):

    childname = fields.CharField(max_length=300, null=False, blank=False)
Ejemplo n.º 22
0
class Thing(persistentmodels.Model):

    country = fields.CharField(choices=CODES)
Ejemplo n.º 23
0
class ToValidateListOfChilds(Model):
    name = fields.CharField(max_length=300, null=False, blank=False)
    childs = related.ListOf(ToValidateChild,
                            null=False,
                            min_length=2,
                            max_length=100)
class Registration(persistentmodels.Model):
    licenceNumber = fields.CharField()
Ejemplo n.º 25
0
class Image(Model):
    thumbnail_url = fields.CharField(max_length=300, null=False, blank=False)
    image_url = fields.CharField(max_length=300, null=False, blank=False)
class Car(Vehicle):
    type = fields.CharField()
Ejemplo n.º 27
0
class Person(persistentmodels.Model):
    """
    this is the definition of a simple model
    """
    first_name = fields.CharField()
    last_name = fields.CharField()
class Vehicle(persistentmodels.Model):
    name = fields.CharField()
Ejemplo n.º 29
0
class ModelWithChoices(Model):
    name = fields.CharField(choices=PARKING_FACILITIES_CHOICES_TR)
class ModelWithAllBaseFields(persistentmodels.Model):
    float = fields.FloatField()
    date = fields.DateField()
    char = fields.CharField()
    integer = fields.IntegerField()