Exemplo n.º 1
0
class Gamer(db.Model,UserMixin):
    __tablename__ = "gamers"
    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String)
    email = db.Column(db.String,unique=True)
    password = db.Column(db.String)
    photo = db.Column(db.String)
    role = db.Column(db.String)
    posts = db.relationship('Post', backref="gamers",lazy='dynamic')
    # clan = relationship('clans', backref="member")
    admin = db.relationship('Admin',backref="gamers")
    photos = db.relationship("Photo",backref="gamers",lazy="dynamic")


    def __init__(self, name,email,password):
        # მხოლოდ გვჭირდება ამ ბაზის მოდელისთვის უნიკალური წევრის ატრიბუტის აღწერა
        self.name = name
        self.email=email
        self.password=generate_password_hash(password)

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

    def __repr__(self):

        return f"Gamer: {self.name}"
Exemplo n.º 2
0
class PatientTest(db.Model):
    __tablename__ = 'patient_test'

    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(80), nullable=False)
    details = db.Column(db.String(150))
    patient_id = db.Column(db.Integer,
                           db.ForeignKey('patient.id'),
                           nullable=False)
    appointment_id = db.Column(db.Integer,
                               db.ForeignKey('appointment.id'),
                               nullable=False)

    patient = db.relationship('Patient',
                              backref=db.backref('test',
                                                 lazy='dynamic',
                                                 cascade="all, delete"))
    appointment = db.relationship('Appointment',
                                  backref=db.backref('patient_test',
                                                     lazy='dynamic',
                                                     cascade="all, delete"))

    def __init__(self, name, details, patient_id, appointment_id):
        self.name = name
        self.details = details
        self.patient_id = patient_id
        self.appointment_id = appointment_id

    def __repr__(self):
        return f'patient_test({self.id},{self.name},{self.patient_id},{self.details},{self.appointment_id})'

    def save(self):
        db.session.add(self)
        db.session.commit()
Exemplo n.º 3
0
class Solved_Classroom_Assignment(db.Model):
    __tablename__ = 'solved_classroom_assignments'

    classroom_id = db.Column(db.Integer, db.ForeignKey('classroom.id'))
    student_id = db.Column(db.Integer, db.ForeignKey('students.id'))
    assignment_id = db.Column(db.Integer, db.ForeignKey('assignments.id'))
    points = db.Column(db.Integer)

    classroom = db.relationship(
        'Classroom',
        backref=backref("Solved_Classroom_Assignment_JOIN_Classroom",
                        cascade="all,delete"))
    student = db.relationship(
        'Student', backref="Solved_Classroom_Assignment_JOIN_Student")
    assignment = db.relationship(
        'Assignments',
        backref=backref("Solved_Classroom_Assignment_JOIN_Assignments",
                        cascade="all,delete"))

    __table_args__ = (db.PrimaryKeyConstraint(
        classroom_id,
        student_id,
        assignment_id,
    ), )

    def __init__(self, classroom_id, assignment_id, student_id, points):
        self.classroom_id = classroom_id
        self.student_id = student_id
        self.assignment_id = assignment_id
        self.points = points
Exemplo n.º 4
0
class AppointmentRequest(db.Model):
    __tablename__ = 'appointment_request'

    id = db.Column(db.Integer, primary_key=True)
    date = db.Column(db.Date, nullable=False, index=True)
    visit_reason = db.Column(db.String(60), nullable=False)
    status = db.Column(db.SmallInteger, default=0)
    patient_id = db.Column(db.Integer,
                           db.ForeignKey('patient.id'),
                           nullable=False)
    doctor_id = db.Column(db.Integer,
                          db.ForeignKey('doctor.id'),
                          nullable=False)

    patient = db.relationship('Patient',
                              backref=db.backref('appointment_request',
                                                 lazy='dynamic'))
    doctor = db.relationship('Doctor',
                             backref=db.backref('appointment_request',
                                                lazy='dynamic'))

    def __init__(self, date, visit_reason, patient_id, doctor_id):
        self.date = date
        self.visit_reason = visit_reason
        self.patient_id = patient_id
        self.doctor_id = doctor_id

    def __repr__(self):
        return f'appointment({self.id},{self.date},{self.visit_reason},{self.status},{self.patient_id},{self.doctor_id})'

    def save(self):
        db.session.add(self)
        db.session.commit()
