Esempio n. 1
0
class Transaction(db.Document):
    ws_cust_id = db.IntField(required=True, length=9)
    ws_acct_id = db.IntField(required=True, length=9)
    ws_transaction_id = db.IntField(required=True, length=9)
    ws_description = db.StringField(required=True, length=9)
    ws_amount = db.IntField(required=True)
    ws_trxn_date = db.DateField(required=True)
Esempio n. 2
0
class User(db.Document):
    user_id     =   db.IntField(unique=True)
    first_name  =   db.StringField(max_length=20)
    last_name   =   db.StringField(max_length=20)
    email       =   db.EmailField(max_length=30, unique=True)
    birthday    =   db.DateField()
    gender      =   db.StringField()
    address     =   db.StringField()
    suburb      =   db.StringField()
    postcode    =   db.IntField(length=4)
    description =   db.StringField(max_length = 200)
    password    =   db.StringField(max_length=20)
    available   =   db.BooleanField(default=True)
    token       =   db.StringField()
    contacts    =   db.ListField(Contact)
    # profile_pic =   
    
    def set_password(self, password):
        self.password = generate_password_hash(password)

    def get_password(self, password):
        return check_password_hash(self.password, password)   

    def assign_token(self, id):
        secret = 'YUWA'
        token = str(jwt.encode({'id': id}, secret, algorithm='HS256'))
        self.token = token
        db.Users.update(
            {"_id": id}, 
            {$set: {"token": token}}
        )
        return token

    def invalidate_token(self, token):
        self.token = ""
Esempio n. 3
0
class Account(db.Document):
    ws_cust_id = db.IntField(required=True, length=9)
    ws_acct_id = db.IntField(required=True, length=9)
    ws_acct_type = db.StringField(required=True, length=9)
    ws_acct_balance = db.IntField(required=True)
    ws_acct_crdate = db.DateField(required=True)
    ws_acct_lasttrdate = db.DateField()
Esempio n. 4
0
class Message(db.Document):
    from_user = db.ReferenceField(User, db_field="fu", reverse_delete_rule=CASCADE)
    to_user = db.ReferenceField(User, db_field="tu", default=None, reverse_delete_rule=CASCADE)
    text = db.StringField(db_field="t", max_length=1024)
    live = db.BooleanField(db_field="l", default=None)
    create_date = db.IntField(db_field="c", default=now())
    parent = db.ObjectIdField(db_field="p", default=None)
    images = db.ListField(db_field="ii")
    message_type = db.IntField(db_field='mt', default=POST, choices=MESSAGE_TYPE)
    
    @property
    def text_linkified(self):
        return linkify(self.text)
    
    @property
    def human_timestamp(self):
        return ms_stamp_humanize(self.create_date)
    
    @property
    def comments(self):
        return Message.objects.filter(parent=self.id, message_type=COMMENT).order_by('create_date')

    @property
    def likes(self):
        return Message.objects.filter(parent=self.id, message_type=LIKE).order_by('-create_date')
        
    def post_imgsrc(self, image_ts, size):
        if AWS_BUCKET:
            return os.path.join(AWS_CONTENT_URL, AWS_BUCKET, 'posts', '%s.%s.%s.png' % (self.id, image_ts, size))
        else:
            return url_for('static', filename=os.path.join(STATIC_IMAGE_URL, 'posts', '%s.%s.%s.png' % (self.id, image_ts, size)))
    
    meta = {
        'indexes': [('from_user', 'to_user', '-create_date', 'parent', 'live')]
    }
class Application(db.Document):
    apply_id      = db.IntField(  )
    applicant_id  = db.IntField( required=True )
    applicant_name= db.StringField( max_length = 50 )
    activity_id   = db.IntField( required=True )
    activity_name = db.StringField( max_length = 50 )
    status        = db.IntField( required=True, default=0 )
