예제 #1
0
class Request(db.Model):
    origin = db.GeoPtProperty(required=True)
    destination = db.GeoPtProperty(required=True)
    start_time = db.DateTimeProperty(required=True)
    end_time = db.DateTimeProperty(required=True)
    price = db.FloatProperty(required=True)
    user_id = db.StringProperty(required=True)
    created = db.DateTimeProperty(auto_now_add=True)

    # def render(self):
    # 	self._render_text = self.content.replace('\n', '<br>')
    # 	return render_str("post.html", p = self)

    def as_dict(self):
        time_fmt = '%c'
        d = {
            'origin': self.origin,
            'destination': self.destination,
            'start_time': self.start_time.strftime(time_fmt),
            'end_time': self.end_time.strftime(time_fmt),
            'price': self.price,
            'user_id': self.user_id,
            'created': self.created.strftime(time_fmt)
        }
        return d
예제 #2
0
class Album(db.Model):
    title = db.StringProperty()
    post_code = db.StringProperty()
    address = db.StringProperty()
    station = db.StringProperty()
    bus_stop = db.StringProperty()
    start = db.StringProperty()
    start_post_code = db.StringProperty()
    start_address = db.StringProperty()
    pictureid = db.IntegerProperty()
    time = db.StringProperty()
    tag = db.StringListProperty()
    tag_str = db.StringProperty()
    search_index = db.StringListProperty()
    timezone = db.IntegerProperty()
    season = db.IntegerProperty()
    recital = db.TextProperty()
    point = db.GeoPtProperty()
    point2 = db.GeoPtProperty()
    latitude = db.StringProperty()
    longitude = db.StringProperty()
    user = db.ReferenceProperty(reference_class=User)
    openflg = db.IntegerProperty()
    picture_max = db.IntegerProperty()
    picture_counter = db.IntegerProperty()
    watch_counter = db.IntegerProperty()
    registerDate = db.DateTimeProperty(auto_now_add=True)
    updateDate = db.DateTimeProperty(auto_now=True)
예제 #3
0
class Game(db.Model):
	""" game data model """
	name = db.StringProperty(multiline=False)
	# 0 = not yet started
	# 1 = running
	# 2 = stopped
	# 3 = finished
	status = db.IntegerProperty()

	version = db.IntegerProperty() # used when there are multiple versions

	# 0 = race to the point
	# 1 = chain-catch, who catches first wins
	mode = db.IntegerProperty() # used when there are multiple gamemodes

	creator = db.ReferenceProperty(Player)
	creatorLocation = db.GeoPtProperty()
	date = db.DateTimeProperty(auto_now_add=True)

	timer = db.IntegerProperty()

	players = db.ListProperty(db.Key) #TODO: any way to create a list with keys only from players?
	#how to handle: http://groups.google.com/group/google-appengine/msg/f3139e97ee01ce65
	#http://www.gomuse.com/google-app-engine-using-the-list-property-dbl

	playerCount = db.IntegerProperty()
	maxPlayerCount = db.IntegerProperty()

	goal = db.GeoPtProperty()
	winner = db.ReferenceProperty(Player, collection_name="winner_set")

	started = db.DateTimeProperty() #when the creator started it
	starting = db.DateTimeProperty() #when it will really start eg the timer reach zero
