#encoding: utf-8

from app import db

class User(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    username = db.Column(db.String(80), unique=True)
    password = db.Column(db.String(40))
    email = db.Column(db.String(250))

    def __init__(self, username=None, password=None, email=None):
        self.username = username
        self.password = password
        self.email = email

    def create(self, form):
        if form['username']=='':
            return True, "Username should not be empty."
        if form['password']=='':
            return True, "Password should not be empty."
        if form['password']!=form['password_cross']:
            return True, "Password and confirmation are not the same."
        return False, "Subscription complete! You can now connect directly!"