Esempio n. 6
0
class Product(db.DynamicDocument):
    meta = {
        'collection':
        'products',
        'shard_key':
        'asin',
        'indexes': [
            'title', "asin", "pI", '-created', {
                "fields": ['$title', '$description'],
                "default_language": 'english',
                'weights': {
                    'title': 7,
                    'description': 3
                }
            }
        ]
    }
    asin = db.StringField(db_field="asin", required=True, unique=True)
    productIntId = db.IntField(db_field="pI")
    title = db.StringField(db_field="title", required=True)
    description = db.StringField(db_field="description", required=True)
    imageUrl = db.StringField(db_field="imUrl")
    created = db.IntField(db_field="c", default=now())
    related = db.DictField(db_field="related")
    price = db.FloatField(db_field="price")
Esempio n. 7
0
class Room(db.Document):
    room_name = db.StringField(max_length=30, unique=True)
    length = db.IntField()
    width = db.IntField()
    pos_x = db.IntField()
    pos_y = db.IntField()
    doors = db.StringField()
Esempio n. 8
0
class User(db.Document):
    username = db.StringField(db_field="u", required=True)
    password = db.StringField(db_field="p", required=True)
    email = db.EmailField(db_field="e", required=True, unique=True)
    created = db.IntField(db_field="c", default=now())
    userIntId = db.IntField(db_field="rI", default=now())
    meta = {'indexes': ['username', 'email', '-created']}
Esempio n. 9
0
class Account_Status(db.Document):
    ws_cust_id = db.IntField(required=True, length=9)
    ws_acct_id = db.IntField(required=True, length=9)
    ws_acct_type = db.StringField(required=True, length=9)
    ws_acct_status = db.StringField(required=True)
    ws_message = db.StringField()
    ws_acct_lastUdate = db.DateField()
Esempio n. 10
0
class CreditRedemption(db.Document):
    credit_redemption_id = db.StringField(db_field="credit_redemption_id", primary_key=True)
    credit = db.ReferenceField(Credit, db_field="credit_id")
    invoice = db.ReferenceField(Invoice, db_field="invoice_id")
    amount = db.IntField()
    remaining_balance = db.IntField()
    created_at = db.DateTimeField(default=datetime.now())
Esempio n. 11
0
class Relationship(db.Document):
    FRIENDS = 1
    BLOCKED = -1

    RELATIONSHIP_TYPE = (
        (FRIENDS, 'Friends'),
        (BLOCKED, 'Blocked'),
    )

    PENDING = 0
    APPROVED = 1

    STATUS_TYPE = (
        (PENDING, 'Pending'),
        (APPROVED, 'Approved'),
    )

    from_user = db.ReferenceField(User, db_field='fu', reverse_delete_rule=CASCADE)
    to_user = db.ReferenceField(User, db_field='tu', reverse_delete_rule=CASCADE)
    rel_type = db.IntField(db_field='rt', choices=RELATIONSHIP_TYPE)
    status = db.IntField(db_field='s', choices=STATUS_TYPE)
    req_date = db.IntField(db_field='rd', default=now())
    approved_date = db.IntField(db_field="ad", default=0)

    def is_friend(self, user):
        if user:
            return self.get_relationship(user, self.to_user)
        else:
            return None

    @staticmethod
    def get_relationship(from_user, to_user):
        if from_user == to_user:
            return 'SAME'
        rel = Relationship.objects.filter(
            from_user=from_user,
            to_user=to_user
        ).first()
        if rel and rel.rel_type == Relationship.FRIENDS:
            if rel.status == Relationship.PENDING:
                return "FRIENDS_PENDING"
            if rel.status == Relationship.APPROVED:
                return "FRIENDS_APPROVED"
        elif rel and rel.rel_type == Relationship.BLOCKED:
            return "BLOCKED"
        else:
            reverse_rel = Relationship.objects.filter(
                from_user=to_user,
                to_user=from_user
            ).first()
            if reverse_rel and reverse_rel.rel_type == Relationship.FRIENDS:
                if reverse_rel.status == Relationship.PENDING:
                    return "REVERSE_FRIENDS_PENDING"
            elif reverse_rel and reverse_rel.rel_type == Relationship.BLOCKED:
                return "REVERSE_BLOCKED"
            return None

    meta = {
        'indexes': [('from_user', 'to_user'), ('from_user', 'to_user', 'rel_type', 'status')]
    }
