from mongoengine import *
from werkzeug.security import generate_password_hash, check_password_hash
from util import derefer

class UserCompany(Document):
    email = StringField(unique=True, max_length=255, required=True)
    password = StringField(max_length=255, required=True)
    company = ReferenceField('Company', reverse_delete_rule=NULLIFY)

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

    def set_password(self, password):
        if(len(password) > 0):
            self.password = generate_password_hash(password)

    def serialize(self):
        return {
            'email': self.email,
            'company': derefer(self.company),
            'created_at': self.id.generation_time.isoformat()
        }

0ef085ed69a7ecad3861ba8a9cdec1861e81f28a
<mask token>


class UserCompany(Document):
    <mask token>
    <mask token>
    <mask token>

    def check_password(self, password):
        return check_password_hash(self.password, password)
    <mask token>

    def serialize(self):
        return {'email': self.email, 'company': derefer(self.company),
            'created_at': self.id.generation_time.isoformat()}

<mask token>


class UserCompany(Document):
    <mask token>
    <mask token>
    <mask token>

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

    def set_password(self, password):
        if len(password) > 0:
            self.password = generate_password_hash(password)

    def serialize(self):
        return {'email': self.email, 'company': derefer(self.company),
            'created_at': self.id.generation_time.isoformat()}

<mask token>


class UserCompany(Document):
    email = StringField(unique=True, max_length=255, required=True)
    password = StringField(max_length=255, required=True)
    company = ReferenceField('Company', reverse_delete_rule=NULLIFY)

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

    def set_password(self, password):
        if len(password) > 0:
            self.password = generate_password_hash(password)

    def serialize(self):
        return {'email': self.email, 'company': derefer(self.company),
            'created_at': self.id.generation_time.isoformat()}

from mongoengine import *
from werkzeug.security import generate_password_hash, check_password_hash
from util import derefer


class UserCompany(Document):
    email = StringField(unique=True, max_length=255, required=True)
    password = StringField(max_length=255, required=True)
    company = ReferenceField('Company', reverse_delete_rule=NULLIFY)

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

    def set_password(self, password):
        if len(password) > 0:
            self.password = generate_password_hash(password)

    def serialize(self):
        return {'email': self.email, 'company': derefer(self.company),
            'created_at': self.id.generation_time.isoformat()}

from mongoengine import *
from werkzeug.security import generate_password_hash, check_password_hash
from util import derefer

class UserCompany(Document):
    email = StringField(unique=True, max_length=255, required=True)
    password = StringField(max_length=255, required=True)
    company = ReferenceField('Company', reverse_delete_rule=NULLIFY)

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

    def set_password(self, password):
        if(len(password) > 0):
            self.password = generate_password_hash(password)

    def serialize(self):
        return {
            'email': self.email,
            'company': derefer(self.company),
            'created_at': self.id.generation_time.isoformat()
        }
