예제 #1
0
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
예제 #2
0
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']}
예제 #3
0
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']
    }
예제 #4
0
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
예제 #5
0
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)