Esempio n. 12
0
class Character(db.Document):
    char_id         =   db.IntField( unique=True )
    char_name       =   db.StringField( max_length=50 )
    char_class      =   db.StringField( max_length=30 )
    char_atk        =   db.IntField()
    char_def        =   db.IntField()
    char_hp         =   db.IntField()
Esempio n. 13
0
class Transaction(db.Document):
    transaction_id = db.IntField(unique=True)
    user_id = db.IntField(unique=False)
    transaction_type = db.StringField(max_length=10)
    currency_symbol = db.StringField(max_length=30)
    amount = db.FloatField()
    value = db.FloatField()
    date = db.DateTimeField()
class Appointment(db.Document):
    myid        =   db.IntField( db_field='id', unique=True)
    prof_id     =   db.IntField( max_length=50 )    
    user_id     =   db.IntField( max_length=50 )
    prof_name   =   db.StringField( max_length=50 )  
    status      =   db.StringField( max_length=20 )  
    slot        =   db.StringField( max_length=30 )   
    date        =   db.DateField()
Esempio n. 15
0
class Diamonds(db.Document):
    skus = db.StringField()
    carat = db.IntField()
    price = db.IntField()
    cut = db.StringField()
    color = db.StringField()
    clarity = db.StringField()
    shapeCode = db.StringField()
class medicine_details(db.Document):
    medId = db.IntField(unique=True)
    medName = db.StringField()
    qty = db.IntField()
    rate = db.IntField()

    def get_cost(self, quantity):
        return (quantity * self.rate)
class staffDetails(db.Document):
    staffId = db.StringField(unique=True)
    staffSSN = db.IntField(unique=True)
    staffName = db.StringField(max_length=50)
    staffPhone = db.IntField(max_length=10)
    staffDept = db.StringField()
    staffDob = db.DateTimeField()
    staffDoj = db.DateTimeField()
    staffAddress = db.StringField()
class Patient(db.Document):
    ssnid = db.IntField(max_length=50, unique=True)
    name = db.StringField(max_length=50)
    age = db.IntField(max_length=50)
    address = db.StringField(max_length=50)
    dateofadmit = db.StringField(max_length=50)
    typeofbed = db.StringField(max_length=50)
    city = db.StringField(max_length=50)
    state = db.StringField(max_length=50)
Esempio n. 19
0
class Course(db.Document):
    course_id = db.IntField(unique=True)
    title = db.StringField(max_length=100)
    description = db.StringField(max_length=255)
    credits = db.IntField()
    term = db.StringField(max_length=25)

    def __repr__(self):
        return '<Course %r>' % self.title
Esempio n. 20
0
class Trumptweet(db.Document):
    source = db.StringField(max_length=50)
    id_str = db.StringField(max_length=50)
    text = db.StringField(max_length=280)
    created_at = db.StringField(max_length=50)
    retweet_count = db.IntField(max_length=50)
    in_reply_to_user_id_str = db.StringField(max_length=50)
    favorite_count = db.IntField(max_length=50)
    is_retweet = db.BooleanField(max_length=50)
Esempio n. 21
0
class Urls_to_crawl(db.Document):
    url = db.StringField(max_length=500, unique=True, required=True)
    channel_id = channel_id = db.IntField()
    title = db.StringField(max_length=200)
    topic_id = db.IntField()
    published_date = db.DateTimeField(default=datetime.now)
    description = db.StringField(max_length=500)
    visited = db.BooleanField(default=False)
    page_depth = db.IntField(required=True)
Esempio n. 22
0
class Registration(db.Document):
    patient_id = db.IntField(max_length=9, unique=True)
    patient_name = db.StringField(max_length=50)
    patient_age = db.IntField()
    date_of_join = db.StringField()
    type_of_bed = db.StringField()
    address = db.StringField(max_length=200)
    city = db.StringField()
    state = db.StringField()