Exemplo n.º 5
0
class Assignments(db.Model):
    __tablename__ = 'assignments'

    id = db.Column(db.Integer, primary_key=True)
    assignment_name = db.Column(db.Text)
    course_id = db.Column(db.Integer,
                          db.ForeignKey('courses.id'))  # Assignment tag
    course = db.relationship('Courses',
                             backref='Courses_JOIN_Assignments')  # Backref
    difficulty = db.Column(db.Text)
    assignment_rating = db.Column(db.Float)
    assignment_no_of_reviews = db.Column(db.Integer)
    assignment_no_of_ratings = db.Column(db.Integer)
    active_status = db.Column(db.Integer)
    teacher_id = db.Column(db.Integer, db.ForeignKey('teachers.id'))
    teacher = db.relationship('Teacher',
                              backref=backref("Teacher_JOIN_Assignments",
                                              cascade="all,delete"))  # Backref

    def __init__(self, assignment_name, course_id, difficulty,
                 assignment_rating, assignment_no_of_reviews,
                 assignment_no_of_ratings, active_status, teacher_id):
        self.assignment_name = assignment_name
        self.course_id = course_id
        self.difficulty = difficulty
        self.assignment_rating = assignment_rating
        self.assignment_no_of_reviews = assignment_no_of_reviews
        self.assignment_no_of_ratings = assignment_no_of_ratings
        self.active_status = active_status
        self.teacher_id = teacher_id
Exemplo n.º 6
0
class Students(db.Model):

    __tablename__ = 'student'

    usn = db.Column(db.String(40), primary_key=True, unique=True)
    user_id = db.Column(db.Integer, db.ForeignKey('users.id'), nullable=False)
    first_name = db.Column(db.String(140))
    last_name = db.Column(db.String(140))
    address = db.Column(db.String(240))
    branch = db.Column(db.String(140),
                       db.ForeignKey('branch.branch_id'),
                       nullable=False)
    sem = db.Column(db.String(140))
    sec = db.Column(db.String(140))
    attend = db.relationship('Attendances',
                             backref='attendances',
                             foreign_keys='Attendances.usn')
    s_users = db.relationship('User', backref='students', uselist=False)

    def __init__(self, usn, first_name, last_name, branch, sem, sec, address,
                 user_id):
        self.usn = usn
        self.first_name = first_name
        self.last_name = last_name
        self.address = address
        self.branch = branch
        self.sem = sem
        self.sec = sec
        self.user_id = user_id
Exemplo n.º 7
0
class User(db.Model, UserMixin):

    __tablename__ = 'users'

    id = db.Column(db.Integer, primary_key=True)
    email = db.Column(db.String(64))
    username = db.Column(db.String(64))
    password_hash = db.Column(db.String)
    job = db.Column(db.String)
    name = db.Column(db.String(64))
    phone = db.Column(db.String)
    profile_image = db.Column(db.String)
    doctor_rel = db.relationship('D_accounts', backref='duser', uselist=False)
    patient_rel = db.relationship('P_accounts', backref='puser', uselist=False)
    blog_rel = db.relationship('BlogPost', backref='post', lazy='dynamic')

    def __init__(self, email, username, password, job, name, phone,
                 profile_image):
        self.email = email
        self.username = username
        self.password_hash = generate_password_hash(password)
        self.job = job
        self.name = name
        self.phone = phone
        self.profile_image = profile_image

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

    def __repr__(self):
        return f"Welcome {self.username}"
Exemplo n.º 8
0
class Elderly(db.Model):

    __tablename__ = 'Elderlies'

    id = db.Column(db.Integer, primary_key=True)
    full_name = db.Column(db.Text)
    username = db.Column(db.Text)
    password = db.Column(db.Text)
    contact1 = db.Column(db.Integer)
    area = db.Column(db.Text)
    address = db.Column(db.Text)
    groceries = db.relationship('Grocery', backref='elderly')
    helper = db.relationship('Helper', backref='elderly')

    def __init__(self, full_name, username, password, contact1, area, address):
        self.full_name = full_name
        self.username = username
        self.password = password
        self.contact1 = contact1
        self.area = area
        self.address = address

    def __repr__(self):
        if self.helper:
            return f" {self.full_name} is helped by {self.helper}"
        else:
            return f"{self.password}"
