Esempio n. 1
0
 def put(self):
     """
     updates current artist location
     :return:
     """
     auth_token = self.request.headers.get('auth-token')
     data = escape.json_decode(self.request.body)
     dao = user.UserDAO()
     #2012-09-17T21:30:54-0400
     date_start = time.mktime(
         datetime.strptime(data['next-show-start'],
                           '%Y-%m-%dT%H:%M:%S%z').timetuple())
     date_end = time.mktime(
         datetime.strptime(data['next-show-end'],
                           '%Y-%m-%dT%H:%M:%S%z').timetuple())
     print(date_end)
     response = dao.user_exists(auth_token=auth_token)
     if response['exists']:
         dao.update_location(latitude=data['latitude'],
                             longitude=data['longitude'],
                             show_start=date_start,
                             show_end=date_end,
                             artist_id=response['id'])
     else:
         self.write("""
         {
         "message": "Invalid auth token"
         }
         """)
Esempio n. 2
0
 def post(self):
     data = escape.json_decode(self.request.body)
     dao = user.UserDAO()
     self.write(
         dao.in_radius(radius=data['radius'],
                       longitude=data['longitude'],
                       latitude=data['latitude']))
Esempio n. 3
0
 def post(self):
     """
     Returns all artist to which the user is connected.
     :return:
     """
     data = escape.json_decode(self.request.body)
     print(data)
     dao = user.UserDAO()
     self.write(dao.connected_to(user_id=data['user-id'], is_artist=False))
Esempio n. 4
0
 def put(self):
     data = escape.json_decode(self.request.body)
     dao = user.UserDAO()
     cookie = str(uuid.uuid4())
     if not data or not dao.login(email_address=data['email'],
                                  password=data['password']):
         self.write("{ \"message\": \"Email and password don't match.\"} ")
     else:
         self.write("{ \"auth-token\": \"" + cookie + "\"} ")
     dao.upsert(email_address=data['email'], cookie=cookie)
Esempio n. 5
0
 def put(self):
     if not self.request.body:
         #data = {"email": None, "password": None, "facebook-id": None, "twitter-id": None}
         data = {"unique-id": None}
     else:
         data = escape.json_decode(self.request.body)
     dao = user.UserDAO()
     generated_id = dao.upsert(unique_id=data['unique-id'])
     # generated_id = dao.upsert(email_address=data['email'], password=data['password'],
     #                           facebook_id=data['facebook-id'], twitter_id=data['twitter-id'])
     self.write("{ \"user_id\": \"" + str(generated_id) + "\" }")
Esempio n. 6
0
 def put(self):
     data = escape.json_decode(self.request.body)
     dao = user.UserDAO()
     dao.upsert(cookie=data['auth-token'], logout=True)
Esempio n. 7
0
 def put(self):
     data = escape.json_decode(self.request.body)
     dao = user.UserDAO()
     artist_id = str(self.request.uri).split("/")[2]
     dao.link(user_id=data['user-id'], artist_id=artist_id)
Esempio n. 8
0
 def get(self):
     dao = user.UserDAO()
     artist_id = str(self.request.uri).split("/")[2]
     self.write(dao.connected_to(user_id=artist_id, is_artist=True))
Esempio n. 9
0
 def get(self):
     dao = user.UserDAO()
     artist_id = str(self.request.uri).split("/")[2]
     self.write(dao.artist_info(artist_id=artist_id))