예제 #1
0
class Event(Thing):
    __tablename__ = 'event'

    id = db.Column(db.Integer, db.ForeignKey('thing.id'), primary_key=True)

    parent_id = db.Column(db.Integer, db.ForeignKey('event.id'))
    parent = db.relationship('Event',
                             remote_side=[id],
                             foreign_keys=[parent_id])

    door_time = db.Column(db.DateTime, index=True)

    start_time_ = db.Column('start_time', db.DateTime, index=True)
    end_time = db.Column(db.DateTime, index=True)

    @property
    def start_time(self):
        eastern = timezone('US/Eastern')

        return self.start_time_.replace(tzinfo=pytz.UTC).astimezone(eastern)

    @start_time.setter
    def start_time(self, value):
        self.start_time_ = value

    start_time = synonym('start_time_', descriptor=start_time)

    maximum_attendee_capacity = db.Column(db.Integer)

    child_events = db.relationship('Event', foreign_keys=[parent_id])

    audience_id = db.Column(db.Integer, db.ForeignKey('audience.id'))
    audience = db.relationship("Audience", foreign_keys=[audience_id])

    # Slug for site url
    slug = db.Column(db.String(256))

    # Shorthand code that will show up on the calendar
    calendar_code = db.Column(db.String(16))

    # Two images per show/event
    primary_image = db.Column(db.String(128))
    secondary_image = db.Column(db.String(128))

    offers = db.relationship('Offer', secondary=event_offer)

    #tickets = db.relationship('Ticket', back_populates='event')

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

    is_basic = db.Column(db.Boolean, default=True)

    def __repr__(self):
        return '<Event {}: {}>'.format(self.name, self.start_time)

    __mapper_args__ = {
        'polymorphic_identity': 'event',
    }
예제 #2
0
class Post(db.Model):
    id = db.Column(db.Integer, primary_key=True)

    body = db.Column(db.Text)

    timestamp = db.Column(db.DateTime, index=True, default=datetime.now)

    user_id = db.Column(db.Integer, db.ForeignKey('user.id'))
    author = db.relationship('User', foreign_keys=[user_id])

    thing_id = db.Column(db.Integer, db.ForeignKey('thing.id'))
    thing = db.relationship('Thing', foreign_keys=[thing_id])

    def __repr__(self):
        return '<Post {}>'.format(self.body)
예제 #3
0
class Ticket(Thing):

    id = db.Column(db.Integer, db.ForeignKey('thing.id'), primary_key=True)

    face_value = db.Column(db.Numeric(12, 2))

    event_id = db.Column(db.Integer, db.ForeignKey('event.id'))
    event = db.relationship('Event', foreign_keys=[event_id])

    reservation_id = db.Column(db.Integer, db.ForeignKey('reservation.id'))
    reservation = db.relationship('Reservation',
                                  foreign_keys=[reservation_id],
                                  backref='tickets')

    offer_id = db.Column(db.Integer, db.ForeignKey('offer.id'))
    offer = db.relationship('Offer', foreign_keys=[offer_id])

    __mapper_args__ = {'polymorphic_identity': 'ticket'}
예제 #4
0
class Thing(db.Model):
    __tablename__ = 'thing'

    id = db.Column(db.Integer, primary_key=True)

    # The type of the item
    type = db.Column(db.String(50))

    # UUID of item
    uuid = db.Column(db.String(64), default=get_uuid)

    # An alias for the item
    alternate_name = db.Column(db.String(256))

    # A description of the item
    description = db.Column(db.String(1024))

    # A sub property of description. A short description of the
    # item used to disambiguate from other, similar items. Information
    # from other properties (in particular, name) may be necessary for
    # the description to be useful for disambiguation.
    disambiguating_description = db.Column(db.String(1024))

    # The identifier property represents any kind of identifier for any
    # kind of Thing, such as ISBNs, GTIN codes, UUIDs etc.
    identifier = db.Column(db.String(256))

    # An image of the item
    image = db.Column(db.String(256))

    # Indicates a page for which this thing is the main entity being described.
    main_entity_of_page = db.Column(db.String(256))

    # The name of the item.
    name = db.Column(db.String(256))

    # URL of the item.
    url = db.Column(db.String(256))

    # IP Address
    ip_address = db.Column(db.String(32))

    created = db.Column(db.DateTime, default=datetime.now)
    created_by = db.Column(db.String(64))

    modified = db.Column(db.DateTime, default=datetime.now)
    modified_by = db.Column(db.String(64))

    is_default = db.Column(db.Boolean)

    comments = db.relationship('Post')

    __mapper_args__ = {
        'polymorphic_identity': 'thing',
        'polymorphic_on': type
    }
