class PiInfo(db.Document): ip = db.StringField() mac = db.StringField() description = db.StringField() alias = db.StringField() def get_absoluter_url(self): return url_for('post', kwargs={"slug": self.slug}) def __unicode__(self): return self.ip
class Data(db.Document): domain = db.StringField() address = db.StringField() property = db.StringField() timestamp = db.DateTimeField(unique=True) value = db.IntField() def get_absolute_url(self): return url_for('post', kwargs={"slug": self.slug}) def __unicode__(self): return self.address
class User(db.Document, UserMixin): username = db.StringField(required=True, unique=True) email = db.EmailField(required=True, unique=True) password = db.StringField(required=True) profile_pic = db.ImageField() otp_secret = db.StringField(required=True, min_length=16, max_length=16, default=pyotp.random_base32()) # Returns unique string identifying our object def get_id(self): return self.username
class Bill(db.Document): orden = db.IntField(default=10000, required=True, primary_key=True) client_orden = db.IntField(required=True) session_id = db.StringField(max_length=200, required=True) amount = db.IntField(required=True) ip = db.StringField(max_length=15, required=True) state = db.ReferenceField(State) succ_url = db.URLField(required=True) fail_url = db.URLField(required=True) auth_code = db.IntField() trx_id = db.IntField() trx_date = db.DateTimeField() last_digits = db.IntField() tipo_cuota = db.StringField(max_length=200) num_cuota = db.IntField() message = db.StringField(max_length=200) meta = {'ordering': ['orden']}
class Post(db.DynamicDocument): created_at = db.DateTimeField(default=datetime.datetime.now, required=True) title = db.StringField(max_length=255, required=True) slug = db.StringField(max_length=255, required=True) body = db.StringField(required=True) comments = db.ListField(db.EmbeddedDocumentField('Comment')) #make a array save the comments . def get_absolute_url(self): return url_for('post', kwargs={"slug": self.slug}) def __unicode__(self): return self.title @property def post_type(self): return self.__class__.__name__ meta = { 'allow_inheritance': True, 'indexes': ['-created_at', 'slug'], 'ordering': ['-created_at'] }
class Zhihu(db.Document): meta = { 'collection': 'ZhihuItem', 'ordering': ['-add_time'], 'strict': False, } title = db.StringField() content = db.StringField() message_url = db.StringField() id = db.StringField() image_url = db.StringField() source_from = db.StringField() add_time = db.DateTimeField(default=datetime.utcnow) def to_json(self): json_douban = { 'title': self.title, 'content': self.content, 'message_url': self.message_url, 'image_url': self.image_url, 'source_from': self.source_from } return json_douban
class State(db.Document): name = db.StringField(max_length=50, required=True) def __unicode__(self): return self.name
class Quote(Post): body = db.StringField(required=True) author = db.StringField(verbose_name="Author Name",required=True, max_length=255)
class Comment(db.EmbeddedDocument): created_at = db.DateTimeField(default=datetime.datetime.now, required=True) body = db.StringField(verbose_name="Comment", required=True) author = db.StringField(verbose_name="Name", max_length=255, required=True)
class Image(Post): image_url = db.StringField(required=True, max_length=255)
class Video(Post): embed_code = db.StringField(required=True)
class BlogPost(Post): body = db.StringField(required=True)
class CatImage(db.Document): commenter = db.ReferenceField(User, required=True) im = db.ImageField() date = db.StringField(required=True) cat_name = db.StringField(required=True, min_length=1, max_length=100)
class Review(db.Document): commenter = db.ReferenceField(User, required=True) content = db.StringField(required=True, min_length=5, max_length=500) date = db.StringField(required=True) cat_name = db.StringField(required=True, min_length=1, max_length=100)