class SystemFertilizer(db.Model): __tablename__ = 'systemfertilizer' id = db.Column(db.Integer, primary_key=True) fertilizer_name = db.Column(db.Text, nullable=True) fertilizer_image = db.Column(db.String(255), nullable=True) fertilizer_document = db.Column(db.String(255), nullable=True) fertilizer_descreption = db.Column(db.Text, nullable=True) fertilizer_main_type_name = db.Column(db.Text, nullable=True) fertilizer_sub_type_name = db.Column(db.Text, nullable=True) fertilizer_user_instructons = db.Column(db.Text, nullable=True) fertilizer_matter = db.Column(db.Text, nullable=True) systemfertilizertyeps_id = db.Column( db.Integer(), db.ForeignKey('systemfertilizertyeps.id')) fertilizermatter_id = db.Column(db.Integer(), db.ForeignKey('fertilizermatter.id')) systemsubfertilizertyeps_id = db.Column( db.Integer(), db.ForeignKey('systemsubfertilizertyeps.id')) user_id = db.Column(db.Integer, db.ForeignKey('user.id')) created_timestamp = db.Column(db.DateTime, default=datetime.now) modified_timestamp = db.Column(db.DateTime, default=datetime.now, onupdate=datetime.now) systemcommonfertilizerplan = db.relationship('SystemCommonFertilizerPlan', backref='systemFertilizer') farmfertilizerplan = db.relationship('FarmFertilizerPlan', backref='systemFertilizer') farm_fertilizer_results = db.relationship('FarmFertilizerResults', backref='systemFertilizer')
class SubCatYield(db.Model): id = db.Column(db.Integer, primary_key=True) highest_yield_recorded = db.Column(db.String(255), nullable=True) average_yield = db.Column(db.String(255), nullable=True) average_yield_yla = db.Column(db.String(255), nullable=True) average_yield_mha = db.Column(db.String(255), nullable=True) reaction_to_salinity = db.Column(db.String(255), nullable=True) syssubcategory_id = db.Column(db.Integer(), db.ForeignKey('syssubcategory.id')) user_id = db.Column(db.Integer, db.ForeignKey('user.id')) created_timestamp = db.Column(db.DateTime, default=datetime.now) modified_timestamp = db.Column(db.DateTime, default=datetime.now, onupdate=datetime.now)
class FarmFertilizerResults(db.Model): __tablename__ = 'farm_fertilizer_results' id = db.Column(db.Integer, primary_key=True) fertilizer_name = db.Column(db.Text, nullable=True) main_fertilizer_type = db.Column(db.Text, nullable=True) sub_fertilizer_type = db.Column(db.Text, nullable=True) farm_used_fertilizer_amount = db.Column(db.Text, nullable=True) fertilizer_matter_name = db.Column(db.Text, nullable=True) system_crop_name = db.Column(db.Text, nullable=True) variety_name = db.Column(db.Text, nullable=True) fertilizer_surface = db.Column(db.String(255), nullable=True) fertilizer_result = db.Column(db.Integer, nullable=True) syssubcategory_id = db.Column(db.Integer, db.ForeignKey('syssubcategory.id')) syscrop_id = db.Column(db.Integer, db.ForeignKey('syscrop.id')) fertilizermatter_id = db.Column(db.Integer, db.ForeignKey('fertilizermatter.id')) systemsubfertilizertyeps_id = db.Column( db.Integer, db.ForeignKey('systemsubfertilizertyeps.id')) systemfertilizertyeps_id = db.Column( db.Integer, db.ForeignKey('systemfertilizertyeps.id')) systemfertilizer_id = db.Column(db.Integer, db.ForeignKey('systemfertilizer.id')) user_id = db.Column(db.Integer, db.ForeignKey('user.id')) fertilizer_date = db.Column(db.DateTime) farm_id = db.Column(db.Integer)
class Crop(db.Model): id = db.Column(db.Integer, primary_key=True) cropeName = db.Column(db.Text, nullable=False) cropImage = db.Column(db.String(255), nullable=True) farm_id = db.Column(db.Integer, db.ForeignKey('farm.id')) farms = db.relationship('Farm', secondary=farm_crops, backref='crop') harvest = db.relationship('Harvest', backref='crop') pestdisease = db.relationship('Pestdisease', backref='crop') created_timestamp = db.Column(db.DateTime, default=datetime.now) modified_timestamp = db.Column(db.DateTime, default=datetime.now, onupdate=datetime.now) sys_sub_crop_id = db.Column(db.Integer(), db.ForeignKey('syssubcategory.id')) production_type = db.Column(db.String(255), nullable=True) panting_unit = db.Column(db.String(255), nullable=True) crop_surface_on_farm = db.Column(db.String(255), nullable=True)
class Maturity(db.Model): id = db.Column(db.Integer, primary_key=True) seson_name = db.Column(db.Text, nullable=True) num_of_date = db.Column(db.String(255), nullable=True) syssubcategory_id = db.Column(db.Integer(), db.ForeignKey('syssubcategory.id')) user_id = db.Column(db.Integer, db.ForeignKey('user.id')) created_timestamp = db.Column(db.DateTime, default=datetime.now) modified_timestamp = db.Column(db.DateTime, default=datetime.now, onupdate=datetime.now)
class Farm(db.Model): id = db.Column(db.Integer, primary_key=True) farmname = db.Column(db.Text, nullable=False) latitude = db.Column(db.Float(10, 6), nullable=False) longitude = db.Column(db.Float(10, 6), nullable=False) phone = db.Column(db.Integer, nullable=False, unique=False) address = db.Column(db.Text, nullable=False) email = db.Column(db.String(255), nullable=True, unique=False) farmtask = db.relationship('Farmtask', backref='farm') farmworker = db.relationship('Farmworker', backref='farm') fieldvisit = db.relationship('Fieldvisit', secondary=farm_fieldvisits, backref='farm') farmfertilizerplan = db.relationship('FarmFertilizerPlan', backref='farm') user_id = db.Column(db.Integer, db.ForeignKey('user.id')) created_timestamp = db.Column(db.DateTime, default=datetime.now) modified_timestamp = db.Column(db.DateTime, default=datetime.now, onupdate=datetime.now) surface = db.Column(db.String(255), nullable=True, unique=False) devisionoffice_id = db.Column(db.Integer) farm_pest_details = db.relationship('Farm_pest_details', backref='farm')
class Farmworker(db.Model): id = db.Column(db.Integer, primary_key=True) worker_frist_name = db.Column(db.Text, nullable=False) worker_last_name = db.Column(db.Text, nullable=False) worker_gender = db.Column(db.Boolean) worker_dob = db.Column(db.DateTime, nullable=False) worker_address = db.Column(db.Text, nullable=False) worker_phone = db.Column(db.Integer, nullable=False, unique=False) worker_type = db.Column(db.String(200), nullable=False) farmworker = db.relationship('FarmworkerAlarms', backref='farmworker') farmcomment = db.relationship('FarmWorkerComments', backref='farmworker') workedocument = db.relationship('FarmWorkerDocuments', backref='farmworker') farm_id = db.Column(db.Integer, db.ForeignKey('farm.id')) created_timestamp = db.Column(db.DateTime, default=datetime.now) modified_timestamp = db.Column(db.DateTime, default=datetime.now, onupdate=datetime.now)
class SystemCommonFertilizerPlan(db.Model): __tablename__ = 'systemcommonfertilizerplan' id = db.Column(db.Integer, primary_key=True) crop_age_range = db.Column(db.Text, nullable=True) fertilizer_need_time = db.Column(db.Text, nullable=True) fertilizer_name = db.Column(db.Text, nullable=True) fertilizer_amount = db.Column(db.Text, nullable=True) sys_crop_category_name = db.Column(db.Text, nullable=True) syscrop_id = db.Column(db.Integer(), db.ForeignKey('syscrop.id')) user_id = db.Column(db.Integer, db.ForeignKey('user.id')) created_timestamp = db.Column(db.DateTime, default=datetime.now) modified_timestamp = db.Column(db.DateTime, default=datetime.now, onupdate=datetime.now) fertilizer_need_time_name = db.Column(db.Text, nullable=True) systemfertilizer_id = db.Column(db.Integer, db.ForeignKey('systemfertilizer.id')) production_type = db.Column(db.String(255), nullable=True) season_id = db.Column(db.Integer)
class SysSubCategory(db.Model): __tablename__ = 'syssubcategory' id = db.Column(db.Integer, primary_key=True) variety_name = db.Column(db.Text, nullable=True) line_designation = db.Column(db.Text, nullable=True) pedgiree = db.Column(db.Text, nullable=True) origin = db.Column(db.Text, nullable=True) method_of_propagation = db.Column(db.Text, nullable=True) syscrop_id = db.Column(db.Integer(), db.ForeignKey('syscrop.id')) sub_cat_yield = db.relationship('SubCatYield', backref='syssubcategory', uselist=False) maturity = db.relationship('Maturity', backref='syssubcategory', uselist=False) importanttrait = db.relationship('ImportantTrait', backref='syssubcategory', uselist=False) reactiontodisease = db.relationship('ReactionToDisease', backref='syssubcategory', uselist=False) reactiontoinsectpest = db.relationship('ReactionToInsectPest', backref='syssubcategory', uselist=False) qulitycharacteristic = db.relationship('QulityCharacteristic', backref='syssubcategory', uselist=False) farmfertilizerplan = db.relationship('FarmFertilizerPlan', backref='syssubcategory') user_id = db.Column(db.Integer, db.ForeignKey('user.id')) created_timestamp = db.Column(db.DateTime, default=datetime.now) modified_timestamp = db.Column(db.DateTime, default=datetime.now, onupdate=datetime.now) sub_crop_image = db.Column(db.String(255), nullable=True) crops = db.relationship('Crop', backref='syssubcategory') farm_fertilizer_results = db.relationship('FarmFertilizerResults', backref='syssubcategory') farm_pest_details = db.relationship('Farm_pest_details', backref='syssubcategory')
class SysCrop(db.Model): __tablename__ = 'syscrop' id = db.Column(db.Integer, primary_key=True) system_crop_name = db.Column(db.Text, nullable=True) system_crop_sci_name = db.Column(db.Text, nullable=True) system_crop_catgoery = db.Column(db.Text, nullable=True) system_crop_growing_time = db.Column(db.Text, nullable=True) system_crop_image = db.Column(db.String(255), nullable=True) # crop_id = db.Column(db.Integer(), db.ForeignKey('crop.id')) user_id = db.Column(db.Integer, db.ForeignKey('user.id')) syssubcategory = db.relationship('SysSubCategory', backref='syscrop') cropseason = db.relationship('CropSeason', backref='syscrop') systemcommonfertilizerplan = db.relationship('SystemCommonFertilizerPlan', backref='syscrop') farmfertilizerplan = db.relationship('FarmFertilizerPlan', backref='syscrop') created_timestamp = db.Column(db.DateTime, default=datetime.now) modified_timestamp = db.Column(db.DateTime, default=datetime.now, onupdate=datetime.now) farm_fertilizer_results = db.relationship('FarmFertilizerResults', backref='syscrop') farm_pest_details = db.relationship('Farm_pest_details', backref='syscrop')
class User(db.Model, UserMixin): id = db.Column(db.Integer, primary_key=True) fristname = db.Column(db.Text, nullable=False) lastname = db.Column(db.Text, nullable=False) email = db.Column(db.String(255), nullable=False, unique=True) confirmed = db.Column(db.Boolean, nullable=False, default=False) confirmed_on = db.Column(db.DateTime, nullable=True) password = db.Column(db.String(255), nullable=False) phone = db.Column(db.Integer, nullable=False, unique=True) address = db.Column(db.Text, nullable=False) profile = db.Column(db.String(255), nullable=True) usertype = db.Column(db.String(20), nullable=False) active = db.Column(db.Boolean) farm = db.relationship('Farm', backref='user') fieldvisit = db.relationship('Fieldvisit', backref='user') systemfertilizertypes = db.relationship('SystemFertilizerTypes', backref='user') systemsubfertilizertyeps = db.relationship('SystemSubFertilizerTypes', backref='user') fertilizermatter = db.relationship('FertilizerMtter', backref='user') systemfertilizer = db.relationship('SystemFertilizer', backref='user') systemcommonfertilizerplan = db.relationship('SystemCommonFertilizerPlan', backref='user') farmfertilizerplan = db.relationship('FarmFertilizerPlan', backref='user') devisionoffice_id = db.Column(db.Integer, db.ForeignKey('devisionoffice.id')) created_timestamp = db.Column(db.DateTime, default=datetime.now) modified_timestamp = db.Column(db.DateTime, default=datetime.now, onupdate=datetime.now) syscrops = db.relationship('SysCrop', backref='user') syssubcategories = db.relationship('SysSubCategory', backref='user') subcatyield = db.relationship('SubCatYield', backref='user') maturityies = db.relationship('Maturity', backref='user') importanttraits = db.relationship('ImportantTrait', backref='user') reactiontodiseases = db.relationship('ReactionToDisease', backref='user') reactiontoinsectpest = db.relationship('ReactionToInsectPest', backref='user') qulitycharacteristic = db.relationship('QulityCharacteristic', backref='user') cropseason = db.relationship('CropSeason', backref='user') farm_fertilizer_results = db.relationship('FarmFertilizerResults', backref='user') system_pest_and_diseases = db.relationship('System_Pest_and_Diseases', backref='user') system_pest_disease_soulutions = db.relationship( 'System_Pest_Disease_Soulutions', backref='user') farm_pest_details = db.relationship('Farm_pest_details', backref='user') field_visit = db.relationship('Field_Visit', backref='user') # one to many relationship between district and user which mean one district live in many 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 get_email_confirm_token(self, expier_time=1800): es = Serializer(app.config['SECRET_KEY'], expier_time) return es.dumps({'user_id': self.id}).decode('utf-8') @staticmethod def verify_email_token(token): se = Serializer(app.config['SECRET_KEY']) try: user_id = se.loads(token)['user_id'] except: return None return User.query.get(user_id)