class User(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    uname = db.Column(db.String(20), unique=True)
    upass = db.Column(db.String(20))
    email = db.Column(db.String(20))
    phone = db.Column(db.String(20))
    skills = db.Column(db.String(300))
    roll_no = db.column(db.String(20), unique=True)
    branch = db.column(db.String(100))
    post = db.relationship('posts',backref='student',lazy='dynamic')
    

    def __init__(self, uname, upass, email, phone,skills,roll_no,branch):
        self.uname = uname
        self.upass = upass
        self.email = email
        self.phone = phone
        self.skills = skills
        self.roll_no = roll_no
        self.branch = branch

        def __repr__(self):
        return ('<User {}>'.format(self.uname))

class posts(db.model):
    id = db.Column('post_id', db.Integer, primary_key = True)
    student_id = db.Column(db.Integer,db.foreign_key("students.id"))
    post = db.Column(db.String(10000))
    comment = db.relationship('comments',backref='post',lazy='dynamic')

     def __init__(self,post ):
        self.post = post
Exemple #2
0
class Offering(db.Model):
    __tablename__ = "offerings"
    id = db.Column(db.Integer, primary_key=True, unique=True)
    courseform_id = db.Column(db.Integer,
                              db.ForeignKey('courseforms.id'),
                              nullable=False)
    course_id = db.Column(db.Integer,
                          db.ForeignKey('courses.id'),
                          nullable=False)
    submitted = db.Column(db.Boolean)
    signed = db.Column(db.Integer)
    date_signed = db.column(db.DateTime)
    date_created = db.column(db.DateTime)
    course = db.relationship('Course',
                             backref="offerings",
                             lazy=True,
                             uselist=False)

    def save(self):
        db.session.add(self)
        db.session.commit()

    @staticmethod
    def get_all():
        return Offering.query.all()

    def delete(self):
        db.session.delete(self)
        db.session.commit()

    def __repr__(self):
        return '<Offering %r>' % self.signed
Exemple #3
0
class User(db.Model):
    id = db.column(db.Integer, primary_key=True, nullable=False)
    name = db.column(db.String(80), nullable=False)
    register_time = db.column(db.Date, nullable=False, default=datetime.utcnow())

    def get_reminders(self):
        return ReminderEntry.query.filter_by(user_id=self.id).all()
Exemple #4
0
class Degree(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    name = db.column(db.String(128))
    description = db.column(db.Text)
    school_id = db.Column(db.Integer, db.ForeignKey('school.id'))

    def __repr__(self):
        return '<Degree: {}>'.format(self.name)
Exemple #5
0
class User(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    nickname = db.column(db.String(64), index=True, unique=True)
    email = db.column(db.String(120), index=True, unique=True)

    #tells python how to print objects of this class
    def __repr__(self):
        return '<User %r>' % (self.nickname)
Exemple #6
0
class School(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    name = db.column(db.String(128))
    country = db.column(db.String(64))
    city = db.Column(db.String(64))
    degrees = db.relationship('Degree', backref='school', lazy='dynamic')

    def __repr__(self):
        return '<School: {}>'.format(self.name)
class InOutFun(db.Model):
    rec_id = db.Column(db.Integer, primary_key=True)
    index = db.Column(db.Integer, index=True, unique=True)
    time_zone_num = db.Column(db.Integer, db.ForeignKey("time_zone.rec_id"))
    event_num = db.Column(db.Integer, db.ForeignKey("event.event_num"))
    input_num = db.Column(db.String(45), db.ForeignKey("input_param.input_num"))
    out_type = db.column(db.Integer)
    out_addr = db.column(db.Integer)
    out_time = db.column(db.Integer)
    delay = db.column(db.Integer)
Exemple #8
0
class Handover(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    artifact_id = db.column(db.Integer, db.ForeignKey('artifact.id'))
    predecessor_id = db.column(db.Integer, db.ForeignKey('handover.id'))
    user_id = db.column(db.Integer, db.ForeignKey('user.id'))
    media_id = db.column(db.Integer, db.ForeignKey('media.id'))
    date = db.Column(db.DateTime, index=True, default=datetime.utcnow)
    lat = db.Column(db.Float)
    lon = db.Column(db.Float)
    predecessor = db.relationship('Handover',
                                  backref=db.backref('previous',
                                                     remote_side=id))
Exemple #9
0
class ReminderEntry(db.Model):
    entry_id = db.column(db.Integer, primary_key=True)
    user_id = db.column(db.Integer, db.ForeignKey('user.id'), nullable=False)
    message = db.column(db.Integer,
                        db.ForeignKey('message.msg_id'),
                        nullable=True)
    time = db.column(db.DateTime)

    def get_message(self):
        return Message.query.filter_by(msg_id=self.message).first()

    def find_date_diff(self):
        return (datetime.utcnow() - self.time).days
Exemple #10
0
class BlogPost(db.model):

	__tablename__ = "posts"

	id = db.column(db.integer, primary_key=True)
	title = db.column(db.string, nullable=False)
	description = db.column(db.string, nullable=False)


	def __init__(self, title, description):
		self.title = title
		self.description = description

	def __repr__(self):
		return '<title {}'.format(self.title)
Exemple #11
0
class HangboardWerkout(db.Model):

    __tablename__ = "hangboardwerkout"
    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(4096))
    board = db.column(db.String(96))
    holds_used = db.Column(db.Integer)
    arm_used = db.Column(db.String(96))
    hangtime = db.Column(db.Integer)
    resttime = db.Column(db.Integer)
    reps = db.Column(db.Integer)
    sets = db.Column(db.Integer)
    setrest = db.Column(db.Integer)
    weight_kg = db.Column(db.Integer)
    timestamp = db.Column(db.DateTime)
    user_id = db.Column(db.Integer, db.ForeignKey('users.id'))

    def __init__(self, name, board, holds_used, reps, sets, setrest, arm_used,
                 hangtime, resttime, weight_kg, timestamp, user_id):
        self.name = name
        self.board = board
        self.holds_used = holds_used
        self.arm_used = arm_used
        self.hangtime = hangtime
        self.resttime = resttime
        self.reps = reps
        self.sets = sets
        self.setrest = setrest
        self.weight_kg = weight_kg
        self.timestamp = timestamp
        self.user_id = user_id
Exemple #12
0
class Posts(db.Model):
    STATUS_PUBLIC = 0
    STATUS_DRAFT = 1
    id = db.Column(db.Integer, primary_key=True)
    title = db.Column(db.String(200))
    slug = db.Column(db.String(100), unique=True)
    body = db.column(db.Text)
    status = db.Column(db.SmallInteger, default=STATUS_PUBLIC)
    created_timestamp = db.Column(db.DateTime, default=datetime.datetime.now)
    modified_timestamp = db.Column(db.DateTime,
                                   default=datetime.datetime.now,
                                   onupdate=datetime.datetime.now)
    tags = db.relationship('Tag',
                           secondary=post_tags,
                           backref=db.backref('Posts', lazy='dynamic'))

    def __init__(self, *args, **kwargs):
        super(Posts, self).__init__(*args,
                                    **kwargs)  #call current constructors
        self.generate_slug()

    def generate_slug(self):
        self.slug = ''
        if self.title:
            self.slug = slugify(self.title)

    def __repr__(self):
        return '<Post : %r>' % self.title
class User(db.Model):
    __tablename__ = "users"
    id = db.Column(db.Integer, primary_key=True)
    username = db.Column(db.String(20), unique=True)
    fullname = db.Column(db.String(50))
    password = db.column(db.String(50))

    recipes = db.relationship('Recipe', backref="users")

    def __init__(self):
        pass

    def new_user(self, username, fullname, password):
        self.username = username
        self.fullname = fullname
        self.password = password

    @staticmethod
    def get_all_users():
        return User.query.all()

    def save(self):
        db.session.add(self)
        db.session.commit()

    def delete(self):
        db.session.delete(self)
        db.session.commit()

    def __repr__(self):
        return "<User: {}>".format(self._name)
Exemple #14
0
class Body(db.Model):
    """
    Body table

    Contains raw text used to render a version of a song. The name should
    describe the version, and not repeat the song metadata. If empty, it will
    default to 'Default'

    Good names might be:
    - 'Beginner version'
    - '100% super-pedantic hard version'
    - 'Crazy jazz re-harm.'

    Bad names are things like:
    - 'Bad moon rising' -- This repeats the metadata
    - 'C Major Version' -- Use transposition tools instead of a new version
    - 'Artist So-and-so cover' -- Submit a new song with the covering artist
    """
    id = db.Column(db.Integer, primary_key=True)
    timestamp = db.Column(db.DateTime, index=True, default=datetime.utcnow)
    song_id = db.Column(db.Integer, db.ForeignKey('song.id'))
    name = db.Column(db.String(50))
    body = db.Column(db.String(10000))
    revision = db.column(db.Integer())

    def __repr__(self):
        return '<Body>'
Exemple #15
0
class Book(db.Model):
    """图书信息"""
    __tablename__ = "books"

    book_id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(256), nullable=False, index=True)
    press_time = db.Column(db.Date())
    isbn = db.Column(db.String(128))
    price = db.Column(db.DECIMAL(5, 2))
    category = db.Column(db.String(128))
    coden = db.column(db.String(128))  # 分类号
    total_page = db.Column(db.Integer)
    summary = db.column(db.Text)

    press_id = db.Column(db.Integer, db.ForeignKey("press.press_id"))
    author_id = db.Column(db.Integer, db.ForeignKey("authors.author_id"))
def read_near_ads(latitude, longitude, distance):
	'''
	This function reads, serializes and returns all tupples in Ad table that
	their geographical location is nearer than distance (Killometer) in order.
	Instead of using GIS database extensions, SqlAlchemy Hybrid method and Great Circle
	formula are used here to query the database for calculating the distances.
	'''
	try:
		ads = db.session.query(
			Ad,
			Ad.distance(latitude, longitude).label('distance'),
			Ad.agency_id,
			Ad.name,
			Ad.latitude,
			Ad.longitude
		).having(db.column('distance') <= distance).order_by('distance').all()
		ads_json = [{
		'agency_id' : ad.agency_id,
		'name': ad.name,
    	'latitude': float(ad.latitude),
    	'longitude': float(ad.longitude),
    	'distance': ad.distance
    	} for ad in ads]
		return ads_json
	except Exception as e:
		print('error while reading near ads: ' + str(e))
		return None
Exemple #17
0
class Post(db.model):
    id = db.Column(db.Integer, primary_key=True)
    body = db.column(db.String(140))
    timestamp = db.Column(db.DateTime, index=True, default=datetime.utcnow)
    user_id = db.Column(db.Integer,db.ForeignKey('user.id'))

    def __repr__(self):
        return '<Post {}>'.format(self.body)
Exemple #18
0
class Post(db.Model):
    id = db.Column(db.Integer(), primary_key=True)
    title = db.column(db.String(140), nullable=False)
    slug = db.column(db.String(140), unique=True)
    body = db.column(db.TEXT(), nullable=False)
    created = db.column(db.DateTime(), nullable=False)

    def __init__(self, *args, **kwargs):
        super(Post, self).__init__(*args, **kwargs)
        self.generate_slug()

    def generate_slug(self):
        if self.title:
            self.slug = slugify(self.title)

    def __repr__(self):
        return f'<Post id is {self.id}, title is {self.title}>'
Exemple #19
0
class Todo(db.Model):
    id = db.column(db.Integer, primary_key=True)
    content = db.Column(db.String(200), nullable=False)
    completed = db.Column(db.Integer, default=0)
    date_created = db.Column(db.DateTime, default=datetime.utcnow)

    def __repr__(self):
        return '<Task %r>' % self.id
class User(db.Model):
	__tablename__ = 'user'
	id = db.column(db.Integer, primary_key=True)
	name = db.Column(db.String(255), index=True, nullable=False)
	#groups = db.relationship('Group', secondary=group_relationship_table, backref='users')

	def __repr__(self):
		return 'User: %r' % self.name
Exemple #21
0
class Post(db.Model):
    __tablename__ = "posts"
    id = db.Column(db.Integer, primary_key=True, autoincrement=True)
    body = db.Column(db.String(140))
    timestamp = db.Column(db.DateTime)
    user_id = db.column(db.Integer, db.ForeignKey('user.id'))

    def __repr__(self):
        return '<Post %r>' % (self.body)
Exemple #22
0
class Message(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    sender_id = db.Column(db.Integer, db.ForeignKey('user.id'))
    recipient_id = db.column(db.Integer, db.ForeignKey('user.id'))
    body = db.Column(db.String(140))
    timestamp = db.Column(db.DateTime, index=True, default=datetime.utcnow)

    def __repr__(self):
        return '<Message {}>'.format(self.body)
Exemple #23
0
class Follow(db.Model):
    __tablename__ = "follow"

    id = db.column(db.Integer, primary_key=True)
    user_id = db.Column(db.Integer, db.ForeignKey('users.id'))
    follower_id = db.Column(db.Integer, db.ForeignKey('users.id'))

    user = db.relationship('User', foreign_keys=user_id)
    follower = db.relationship('User', foreign_keys=follower_id)
class User(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    username = db.Column(db.String(64), index=True, unique=True)
    email = db.Column(db.String(120), index=True, unique=True)
    password_hash = db.column(db.String(128))
    posts = db.relationship('Post', backref='author', lazy='dynamic')

    def __repr__(self):
        return '<User> {}>'.format(self.username)
Exemple #25
0
class User(db.Model):
    """
    The User model which stores the email, password and the names of the users
    @TODO: add from_json properties
    """
    id = db.column(db.Integer, primary_key=True)
    email = db.Column(db.String, default=None)
    first_name = db.Column(db.String, default=None)
    last_name = db.Column(db.String, default=None)
Exemple #26
0
class User(UserMixin, db.Model):
    """ Create a User table """

    # Ensures table will be named in plural and not in singular as is the name of the model

    __tablename__ = 'users'

    id = db.Column(db.Integer, primary_key=True)
    first_name = db.Column(db.String(60), index=True)
    last_name = db.Column(db.String(60), index=True)
    email = db.Column(db.String(60), index=True, unique=True)
    phone_number = db.column(db.Integer(15), index=True, unique=True)
    category = db.column(db.String(60), index=True)
    description = db.column(db.String(100), index=True)
    password_hash = db.Column(db.String(128))
    # department_id = db.Column(db.Integer, db.ForeignKey('departments.id'))
    # role_id = db.Column(db.Integer, db.ForeignKey('roles.id'))
    is_admin = db.Column(db.Boolean, default=False)

    @property
    def password(self):
        """ Prevents password from being accessed """

        raise AttributeError('password is not a readable attribute.')

    @password.setter
    def password(self, password):
        """ Set password to a hashed password """

        self.password_hash = generate_password_hash(password)

    def verify_password(self, password):
        """ Check if hashed password matches actual password """

        return check_password_hash(self.password_hash, password)

    def __repr__(self):
        return '<Donor: {}>'.format(self.first_name)

    # set up user_loader
    @login_manager.user_loader
    def load_user(user_id):
        return User.query.get(int(user_id))
Exemple #27
0
class User(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    nickname = db.column(db.String(64), index=True, unique=True)
    email = db.Column(db.String(120), index=True, unique=True)

    def __repr__(self):
        '''The __repr__ method tells Python how to print objects of this class. 
        We will use this for debugging.'''

        return '<User %>' % self.nickname
Exemple #28
0
class Tag(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    body = db.column(db.String(140))
    timestamp = db.Column(db.DateTime, index=True, default=datetime.utcnow)
    note_id = db.Column(db.Integer, db.ForeignKey('note.id'))
    section_id = db.Column(db.Integer, db.ForeignKey('section.id'))
    user_id = db.Column(db.Integer, db.ForeignKey('user.id'))

    def __repr__(self):
        return '<Note {}>'.format(self.body)
Exemple #29
0
class Fabu(db.Model):
    """发布模型"""
    __tablename__ = 'T_Fabu_Data'

    id = db.Column(db.Integer, primary_key=True)
    goodsid = db.Column(db.String(50))

    premium = db.Column(db.String(50))
    invalidTime = db.Column(db.String(50))
    issueTime = db.Column(db.String(50))
    cancelTime = db.Column(db.String(50))

    username = db.Column(db.String(50))
    stockCode = db.Column(db.String(50))
    factoryname = db.Column(db.String(50))
    weight = db.Column(db.String(50))
    material = db.Column(db.String(50))
    standard_thickness = db.Column(db.String(50))
    standard_width = db.Column(db.String(50))
    format = db.Column(db.String(50))
    width = db.Column(db.String(50))
    edge = db.Column(db.String(50))
    level = db.Column(db.String(50))
    thickness = db.Column(db.String(50))
    warehouse = db.Column(db.String(50))
    applyid = db.Column(db.String(50))
    stockid = db.column(db.String(50))
    contract = db.Column(db.String(50))
    status = db.Column(db.Integer)

    def __init__(self, username, goodsid, stockCode, factoryname, weight,
                 material, standard_thickness, standard_width, format, width,
                 edge, level, thickness, warehouse, applyid, stockid, status,
                 premium, invalidtime, contract):
        self.username = username
        self.goodsid = goodsid
        self.stockCode = stockCode
        self.factoryname = factoryname
        self.weight = weight
        self.material = material
        self.standard_thickness = standard_thickness
        self.standard_width = standard_width
        self.format = format
        self.width = width
        self.edge = edge
        self.level = level
        self.thickness = thickness
        self.warehouse = warehouse
        self.applyid = applyid
        self.stockid = stockid
        self.status = status

        self.premium = premium
        self.invalidTime = invalidtime
        self.contract = contract
Exemple #30
0
class Tag(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    name = db.column(db.String(64))
    slug = db.Column(db.String(64), unique=True)

    def __init__(self, *args, **kwargs):
        super(Tag, self).__init__(*args, **kwargs)
        self.slug = slugify(self.name)

    def __repr__(self):
        return '<Tag: %s>' % self.slug