class EventPerson(BasicModel): event_person_id = ndb.IntegerProperty(required=True) market_place_person_id = ndb.IntegerProperty() first_name = ndb.StringProperty() last_name = ndb.StringProperty() picture_url = ndb.StringProperty() emails = ndb.StringProperty(repeated=True)
class Video(BasicModel): resource_id = ndb.IntegerProperty(required=True) title = ndb.StringProperty() description = ndb.StringProperty() url_where_to_donwload = ndb.StringProperty() thumbnail_url = ndb.StringProperty() extension = ndb.StringProperty( choices=( 'mp4','mkv','avi','flv' ) )
class GeneralEvent(BasicModel): event_id = ndb.IntegerProperty(required=True) keyname = ndb.StringProperty(required=True) name = ndb.StringProperty() privacy = ndb.StringProperty( choices=( 'Private','Public','Secret' ) ) picture = ndb.StringProperty() start_datetime = ndb.DateTimeProperty() end_datetime = ndb.DateTimeProperty() languages = ndb.StringProperty( choices=( 'English','Spanish','Portugese' ) ) location = ndb.StringProperty() active = ndb.BooleanProperty() #agenda_items = ndb.LocalStructuredProperty( AgendaItem , repeated=True ) #participants = ndb.StructuredProperty( Participant , repeated=True ) #anchors = ndb.StructuredProperty( Anchor , repeated=True ) description = StringTranslationProperty() title = ChoiceTranslationProperty( choices= { 'choice1': { 'spanish': 'mango', 'english': 'mangon', }, 'choice2': { 'spanish': 'tomate', 'english': 'tomato', }, 'choice3': { 'spanish': 'pollo', 'english': 'chicken', } })
class IdTracker(Model): ticket_number = ndb.IntegerProperty(required=True, default=0) event_number = ndb.IntegerProperty(required=True, default=0) @staticmethod def generate_number(tracker_name, width=9): instance = ndb.Key(IdTracker, tracker_name).get() if not instance: instance = IdTracker(id=tracker_name) if tracker_name == 'ticket': instance.ticket_number += 1 elif tracker_name == 'event': instance.event_number += 1 instance.put() if tracker_name == 'ticket': return str(instance.ticket_number).zfill(width) return str(instance.event_number).zfill(width)
class HouseAndLot(Property): floors = ndb.IntegerProperty(required=True, default=1) bedrooms = ndb.IntegerProperty(required=True) floor_area = ndb.FloatProperty() land_area = ndb.FloatProperty()
class Ticket(BasicModel): event = ndb.KeyProperty(kind='Event', indexed=True) scalper_name = ndb.KeyProperty(kind='Account', indexed=True) ticket_img = ndb.BlobKeyProperty() ticket_url = ndb.StringProperty(indexed=True) section = ndb.StringProperty(indexed=True) quantity = ndb.IntegerProperty(indexed=True) price = ndb.FloatProperty(indexed=True) sold = ndb.BooleanProperty(default=False, indexed=True) @classmethod def list_all(cls): return cls.query(cls.sold == False).order(cls.price) @classmethod def list_per_user(cls, key): csas = cls.query(cls.scalper_name == key).order(cls.price) tickets = [cls.buildTicket(ticket) for ticket in csas] return CompletedTickets(tickets=tickets) @classmethod def create(cls, params): params['event'] = ndb.Key(urlsafe=params['event']) # params['ticket_number'] = IdTracker.generate_number('ticket') item = cls() item.populate(**params) item.put() return item @classmethod def remove(cls): ndb.delete_multi( Ticket.query().fetch(keys_only=True) ) @classmethod def find_tickets(cls, key): csas = cls.find_all_by_event(key).filter(cls.sold == False).order(cls.price) tickets = [cls.buildTicket(ticket) for ticket in csas] return CompletedTickets(tickets=tickets) @classmethod def to_message(cls, entity): tickets = [cls.buildTicket(entity)] return CompletedTickets(tickets=tickets) @classmethod def buildTicket(cls, ticket): return TicketMessage( key=ticket.key.urlsafe(), section=ticket.section, quantity=ticket.quantity, price=ticket.price, scalper_name=cls.buildScalpers(ticket.scalper_name.get()), sold=ticket.sold, event=Event.buildEvent(ticket.event.get()) ) @classmethod def buildScalpers(cls, name): return ScalperMessage( key=name.key.urlsafe(), first_name=name.first_name, last_name=name.last_name, email=name.email )
class CondoUnit(Property): capacity = ndb.IntegerProperty(required=False) bedrooms = ndb.IntegerProperty(required=False) floor_area = ndb.FloatProperty(required=False)
class Hotel(Property): floors = ndb.IntegerProperty(required=True, default=1) floor_area = ndb.FloatProperty() land_area = ndb.FloatProperty() rooms = ndb.IntegerProperty()