Exemple #1
0
class TeamMember(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    title = db.Column(db.String(256), nullable=False)
    description = db.Column(db.String(512), nullable=False)
    is_active = db.Column(db.Boolean(), default=False, nullable=False)
    date = db.Column(db.DateTime)

    user_id = db.Column(db.Integer(), db.ForeignKey(User.id))
    user = db.relationship(User, backref='teammember')

    campaign_id = db.Column(db.Integer(), db.ForeignKey(Campaign.id))
    campaign = db.relationship(Campaign, backref='teammember')
Exemple #2
0
class SocialLink(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    title = db.Column(db.String(256), nullable=False)
    url = db.Column(db.String(256), nullable=False)

    campaign_id = db.Column(db.Integer(), db.ForeignKey(Campaign.id))
    campaign = db.relationship(Campaign, backref='socaillink')
Exemple #3
0
class Order(db.Model):
    id = db.Column(UUID(as_uuid=True),
                   default=lambda: uuid.uuid4(),
                   primary_key=True)
    cost = db.Column(db.Float, default=0, nullable=False)
    contribution = db.Column(db.Float, default=0, nullable=False)
    tax = db.Column(db.Float, default=0, nullable=False)
    shipping = db.Column(db.Float, default=0, nullable=False)
    total = db.Column(db.Float, default=0, nullable=False)

    order_status_id = db.Column(db.Integer, nullable=False)

    is_shipping = db.Column(db.Boolean())
    is_private = db.Column(db.Boolean())

    shipping_info_id = db.Column(db.ForeignKey('contact_info.id'))
    shipping_info = db.relationship('ContactInfo',
                                    foreign_keys=[shipping_info_id],
                                    cascade='all,delete',
                                    backref='shipping_order')

    billing_info_id = db.Column(db.ForeignKey('contact_info.id'))
    billing_info = db.relationship('ContactInfo',
                                   foreign_keys=[billing_info_id],
                                   cascade='all,delete',
                                   backref='billing_order')

    shipping_date = db.Column(db.DateTime)

    user_id = db.Column(db.Integer, db.ForeignKey(User.id), nullable=False)
    user = db.relationship('User')

    reward_id = db.Column(UUID(as_uuid=True), db.ForeignKey(Reward.id))
    reward = db.relationship('Reward')

    campaign_id = db.Column(db.Integer,
                            db.ForeignKey(Campaign.id),
                            nullable=False)
    campaign = db.relationship('Campaign')

    created_date = db.Column(db.DateTime, default=datetime.datetime.now())

    paypal_order_id = db.Column(db.String(128), nullable=False)
Exemple #4
0
class CampaignFeeOverride(db.Model):
    id = db.Column(UUID(as_uuid=True), default=lambda: uuid.uuid4(), primary_key=True)
    base_fee = db.Column(db.Float, default=0, nullable=False)
    evergreen_cost = db.Column(db.Float, default=0, nullable=False)
    campaign_management = db.Column(db.Float, default=0, nullable=False)
    fulfillment = db.Column(db.Float, default=0, nullable=False)
    first_money_threshold = db.Column(db.Float, default=0, nullable=False)

    campaign_id = db.Column(db.Integer, db.ForeignKey(Campaign.id), nullable=False)
    campaign = db.relationship('Campaign',primaryjoin="Campaign.id==CampaignFeeOverride.campaign_id")
class ModelUser(db.Model):
    __tablename__ = 'user'
    id = db.Column(db.Integer, primary_key=True)
    email = db.Column(db.String(120), unique=True, nullable=False)
    password = db.Column(db.String(120), unique=False, nullable=False)
    roles = db.relationship('ModelRole',
                            secondary='user_role',
                            lazy='subquery',
                            backref=db.backref('users', lazy=True))

    def __repr__(self):
        return '<User %r>' % self.email
Exemple #6
0
class CampaignUpdate(db.Model):
    id = db.Column(UUID(as_uuid=True), default=lambda: uuid.uuid4(), primary_key=True)
    text = db.Column(db.String(5120), nullable=False)

    user_id = db.Column(db.Integer, db.ForeignKey(User.id), nullable=False)
    user = db.relationship('User')

    campaign_id = db.Column(db.Integer, db.ForeignKey(Campaign.id), nullable=False)

    is_active = db.Column(db.Boolean(), default=True, nullable=False)

    is_exclusive = db.Column(db.Boolean(), default=False, nullable=False)

    created_date = db.Column(db.DateTime, default=datetime.datetime.now())
Exemple #7
0
class Reward(db.Model):
    id = db.Column(UUID(as_uuid=True), default=lambda: uuid.uuid4(), primary_key=True)
    title = db.Column(db.String(256), nullable=False)
    description = db.Column(db.String(2048), nullable=False)
    thumbnail_url = db.Column(db.String(512))
    is_active = db.Column(db.Boolean(), default=False, nullable=False)
    is_available = db.Column(db.Boolean(), default=False, nullable=False)
    cost = db.Column(db.Float, default=0, nullable=False)
    expiration_date = db.Column(db.DateTime)
    delivery_date = db.Column(db.DateTime)
    inventory = db.Column(db.Integer, nullable=False)
    claimed = db.Column(db.Integer, nullable=False)
    is_shipping_required = db.Column(db.Boolean(),nullable=False)
    shipping_fee = db.Column(db.Float, default=0, nullable=False)
    international_shipping_fee = db.Column(db.Float, default=0, nullable=False)
    is_limited_quantity = db.Column(db.Boolean(),nullable=False)
    is_featured = db.Column(db.Boolean(),nullable=False,default=False)
    ordinal = db.Column(db.Integer, nullable=False, default=0)
    referrals_needed = db.Column(db.Integer,default=0, nullable=False)

    campaign_id = db.Column(db.Integer, db.ForeignKey(Campaign.id), nullable=False)
    campaign = db.relationship('Campaign',primaryjoin="Campaign.id==Reward.campaign_id")
Exemple #8
0
class Campaign(db.Model):

    #__tablename__ = 'campaigns'

    id = db.Column(db.Integer, primary_key=True)
    draft_id = db.Column(db.String(256))
    published_document_id = db.Column(db.String(256))
    user_id = db.Column(db.Integer, db.ForeignKey(User.id), nullable=False)
    short_vanity_url = db.Column(db.String(64))
    google_analytics = db.Column(db.String(64))
    vanity_url = db.Column(db.String(256))
    thumbnail_url = db.Column(db.String(512))
    confirmation_message = db.Column(db.String(2048))
    created_date = db.Column(db.DateTime)
    campaign_status_id = db.Column(db.Integer)
    is_active = db.Column(db.Boolean(), default=False, nullable=False)

    #form_campaign_info
    short_description = db.Column(db.String(256))
    description = db.Column(db.Text())
    title = db.Column(db.String(256), nullable=False)

    #form_basics
    campaign_receiver_id = db.Column(db.Integer)
    campaign_type_id = db.Column(db.Integer)
    category_id = db.Column(db.Integer)
    expiration_date = db.Column(db.DateTime)
    funding_goal = db.Column(db.Float, default=0)
    funded = db.Column(db.Float, default=0)
    campaign_management = db.Column(db.Boolean(), default=False)
    fulfillment_service = db.Column(db.Boolean(), default=False)
    evergreen_campaign_page = db.Column(db.Boolean(), default=False)

    rewards = db.relationship('Reward',lazy='dynamic',primaryjoin="and_(Reward.campaign_id==Campaign.id,Reward.referrals_needed==0)")
    updates = db.relationship('CampaignUpdate', lazy='dynamic', backref='campaign')
    comments = db.relationship('Comment', backref='campaign', lazy='dynamic')

    campaign_fee_override_id = db.Column(UUID(as_uuid=True), db.ForeignKey('campaign_fee_override.id', use_alter=True,name="fk_campaign_fee_override"), nullable=True)
    campaign_fee_override = db.relationship('CampaignFeeOverride', foreign_keys=[campaign_fee_override_id],primaryjoin="CampaignFeeOverride.id==Campaign.campaign_fee_override_id",post_update=True)

    bonus_reward_id = db.Column(UUID(as_uuid=True), db.ForeignKey('reward.id', use_alter=True,name="fk_bonus_reward"), nullable=True)
    bonus_reward = db.relationship('Reward', foreign_keys=[bonus_reward_id],primaryjoin="Reward.id==Campaign.bonus_reward_id",post_update=True)

    orders = db.relationship('Order',lazy='dynamic')

    active_updates = db.relationship('CampaignUpdate',lazy='dynamic',primaryjoin="and_(CampaignUpdate.campaign_id==Campaign.id,CampaignUpdate.is_active==True)")

    #backers = db.relationship('User',secondary="join(Campaign, User, Campaign.user_id == User.id)",primaryjoin="and_(Order.campaign_id==Campaign.id,Order.order_status_id==3)",secondaryjoin="User.id==Campaign.user_id")

    def __str__(self):
        return self.title

    @property
    def days_left(self):
        return (self.expiration_date-datetime.datetime.now()).days

    @property
    def percent_funded(self):
        return '{0:.2g}'.format((self.funded/self.funding_goal)*100 if self.funded > 0 else 0)

    @property
    def total_fee_percent(self):
        total = 0.0
        if self.campaign_fee_override:
            total += self.campaign_fee_override.base_fee
            total += self.campaign_fee_override.evergreen_cost if self.evergreen_campaign_page else 0.0
            total += self.campaign_fee_override.fulfillment if self.fulfillment_service else 0.0
            total += self.campaign_fee_override.campaign_management if self.campaign_management else 0.0
        else:
            total += FANBACKED_BASE_FEE
            total += FANBACKED_EVERGREEN_COST if self.evergreen_campaign_page else 0.0
            total += FANBACKED_FULFILLMENT if self.fulfillment_service else 0.0
            total += FANBACKED_CAMPAIGN_MANAGEMENT if self.campaign_management else 0.0

        return total
Exemple #9
0
class User(db.Model):

    #__tablename__ = 'users'

    id = db.Column(db.Integer, primary_key=True)
    first_name = db.Column(db.String(100))
    last_name = db.Column(db.String(100))
    username = db.Column(db.String(80), unique=True)
    password = db.Column(db.String(80), nullable=False)
    email = db.Column(db.String(120), nullable=False)
    icon_url = db.Column(db.String(512))
    api_key = db.Column(db.String(256))
    reset_hash = db.Column(db.String(256))
    user_type = db.Column(db.Integer, default=0, nullable=False)
    is_verified = db.Column(db.Boolean(), default=False, nullable=False)
    is_user_active = db.Column('is_active',
                               db.Boolean(),
                               default=True,
                               nullable=False)
    birth_date = db.Column(db.DateTime)
    date = db.Column(db.DateTime, default=datetime.datetime.now())
    phone = db.Column(db.String(32))
    is_anonymous = db.Column(db.Boolean(), default=False, nullable=False)

    avatar = db.Column(
        db.String(512),
        default=
        'http://res.cloudinary.com/hzdmrhkl4/image/upload/v1399526643/yf6s7buokuqcubtiiyjb.png'
    )

    company_name = db.Column(db.String(100), nullable=True)
    title = db.Column(db.String(100), nullable=True)
    bio = db.Column(db.String(500), nullable=True)

    fb_profile = db.Column(db.String(200), nullable=True)
    linkedin_profile = db.Column(db.String(200), nullable=True)
    twitter_profile = db.Column(db.String(200), nullable=True)
    youtube_profile = db.Column(db.String(200), nullable=True)
    imdb_profile = db.Column(db.String(200), nullable=True)
    website_profile = db.Column(db.String(200), nullable=True)

    shipping_info_id = db.Column(db.ForeignKey('contact_info.id'))
    shipping_info = relationship('ContactInfo',
                                 foreign_keys=[shipping_info_id],
                                 cascade='all,delete',
                                 backref='shipping_user')

    billing_info_id = db.Column(db.ForeignKey('contact_info.id'))
    billing_info = relationship('ContactInfo',
                                foreign_keys=[billing_info_id],
                                cascade='all,delete',
                                backref='billing_user')

    notif_featured_newsletter = db.Column(db.Boolean(), default=False)
    notif_partner_events = db.Column(db.Boolean(), default=False)
    notif_sneak_peeks = db.Column(db.Boolean(), default=False)
    notif_project_updates = db.Column(db.Boolean(), default=False)
    notif_backer_summary = db.Column(db.Boolean(), default=False)
    notif_comments = db.Column(db.Boolean(), default=False)
    notif_follower_summary = db.Column(db.Boolean(), default=False)

    campaigns = db.relationship('Campaign', backref='user', lazy='dynamic')
    comments = db.relationship('Comment', backref='user', lazy='dynamic')

    @property
    def is_admin(self):
        return self.user_type == UserType.Admin

    def is_authenticated(self):
        return True

    def is_active(self):
        return True

    def is_anonymous(self):
        return False

    def get_id(self):
        return unicode(self.id)

    def get_user_type(self):
        return UserType(self.user_type)

    # Required for administrative interface
    def __str__(self):
        return self.username

    @property
    def serialize(self):
        return {
            'id': self.id,
            'first_name': unicode(self.first_name),
            'last_name': unicode(self.last_name),
            'username': unicode(self.username),
            'icon_url': unicode(self.icon_url),
            'is_active': unicode(self.is_active),
            'api_key': unicode(self.api_key),
        }

    @property
    def serialize_light(self):
        return {
            'id': self.id,
            'first_name': unicode(self.first_name),
            'last_name': unicode(self.last_name),
            'username': unicode(self.username),
            'icon_url': unicode(self.icon_url),
            'is_active': unicode(self.is_active),
            'api_key': unicode(self.api_key),
        }