Exemplo n.º 9
0
class User(db.Model, UserMixin):

    # Create a table in the db
    __tablename__ = 'users'

    id = db.Column(db.Integer, primary_key=True)
    profile_image = db.Column(db.String(20), default='default_profile.png')
    email = db.Column(db.String(64), unique=True, index=True)
    username = db.Column(db.String(64), unique=True, index=True)
    password_hash = db.Column(db.String(128))
    user_type = db.Column(db.String(64), index=True)
    roles = db.relationship('Role', secondary='user_roles')
    s_user = db.relationship('Students', backref='students', uselist=False)
    t_user = db.relationship('Teachers', backref='teachers', uselist=False)
    posts = db.relationship('BlogPost', backref='author', lazy=True)

    def __init__(self, email, username, password, user_type):
        self.email = email
        self.username = username
        self.password_hash = generate_password_hash(password)
        self.user_type = user_type

    def check_password(self, password):
        # https://stackoverflow.com/questions/23432478/flask-generate-password-hash-not-constant-output
        return check_password_hash(self.password_hash, password)
Exemplo n.º 10
0
class BlogPost(db.Model):
    # Setup the relationship to the User table
    users = db.relationship(User)

    # Model for the Blog Posts on Website
    id = db.Column(db.Integer, primary_key=True)
    # Notice how we connect the BlogPost to a particular author
    user_id = db.Column(db.Integer, db.ForeignKey('users.id'), nullable=False)
    date = db.Column(db.DateTime, nullable=False, default=datetime.utcnow)
    blog_img = db.Column(db.String(20), default='default_img.png')
    title = db.Column(db.String(140), nullable=False)
    topic = db.Column(db.String(60), nullable=False)
    text = db.Column(db.Text, nullable=False)
    blogcount = db.relationship('Blogcount', backref='coupos')
    usr = db.relationship('User', backref='userspost')

    def __init__(self, title, text, topic, blog_img, user_id):
        self.title = title
        self.text = text
        self.topic = topic
        self.blog_img = blog_img
        self.user_id = user_id

    def __repr__(self):
        return f"Post Id: {self.id} --- Date: {self.date} --- Title: {self.title}"
Exemplo n.º 11
0
class Elderly(db.Model):

    __tablename__ = 'Elderlies'

    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.Text)
    password = db.Column(db.Text)
    contact = db.Column(db.Integer)
    area = db.Column(db.Text)
    address = db.Column(db.Text)
    groceries = db.relationship('Grocery', backref='elderly')
    helper = db.relationship('Helper', backref='elderly')

    def __init__(self, name, password, contact, area, address):
        self.name = name
        self.password = password
        self.contact = contact
        self.area = area
        self.address = address

    def __repr__(self):
        if self.groceries:
            return f" {self.name} would like {self.groceries}"
        else:
            return f"{self.name} has no orders yet"
Exemplo n.º 12
0
class Actor(db.Model):
    """This class represents a table actors in the database
    """
    __tablename__ = 'actors'

    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(64), unique=True, index=True)
    added_on = db.Column(db.DateTime, nullable=False, default=datetime.utcnow)
    short_bio = db.Column(db.Text, nullable=False)
    picture = db.Column(db.String())
    # Connecting the Actor to a particular user (adder)
    user_id = db.Column(db.Integer, db.ForeignKey('users.id'), nullable=False)
    # Setup the relationship to the User table
    users = db.relationship(User)

    # This connects Movie to an Actor Author.
    movies = db.relationship('Movie', backref='author', lazy=True)

    def __repr__(self):
        """This method helps to easily print an instance of the class"""
        return f"<Actor ID: {self.id} --{self.name}--Added_on:{self.added_on}>"

    @property
    def serialize(self):
        """This method will help to represent the class User as a json object
        """
        return {
            'id': self.id,
            'name': self.name,
            'added_on': self.added_on,
            'short_bio': self.short_bio,
            'picture': self.picture,
            'user_id': self.user_id,
            'movies': [m.serialize for m in self.movies]
        }
