-
Notifications
You must be signed in to change notification settings - Fork 0
/
models.py
38 lines (27 loc) · 1.44 KB
/
models.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
__author__ = 'Binnie'
from google.appengine.ext import ndb
# I think these models are pretty much right now.
#
# The tree structure goes like this;
# Album <- Image
# This allows for a lot of flexibility and fast querying
class Album(ndb.Model):
def ukey(self): # To get urlsafe key easily in templates
return self.key.urlsafe()
name = ndb.StringProperty() # Album name
description = ndb.TextProperty() # Any text to accompany the album
start_date = ndb.DateTimeProperty() # When the photos were taken. This will be used to sort the albums.
end_date = ndb.DateTimeProperty() # If the photos were taken over a longer period of time, this might be useful.
thumbnail_serving_url = ndb.StringProperty() # Easy access to thumbnail
class Image(ndb.Model):
image_blob = ndb.BlobKeyProperty() # or maybe ndb.BlobReferenceProperty, or blobstore.BlobReferenceProperty?
caption = ndb.TextProperty()
serving_url = ndb.StringProperty()
index = ndb.IntegerProperty()
def ukey(self): # To get urlsafe key easily in templates
return self.key.urlsafe()
class Thumbnail(ndb.Model):
image_blob = ndb.BlobKeyProperty() # or maybe ndb.BlobReferenceProperty, or blobstore.BlobReferenceProperty?
serving_url = ndb.StringProperty()
def ukey(self): # To get urlsafe key easily in templates
return self.key.urlsafe()