def get(self, user_id): user_id = int(user_id) if debugconstants.eggPrivileges: # check privileges # only user can see/change it's blacklist if int(self.current_user) != user_id: self.write(egg_errors.PrivilegeException().get_json()) return self.write(json.dumps(self.b2dic.get(user_id, []), ensure_ascii=False))
def post(self, user_id, friend_id): if debugconstants.eggPrivileges: # check privileges # only user can see change it's friends if int(self.current_user) != user_id: self.write(egg_errors.PrivilegeException().get_json()) return try: self.friends.approve_friend(user_id, friend_id) except egg_errors.BaseException as e: self.write(e.get_json())
def get(self, user_id, status_id): user_id = int(user_id) status_id = int(status_id) if debugconstants.eggPrivileges: # check privileges # only user can delete it's status if int(self.current_user) != user_id: self.write(egg_errors.PrivilegeException().get_json()) return try: self.dbp.delete_status(user_id, status_id) except egg_errors.BaseException as e: self.write(e.get_json())
def delete(self, user_id, friend_id): user_id = int(user_id) friend_id = int(friend_id) if debugconstants.eggPrivileges: # check privileges # only user can change it's badges if int(self.current_user) != user_id: self.write(egg_errors.PrivilegeException().get_json()) return try: self.bu.delete_user_badge(user_id, friend_id) except egg_errors.BaseException as e: self.write(e.get_json())
def get(self, user_id): user_id = int(user_id) if debugconstants.eggPrivileges: # check privileges # only user can see/change it's baskets if int(self.current_user) != user_id: self.write(egg_errors.PrivilegeException().get_json()) return try: baskets = self.dbp.get_baskets(user_id) self.write(json.dumps(baskets)) except egg_errors.BaseException as e: self.write(e.get_json())
def delete(self, user_id, blacklisted_id): user_id = int(user_id) if debugconstants.eggPrivileges: # check privileges # only user can see/change it's blacklist if int(self.current_user) != user_id: self.write(egg_errors.PrivilegeException().get_json()) return blacklisted_id = int(blacklisted_id) try: self.b2db.delete_from_blacklist(user_id, blacklisted_id) except egg_errors.BaseException as e: self.write(e.get_json()) return self.b2dic[user_id].remove(blacklisted_id)
def post(self, user_id, blacklisted_id): user_id = int(user_id) if debugconstants.eggPrivileges: # check privileges # only user can see/change it's blacklist if int(self.current_user) != user_id: self.write(egg_errors.PrivilegeException().get_json()) return blacklisted_id = int(blacklisted_id) try: self.b2db.add_to_blacklist(user_id, blacklisted_id) except egg_errors.BaseException as e: self.write(e.get_json()) return self.b2dic.setdefault(user_id, []).append(blacklisted_id)
def get(self, user_id, start_id, size): user_id = int(user_id) start_id = int(start_id) size = int(size) if debugconstants.eggPrivileges: # check privileges # only user can see it's recommended if int(self.current_user) != user_id: self.write(egg_errors.PrivilegeException().get_json()) return try: recommended = self.dbp.get_recommended(user_id, start_id, size) self.write(json.dumps(recommended, ensure_ascii=False)) except egg_errors.BaseException as e: self.write(e.get_json())
def delete(self, user_id, basket_id, add_user_id): user_id = int(user_id) basket_id = int(basket_id) del_user_id = int(add_user_id) if debugconstants.eggPrivileges: # check privileges # only user can see/change it's baskets if int(self.current_user) != user_id: self.write(egg_errors.PrivilegeException().get_json()) return try: basket = self.dbp.delete_user_from_basket(user_id, basket_id, del_user_id) except egg_errors.BaseException as e: self.write(e.get_json())
def post(self, user_id): user_id = int(user_id) if debugconstants.eggPrivileges: # check privileges # only user can add a status if int(self.current_user) != user_id: self.write(egg_errors.PrivilegeException().get_json()) return status = self.get_argument("status") if not status: self.write("sranje") try: self.dbp.add_status(user_id, unicode(status)) except egg_errors.BaseException as e: self.write(e.get_json())
def post(self, user_id): user_id = int(user_id) if debugconstants.eggPrivileges: # check privileges # only user can see/change it's baskets if int(self.current_user) != user_id: self.write(egg_errors.PrivilegeException().get_json()) return basket_name = self.get_argument("basket_name") if not basket_name: self.write("sranje") try: self.dbp.add_basket(user_id, basket_name) except egg_errors.BaseException as e: self.write(e.get_json())
def post(self, user_id): user_id = int(user_id) if debugconstants.eggPrivileges: # check privileges # only user can see/change it's baskets if int(self.current_user) != user_id: self.write(egg_errors.PrivilegeException().get_json()) return try: new_order = tornado.escape.json_decode(self.request.body) try: baskets = self.dbp.change_order_of_baskets(user_id, new_order) except egg_errors.BaseException as e: self.write(e.get_json()) except ValueError: e = egg_errors.InvalidJSONException() self.write(e.get_json())
def post(self, user_id, friend_id): user_id = int(user_id) friend_id = int(friend_id) if debugconstants.eggPrivileges: # check privileges # only user can change it's badges if int(self.current_user) != user_id: self.write(egg_errors.PrivilegeException().get_json()) return try: body = tornado.escape.json_decode(self.request.body) # mora dobiti i nekakav description i visibility try: self.bu.addchange_user_badge(user_id, friend_id, body[0], body[1]) except egg_errors.BaseException as e: self.write(e.get_json()) except ValueError: e = egg_errors.InvalidJSONException() self.write(e.get_json())