예제 #5
0
class TransactionRequest(Thing):
    __tablename__ = 'transaction_request'

    id = db.Column(db.Integer, db.ForeignKey('thing.id'), primary_key=True)

    # The amount of the transaction request
    amount = db.Column(db.Numeric(12, 2))
    taxes = db.Column(db.Numeric(12, 2))
    fees = db.Column(db.Numeric(12, 2))

    payment_id = db.Column(db.Integer, db.ForeignKey('payment.id'))
    payment = db.relationship('Payment',
                              backref='transaction_request',
                              foreign_keys=[payment_id])

    order_id = db.Column(db.Integer, db.ForeignKey('order.id'))
    order = db.relationship('Order',
                            backref='transaction_request',
                            foreign_keys=[order_id])

    customer_address_id = db.Column(db.Integer,
                                    db.ForeignKey('customer_address.id'))
    bill_to = db.relationship('CustomerAddress',
                              backref='transaction_request',
                              foreign_keys=[customer_address_id])

    customer_data_id = db.Column(db.Integer, db.ForeignKey('customer_data.id'))
    customer = db.relationship('CustomerData',
                               backref='transaction_request',
                               foreign_keys=[customer_data_id])

    transaction_response_id = db.Column(
        db.Integer, db.ForeignKey('transaction_response.id'))
    transaction_response = db.relationship(
        'TransactionResponse',
        backref='transaction_request',
        foreign_keys=[transaction_response_id])

    __mapper_args__ = {
        'polymorphic_identity': 'transaction_request',
    }
예제 #6
0
class Reservation(Thing):
    __tablename__ = 'reservation'

    id = db.Column(db.Integer, db.ForeignKey('thing.id'), primary_key=True)

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

    reservation_for_id = db.Column(db.Integer, db.ForeignKey('event.id'))
    reservation_for = db.relationship('Event',
                                      foreign_keys=[reservation_for_id],
                                      backref='reservations')

    under_name = db.Column(db.String(256))

    total_price = db.Column(db.Numeric(12, 2))

    transaction_request_id = db.Column(db.Integer,
                                       db.ForeignKey('transaction_request.id'))
    transaction_request = db.relationship(
        'TransactionRequest', foreign_keys=[transaction_request_id])

    __mapper_args__ = {'polymorphic_identity': 'reservation'}
예제 #7
0
class Payment(Thing):
    __tablename__ = 'payment'

    id = db.Column(db.Integer, db.ForeignKey('thing.id'), primary_key=True)

    payment_type = db.Column(db.String(32))

    credit_card_id = db.Column(db.Integer, db.ForeignKey('credit_card.id'))
    credit_card = db.relationship('CreditCard',
                                  backref='payment',
                                  foreign_keys=[credit_card_id])

    __mapper_args__ = {
        'polymorphic_identity': 'payment',
    }
예제 #8
0
class LineItem(Thing):
    __tablename__ = 'line_item'

    id = db.Column(db.Integer, db.ForeignKey('thing.id'), primary_key=True)

    transaction_request_id = db.Column(db.Integer,
                                       db.ForeignKey('transaction_request.id'))
    transaction_request = db.relationship(
        'TransactionRequest',
        foreign_keys=[transaction_request_id],
        backref='line_items')

    unit_price = db.Column(db.Numeric(12, 2))

    fee = db.Column(db.Numeric(12, 2))

    quantity = db.Column(db.Integer)

    __mapper_args__ = {
        'polymorphic_identity': 'line_item',
    }