def get(self, mid): if not mid: return category = self.request.get('category') #TODO reduce these codes if category: res = favorites.add_user_favorite(self.uid, mid, category) else: res = favorites.add_user_favorite(self.uid, mid) response_json(self, res)
def get(self, mid): if not mid: return mid = int(mid) max_fetch = self.request.get("max_fetch") offset = self.request.get("offset") if offset and max_fetch: comments = obj_list(comment.get_comment(mid, max_fetch, offset)) elif max_fetch: comments = obj_list(comment.get_comment(mid, max_fetch)) else: comments = obj_list(comment.get_comment(mid)) response_json(self, comments)
def get(self, type): if not type: self.error(404) return if type == 'popular': memes = obj_list(meme.get_popular_memes()) response_json(self, memes) if type == 'latest': memes = obj_list(meme.get_latest_memes()) response_json(self, memes) if type == 'byuser': uid = self.request.get("uid")
def post(self, check_field): value = self.request.get('value') result = '' if check_field == 'username': result = user.validate_username(value) if not result: result = 'good' elif check_field == 'email': result = user.validate_email(value) if not result: result = 'good' response_json(self, result, 'text/plain');
def get(self): response_json(self, obj_list(favorites.get_favorites(self.uid)))
def get(self): response_json(self, obj_list(messages.get_user_messages(self.uid)))
def get(self, mid): if not mid: return response_json(self, likes.like_record(self.uid, int(mid)))
def post(self, mid): if not mid: return mid = int(mid) content = self.request.get("content") response_json(self, comment.post_comment(self.uid, mid, content))
def get(self, type): if not type: type = 'popular' if type == 'popular': templates = obj_list(meme.get_popular_templates()) response_json(self, templates) return