-
Notifications
You must be signed in to change notification settings - Fork 2
/
models.py
96 lines (74 loc) · 2.97 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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
"""
#
# File: models.py
# Description: Model objects
#
# Copyright 2011-2013 Adam Meadows
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
"""
from google.appengine.ext import db
import model_fields as mf
FIELD_MAP = {
db.DateTimeProperty: mf.DateTime,
db.StringProperty: mf.String,
db.ReferenceProperty: mf.Reference,
db.BooleanProperty: mf.Boolean,
db.UserProperty: mf.User,
}
class Db(db.Model):
last_modified = db.DateTimeProperty(indexed=False, auto_now=True)
def put(self):
super(Db, self).put()
return self
class AccessReqDb(Db):
user = db.UserProperty(auto_current_user_add=True)
denied = db.BooleanProperty(default=False)
class ListOwnerDb(Db):
name = db.StringProperty(indexed=False)
nickname = db.StringProperty(indexed=False)
email = db.StringProperty(indexed=False)
user = db.UserProperty(auto_current_user_add=True)
def label(self):
return '{} ({})'.format(self.name, self.email)
class ListPermissionDb(Db):
owner = db.ReferenceProperty(ListOwnerDb, collection_name='permissions')
email = db.StringProperty()
class GroupDb(Db):
name = db.StringProperty()
description = db.StringProperty(indexed=False, multiline=True)
owner = db.ReferenceProperty(ListOwnerDb, collection_name='groups')
class GroupInvitationDb(Db):
group = db.ReferenceProperty(GroupDb, collection_name='invitations')
email = db.StringProperty()
class GroupMemberDb(Db):
member = db.ReferenceProperty(ListOwnerDb, collection_name='memberships')
group = db.ReferenceProperty(GroupDb, collection_name='members')
class ListDb(Db):
name = db.StringProperty()
description = db.StringProperty(indexed=False)
owner = db.ReferenceProperty(ListOwnerDb, collection_name='lists')
class ListItemDb(Db):
parent_list = db.ReferenceProperty(ListDb, collection_name='items')
name = db.StringProperty(indexed=False)
category = db.StringProperty(indexed=False)
description = db.StringProperty(indexed=False, multiline=True)
url = db.StringProperty(indexed=False)
reserved_by = db.ReferenceProperty(ListOwnerDb,
collection_name='reservations',
default=None)
purchased_by = db.ReferenceProperty(ListOwnerDb,
collection_name='purchases',
default=None)
is_surprise = db.BooleanProperty(indexed=False, default=False)