forked from iliu88/usell
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmodel.py
More file actions
61 lines (50 loc) · 1.6 KB
/
model.py
File metadata and controls
61 lines (50 loc) · 1.6 KB
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File used to define the entity types within the data store.
# Data is stored hierarchically: all items belong to a user,
# all users belong to a network.
from google.appengine.ext import db
# An object representing a network (a college/university/other
# community group if we include non-colleges)
class Network(db.Model):
name = db.StringProperty()
# some form of token
# test if a given value is in the database
def exists(self):
ex = False
q = Network.all()
q.filter("name =", self.name)
q.run(limit=1)
for entity in q:
return entity
return None
# An object representing a user of our application
class User(db.Model):
firstName = db.StringProperty()
lastName = db.StringProperty()
# fb_id_token
# return full name
def fullName(self):
return self.firstName + " " + self.lastName
# test if a given value is in the database
def exists(self):
ex = False
q = User.all()
q.filter("firstName =", self.firstName)
q.filter("lastName =", self.lastName)
q.run(limit=1)
for entity in q:
return entity
return None
# An object representing an item within the marketplace
class Item(db.Model):
name = db.StringProperty()
description = db.StringProperty(multiline=True)
# photo?
# test if a given value is in the database
def exists(self):
ex = False
q = Item.all()
q.filter("name =", self.name)
q.run(limit=1)
for entity in q:
return entity
return None