class User(db.Document, UserMixin,JsonSerializable): # query_class = UserModel email = db.StringField(max_length=50,required=True, primary_key=True) username = db.StringField(max_length=50,required=True) image_file = db.StringField(max_length=50,required=True, default='avatar.png') password = db.StringField(max_length=100,required=True) role = db.StringField(max_length=100,required=True) type = db.StringField(required=True, default='none', max_length=10) # get code token for reset password 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') def get_login_token(self, expires_sec = 600): s = Serializer(current_app.config['SECRET_KEY']+'login', 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: return None return User.objects.filter(email=user_id).first() @staticmethod def verify_login_token(token): s = Serializer(current_app.config['SECRET_KEY']+'login') try: user_id = s.loads(token)['user_id'] except: return None return User.objects.filter(email=user_id).first() def __repr__(self): return f"User('{self.username}','{self.email}','{self.password}','{self.image_file}','{self.role}')"
class DataTrain(db.Document): # query_class = UserModel # id = db.StringField(required=True, primary_key=True) author = db.StringField(max_length=100,required=True, default='page') title = db.StringField(required=True, default='title') description = db.StringField(required=True, default='description') # image_file = db.StringField(max_length=50,required=True, default='avatar.png') image_author = db.StringField(required=True, default='avatar.png') url_page = db.StringField(required=True, default='url_page') url_image = db.StringField(required=True, default='url_image') # date_posted = db.DateTimeField(default = datetime.utcnow()) date_posted = db.StringField(max_length=50,required=True, default='date_posted') kind = db.StringField(max_length=100,required=True, default='kind') like = db.StringField(max_length=50,required=True, default='like') brand = db.StringField(required=True, default='brand') tags = db.ListField(db.StringField(max_length=30)) age_data = db.StringField(required=True, default='age_data') view = db.StringField(required=True, default='view') currency = db.StringField(required=True, default='currency') price = db.StringField(required=True, default='price') def to_json(self): return { "_id": str(self.id), "author": self.author, "title": self.title, "description": self.description, # "image_file": self.image_file, "image_author": self.image_author, "url_page": self.url_page, "kind": self.kind, "like": self.like, "brand": self.brand, "tags": self.tags } def __repr__(self): return f"DataTrain('{self.title}','{self.author}','{self.description}')"
class CollectionPageId(db.Document): page_id = db.StringField(primary_key=True,required=True, default='page') quantity = db.IntField(required=True, default=0) updated_date = db.DateTimeField(default = datetime.utcnow()) created_date = db.DateTimeField(default = datetime.utcnow())
class DMMPageAd(db.Document): # 9 field of DMMM page_id = db.StringField(primary_key=True,required=True, default='pageID') page_name = db.StringField(required=True, default='pageName') created_date = db.DateTimeField(default = datetime.utcnow())
class DMMAdTrain(db.Document): # 9 field of DMMM page_id = db.StringField(required=True, default='pageID') dmm_id = db.StringField(required=True, default='dmmID') page_name = db.StringField(required=True, default='pageName') post_id= db.StringField(required=True, default='post_id') number_of_like = db.IntField(required=True, default=0) number_of_comment = db.IntField(required=True, default=0) number_of_share = db.IntField(required=True, default=0) image_url = db.StringField(required=True, default='image_url') image_url_mockup = db.StringField(required=True, default='image_url_mockup') image_url_product = db.StringField(required=True, default='image_url_product') image_url_profile = db.StringField(required=True, default='image_url_profile') link_url = db.StringField(required=True, default='link_url') start_date = db.StringField(required=True, default="1564642800") description = db.StringField(required=True, default='description') platform = db.StringField(required=True, default='platform') domain = db.StringField(required=True, default="domain") title = db.StringField(required=True, default='title') pixel_id = db.StringField(required=True, default='pixel_id') product_url = db.StringField(required=True, default='product_url') is_active = db.BooleanField(required=True, default=True)
class AdTrain(db.Document): #combine to Adtrain 16 field of Adtrain combinate with FB vs DMM page_id = db.StringField(required=True, default='pageID') page_name = db.StringField(required=True, default='pageName') post_id= db.StringField(required=True, default='post_id') ad_id = db.StringField(required=True, default='ad_id') title = db.StringField(required=True, default='title') start_date = db.StringField(required=True, default="1564642800") number_of_like = db.IntField(required=True, default=0) number_of_comment = db.IntField(required=True, default=0) number_of_share = db.IntField(required=True, default=0) image_url_mockup = db.StringField(required=True, default='image_url_mockup') image_url_product = db.StringField(required=True, default='image_url_product') image_url_profile = db.StringField(required=True, default='image_url_profile') link_url = db.StringField(required=True, default='link_url') description = db.StringField(required=True, default='description') platform = db.StringField(required=True, default='platform') domain = db.StringField(required=True, default="domain") pixel_id = db.StringField(required=True, default='pixel_id') tags = db.ListField(db.StringField(max_length=30)) age_data = db.StringField(required=True, default='age_data') view = db.StringField(required=True, default='view') currency = db.StringField(required=True, default='currency') price = db.StringField(required=True, default='price') region_data = db.StringField(required=True, default='region_data') is_active = db.BooleanField(required=True, default=True) created_date = db.DateTimeField(default = datetime.utcnow())
class FBAdTrain(db.Document,JsonSerializable): # 16 field of FB ok ? ad_id = db.StringField(required=True, default='adId') ad_archive_id = db.StringField(required=True, default='ad_archiveID') end_date= db.IntField(required=True, default=0) start_date = db.IntField(required=True, default=0) gated_type = db.StringField(required=True, default='gated_type') is_active = db.BooleanField(required=True, default=False) is_profile_page = db.BooleanField(required=True, default=False) is_promoted_news= db.BooleanField(required=True, default=False) page_id = db.StringField(required=True, default='pageID') page_name = db.StringField(required=True, default='pageName') snap_shot = db.StringField(required=True, default='snap_shot') tags = db.ListField(db.StringField(max_length=30)) age_data = db.StringField(required=True, default='age_data') view = db.StringField(required=True, default='view') currency = db.StringField(required=True, default='currency') price = db.StringField(required=True, default='price') region_data = db.StringField(required=True, default='region_data')
class InfoAd(db.Document,JsonSerializable): ad_creative_id = db.StringField(required=True, default='ad_creative_id') additional_info = db.StringField(required=True, default='additional_info') by_line = db.StringField(required=True, default='by_line') caption = db.StringField(required=True, default='caption') country_iso_code = db.StringField(required=True, default='caption') creation_time = db.IntField(required=True, default='0') current_page_name = db.StringField(required=True, default='current_page_name') original_image_url = db.StringField(required=True, default='original_image_url') resize_image_url = db.StringField(required=True, default='resize_image_url') instagram_actor_name = db.StringField(required=True, default='instagram_actor_name') instagram_profile_pic_url = db.StringField(required=True, default='instagram_profile_pic_url') link_description = db.StringField(required=True, default='link_description') link_url = db.StringField(required=True, default='link_url') page_categories = db.StringField(required=True, default='page_categories') page_id = db.StringField(required=True, default='page_id') page_is_deleted = db.BooleanField(required=True, default=False) page_like_count = db.StringField(required=True, default='page_like_count') page_name = db.StringField(required=True, default='page_name') page_profile_picture_url = db.StringField(required=True, default='page_profile_picture_url') page_profile_uri = db.StringField(required=True, default='page_profile_uri') page_welcome_message = db.StringField() root_reshared_post = db.StringField() title = db.StringField(required=True, default='title') version = db.StringField(required=True, default='version')
class AdditionalInfo(db.Document,JsonSerializable): city = db.StringField() committee_id = db.StringField() director_name = db.StringField() email = db.StringField() phone_number = db.StringField() point_of_contact = db.StringField() state = db.StringField() street_address_1 = db.StringField() street_address_2 = db.StringField() treasurer_name = db.StringField() website = db.StringField() zipcode = db.StringField()