예제 #4
0
class Tag(db.Model):
	account = db.ReferenceProperty(Account) #ref
	name = db.StringProperty(required=True)
	status = db.StringProperty(required=True,default='new') #three states (new,enabled,ended)

	destinationCoordinate = db.GeoPtProperty(required=True)
	currentCoordinate = db.GeoPtProperty(required=True)

	pickedUp = db.BooleanProperty(required=True)
	distanceTraveled = db.IntegerProperty(required=True,default=0) #cache
	markCount = db.IntegerProperty(required=True,default=0) #cache
	
	destinationLegDistance = db.IntegerProperty(required=True,default=0) #rename to distanceTraveled
	hasReachedDestination = db.BooleanProperty(required=True,default=False)
	dateArrivedAtDestination = db.DateTimeProperty(required=True,default=datetime.datetime.utcnow())

	dateCreated = db.DateTimeProperty(required=True, default=datetime.datetime.utcnow())
	lastUpdated = db.DateTimeProperty(required=True, default=datetime.datetime.utcnow())
	
	destinationAccuracy = db.IntegerProperty(required=True,default=int(jt.gamesettings.defaultDestinationAccuracy)) #meters
	
	deleted = db.BooleanProperty(required=True,default=False)
	problemCode = db.IntegerProperty(required=True,default=0) #0=none,1=Network,2=NotReachable,3=GpsProblem
	
	withinPickupRange = False #this is a helper property, only used during map loading, doesn't belong here, will move when I think it will work, it is set to value somewhere else because it depends upon currentLocation
	youOwn = False #helper property used during view on map, someday I need to figure where to put these
	def toJSON(self):
	    return '{"key":"%s", "account":"%s", "name":"%s", "status":"%s", "currentCoordinate":{"lat":"%s","lon":"%s"}, "pickedUp":"%s", "distanceTraveled":"%d", "markCount":"%d", "account_username":"******","payout":"%s", "level":"%s", "withinPickupRange":"%s", "currentDestinationCoordinate":{"lat":"%s","lon":"%s"}, "hasReachedDestination":"%s", "youOwn":"%s", "dateCreated":"%s", "lastUpdated":"%s", "destinationCoordinate":{"lat":"%s","lon":"%s"}, "destinationAccuracy":"%s", "problemCode":"%s" }' % (self.key(), self.account.key(), self.name, self.status, self.currentCoordinate.lat, self.currentCoordinate.lon, self.pickedUp, self.distanceTraveled, self.markCount, self.account.username,self.payout(), self.level(), self.withinPickupRange, self.destinationCoordinate.lat, self.destinationCoordinate.lon, self.hasReachedDestination, self.youOwn, formatDateAsUtc(self.dateCreated), formatDateAsUtc(self.lastUpdated), self.destinationCoordinate.lat, self.destinationCoordinate.lon, self.destinationAccuracy,self.problemCode)

	def payout(self):
	    return jtPayout.calculatePayout(self.account.computeTotalScore())
	
	def level(self):
	    return jtPayout.calculateLevel(self.account.computeTotalScore())
예제 #5
0
class TrackPoint(db.Model):
    trackid = db.ReferenceProperty(Track)
    time = db.DateTimeProperty()
    point = db.GeoPtProperty()
    elevation = db.FloatProperty()
    speed = db.FloatProperty()
    pdop = db.FloatProperty()
예제 #6
0
파일: rpc.py 프로젝트: paulpv/evchargesites
class Site(db.Model):
  
  # RPC private/protected properties: read-only for ALL
  _deleted = db.BooleanProperty(default=False)
  _dateCreated = db.DateTimeProperty(auto_now_add=True)
  _dateModified = db.DateTimeProperty(auto_now=True)
  _dateAccessed = db.DateTimeProperty()
  _userLastAccessed = db.UserProperty()
  _rating = db.RatingProperty()
  
  # RPC public properties: writable by creator/admin
  userCreator = db.UserProperty(required=True) # creator or admin may change creator
  name = db.StringProperty(required=True)
  latlng = db.GeoPtProperty(required=True)
  address = db.PostalAddressProperty()
  description = db.TextProperty()
  pay = db.BooleanProperty() # pay access only?
  restricted = db.BooleanProperty() # authorized access only?
  
  # List of Service entries in the DB 
  services = db.ListProperty(db.Key) # List of keys to Service entities

  #db.BlobProperty() # images, etc
  #db.ListProperty() # images, history, ...
  # ReferenceProperty?
  # Related sites?
  
  contactName = db.StringProperty()
  contactAddress = db.PostalAddressProperty()
  contactPhone = db.PhoneNumberProperty()
  contactEmail = db.EmailProperty()
  contactURL = db.LinkProperty()
  contactIM = db.IMProperty()

  evcmid = db.StringProperty() # ID, if imported from EVChargerMaps.com
