Esempio n. 1
0
class Recipe(MongoModel):

    ingredients = fields.EmbeddedModelListField(Ingredient)

    source = fields.EmbeddedModelField(RecipeSource)

    notes = fields.ListField(Note)

    tags = fields.EmbeddedModelListField(Tag)

    instructions = fields.CharField()
Esempio n. 2
0
class Post(MongoModel):
    # We set "blank=False" so that values like the empty string (i.e. u'')
    # aren't considered valid. We want a real title.  As above, we also make
    # most fields required here.
    title = fields.CharField(required=True, blank=False)
    body = fields.CharField(required=True)
    date = fields.DateTimeField(required=True)
    author = fields.ReferenceField(User, required=True)
    # Comments will be stored as a list of embedded documents, rather than
    # documents in their own collection. We also set "default=[]" so that we can
    # always do:
    #
    #     post.comments.append(Comment(...))
    #
    # instead of:
    #
    #     if post.comments:
    #         post.comments.append(Comment(...))
    #     else:
    #         post.comments = [Comment(...)]
    comments = fields.EmbeddedModelListField(Comment, default=[])

    @property
    def summary(self):
        """Return at most 100 characters of the body."""
        if len(self.body) > 100:
            return self.body[:97] + '...'
        return self.body
Esempio n. 3
0
class PreDigitalPhoto(MongoModel):

    datetime_added = fields.DateTimeField()

    front_reproductions = fields.ListField(fields.ImageField(), blank=True)
    back_reproductions = fields.ListField(fields.ImageField(), blank=True)

    front_marking = fields.CharField(blank=True)
    back_marking = fields.CharField(blank=True)

    fuzzy_location = fields.EmbeddedModelField(FuzzyLocation, blank=True)
    fuzzy_datetime = fields.EmbeddedModelField(FuzzyDateTime, blank=True)

    notes = fields.EmbeddedModelListField(PreDigitalPhotoNote, blank=True)

    people = fields.ListField(fields.ReferenceField(Person), blank=True)

    class Meta:
        connection_alias = 'pre-digital-photos-connection'
        collection_name = 'photos'
class User(MongoModel):
    fname = fields.CharField()
    friend = fields.ReferenceField('test.test_context_managers.User')
    badges = fields.EmbeddedModelListField(Badge)
class Post(MongoModel):
    body = fields.CharField()
    images = fields.EmbeddedModelListField(Image)
 class Blog(MongoModel):
     name = fields.CharField()
     reviews = fields.EmbeddedModelListField(Review)
Esempio n. 7
0
 class MultiReferenceModel(MongoModel):
     comments = fields.ListField(fields.ReferenceField(Comment))
     posts = fields.ListField(fields.ReferenceField(Post))
     embeds = fields.EmbeddedModelListField(MultiReferenceModelEmbed)
Esempio n. 8
0
class CommentWrapperList(MongoModel):
    wrapper = fields.EmbeddedModelListField(CommentWrapper)
Esempio n. 9
0
 class Container(MongoModel):
     lst = fields.EmbeddedModelListField(OtherRefModel)