Exemplo n.º 13
0
class Login(db.Model):
    __tablename__ = 'login_users'

    id = db.Column(db.Integer, primary_key=True)
    username = db.relationship('Registration',
                               backref='login_user',
                               uselist=False)
    password = db.relationship('Registration',
                               backref='login_user',
                               uselist=False)
Exemplo n.º 14
0
class Intent(db.Model):

    __tablename__= 'intent'
    intentid=db.Column(db.Integer,primary_key=True)
    intentname = db.Column(db.Text)
    projectid =db.Column(db.Integer,db.ForeignKey('project.projectid'))
    responses=db.relationship('Response',backref='intent')
    userqueries = db.relationship('User_query',backref='intent')

    def __init__(self,intentname,projectid):
        self.intentname = intentname
        self.projectid= projectid
Exemplo n.º 15
0
class Project(db.Model):

        __tablename__= 'project'
        projectid=db.Column(db.Integer,primary_key=True)
        projectname = db.Column(db.Text)
        userid =db.Column(db.Integer,db.ForeignKey('user.id'))
        intents=db.relationship('Intent',backref='project')
        entities = db.relationship('Entity',backref='project')

        def __init__(self,projectname,userid,token
        ):
            self.projectname = projectname
            self.userid= userid
            self.token = token
Exemplo n.º 16
0
class Doctor(db.Model):
    __tablename__ = 'doctor'

    id = db.Column(db.Integer, primary_key=True, index=True)
    name = db.Column(db.String(70), nullable=False)
    gender = db.Column(db.String(8), nullable=False)
    address = db.Column(db.String(150), nullable=False)
    city = db.Column(db.String(150))
    dob = db.Column(db.DateTime)
    contact = db.Column(db.BigInteger, unique=True)
    user_id = db.Column(db.BigInteger,
                        db.ForeignKey('user.id'),
                        nullable=False)

    user = db.relationship('User',
                           backref=db.backref('doctor',
                                              lazy='dynamic',
                                              cascade="delete"))

    specialization = db.relationship('Specialization',
                                     secondary='doctor_specializations',
                                     backref=db.backref('doctor',
                                                        lazy='dynamic'))

    degree = db.relationship('Degree',
                             secondary='doctor_degrees',
                             backref=db.backref('doctor', lazy='dynamic'))

    def __init__(self, name, gender, address, city, dob, contact, user_id):
        self.name = name
        self.gender = gender
        self.address = address
        self.city = city
        self.dob = dob
        self.contact = contact
        self.user_id = user_id

    def __repr__(self):
        return f'doctor({self.id},{self.name},{self.gender},{self.address},{self.city},{self.dob},{self.contact},{self.user_id})'

    def add_specializations(self, specializations):
        self.specialization.extend(specializations)

    def add_degrees(self, degrees):
        self.degree.extend(degrees)

    def save(self):
        db.session.add(self)
        db.session.commit()
Exemplo n.º 17
0
class BlogPost(db.Model):
    """This class represents a table movies in the database
    """
    __tablename__ = 'blogPosts'

    id = db.Column(db.Integer, primary_key=True)
    posted_on = db.Column(db.DateTime, nullable=False, default=datetime.utcnow)
    title = db.Column(db.String(140), nullable=False)
    text = db.Column(db.Text, nullable=False)
    # Connecting the BlogPost to a particular user (poster)
    user_id = db.Column(db.Integer, db.ForeignKey('users.id'), nullable=False)
    # Setup the relationship to the User table
    users = db.relationship(User)

    @property
    def serialize(self):
        """This method will help to represent the class User as a json object
        """
        return {
            'id': self.id,
            'posted_on': self.posted_on,
            'title': self.title,
            'text': self.text,
            'user_id': self.user_id
        }

    def __repr__(self):
        """This method helps to easily print an instance of the class"""
        return f"<Post ID: {self.id} -- Date: {self.date} --- {self.title}>"
