Esempio n. 1
0
class Experience(db.Model):
    id = db.Column(db.Integer(), primary_key=True)
    title = db.Column(db.String())
    category = db.Column(db.String())
    description = db.Column(db.String())
    policy = db.Column(db.String())
    guest_price = db.Column(db.Float())
    artist_booking_price = db.Column(db.Float())
    guest_slot = db.Column(db.Integer())
    artist_slot = db.Column(db.Integer())
    start_date = db.Column(db.String())
    epoch_start_date = db.Column(db.Integer())
    end_date = db.Column(db.String())
    epoch_end_date = db.Column(db.Integer())
    location = db.Column(db.String())
    can_apply = db.Column(db.Boolean())
    can_purchase = db.Column(db.Boolean())
    potential_to_earn = db.Column(db.Float())
    created_by = db.Column(db.Integer(),
                           ForeignKey('user_v2.id', ondelete='CASCADE'))
    created_at = db.Column(db.String())
    epoch_created_at = db.Column(db.Integer())
    last_updated_at = db.Column(db.String())
    epoch_last_updated_at = db.Column(db.Integer())
    last_updated_by = db.Column(db.String())

    buy_experiences = relationship('BuyExperience',
                                   backref='experience',
                                   cascade="all,delete, delete-orphan")

    def __init__(self, **kwargs):
        super(Experience, self).__init__(**kwargs)

        self.created_at = datetime.datetime.utcnow().isoformat()
        self.epoch_created_at = int(time.time())
Esempio n. 2
0
class AlertLog(db.Model):
    __tablename__ = 'alert_log'
    id = db.Column(db.Integer(), primary_key=True)
    message = db.Column(db.String())
    namespace = db.Column(db.String())
    slack_code_status = db.Column(db.Integer())
    slack_response = db.Column(db.String())
    created_at = db.Column(db.String())

    def __init__(self,
                 message,
                 namespace,
                 slack_code_status,
                 slack_response,
                 created_at=None):
        self.message = message
        self.namespace = namespace
        self.slack_code_status = slack_code_status
        self.slack_response = slack_response

        if not created_at:
            self.created_at = datetime.datetime.utcnow().isoformat()
        else:
            self.created_at = created_at

    @staticmethod
    def log_to_db(message, namespace, slack_code_status, slack_response):
        log = AlertLog(message, namespace, slack_code_status, slack_response)
        db.session.add(log)
        try:
            db.session.commit()
        except Exception as e:
            print("failed to log to db:{}".format(str(e)))
            db.session.rollback()
Esempio n. 3
0
class SyncJobReport(db.Model):
    __tablename = 'sync_job_report'
    id = db.Column(db.Integer(), primary_key=True)
    seller_id = db.Column(db.String(), nullable=False)
    sync_type = db.Column(db.String())
    sync_status = db.Column(db.String())
    start_date_epoch = db.Column(db.Integer())
    end_date_epoch = db.Column(db.Integer())

    def __init__(self, **kwargs):
        super(SyncJobReport, self).__init__(**kwargs)
class ResetToken(db.Model):
    user_id = db.Column(db.Integer(),
                        ForeignKey('user_v2.id', ondelete='CASCADE'),
                        primary_key=True)
    token_str = db.Column(db.String())
    expiration_date = db.Column(db.String())

    def __init__(self, user_id, token_str):
        self.user_id = user_id
        self.token_str = token_str
        expiration_date = datetime.datetime.utcnow() + datetime.timedelta(
            minutes=EXPIRATION_MINUTES)
        self.expiration_date = expiration_date.isoformat()
Esempio n. 5
0
class BuyExperience(db.Model):
    id = db.Column(db.Integer(), primary_key=True)
    experience_id = db.Column(db.Integer(),
                              ForeignKey('experience.id', ondelete='CASCADE'))
    number_of_slots = db.Column(db.Integer())
    email = db.Column(db.String())
    created_at = db.Column(db.String())
    epoch_created_at = db.Column(db.Integer())

    def __init__(self, **kwargs):
        super(BuyExperience, self).__init__(**kwargs)

        self.created_at = datetime.datetime.utcnow().isoformat()
        self.epoch_created_at = int(time.time())
Esempio n. 6
0
class EmailLog(db.Model):
    id = db.Column(db.Integer(), primary_key=True)
    email_type = db.Column(db.String())
    user_id = db.Column(db.Integer(),
                        ForeignKey('user_v2.id', ondelete='CASCADE'))
    email_from_name = db.Column(db.String())
    email_to = db.Column(db.String())
    email_subject = db.Column(db.String())
    email_body = db.Column(db.String())
    status_code = db.Column(db.Integer())
    message = db.Column(db.String(), nullable=True)
    created_at = db.Column(db.String())
    epoch_created_at = db.Column(db.Integer())

    def __init__(self, **kwargs):
        super(EmailLog, self).__init__(**kwargs)

        self.created_at = datetime.datetime.utcnow().isoformat()
        self.epoch_created_at = int(time.time())

    @staticmethod
    def log_to_db(**kwargs):
        log = EmailLog(**kwargs)
        db.session.add(log)
        try:
            db.session.commit()
        except Exception as e:
            print("failed to log to db:{}".format(str(e)))
            db.session.rollback()
