class Post(db.Model): id = db.Column(db.Integer, primary_key=True) title = db.Column(db.String(100), nullable=False) date_posted = db.Column(db.DateTime, nullable=False, default=datetime.utcnow) content = db.Column(db.Text, nullable=False) user_id = db.Column(db.Integer, db.ForeignKey('user.id'), nullable=False) book_id = db.Column(db.Integer, db.ForeignKey('book.id'), nullable=True) rating = db.Column(db.Integer, nullable=False) books = db.relationship('Book', backref='post', lazy=True) def __repr__(self): return f"Post('{self.title}', '{self.date_posted}')"
class User(db.Model): id = db.Column(db.Integer, primary_key=True) username = db.Column(db.String(80), unique=True, nullable=False) email = db.Column(db.String(120), unique=True, nullable=False) password = db.Column(db.String(60), nullable=False) posts = db.relationship('Post', backref='author', lazy=True) def __init__(self, username, email, password): self.username = username self.email = email self.password = password def __repr__(self): return '<User %r>' % self.username
class User(db.Model, UserMixin): """User""" id = db.Column(db.Integer, primary_key=True) username = db.Column(db.String(20), unique=True, nullable=False) email = db.Column(db.String(120), 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 __repr__(self): return f"User('{self.username}', '{self.email}', '{self.image_file}')"
class User( db.Model, UserMixin ): #login model expects 4 attributes (isauthenticated, isactive, isanonymous, getid) id = db.Column(db.Integer, primary_key=True) username = db.Column(db.String(20), unique=True, nullable=False) email = db.Column(db.String(120), unique=True, nullable=False) image_file = db.Column(db.String(20), nullable=False, default='default.jpeg') password = db.Column(db.String(60), nullable=False) posts = db.relationship('Post', backref='author', lazy=True) def __repr__(self): return f"User('{self.username}', '{self.email}', '{self.image_file}')"
class User(db.Model): ''' Setting up the database model for the User. One to many relationship ''' id = db.Column(db.Integer, primary_key=True) username = db.Column(db.String(20), unique=True, nullable=False) email = db.Column(db.String(120), unique=True, nullable=False) image_file = db.Column(db.String(20), nullable=False, default='default.jpg') password = db.Column(db.String(60), nullable=False) # Load the post from the unique individual posts = db.relationship('Post', backref='author', lazy=True) def __repr__(self): return f"User('{self.username}', '{self.email}', '{self.image_file}')"
class Post(db.Model): id = db.Column(db.Integer, primary_key=True) title = db.Column(db.String(120), nullable=False) date_posted = db.Column(db.DateTime, nullable=False, default=datetime.now(timezone('Europe/Moscow'))) content = db.Column(db.Text, nullable=False) user_id = db.Column(db.Integer, db.ForeignKey('user.id'), nullable=False) tags = db.relationship('Tag', secondary=post_tags, backref=db.backref('posts', lazy='dynamic')) def __repr__(self): return f"Post('{self.title}', '{self.date_posted}')"
class Post(db.Model): id = db.Column(db.Integer, primary_key=True) title = db.Column(db.String(100), nullable=False) date_posted = db.Column(db.DateTime, nullable=False, default=datetime.utcnow) content = db.Column(db.Text, nullable=False) # user.id because this will actually look into the database thats why smaller case likes = db.relationship('PostLike', backref='post', lazy='dynamic') user_id = db.Column(db.Integer, db.ForeignKey('user.id'), nullable=False) def __repr__(self): return f"Post('{self.title}', '{self.date_posted}')"
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(120), 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) messages_received = db.relationship('Message', foreign_keys='Message.recipient_id', backref='recipient', lazy='dynamic') last_message_read_time = db.Column(db.DateTime) def __repr__(self): return f"User('{self.username}', '{self.email}', '{self.image_file}')" def new_messages(self): last_read_time = self.last_message_read_time or datetime(1900, 1, 1) return Message.query.filter_by(recipient=self).filter( Message.timestamp > last_read_time).count()
class User(db.Model): id = db.Column(db.Integer, primary_key=True) username = db.Column(db.String(20), unique=True, nullable=False) email = db.Column(db.String(120), 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) # double underscore methods known as 'magic methods' def __repr__(self): return f"User('{self.username}', '{self.email}', '{self.image_file}')"
class Seat(db.Model): __table_args__ = ( db.UniqueConstraint('location_name', 'seat_num', name='unique_seat_info'), ) id = db.Column(db.Integer, primary_key=True) location_name = db.Column(db.String(100), nullable=False) seat_num = db.Column(db.Integer, nullable=False) seat_img_id = db.Column(db.Integer, nullable=False) users = db.relationship('User', backref='seated', lazy=True) location_id = db.Column(db.Integer, db.ForeignKey('location.id')) def __repr__(self): return f"Seat('{self.location_name}', '{self.seat_num}')"
class Patient(db.Model, UserMixin): patient_id = db.Column(db.Integer, primary_key=True) username = db.Column(db.String(20), unique=True, nullable=False) patient_age = db.Column(db.Integer) date_posted = db.Column(db.String(120), unique=True, nullable=False) type_of_bed = db.Column(db.String(120), unique=True, nullable=False) address = db.Column(db.String(120), unique=True, nullable=False) state = db.Column(db.String(120), unique=True, nullable=False) city = db.Column(db.String(120), unique=True, nullable=False) user_id = db.Column(db.Integer, db.ForeignKey('user.id'), nullable=False) posts1 = db.relationship('Pharmcy', backref='patient', lazy=True) def __repr__(self): return f"Patient('{self.username}', '{self.patient_age}', '{self.date_posted}', '{self.type_of_bed}', '{self.address}', '{self.state}', '{self.city}', '{self.user_id}')"
class User(db.Model, UserMixin): # Changed the nullable fields for password and email # username can be the Hive username id = db.Column(db.Integer, primary_key=True) username = db.Column(db.String(20), unique=True, nullable=False) email = db.Column(db.String(120), nullable=True) image_file = db.Column(db.String(20), nullable=False, default='default.jpg') password = db.Column(db.String(60), nullable=True) posts = db.relationship('Post', backref='author', lazy=True) def __repr__(self): return f"User('{self.username}', '{self.email}', '{self.image_file}')"
class User(db.Model): id = db.Column(db.Integer, primary_key=True) username = db.Column(db.String(20), unique=True, nullable=False) email = db.Column(db.String(120), 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) # get all the post this user has created def __repr__(self): return f"User('{self.username}', '{self.email}', '{self.image_file}')"
class Event(db.Model): id = db.Column(db.Integer, primary_key=True) date = db.Column(db.Date, nullable=False) time = db.Column(db.Time, nullable=False) cost = db.Column(db.Float, nullable=False, default='To be defined') np = db.Column(db.Integer, nullable=False) user_id = db.Column(db.Integer, db.ForeignKey('user.id'), nullable=False) club_id = db.Column(db.Integer, db.ForeignKey('club.id'), nullable=False) sport_id = db.Column(db.Integer, db.ForeignKey('sport.id'), nullable=False) level = db.Column(db.String(60)) participant2 = db.relationship('Participant', foreign_keys=[Participant.e_id], backref='part', lazy=True) def __repr__(self): return '<Event %r %r %r>' % self.date % self.time % self.np
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(120), unique=True, nullable=False) image_file = db.Column(db.String(20), nullable=False, default='default.jpg') password = db.Column(db.String(60), nullable=False) #user and post models are going to have a one-to-many relationship as users are the authors who can write as many posts as they want posts = db.relationship('Post', backref='author', lazy=True) #this is a magic method which is used to return object representation(i.e to display object) def __repr__(self): return f"User('{self.username}', '{self.email}', '{self.image_file}')"
class User(db.Model, UserMixin): __tablename__ = 'user' id = db.Column(db.Integer, primary_key=True) username = db.Column(db.String(20), unique=True, nullable=False) email = db.Column(db.String(120), 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 __repr__(self): return f"User('{self.username}', '{self.email}', '{self.image_file}')"
class User(db.Model, UserMixin): """docstring for User.""" id = db.Column(db.Integer, primary_key=True) username = db.Column(db.String(25), unique=True, nullable=False) email = db.Column(db.String(125), unique=True, nullable=False) image_file = db.Column(db.String(20), nullable=False, default='default.jpg') password = db.Column(db.String(60), nullable=True) posts = db.relationship('Post', backref='author', lazy=True) comments = db.relationship('Comment', backref='author', lazy=True) def get_reset_token(self, expires_sec=1800): s = Serializer(current_app.config['SECRET_KEY'], expires_sec) return s.dumps({'user_id': self.id}).decode('utf-8') @staticmethod def verify_reset_token(token): s = Serializer(current_app.config['SECRET_KEY']) try: user_id = s.loads(token)['user_id'] except Exception: return None return User.query.get(user_id) def __repr__(self): return f"User('{self.username}', '{self.email}', '{self.image_file}')"
class Post2(db.Model): id = db.Column(db.Integer, primary_key=True) title = db.Column(db.String(100), unique=True, nullable=False) date_posted = db.Column(db.DateTime, nullable=False, default=datetime.utcnow) content = db.Column(db.Text, nullable=False) #file = db.Column(db.String(100), nullable=False, default='default.csv') data = db.relationship('Data_hive', backref='author', lazy=True) def __repr__(self): id = 1000 return "Post2({title}, {date_posted})".format( title=self.title, date_posted=self.date_posted)
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(120), unique=True, nullable=False) image_file = db.Column(db.String(20), nullable=False, default='default.jpg') password = db.Column(db.String(60), nullable=False) # The following posts column will be a backref which allows SQLAlchemy to link # a specific user (author) back to a bunch of different posts they wrote posts = db.relationship('Post', backref='author', lazy=True) # Defines the default manner in which our object will be printed out def __repr__(self): return f"User('{self.username}', '{self.email}', '{self.image_file}')"
class Product(db.Model): id = db.Column(db.Integer, primary_key=True) name = db.Column(db.String(100), nullable=False) tags = (db.String(160)) sellable_units = db.relationship('ProductSellableUnit', backref='Product', lazy=True) image_file = db.Column(db.String(20), nullable=False, default='default.jpg') tax_rate = db.Column(db.Integer, nullable=False, default = 25) base_unit_price = db.Column(db.Integer, nullable=False) base_discount = db.Column(db.Integer, nullable=False, default = 0) @property def product_url(self): return current_app.config['ROOT_DOMAIN_URL']+ url_for('webshop.product_page', product_id = self.product_id)
class User(db.Model, UserMixin): id = db.Column(db.Integer, primary_key=True) username = db.Column(db.String(20), nullable=False, unique=True) email = db.Column(db.String(120), nullable=False, unique=True) image_file = db.Column(db.String(20), nullable=False, default='default.png') password = db.Column(db.String(60), nullable=False) # Establishing realtionship between the 'User' and 'Post' Models posts = db.relationship('Post', backref='author', lazy=True) def __repr__(self): return f"User('{self.username}', '{self.email}', '{self.image_file}')"
class Doctor(db.Model, UserMixin): # creates a User database model id = db.Column(db.Integer, primary_key=True) username = db.Column(db.String(20), unique=True, nullable=False) email = db.Column(db.String(120), unique=True, nullable=False) password = db.Column(db.String(60), nullable=False) doctor_type = db.Column(db.String(50), nullable=False) payment = db.Column(db.String(10), nullable=False) # defines the one to many relationship of a user to his/her posts # the author attribute is used to get the details of the user who created the post, from a post itself # the lazy argument means that SQLAlchemy will load all the data (posts) of a user in one go reports = db.relationship('Report', backref='doctor', lazy=True) # how the object is printed def __repr__(self): return f"Doctor('{self.username}', '{self.email}')"
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(120), unique=True, nullable=False) image_file = db.Column(db.String(20), nullable=False, default='5.jpg') password = db.Column(db.String(60), nullable=False) admin = db.Column(db.Boolean, nullable=False, default=False) posts = db.relationship('Post', backref='author', lazy=True) user_comment = db.relationship('Comment', backref='author_comm', lazy=True) followers = db.relationship('Followers', backref='user_followers', lazy=True) following = db.relationship('Following', backref='user_following', lazy=True) likes = db.relationship('Like', backref='user_like', 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') def __repr__(self): return 'User {}, {}, {}'.format(self.username, self.email, self.image_file)
class StaffMember(db.Model): id = db.Column(db.Integer, primary_key=True) user_id = db.Column(db.Integer, db.ForeignKey('user.id'), nullable=False) bank_name = db.Column(db.String(20), nullable=True) account_holder_name = db.Column(db.String(20), nullable=True) account_number = db.Column(db.Integer, nullable=True) branch_name = db.Column(db.String(20), nullable=True) branch_number = db.Column(db.Integer, nullable=True) WorkPermit_number = db.Column(db.String(20), nullable=True) tax_number = db.Column(db.Integer, nullable=True) chronic_condition = db.Column(db.String(50), nullable=True) allergies = db.Column(db.String(50), nullable=True) # creating a one-to-one relationship to the Leave class leaves = db.relationship("LeaveApplication", backref='leave', lazy=True)
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(120), unique=True, nullable=False) image_file = db.Column(db.String(20), nullable=False, default='default.jpg') password = db.Column(db.String(60), nullable=False) # extra info about the user ID_number = db.Column(db.String(13), unique=True, nullable=False) first_name = db.Column(db.String(20), nullable=False) last_name = db.Column(db.String(20), nullable=False) phone_number = db.Column(db.String(10), nullable=False) next_of_kin = db.Column(db.String(20)) next_of_kin_phone_number = db.Column(db.Integer, nullable=True) address = db.Column(db.String(120)) active = db.Column(db.Boolean, nullable=False, default=False) user_type = db.Column(db.Enum(UserRole), default=UserRole.visitor, nullable=False) # # creating a one-to-one relationship to the Leave class # leaves = db.relationship("LeaveApplication", backref='leave', lazy=True) # creating a one-to-one relationship to the CovidQuestionnaire class covid_question = db.relationship("CovidQuestionnaire", backref='covid', lazy=True) students = db.relationship("Student", backref='students', lazy=True) staff_members = db.relationship("StaffMember", backref='staff_members', lazy=True) def __repr__(self): return f"User '{self.username}', '{self.email}', '{self.image_file}'" @staticmethod @login_manager.user_loader def load_user(user_id): return User.query.filter_by(id=user_id).first()
class User(db.Model, UserMixin): #add usermixin and it will manage for us id = db.Column(db.Integer, primary_key=True) username = db.Column(db.String(20), unique=True, nullable=False) email = db.Column(db.String(120), unique=True, nullable=False) image_file = db.Column( db.String(20), nullable=False, default='default.jpg' ) # we will later hash this image file later, of 20 characters password = db.Column( db.String(60), nullable=False) #we will hash password to 60 char long posts = db.relationship('Post', backref='author', lazy=True) # backref = use author to see the post def __repr__(self): #how our object is printed return f"User('{self.username}', '{self.email}', '{self.image_file}')"
class Post(db.Model): id = db.Column(db.Integer, primary_key=True) title = db.Column(db.String(20), nullable=False) date_posted = db.Column(db.DateTime, index=True, nullable=False, default=datetime.utcnow) content = db.Column(db.Text, nullable=False) image_file = db.Column(db.String(20)) upvotes = db.Column(db.Integer) seller_id = db.Column(db.Integer, db.ForeignKey('user.id'), nullable=False) comments = db.relationship('Comment', backref='mypost', lazy=True) def __repr__(self): return f"Post('{self.title}', '{self.date_posted}')"
class User(db.Model): #because id is primary_key it will be generated automatically id = db.Column(db.Integer, primary_key=True) username = db.Column(db.String(20), unique=True, nullable=False) email = db.Column(db.String(120), unique=True, nullable=False) image_file = db.Column(db.String(20), nullable=False, default="default.jpg") password = db.Column(db.String(60), nullable=False) #backref : similar to adding new column to Post Model #lazy: justify sqlAlchemy to load data as necessary in one go posts = db.relationship('Post', backref='author', lazy=True) def __repr__(self): return f"User('{self.username}', '{self.email}', '{self.image_file}')"
class User(db.Model, UserMixin): id = db.Column(db.Integer, primary_key=True) username = db.Column(db.String(20), unique=True, nullable=False) usertype = db.Column(db.String(20), nullable=False) location = db.Column(db.String(20), nullable=False) email = db.Column(db.String(120), unique=True, nullable=False) image_file = db.Column(db.String(20), nullable=False, default='default.jpg') password = db.Column(db.String(60), nullable=False) accept_flag = db.Column(db.Boolean, default=False) decline_flag = db.Column(db.Boolean, default=False) RequestIN_flag = db.Column(db.Integer, default=0) RequestOUT_flag = db.Column(db.Integer, default=0) RequestCheythaAldeID = db.Column(db.Integer, default=-1) RequestThannaAldeID = db.Column(db.Integer, default=-1) key = db.Column(db.Integer) key_flag = db.Column(db.Boolean, default=False) KeyThannaAal = db.Column(db.String(20)) posts = db.relationship('Post', backref='author', lazy=True) notifications = db.relationship('Notification', backref='owner', lazy=True) def __repr__(self): return f"User('{self.username}', '{self.email}', '{self.image_file}')"
class Institute(db.Model): id = db.Column(db.Integer, primary_key=True) instName = db.Column(db.String(200)) supName = db.Column(db.String(100)) mobile = db.Column(db.String(10)) email = db.Column(db.String(120), unique=True, nullable=False) studenMaxNum = db.Column(db.Integer) users = db.relationship("User", back_populates="institute") #user_id = db.Column(db.Integer,db.ForeignKey('user.id'),nullable=True) def __repr__(self): return f"Institute('{self.instName}', '{self.supName}')" """