-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmodels.py
45 lines (41 loc) · 1.38 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
from pynamodb.models import Model
from pynamodb.attributes import UnicodeAttribute, JSONAttribute, NumberAttribute
from util import create_spotify_auth_url
class User(Model):
"""
User
"""
def as_json(self):
lastfm = self.lastfm
if lastfm is None:
lastfm = {}
spotify = self.spotify
if spotify is None:
spotify = {'login_url':create_spotify_auth_url()}
print 'self.lastfm is bad'
return dict(
athlete_id=self.athlete_id,
strava=self.strava,
lastfm=lastfm,
spotify=spotify,
)
class Meta:
table_name = "user2" #should be an environmental variable + this field
athlete_id = NumberAttribute(hash_key=True)
strava = JSONAttribute(default=None)
spotify = JSONAttribute(null=True,default=None)
lastfm = JSONAttribute(null=True,default=None)
tokens = JSONAttribute(null=True,default=None)
# class Activity(Model):
# """
# Strava Activities
# """
#
# class Meta:
# table_name = "activity"
# activity_id = NumberAttribute(hash_key=True)
# athlete_id = NumberAttribute(range_key=True)
# activity = JSONAttribute()
# activity_start_date_local = UnicodeAttribute()
# last_fm_last_sync = UnicodeAttribute(null=True,default=None)
# spotify_last_sync = UnicodeAttribute(null=True,default=None)