Exemple #1
0
class MenuItemRating(db.Model):
    id = db.Column(db.Integer,
                   db.Sequence('seq_reg_id', start=1, increment=1),
                   unique=True)
    restaurantId = db.Column(db.Integer,
                             db.ForeignKey("restaurant.id"),
                             primary_key=True)
    menuitemId = db.Column(db.Integer,
                           db.ForeignKey("menu_item.id"),
                           primary_key=True)
    userId = db.Column(db.Integer, db.ForeignKey("user.id"), primary_key=True)
    rating = db.Column(db.Integer, db.CheckConstraint('rating<6'),
                       db.CheckConstraint('rating>0'))
    date = db.Column(db.Date)
class Todo(db.Model):
    __tablename__ = 'todos333'
    id = db.Column('todo_id', db.Integer, primary_key=True)
    title = db.Column(db.String(60))
    text = db.Column(db.String)
    done = db.Column(db.Boolean)
    pub_date = db.Column(db.DateTime)
    user_id = db.Column(db.Integer, db.ForeignKey('users333.user_id'))

    def __init__(self, title, text):
        self.title = title
        self.text = text
        self.done = False
        self.pub_date = datetime.utcnow()
Exemple #3
0
class Medicamentos(db.Model):
    '''
        Define as tablelas do banco de dados:

        Medicamentos
            Tabela com caracteristicas dos mediacamentos cadastrados no sistema.

            :type db.Model: object
            :param db.Model: importa todos os tipos de dados para criar a tabela           
    '''
    __tablename__ = 'Medicamentos'
    id = db.Column(db.Integer, primary_key=True, autoincrement=True)
    nome = db.Column(db.String(30))
    tipo = db.Column(db.String(20))
    dosagem_type = db.Column(db.String(2))
    dosagem_vol = db.Column(db.Integer)
    valor = db.Column(db.Numeric(10, 2))
    fabricante = db.Column(db.String(80))
Exemple #4
0
class User(UserMixin, db.Model):
    """Main User class for the DB"""

    id = db.Column(db.Integer, primary_key=True)
    email = db.Column(db.String(64), unique=True)
    username = db.Column(db.String(24), unique=True)
    pwd = db.Column(db.Text())
    about_me = db.Column(db.Text())
    date = db.Column(Date, default=datetime.datetime.now)

    # Constructor
    def __init__(self, username, email, pwd, about_me=None):
        self.username = username
        self.email = email
        self.pwd = pwd
        self.about_me = about_me
Exemple #5
0
class User_books(db.Model):
    """User_books DB Class that connects user and the book based on user ID"""

    id = db.Column(db.Integer, primary_key=True)
    user_id = db.Column(db.Integer)
    book_id = db.Column(db.Integer)
    date = db.Column(Date, default=datetime.datetime.now)
    summary = db.Column(db.String)
    rating = db.Column(db.Integer)

    # Constructor
    def __init__(self, user_id, book_id, summary, rating):
        self.user_id = user_id
        self.book_id = book_id
        self.summary = summary
        self.rating = rating
Exemple #6
0
class TestCase(SAFRSBase, db.Model):
    __tablename__ = 'TestCase'

    id = db.Column(db.Integer,
                   primary_key=True,
                   server_default=db.FetchedValue())
    test_case_static_id = db.Column(db.ForeignKey('TestCaseStatic.id'))
    test_suite_id = db.Column(db.ForeignKey('TestSuite.id'))
    time = db.Column(db.Numeric, nullable=False)
    properties = db.Column(db.JSON)
    system_out = db.Column(db.String)
    system_err = db.Column(db.String)

    test_case_static = db.relationship(
        'TestCaseStatic',
        primaryjoin='TestCase.test_case_static_id == TestCaseStatic.id',
        backref='test_cases')
    test_suite = db.relationship(
        'TestSuite',
        primaryjoin='TestCase.test_suite_id == TestSuite.id',
        backref='test_cases')
Exemple #7
0
class Customer(db.Model):
	cid = db.Column(db.String(10), primary_key = True)
	c_name = db.Column(db.String(25))
	c_number = db.Column(db.String(), unique = True)
	c_email = db.Column(db.String(30))
	c_address = db.Column(db.String(50))
	city = db.Column(db.String(20))
	country = db.Column(db.String(20))
	

	ref_from_bills_for_cid = db.relationship('Bills' , backref = 'customer', lazy = 'dynamic', passive_deletes=True)
	#ref_from_transactions_for_cid = db.relationship('Transactions' , backref = 'customer', lazy = 'dynamic')
	
	def __init__(self, cid, c_name, c_number, c_email, c_address, city, country):
		self.cid = cid
		self.c_name = c_name
		self.c_number = c_number
		self.c_email = c_email
		self.c_adddress = c_adddress
		self.city = city
		self.country = country
Exemple #8
0
class User(TimeStampedModel):
    __tablename__ = 'users'

    id = db.Column(db.Integer, primary_key=True)
    password = db.Column(db.Text)
    username = db.Column(db.String(20), unique=True, nullable=False)
    email = db.Column(db.String(120), unique=True, nullable=True)
    post_ids = db.Column(db.String, default=None)
    is_deleted = db.Column(db.Boolean, default=False)
    posts = db.relationship('Post', backref='users', lazy='dynamic')
    comments = db.relationship('Comment', backref='users', lazy='dynamic')

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

    def is_authenticated(self):
        return True

    def is_active(self):
        return True

    def is_anonymous(self):
        return False

    def get_username(self):
        return self.username

    def get_id(self):
        try:
            return unicode(self.id)  # python 2
        except NameError:
            return str(self.id)  # python 3

    def __repr__(self):
        return '<User %r>' % (self.username)
Exemple #9
0
class Task(db.Model):
    __tablename__ = 'tasks'

    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(20), unique=True, nullable=False)
    description = db.Column(db.String(50), nullable=True)
    dashboard_id = db.Column(db.Integer, db.ForeignKey("dashboards.id"))
    creator = db.Column(db.Integer, db.ForeignKey("users.id"))
    users = db.relationship("User", secondary=users_tasks_table, backref="task")
    status = db.Column(db.String(15), nullable=False, default="To do")

    def __repr__(self):
        return f'Table: {self.name}'

    def serialize(self):
        return {
            'id': self.id,
            'name': self.name,
            'description': self.description,
            'dashboard id': self.dashboard_id,
            'creator': self.creator,
            'status': self.status
        }