Esempio n. 23
0
class DetailTemps(db.Document):
    date = db.DateTimeField()
    description = db.StringField()
    heure = db.DateTimeField()
    jour = db.IntField()
    conversion = db.FloatField()
    temps_id = db.ReferenceField(Temps)
    ordre = db.IntField()
    parent = db.IntField()
class Activity(db.Document):
    activity_id   = db.IntField( unique=True )
    activity_name = db.StringField( unique=True, max_length = 50 )
    leader_id     = db.IntField( required=True )
    leader_name   = db.StringField( max_length = 20)
    open_date     = db.DateTimeField( default=datetime.utcnow )
    start_date    = db.DateTimeField( )
    genre         = db.StringField( max_length = 20 )
    skills        = db.StringField( max_length = 50 )
    description   = db.StringField( max_length = 200 )
Esempio n. 25
0
class BestProduct(db.DynamicDocument):
    meta = {'collection': 'best_product', 'indexes': ['t']}
    asin = db.StringField(db_field="asin", required=True)
    avgOverall = db.FloatField(db_field="ao")
    title = db.StringField(db_field="t", required=True)
    price = db.FloatField(db_field="p")
    imageUrl = db.StringField(db_field="iu")
    description = db.StringField(db_field="d")
    cnt = db.IntField(db_field="cnt")
    created = db.IntField(db_field="dc", default=now())
Esempio n. 26
0
class Flight(db.Document):
    dep_date = db.DateTimeField()
    dep_city = db.StringField(max_length=50)
    des1 = db.StringField(max_length=50)
    dur1 = db.IntField(max_length=3)
    des2 = db.StringField(max_length=50)
    dur2 = db.IntField(max_length=3)
    des3 = db.StringField(max_length=50)
    dur3 = db.IntField(max_length=3)
    des4 = db.StringField(max_length=50)
    dur4 = db.IntField(max_length=3)
Esempio n. 27
0
class monster(db.Document):
    monster_id      =   db.IntField( unique=True )
    called          =   db.StringField()
    monster_type    =   db.StringField( max_length=50 )
    damage          =   db.IntField()

    def set_called(self, called):
        self.called = generate_password_hash(called)

    def get_called(self, called):
        return check_password_hash(self.called, called)
Esempio n. 28
0
class Company(db.Document):
    company_id = db.IntField( unique=True )
    fc_id = db.IntField()
    company_name = db.StringField( max_lenght=50 )
    email = db.EmailField( max_lenght=30, unique=True )
    password = db.StringField()
    
    def set_password(self, password):
        self.password = generate_password_hash(password)
        
    def get_password(self, password):
        return check_password_hash(self.password, password)        
Esempio n. 29
0
class Account(db.Document):
    TYPE = (('S', 'Savings'), ('C', 'Current'))
    STATUS = (('UPDATED', 'UPDATED'), ('CREATED', 'CREATED'), ('DELETED',
                                                               'DELETED'))
    ws_cust_id = db.StringField()
    ws_acct_id = db.StringField(unique=True)
    ws_acct_type = db.StringField(max_length=3, choices=TYPE)
    ws_status = db.StringField(max_length=10, choices=STATUS)
    ws_message = db.StringField()
    ws_acct_balance = db.IntField(min_value=0)
    ws_acct_crdate = db.DateTimeField()
    ws_acct_lasttrdate = db.DateTimeField()
    ws_acct_duration = db.IntField(min_value=0)
class ToDoTask(db.Document):
    task_id = db.IntField(unique=True)
    title = db.StringField(max_length=255, required=True)
    date_added = db.StringField(max_length=10)
    date_started = db.StringField(max_length=10)
    deadline_date = db.StringField(max_length=10)
    completion_date = db.StringField(max_length=10)
    description = db.StringField(max_length=255)
    task_type = db.StringField(max_length=10, required=True)
    status = db.StringField(max_length=15)
    time_taken = db.StringField(max_length=15)
    days_taken = db.IntField()
    priority = db.StringField(max_length=5)