Exemplo n.º 18
0
class Branchs(db.Model):

    __tablename__ = 'branch'

    branch_id = db.Column(db.String(40), primary_key=True, unique=True)
    branch_name = db.Column(db.String(140))
    sem = db.Column(db.Integer())
    sub = db.relationship('Subjects', backref='subject', lazy='dynamic')
    student = db.relationship('Students',
                              backref='student',
                              foreign_keys='Students.branch')

    def __init__(self, branch_id, branch_name, sem):
        self.branch_id = branch_id
        self.sem = sem
        self.branch_name = branch_name
Exemplo n.º 19
0
class User(db.Model, UserMixin):

    # this is the table name inside the database
    __tablename__ = 'users'

    id = db.Column(db.Integer, primary_key=True)  # id, remains unique
    name = db.Column(db.String(20))
    email = db.Column(db.String(64), unique=True,
                      index=True)  # email should be unique
    password_hash = db.Column(db.String(128))  # password hash
    diseases = db.relationship('Disease', backref='users', lazy='dynamic')

    def __init__(self, name, email, password):
        self.name = name
        self.email = email
        # saving a sha sum hash instead of actual pass
        self.password_hash = generate_password_hash(password)

    def check_password(self, password):
        # checking if hashes match
        return check_password_hash(self.password_hash, password)

    def diseases_dict(self):
        disease_list = []
        symptoms_list = []
        for disease in self.diseases:
            disease_list.append(disease.disease_name)
            symptoms_list.append(disease.symptoms)
        disease_dict = dict(zip(symptoms_list, disease_list))
        return disease_dict
Exemplo n.º 20
0
class Product(db.Model):
    __tablename__ = "products"

    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String)
    manufacturer = db.Column(db.String)
    quantity = db.Column(db.Float)
    sku = db.Column(db.Float)
    min_Bid = db.Column(db.Float)
    image = db.Column(db.String)
    description = db.Column(db.String)
    sold_quantity = db.Column(db.Float)
    rating = db.Column(db.Float)
    comments = db.Column(db.String)
    category = db.relationship("Category", backref="product", lazy="dynamic")
    #admins = db.relationship('Admin',backref='admins')
    consultant = db.Column(db.String)
    tags = db.Column(db.String)
    shipping_price = db.Column(db.Float)
    location = db.Column(db.String)
    price = db.Column(db.Float)
    expire_data = db.Column(db.String)

    # file = db.relationship('File', backref='users')

    def __init__(self, name, manufacturer, quantity, cost):
        self.name = name
        self.manufacturer = manufacturer
        self.quantity = quantity
        self.cost = cost
Exemplo n.º 21
0
class Settings(db.Model):
    __tablename__ = 'settings'

    student_id = db.Column(
        db.Integer, db.ForeignKey('students.id'),
        primary_key=True)  # Can be a PK because its a 1-1 Relationship
    display_rank = db.Column(db.Boolean)
    display_stats = db.Column(db.Boolean)
    student = db.relationship('Student',
                              backref="Student_JOIN_Settings",
                              uselist=False)  # Backref

    def __init__(self, student_id, display_rank, display_stats):
        self.student_id = student_id
        self.display_rank = display_rank
        self.display_stats = display_stats

    # Function that returns settings code
    def return_setting_preset(self):
        if self.display_rank and self.display_stats:
            return 1  # Display both == 1
        elif self.display_rank and not self.display_stats:
            return 2  # Display rank only == 2
        elif self.display_stats and not self.display_rank:
            return 3  # Display stats only == 3
        else:
            return 4  # Hide both == 4
Exemplo n.º 22
0
class Assignment_Data(db.Model):
    __tablename__ = 'assignment_data'

    assignment_id = db.Column(db.Integer, db.ForeignKey('assignments.id'))
    question_id = db.Column(db.Integer)
    question_text = db.Column(db.Text)

    assignment = db.relationship('Assignments',
                                 backref=backref(
                                     "Assignment_Data_JOIN_Assignments",
                                     cascade="all,delete"))  # Backref
    choice1 = db.Column(db.Text)
    choice2 = db.Column(db.Text)
    choice3 = db.Column(db.Text)
    choice4 = db.Column(db.Text)
    answer = db.Column(db.Text)

    __table_args__ = (db.PrimaryKeyConstraint(
        assignment_id,
        question_id,
    ), )

    def __init__(self, assignment_id, question_id, question_text, choice1,
                 choice2, choice3, choice4, answer):
        self.assignment_id = assignment_id
        self.question_id = question_id
        self.question_text = question_text
        self.choice1 = choice1
        self.choice2 = choice2
        self.choice3 = choice3
        self.choice4 = choice4
        self.answer = answer