Esempio n. 7
0
class BatchUploadJob(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    user_id = db.Column(db.Integer())
    generated_report_id = db.Column(db.Integer())
    job_status = db.Column(db.String())
    error_message = db.Column(db.String())
    created_at = db.Column(db.String())
    updated_at = db.Column(db.String())

    def __init__(self,
                 user_id,
                 job_status,
                 error_message=None,
                 generated_report_id=None):
        self.user_id = user_id
        self.generated_report_id = generated_report_id
        self.created_at = datetime.datetime.utcnow().isoformat()
        self.updated_at = datetime.datetime.utcnow().isoformat()
Esempio n. 8
0
class WebhookLog(db.Model):
    __tablename__ = 'webhook_log'
    id = db.Column(db.Integer(), primary_key=True)
    user_id = db.Column(db.Integer())
    seller_id = db.Column(db.String())
    url = db.Column(db.String())
    request_json = db.Column(db.String())
    response_content = db.Column(db.String())
    status_code = db.Column(db.String())
    created_at = db.Column(db.String())

    def __init__(self, user_id, seller_id, url, request_json, response_content, status_code):
        self.user_id = user_id
        self.seller_id = seller_id
        self.url = url
        self.request_json = request_json
        self.response_content = response_content
        self.status_code = status_code
        self.created_at = datetime.datetime.utcnow().isoformat()

    @staticmethod
    def log_to_db(user_id, seller_id, url, request_json, response_content, status_code):
        log = WebhookLog(user_id, seller_id, url, request_json, response_content, status_code)
        db.session.add(log)
        try:
            db.session.commit()
        except Exception as e:
            print("failed to log to db:{}".format(str(e)))
            db.session.rollback()
class ArtistExperienceApplication(db.Model):
    id = db.Column(db.Integer(), primary_key=True)
    experience_id = db.Column(db.Integer(),
                              ForeignKey('experience.id', ondelete='CASCADE'))
    user_id = db.Column(db.Integer, ForeignKey(User.id, ondelete='CASCADE'))
    images = db.Column(postgresql.ARRAY(sqltypes.Text))
    about = db.Column(db.String())

    __table_args__ = (UniqueConstraint('user_id',
                                       'experience_id',
                                       name='unique_user_experience'), )

    experience = relationship('Experience', backref='artist_applications')

    def __init__(self, **kwargs):
        super(ArtistExperienceApplication, self).__init__(**kwargs)

        self.created_at = datetime.datetime.utcnow().isoformat()
        self.epoch_created_at = int(time.time())
Esempio n. 10
0
class User(db.Model):
    __tablename__ = "user_v2"
    id = db.Column(db.Integer(), primary_key=True)
    role = db.Column(db.String())
    full_name = db.Column(db.String())
    professional_talent = db.Column(db.String())
    email = db.Column(db.String())
    password = db.Column(db.String())
    city = db.Column(db.String())
    state = db.Column(db.String())
    zipcode = db.Column(db.String())
    self_description = db.Column(db.String())
    facebook = db.Column(db.String())
    instagram = db.Column(db.String())
    twitter = db.Column(db.String())
    youtube = db.Column(db.String())
    pinterest = db.Column(db.String())
    image = db.Column(db.String())
    created_at = db.Column(db.String())
    epoch_created_at = db.Column(db.Integer())
    status = db.Column(db.String())

    __table_args__ = (UniqueConstraint('email', name='unique_email'), )

    email_logs = relationship('EmailLog',
                              backref='user',
                              cascade="all,delete, delete-orphan")

    experiences = relationship('Experience',
                               backref='user',
                               cascade="all,delete, delete-orphan")

    artist_applications = relationship('ArtistExperienceApplication',
                                       backref='user',
                                       cascade="all,delete, delete-orphan")

    def __init__(self, **kwargs):
        super(User, self).__init__(**kwargs)
        self.password = pwd_context.hash(kwargs.get('password'))
        self.created_at = datetime.datetime.utcnow().isoformat()
        self.epoch_created_at = int(time.time())

    def update_password(self, password):
        self.password = pwd_context.hash(password)

    def activate_user(self):
        self.is_active = True

    @staticmethod
    def get(user_id):
        return User.query.filter_by(id=user_id).first()

    @staticmethod
    def find_user_by_email(email):
        return User.query.filter(
            func.lower(User.email) == func.lower(email)).first()

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

    @staticmethod
    def get_active_users():
        return User.query.filter_by(is_active=True)