예제 #7
0
파일: main.py 프로젝트: 3380group/project
class User(db.Model):
    status = db.IntegerProperty()
    status_text = db.StringProperty()
    friends = db.ListProperty(int)
    current_location = db.GeoPtProperty(required=True)
    name = db.StringProperty()
    lastUpdated = db.DateTimeProperty(auto_now=True)
예제 #8
0
파일: data.py 프로젝트: gir242/tallyhome
class PlaceMap(db.Model):
    Name = db.StringProperty()
    Class = db.StringProperty()
    Location = db.GeoPtProperty()
    RegionSeriesName = db.StringProperty()
    RegionNameSource = db.StringProperty()
    ParentPlaceName = db.StringProperty()
예제 #9
0
파일: models.py 프로젝트: oby1/oponger
class Player(db.Model):
    date = db.DateTimeProperty(auto_now_add=True)
    user = db.UserProperty(required=True)
    pseudonym = db.StringProperty()
    location = db.GeoPtProperty(default=DC['geoPt'])
    rank = db.FloatProperty(default=INITIAL_RANK)

    def __str__(self):
        return "[Psuedonym: %s, Nickname: %s]" % (self.pseudonym,
                                                  self.user.nickname())

    def games(self):
        """Returns this player's games, sorted by creation date."""
        games = self.game_set_1.order("created_date").fetch(MAX_RESULTS, 0)
        games.extend(
            self.game_set_2.order('created_date').fetch(MAX_RESULTS, 0))
        return sorted(games, key=lambda game: game.created_date, reverse=True)

    def active_games(self):
        return [game for game in self.games() if game.is_active()]

    def available_games(self):
        return [game for game in self.games() if game.is_available()]

    def completed_games(self):
        completed_games = [
            game for game in self.games() if game.is_completed()
        ]
        return sorted(completed_games,
                      key=lambda game: game.completed_date,
                      reverse=True)

    @staticmethod
    def all_by_rank():
        return Player.gql("ORDER BY rank DESC")
예제 #10
0
class Location(db.Model):

    location = db.GeoPtProperty(required=True)
    city = db.StringProperty()
    country = db.StringProperty()
    track_counter = db.IntegerProperty()
    last_time_updated = db.DateTimeProperty()
예제 #11
0
class Blog(db.Model):

    subject = db.StringProperty(required=True)
    content = db.TextProperty(required=True)
    created = db.DateTimeProperty(auto_now_add=True)
    user = db.StringProperty()
    coors = db.GeoPtProperty()
예제 #12
0
class Page(db.Model):
    path = db.StringProperty(required=True)
    content = db.TextProperty(required=True)
    created = db.DateTimeProperty(auto_now_add=True)
    coords = db.GeoPtProperty()
    #last_modified = db.DateTimeProperty(auto_now = True)

    @classmethod
    def by_path(cls, path, update=False):
        pages, age = age_get(path)
        if update or pages is None:
            q = Page.all().filter('path =',
                                  path).order('-created').fetch(limit=100)
            pages = list(q)
            age_set(path, pages)

        return pages, age

    @classmethod
    def by_id(cls, page_id):
        return cls.get_by_id(page_id)

    def as_dict(self):
        d = {
            'subject': self.path,
            'content': self.content,
            'created': (self.created - timedelta(hours=4)).strftime('%c')
        }
        return d
예제 #13
0
class Tweet(db.Model):
    author = db.ReferenceProperty(TwitterAccount, collection_name='tweets')
    text = db.StringProperty(required=True)
    in_reply_to = db.SelfReferenceProperty(collection_name='replies')
    mentions = db.ListProperty(db.Key)
    created_at = db.DateProperty()
    geo = db.GeoPtProperty()
