class StreamedModelMixin(EmbeddedDocument): """This class standardizes the way streaming data is handled by adding two fields that can be used to sort the list. """ created_at = MillisecondField(default=0) updated_at = MillisecondField(default=0) meta = {'mixin': True}
class ShortLink(Document): """A UserProfile is essentially any publicly available info about the user. Stored in a document separate from the User itself for security. """ link = URLField(max_length=100) short_id = StringField(max_length=10) # 10 is HUGE created_at = MillisecondField() updated_at = MillisecondField() dereferences = IntField(default=0) def __unicode__(self): return u'<shortlink: %s>' % (self.short_id)
class ListItem(Document): """Bare minimum to have the concept of streamed item. """ # ownable owner = ObjectIdField(required=True) username = StringField(max_length=30, required=True) # streamable created_at = MillisecondField() updated_at = MillisecondField() url = URLField() _private_fields = [ 'owner', ] def __unicode__(self): return u'%s' % (self.url)
class UserProfile(Document): """A UserProfile is essentially any publicly available info about the user. Stored in a document separate from the User itself for security. """ # ownable owner = ObjectIdField(required=True) username = StringField(max_length=30, required=True) # streamable created_at = MillisecondField() updated_at = MillisecondField() # unique fields name = StringField(max_length=100) location = StringField(max_length=100) website = URLField() _private_fields = [ 'owner', ] def __unicode__(self): return u'%s' % (self.username)