Exemplo n.º 23
0
class TestReport(db.Model):
    __tablename__ = 'test_report'

    id = db.Column(db.Integer, primary_key=True)
    filename = db.Column(db.String(64), nullable=False)
    test_id = db.Column(db.Integer,
                        db.ForeignKey('patient_test.id'),
                        nullable=False,
                        unique=True)

    test = db.relationship('PatientTest',
                           backref=db.backref('report',
                                              uselist=False,
                                              cascade="delete"))

    def __init__(self, filename, test_id):
        self.filename = filename
        self.test_id = test_id

    def __repr__(self):
        return f'test_report({self.id},{self.filename},{self.test_id})'

    def save(self):
        db.session.add(self)
        db.session.commit()
Exemplo n.º 24
0
class Patient(db.Model):
    __tablename__ = 'patient'

    id = db.Column(db.Integer, primary_key=True, index=True)
    name = db.Column(db.String(70), nullable=False)
    gender = db.Column(db.String(8), nullable=False)
    address = db.Column(db.String(150), nullable=False)
    city = db.Column(db.String(150))
    dob = db.Column(db.DateTime)
    contact = db.Column(db.BigInteger, unique=True)
    user_id = db.Column(db.BigInteger,
                        db.ForeignKey('user.id'),
                        nullable=False)

    user = db.relationship('User',
                           backref=db.backref('patient',
                                              lazy='dynamic',
                                              cascade="delete"))

    def __init__(self, name, gender, address, city, dob, contact, user_id):
        self.name = name
        self.gender = gender
        self.address = address
        self.city = city
        self.dob = dob
        self.contact = contact
        self.user_id = user_id

    def __repr__(self):
        return f'patient({self.id},{self.name},{self.gender},{self.address},{self.city},{self.dob},{self.contact})'

    def save(self):
        db.session.add(self)
        db.session.commit()
Exemplo n.º 25
0
class Schedule(db.Model):
    __tablename__ = 'schedule'

    id = db.Column(db.Integer, primary_key=True, index=True)
    day = db.Column(db.String(10), nullable=False)
    start_time = db.Column(db.Time)
    end_time = db.Column(db.Time)
    doctor_id = db.Column(db.Integer,
                          db.ForeignKey('doctor.id'),
                          nullable=False)

    doctor = db.relationship('Doctor',
                             backref=db.backref('schedule',
                                                lazy='dynamic',
                                                cascade="all, delete"))

    def __init__(self, day, start_time, end_time, doctor_id):
        self.day = day
        self.start_time = start_time
        self.end_time = end_time
        self.doctor_id = doctor_id

    def __repr__(self):
        return f'schedule({self.id},{self.day},{self.start_time},{self.end_time})'

    def save(self):
        db.session.add(self)
        db.session.commit()
Exemplo n.º 26
0
class User(db.Model, UserMixin):
    __tablename__ = 'user'

    id = db.Column(db.BigInteger, primary_key=True, index=True)
    email = db.Column(db.String(128), unique=True, nullable=False, index=True)
    password = db.Column(db.String(128), nullable=False)
    created = db.Column(db.DateTime, nullable=False, default=datetime.utcnow)
    modified = db.Column(db.DateTime)
    change_config = db.Column(db.PickleType)

    role = db.relationship('Role',
                           secondary='user_roles',
                           backref=db.backref('user', lazy='dynamic'))

    def __init__(self, email, password):
        self.email = email
        self.password = generate_password_hash(password)

    def __repr__(self):
        return f'user({self.id},{self.email},{self.created})'

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

    def set_password(self, password):
        self.password = generate_password_hash(password)

    def add_role(self, role):
        self.role.append(role)

    def save(self):
        db.session.add(self)
        db.session.commit()