예제 #14
0
파일: tests.py 프로젝트: sskrab001/dpxdt
class AllPropertiesModel(db.Model):
    """Property names are ugly, yes."""
    prop_string = db.StringProperty()
    prop_byte_string = db.ByteStringProperty()
    prop_boolean = db.BooleanProperty()
    prop_integer = db.IntegerProperty()
    prop_float = db.FloatProperty()
    prop_date_time = db.DateTimeProperty()
    prop_date = db.DateProperty()
    prop_time = db.TimeProperty()
    prop_list = db.ListProperty(int)
    prop_string_list = db.StringListProperty()
    prop_reference = db.ReferenceProperty()
    prop_self_refeference = db.SelfReferenceProperty()
    prop_user = db.UserProperty()
    prop_blob = db.BlobProperty()
    prop_text = db.TextProperty()
    prop_category = db.CategoryProperty()
    prop_link = db.LinkProperty()
    prop_email = db.EmailProperty()
    prop_geo_pt = db.GeoPtProperty()
    prop_im = db.IMProperty()
    prop_phone_number = db.PhoneNumberProperty()
    prop_postal_address = db.PostalAddressProperty()
    prop_rating = db.RatingProperty()
예제 #15
0
class ApplicationAuthor(db.Model):
    user = db.UserProperty()
    name = db.StringProperty()
    url = db.StringProperty(default='')
    googler = db.BooleanProperty(default=False)
    location = db.StringProperty(default='')
    latlng = db.GeoPtProperty()
예제 #16
0
파일: main.py 프로젝트: pfn/talkmap
class Message(db.Model):
    user = db.StringProperty()
    message = db.StringProperty()
    nick = db.StringProperty()
    ip = db.StringProperty()
    ts = db.DateTimeProperty(auto_now_add=True)
    geo = db.GeoPtProperty()
예제 #17
0
파일: Server.py 프로젝트: ncvc/Live.fm
class Event(db.Model):
	eventID = db.IntegerProperty()
	eventTitle = db.StringProperty()
	eventDescription = db.TextProperty()
	eventImageURLs = db.ListProperty(db.Link)
	eventAttendance = db.IntegerProperty()
	eventReviews = db.IntegerProperty()
	eventTag = db.StringProperty()
	eventURL = db.LinkProperty()
	eventWebsite = db.LinkProperty()
	eventTickets = db.TextProperty()
	eventCancelled = db.BooleanProperty()
	
	venueID = db.IntegerProperty()
	venueName = db.StringProperty()
	venueURL = db.LinkProperty()
	venueWebsite = db.LinkProperty()
	venuePhoneNumber = db.PhoneNumberProperty()
	venueImageURLs = db.ListProperty(db.Link)
	venueAddress = db.PostalAddressProperty()
	venueTimeZone = db.StringProperty()
	
	artists = db.StringListProperty()
	headliner = db.StringProperty()
	
	tags = db.StringListProperty()
	
	geoPt = db.GeoPtProperty()
	date = db.DateTimeProperty()
	
	dateAdded = db.DateTimeProperty(auto_now_add=True)
예제 #18
0
파일: User.py 프로젝트: Jaden-/App-Factory
class User(db.Model):
    name = db.StringProperty(required=True)
    pw_hash = db.StringProperty(required=True)
    created = db.DateTimeProperty(auto_now_add=True)
    email = db.StringProperty()
    coords = db.GeoPtProperty()

    @classmethod
    def by_id(cls, uid):
        return User.get_by_id(uid, parent=users_key())

    @classmethod
    def by_name(cls, name):
        u = User.all().filter('name =', name).get()
        return u

    @classmethod
    def register(cls, name, pw, email=None, coords=None):
        pw_hash = make_pw_hash(name, pw)
        return User(parent=users_key(),
                    name=name,
                    pw_hash=pw_hash,
                    email=email,
                    coords=coords)

    @classmethod
    def login(cls, name, pw):
        u = cls.by_name(name)
        if u and valid_pw(name, pw, u.pw_hash):
            return u
