class MessageModelTest(ndb.Model): string = ndb.StringProperty() repeatedString = ndb.StringProperty(repeated=True) text = ndb.TextProperty() repeatedText = ndb.TextProperty(repeated=True) blob = ndb.BlobProperty() repeatedBlob = ndb.BlobProperty(repeated=True) keyProp = ndb.KeyProperty() repeatedKey = ndb.KeyProperty(repeated=True) boolean = ndb.BooleanProperty() repeatedBoolean = ndb.BooleanProperty(repeated=True) integer = ndb.IntegerProperty() repeatedInteger = ndb.IntegerProperty(repeated=True) float = ndb.FloatProperty() repeatedFloat = ndb.FloatProperty(repeated=True) datetime = ndb.DateTimeProperty() repeatedDatetime = ndb.DateTimeProperty(repeated=True) time = ndb.TimeProperty() date = ndb.DateProperty() geopt = ndb.GeoPtProperty() repeatedGeopt = ndb.GeoPtProperty(repeated=True) blobkey = ndb.BlobKeyProperty() repeatedBlobkey = ndb.BlobKeyProperty(repeated=True) structured = ndb.StructuredProperty(InnerModel) repeatedStructured = ndb.StructuredProperty(InnerModel, repeated=True)
class Commune(ndb.Model): #record the list of commune in France nom = ndb.StringProperty() CP = ndb.StringProperty() departement = ndb.StringProperty() pays = ndb.StringProperty() coordonnees = ndb.GeoPtProperty() NWcoordonnees = ndb.GeoPtProperty(indexed=False) SEcoordonnees = ndb.GeoPtProperty(indexed=False) nom_lower = ndb.ComputedProperty(lambda self: self.nom.lower()) nbr_aire_de_jeux = ndb.IntegerProperty(default=0) def urlsafe(self): #to get a urlsafe rendering of everything data = { "urlsafeKey": self.key.urlsafe(), "CP": self.CP, "departement": self.departement, "coordonnees": self.coordonnees, "NWcoordonnees": self.NWcoordonnees, "SEcoordonnees": self.SEcoordonnees, "NW": self.NWcoordonnees, "SE": self.SEcoordonnees, "nom": self.nom } return data
class Trip(ndb.Model): """A main model for representing a taxi trip.""" pickup_datetime = ndb.DateTimeProperty(indexed=True) pickup_location = ndb.GeoPtProperty(indexed=False) dropoff_datetime = ndb.DateTimeProperty(indexed=True) dropoff_location = ndb.GeoPtProperty(indexed=False) distance = ndb.FloatProperty(indexed=False)
class Departement(ndb.Model): #record the departement of France numero = ndb.StringProperty() nbr_aire_de_jeux = ndb.IntegerProperty(default=0) lettre = ndb.StringProperty() NWcoordonnees = ndb.GeoPtProperty() SEcoordonnees = ndb.GeoPtProperty()
class UserSession(ndb.Model): """Model that represents a single users's data for a single game.""" user_session_id = ndb.StringProperty() base_point = ndb.GeoPtProperty() drop_off_point = ndb.GeoPtProperty() user_current_gold = ndb.StringProperty() route_id = ndb.StringProperty()
class Order(ndb.Model): createTime = ndb.DateTimeProperty() orderID = ndb.StringProperty() ownerEmail = ndb.StringProperty() restaurant = ndb.StringProperty() restaurant_location = ndb.GeoPtProperty() food = ndb.StringProperty() destination = ndb.StringProperty() destination_location = ndb.GeoPtProperty() due_time = ndb.DateTimeProperty() note = ndb.StringProperty() deliverList = ndb.StringProperty(repeated=True) #deliverList_count = ndb.ComputedProperty(lambda e: len(e.deliverList)) #distance = ndb.FloatProperty() price = ndb.FloatProperty() #price chatChannel = ndb.StringProperty() # created, pending, confirmed and fulfilled status = ndb.StringProperty() # rate requester_rate = ndb.FloatProperty() deliveryperson_rate = ndb.FloatProperty()
class ClockIn(ndb.Model, Entity): time = ndb.DateTimeProperty(auto_now_add=True) org = ndb.KeyProperty() place = ndb.KeyProperty() formatted_address = ndb.StringProperty() address_lat_long = ndb.GeoPtProperty() user_lat_long = ndb.GeoPtProperty()
class Store(ndb.Model): place_id = ndb.StringProperty(indexed=False) name = ndb.StringProperty(indexed=False) vicinity = ndb.StringProperty(indexed=False) icon = ndb.StringProperty(indexed=False) distance = ndb.IntegerProperty(indexed=True) client_latlng = ndb.GeoPtProperty(indexed=True) latlng = ndb.GeoPtProperty(indexed=True)
class FilledForm(ndb.Model, Entity): data = ndb.JsonProperty() creator = ndb.KeyProperty() end = ndb.DateTimeProperty(auto_now_add=True) place = ndb.KeyProperty() start = ndb.DateTimeProperty() formatted_address = ndb.StringProperty() address_lat_long = ndb.GeoPtProperty() start_user_lat_long = ndb.GeoPtProperty() @classmethod def query_by_org(cls, org_key): return cls.query(ancestor=org_key).order(-cls.end)
class Station(ndb.Model): url = ndb.StringProperty() name = ndb.StringProperty() station_id = ndb.StringProperty() last_update = ndb.DateTimeProperty() last_commit = ndb.StringProperty() location = ndb.GeoPtProperty() frame_range = ndb.IntegerProperty() _this_update = datetime.min @classmethod def create_query_for_all(cls): parent = get_parent_key() return cls.query(ancestor=parent) @classmethod def create_or_update_from_url(cls, url, id_table, put_now=False): name = get_name_from_url(url) parent = get_parent_key() id = id_table.get(name) # Possible cases: # 1. No data # 2. Capital cities of provinces if id == None: return station = cls.get_or_insert(id, parent=parent) station.url = url station.name = name station.station_id = id if put_now: station.put() return station
class Shout(ndb.Model): author = ndb.KeyProperty(kind=models.User, indexed=True) userTags = ndb.StructuredProperty(UserTag, repeated=True) hashTags = ndb.StringProperty(repeated=True) Like = ndb.KeyProperty(repeated=True) # prop_count = ndb.ComputedProperty(lambda e: len(e.prop)) # add followers(id) to shout to notify them and allow them to un-follow the shout to not get notification content = ndb.StringProperty() isAnon = ndb.BooleanProperty() isPrivate = ndb.BooleanProperty() location = ndb.GeoPtProperty() commentCount = ndb.IntegerProperty(default=0) date = ndb.DateTimeProperty(auto_now_add=True, indexed=True) @classmethod def query_profile_area(shout, user_id, get_all , sw ,ne): profile_qry = shout.query(ndb.OR(shout.userTags.user_id == user_id, shout.author == ndb.Key(models.User, int(user_id)))) if get_all: return profile_qry else: return profile_qry.filter(Shout.location >= sw, Shout.location <= ne) @classmethod def query_area(shout,sw,ne): return shout.query(Shout.location >= sw, Shout.location <= ne).order()
class Location(ndb.Model): """ Represents a place where the Observador reported coordinates within the platform. - loc: Geographic coordinates of a location """ created = ndb.DateTimeProperty(auto_now_add=True) observador = ndb.KeyProperty(kind=Observador) loc = ndb.GeoPtProperty() @classmethod def create(cls, observador, loc): """ Creates a new location in the datastore. :param: - loc: Geographic coordinates of a location :return: Key of new entity """ try: o = Observador.get_from_datastore(email=observador) geo_pt = ndb.GeoPt(str(loc)) l = Location(loc=geo_pt, observador=o.key) key = l.put() except Exception: logging.exception("[location] - Error in create location", exc_info=True) raise LocationCreationError( 'Error creating the location in platform') else: return key
class Seller(EndpointsModel): '''Franchisor Data Store model ''' status = ndb.BooleanProperty(default=True) name = ndb.StringProperty(default='') person = ndb.StringProperty(default='') telephone = ndb.StringProperty(default='') mobile = ndb.StringProperty(default='') email = ndb.StringProperty(default='') geo_code = ndb.StringProperty(default='') geo = ndb.GeoPtProperty() address = ndb.TextProperty(default='') img_url = ndb.StringProperty(default='') bucket_key = ndb.StringProperty(default='') @classmethod def get_by_email(cls, email): return cls.query(cls.email==email).get() @classmethod def get_list(cls): return cls.query().fetch() @classmethod def get_key_obj_dict(cls): d = {} for e in cls.query(): d[e.key] = e return d
class Flight(ndb.Model): # key = ndb.KeyProperty() flight_num = ndb.StringProperty(indexed=False) altitude = ndb.FloatProperty(indexed=False) speed = ndb.FloatProperty(indexed=False) location = ndb.GeoPtProperty(indexed=False) temperature = ndb.FloatProperty(indexed=False)
class Venue(ndb.Model): """ Model Representing a Place Where an Event Takes Place """ # class? commercial gallery, university, non-profit, etc # open, closed, etc? slug = ndb.StringProperty() name = ndb.StringProperty() address = ndb.StringProperty() address2 = ndb.StringProperty() city = ndb.StringProperty() state = ndb.StringProperty() country = ndb.StringProperty() geo = ndb.GeoPtProperty(repeated=True) website = ndb.StringProperty() phone = ndb.StringProperty() email = ndb.StringProperty() category = ndb.StringProperty() hours = ndb.JsonProperty() content = ndb.TextProperty() summary = ndb.TextProperty() created_date = ndb.DateTimeProperty(auto_now_add=True) modified_date = ndb.DateTimeProperty(auto_now=True) primary_image_resource_id = ndb.StringProperty() attachment_resources = ndb.StringProperty(repeated=True)
class LocationAlert(ndb.Model): alert_status = ndb.BooleanProperty(default=True) alert_name = ndb.StringProperty(required=True, verbose_name="Name your alert") alert_owner = ndb.StringProperty() alert_tracked_people = ndb.StringProperty(repeated=True, verbose_name="People to Track") alert_location_center = ndb.GeoPtProperty() alert_location_radius = ndb.FloatProperty() alert_day_sun = ndb.BooleanProperty(default=False) alert_day_mon = ndb.BooleanProperty(default=False) alert_day_tue = ndb.BooleanProperty(default=False) alert_day_wed = ndb.BooleanProperty(default=False) alert_day_thu = ndb.BooleanProperty(default=False) alert_day_fri = ndb.BooleanProperty(default=False) alert_day_sat = ndb.BooleanProperty(default=False) alert_time_start = ndb.TimeProperty() alert_time_end = ndb.TimeProperty() # direction: False = outward, True = inward alert_direction = ndb.BooleanProperty(default=False) class RESTMeta: user_owner_property = 'alert_owner' # [END LocationAlert] @classmethod def get_by_owner_user(cls, user): return cls.query().filter(cls.alert_owner == user.user_id()).get() @classmethod def get_by_member_user(cls, user): return cls.query().filter(user.user_id() in cls.alert_tracked_people).get()
class Device(ndb.Model): #Stores information about the rain gauge device id = ndb.IntegerProperty(required=True) name = ndb.StringProperty() position = ndb.GeoPtProperty() dateRegistered = ndb.DateTimeProperty(required=True) lastSeen = ndb.DateTimeProperty()
class Permit(ndb.Model): owner = ndb.StructuredProperty(User) name = ndb.StringProperty() geo_location = ndb.GeoPtProperty() city = ndb.StringProperty() type = ndb.StringProperty(choices=['Park', 'School', 'Airport']) creation_date = ndb.DateTimeProperty(auto_now_add=True) start_date = ndb.DateTimeProperty() end_date = ndb.DateTimeProperty() cost = ndb.StringProperty() #form = ndb.StructuredProperty(PermitForm) @staticmethod def get_owner(owner): permit = Permit.query(Permit.owner == owner) if permit.count() > 0: for p in permit: return p else: return False @staticmethod def add_new_permit(owner, name, type): # geo_location permit = Permit(owner=owner, #geolocation=geo_location, name=name, type=type, ) p = permit.put() return p
class Post(BaseModel): userKey = ndb.KeyProperty() text = ndb.StringProperty() geoPt = ndb.GeoPtProperty() date = ndb.DateTimeProperty(auto_now_add=True) @property def __geo_interface__(self): return { 'type': 'Feature', 'properties': { 'date': str(self.date), 'postId': self.id, 'userId': self.userKey.id(), 'text': self.text }, 'geometry': { 'type': 'Point', 'coordinates': [ self.geoPt.__dict__.get("lon"), self.geoPt.__dict__.get("lat") ] } } pass pass
class Search(ndb.Model): chat_id = ndb.IntegerProperty() date = ndb.DateTimeProperty(auto_now=True) location = ndb.GeoPtProperty() search_type = ndb.StringProperty() search_radius = ndb.IntegerProperty() found_location = ndb.BooleanProperty()
class GeoCache(ndb.Model): address = ndb.StringProperty(required=True) geo = ndb.GeoPtProperty(required=True, indexed=False) @classmethod def get_by_address(cls, address): return cls.query(cls.address == address).get()
class GameEntity(ndb.Model): # def to_dict(self): # output = {} # for key, prop in self._properties.iteritems(): # value = coerce(getattr(self, key)) # if value is not None: # output[key] = value # return output # Date date = ndb.DateTimeProperty(auto_now_add=True) # Location location = ndb.GeoPtProperty() # Team #1 colour, score # Team #2 colour, score teams = ndb.StructuredProperty(TeamEntity, repeated=True) # Game start time start_time = ndb.TimeProperty() description = ndb.StringProperty() type = ndb.IntegerProperty() age_category = ndb.IntegerProperty(default=0) gender_category = ndb.IntegerProperty(default=0) # MAYBE # Unique Observers # Unique Contributors def to_dict(self): ret = ndb.Model.to_dict(self, exclude=['date', 'start_time', 'location']) ret['gid'] = str(self.key.id()) ret['start_time'] = self.start_time.strftime('%H:%M') return ret
class Complaint(ndb.Model): user_id = ndb.KeyProperty(kind='User', required=True) # currently just stores user_id given by frontend, no verification.. title = ndb.StringProperty(required=True) location = ndb.GeoPtProperty() subtitle = ndb.TextProperty() # desciptive title date = ndb.DateProperty(auto_now_add=True) votes = ndb.IntegerProperty(default=0) content = ndb.TextProperty() tags = ndb.StringProperty(repeated=True) # the tags eg, Civil, Roadworks, etc. They are strings, user is allowed to add their own smallAdd = ndb.StringProperty() bigAdd = ndb.StringProperty() fb_share = ndb.IntegerProperty(default=0) gp_share = ndb.IntegerProperty(default=0) tw_share = ndb.IntegerProperty(default=0) img_links = ndb.StringProperty(repeated=True) status_owner = ndb.StringProperty(default="No Action", choices=set( ["No Action", "Ongoing", "Solved"])) # whether the problem is solved or not. status_other = ndb.StringProperty(default="No Action", choices=set( ["No Action", "Ongoing", "Solved"])) # status as defined by some non-OP. abuse_reports = ndb.IntegerProperty(default=0)
class UserMeetup(ndb.Model): email = ndb.StringProperty(required=True) name = ndb.StringProperty(required=False) meetup = ndb.KeyProperty(Meetup, required=True) address = ndb.StringProperty(required=False) location = ndb.GeoPtProperty(required=False) moods = ndb.StringProperty(repeated=True) interests = ndb.StringProperty(repeated=True) statuses = ndb.StringProperty(repeated=True) vote = ndb.JsonProperty(required=False) # auto fields created = ndb.DateTimeProperty(auto_now_add=True) modified = ndb.DateTimeProperty(auto_now=True) def _pre_put_hook(self): if 'preferences' not in self.statuses: if self.address and self.moods and self.interests: self.statuses.append('preferences') if 'vote' not in self.statuses: if self.vote: self.statuses.append('vote') if self.address and not self.location: response = GeoCoding.get_location(address=self.address) location = response['results'][0]['geometry']['location'] lat = location['lat'] lng = location['lng'] self.location = ndb.GeoPt(lat=lat, lon=lng) # lat, lon
class Contribution(ndb.Model): chat_id = ndb.IntegerProperty() date = ndb.DateTimeProperty(auto_now=True) location = ndb.GeoPtProperty() node_id = ndb.StringProperty() search_type = ndb.StringProperty() picture_file_id = ndb.StringProperty()
class Game(ndb.Model): birthdate = ndb.DateTimeProperty(auto_now_add=True) lastHeartbeat = ndb.DateTimeProperty(auto_now=True) name = ndb.StringProperty() private = ndb.BooleanProperty() description = ndb.StringProperty() maxPlayers = ndb.IntegerProperty() playerIds = ndb.IntegerProperty(repeated=True) entityIds = ndb.IntegerProperty(repeated=True) gameControllerId = ndb.IntegerProperty() adminId = ndb.StringProperty() center = ndb.GeoPtProperty() def makeStringValuedIds(self): self.playerIdStrings = map(str, self.playerIds) self.entityIdStrings = map(str, self.entityIds) def to_dict(self): return {'name': self.name, 'id': self.key.id(), 'private': self.private, 'description': self.description, 'maxPlayers': self.maxPlayers, 'center': self.center, 'currentPlayers': len(self.playerIds)}
class EventUserStatus(BaseModel): _serialized_fields = ['modified', 'user', 'last_location', 'status'] # event = Parent entity and thus not included in the model user = ndb.KeyProperty(kind=UserData, required=True) last_location = ndb.GeoPtProperty() status = ndb.TextProperty() @classmethod def create_or_update(cls, event_key, user_key, status, location): current_user_status = cls.query(ancestor=event_key).filter( cls.user == user_key).get() if current_user_status is None: next_user_status = cls(parent=event_key, user=user_key, status=status, last_location=location) else: next_user_status = current_user_status if status is not None: next_user_status.status = status if location is not None: next_user_status.last_location = location next_user_status.put()
class TestEntity(base_model.BaseModel): test_string = ndb.StringProperty() test_datetime = ndb.DateTimeProperty(auto_now_add=True) test_keyproperty = ndb.KeyProperty() test_geopt = ndb.GeoPtProperty() test_structuredprop = ndb.StructuredProperty(TestSubEntity) test_repeatedprop = ndb.StringProperty(repeated=True)
class Address(ndb.Model): street = ndb.StringProperty(indexed=True, required=True) number = ndb.IntegerProperty(indexed=False) zipcode = ndb.StringProperty(indexed=False) # The district and region properties can be separate entities district = ndb.StringProperty(indexed=False) region = ndb.StringProperty(indexed=False) latlng = ndb.GeoPtProperty(indexed=False)
class clientLocations(ndb.Model): client = ndb.KeyProperty(kind=Clients) ClientName = ndb.StringProperty() #normalized emailDomains = ndb.StringProperty(repeated=True) #normalized streetAddress = ndb.StringProperty() city = ndb.StringProperty() state = ndb.StringProperty() latlong = ndb.GeoPtProperty()