Exemplo n.º 27
0
class Meetings(db.Model):
    IDM = db.Column(db.Integer,primary_key= True)
    Mdate = db.Column(db.Text)
    Mtime = db.Column(db.Text)
    IDG = db.Column(db.Integer,db.ForeignKey('groups.id'))
    Occurence = db.Column(db.Text) 
    Platform = db.Column(db.Text)
    title = db.Column(db.Text)
    Rate = db.Column(db.Integer)
    Pros = db.Column(db.String(500))
    Cons = db.Column(db.String(500))
    attending = db.Column(db.String(500))
    DateAdded = db.Column(db.Text)

    studentsinMeeting = db.relationship('StudentsInMeeting',backref='meetings',lazy='dynamic')

    def __init__(self,Mdate,Mtime,IDG,Occurence,Platform,title,Rate,Pros,Cons,attending,DateAdded):
        self.Mdate = Mdate
        self.Mtime = Mtime
        self.IDG = IDG
        self.Occurence= Occurence
        self.Platform = Platform
        self.title = title
        self.Rate = Rate
        self.Pros = Pros
        self.Cons = Cons
        self.attending = attending
        self.DateAdded = DateAdded
Exemplo n.º 28
0
class User(db.Model, UserMixin):

    __tablename__ = 'users'

    # Columns or attributes in database table named __tablename__
    id = db.Column(db.Integer,
                   primary_key=True)  # Primary key and will auto increment
    email = db.Column(db.String(128), unique=True, index=True, nullable=False)
    name = db.Column(db.String(128), nullable=False)
    contact_no = db.Column(db.String(20), default='0')
    password_hash = db.Column(db.String(512), nullable=False)

    # First argument is the name of class model to which it will reference
    # backref is the name of the relation
    # backref is a simple way to also declare a new property on the 'BlogPost' class
    # It is a one to many relationship by default
    events = db.relationship('Event', backref='user_of_this_event', lazy=True)

    #If you would want to have a one-to-one relationship you can pass uselist=False to relationship()

    def __init__(self, email, name, password, contact_no=None):
        self.email = email
        self.name = name
        self.contact_no = contact_no
        self.password_hash = generate_password_hash(password)

    def validate_password(self, password):
        return check_password_hash(self.password_hash, password)

    # Returns the string representaion of the class object
    def __repr__(self):
        return f'User mail: {self.email}'
Exemplo n.º 29
0
class User(db.Model, UserMixin):
    id = db.Column(db.Integer, primary_key= True)
    username = db.Column(db.String(20), unique=True, nullable=False)
    email = db.Column(db.String(20), unique=True, nullable=False)
    image_file = db.Column(db.String(20), nullable=False, default='default.jpg')
    password = db.Column(db.String(60), nullable=False)
    posts = db.relationship('Post', backref='author', lazy=True)

    def get_reset_token(self, expires_sec=1800):
        s = Serializer(app.config['SECRET_KEY'], expires_sec)
        return s.dumps({'user_id': self.id}).decode('utf-8')

    @staticmethod
    def verify_reset_token(token):
        s = Serializer(app.config['SECRET_KEY'])
        try:
            user_id = s.loads(token)['user_id']
        except:
            return None
        return User.query.get(user_id)


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

    def __repr__(self):
        return f"User('{self.username}','{self.email}','{self.image_file}')"
    
    def set_password(self, pw):
        pwhash = bcrypt.hashpw(pw.encode('utf8'), bcrypt.gensalt())
        self.password_hash = pwhash.decode('utf8') # decode the hash to prevent is encoded twice
        return self.password_hash
Exemplo n.º 30
0
class Supply(db.Model):

    __tablename__ = "supply"
    id = db.Column(db.Integer,primary_key = True)
    name = db.Column(db.Text)
    type = db.Column(db.Text)
    # Supply should not have price  Supplier quote price instead 
    #unit_price = db.Column(db.Text) 
    supplier = db.relationship('Supplier',backref='supply',lazy='dynamic', cascade="all, delete-orphan")
    uesd_supply = db.relationship("UsedSupply", backref='supply',lazy='dynamic', cascade="all, delete-orphan" )
    
    def __init__(self, name, type):
        self.name, self.type = name, type

    def __repr__(self):
        return f'id: {self.id} name: {self.name}, type: {self.type} '