예제 #19
0
class Profile(BaseStatusModel):
    """profile for a fighter"""
    nickname = db.StringProperty(required=True)
    user = db.UserProperty()  #Represents a user with a Google account
    mood = db.StringProperty()
    city = db.StringProperty()
    photo = db.ReferenceProperty(ImageStore)
    points = db.IntegerProperty(default=20)
    location = db.GeoPtProperty()  #class GeoPt(lat, lon)

    def __str__(self):
        return self.nickname

    def get_skipfields(self):
        #skipped fields in json format
        return ['user', 'photo', 'status']

    def display_location(self):
        if self.location:
            return 'lat=%s, lon=%s' % (str(
                self.location.lat), str(self.location.lon))
        else:
            return ''

    class Admin:
        editlist_display = ('nickname', 'photo', 'mood', 'city', 'points',
                            'location', 'status', 'created', 'modified')
        add_display = ('nickname', 'mood', 'city', 'points', 'location')
        edit_display = ('nickname', 'mood', 'city', 'points', 'location',
                        'status')
        ordering = 'nickname'
예제 #20
0
파일: databases.py 프로젝트: phulei/chirico
class MyDebug(db.Model):
    author = db.UserProperty()
    blob_key = db.StringProperty()
    content = db.StringProperty(multiline=True)
    date = db.DateTimeProperty()
    lock_ts = db.DateTimeProperty(auto_now_add=True)
    pt = db.GeoPtProperty()
예제 #21
0
class User(db.Model, Encoder):
  """This class represents the user google datastore model."""

  name = db.StringProperty()
  email = db.StringProperty()
  picture = db.StringProperty()
  level = db.IntegerProperty(default=1)
  games = db.StringListProperty()
  location = db.GeoPtProperty()

  def __repr__(self):
    return "<User(email='" + str(self.email) + "')>"

  def encode(self):
    response = {
        'type': 'User',
        'name': self.name,
        'email': self.email,
        'picture': self.picture,
        'level': self.level,
        'games': [game for game in self.games]
    }

    if self.location is not None:
      location = {
          'latitude': self.location.lat,
          'longitude': self.location.lon
      }
      response['location'] = location

    return response

  def __eq__(self, other):
    return isinstance(other, User) and other.email == self.email
예제 #22
0
class Comment(db.Model):
    created = db.DateTimeProperty(auto_now_add=True)
    author = db.StringProperty()
    comment_content = db.StringProperty()
    email = db.EmailProperty()
    location = db.GeoPtProperty()
    topic_key = db.StringProperty()
예제 #23
0
class ZThoughts(db.Model):
    author = db.StringProperty()
    title = db.StringProperty()
    content = db.TextProperty()
    date = db.DateTimeProperty(auto_now_add=True)
    location = db.GeoPtProperty()
    email = db.EmailProperty()
예제 #24
0
class Apartment(BaseModel):
    url = db.LinkProperty(required=True)
    id = db.IntegerProperty(required=True)
    updated = db.DateTimeProperty()
    updated_hour = db.IntegerProperty()
    updated_day = db.IntegerProperty()
    region = db.StringProperty()

    location = db.GeoPtProperty()
    location_accuracy = db.StringProperty()
    geohash = db.StringProperty()
    addr = db.StringProperty()

    concierge = db.BooleanProperty()
    washerdryer = db.BooleanProperty()
    hotwater = db.BooleanProperty()
    heat = db.BooleanProperty()
    brokerfee = db.BooleanProperty()
    cats = db.BooleanProperty()

    price = db.FloatProperty()
    price_thousands = db.IntegerProperty()

    size = db.StringProperty()

    def put(self, *args, **kwargs):
        self.updated_hour = int(self.updated.strftime("%Y%m%d%H"))
        self.updated_day = int(self.updated.strftime("%Y%m%d"))
        if self.price:
            self.price_thousands = int(self.price) / 1000 * 1000
        return super(Apartment, self).put(*args, **kwargs)

    def __str__(self):
        return '<Apartment %s: %r>' % (self.id, self.url)

    __repr__ = __str__

    @classmethod
    def delete_some(cls, num=10, N=30):
        read_back = 3
        rpc = db.create_rpc(deadline=30, read_policy=db.EVENTUAL_CONSISTENCY)
        q = db.GqlQuery("SELECT __key__ FROM Apartment WHERE updated < :1",
                        datetime.datetime.now() -
                        datetime.timedelta(days=read_back),
                        rpc=rpc)
        results = q.fetch(N)
        quotient, mod = divmod(num, N)
        quotient += 1
        deleted = 0
        for i in range(quotient):
            results = q.fetch(N)
            c = len(results)
            if i == (quotient - 1):
                results = results[:mod]
            deleted += len(results)
            db.delete(results)
            if c < N:
                break
        return deleted
예제 #25
0
class Entry(db.Model):
    date = db.DateTimeProperty(auto_now_add=True)
    llmap = db.GeoPtProperty()
    img = db.TextProperty()

    def to_dict(self):
        return dict([(p, unicode(getattr(self, p)))
                     for p in self.properties()])
예제 #26
0
파일: kloombaDb.py 프로젝트: glukki/kloomba
class Flowerbed(db.Model):
    point = db.GeoPtProperty(indexed=False)
    tile = db.StringProperty(indexed=False)
    level = db.IntegerProperty(indexed=False, default=1)
    owner = db.StringProperty(indexed=False)
    owner_public_id = db.StringProperty(indexed=False)
    flowers = db.IntegerProperty(indexed=False, default=0)
    timestamp = db.DateTimeProperty(indexed=False, auto_now=True)
예제 #27
0
class Mark(db.Model):
    tag = db.ReferenceProperty(Tag,required=True) #ref
    coordinate = db.GeoPtProperty(required=True)
    dateCreated = db.DateTimeProperty(required=True)
    photo = db.ReferenceProperty(Photo, required=True)
    canVote = True #used later, this like like the properties in Tag, go look
    def toJSON(self):
        return '{ "key":"%s", "dateCreated":"%s", "photoKey":"%s", "coordinate":{"lat":"%s","lon":"%s"}, "photoFlaggedOffensive":"%s", "photoLiked":"%s", "canVote":"%s" }' % (self.key(), formatDateAsUtc(self.dateCreated), self.photo.key(),self.coordinate.lat, self.coordinate.lon, self.photo.flaggedOffensive, self.photo.liked, self.canVote)
예제 #28
0
class Location(db.Model):
    user = db.UserProperty()
    latLong = db.GeoPtProperty()
    dateTime = db.DateTimeProperty(auto_now_add=True)

    def to_dict(self):
        return dict([(p, unicode(getattr(self, p)))
                     for p in self.properties()])
예제 #29
0
class ZPicLife(db.Model):
    author = db.StringProperty()
    content = db.TextProperty()
    date = db.DateTimeProperty(auto_now_add=True)
    location = db.GeoPtProperty()
    email = db.EmailProperty()
    image_key = db.StringProperty()
    image_url = db.LinkProperty()
예제 #30
0
class Art(db.Model):
    title = db.StringProperty(required=True)
    #must be submitted, without it, will get exception. Always good to have reasonable constratints
    #to prevent you from adding bad data into your db.
    art = db.TextProperty(required=True)
    created = db.DateTimeProperty(
        auto_now_add=True)  #automatically adding the current time
    coords = db.GeoPtProperty()