Esempio n. 1
0
File: api.py Progetto: niczy/Memegen
 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)
Esempio n. 2
0
File: api.py Progetto: niczy/Memegen
 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)
Esempio n. 3
0
File: api.py Progetto: niczy/Memegen
 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")
Esempio n. 4
0
    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');
Esempio n. 5
0
File: api.py Progetto: niczy/Memegen
 def get(self):
     response_json(self, obj_list(favorites.get_favorites(self.uid)))
Esempio n. 6
0
File: api.py Progetto: niczy/Memegen
 def get(self):
     response_json(self, obj_list(messages.get_user_messages(self.uid)))
Esempio n. 7
0
File: api.py Progetto: niczy/Memegen
 def get(self, mid):
     if not mid: return
     response_json(self, likes.like_record(self.uid, int(mid)))
Esempio n. 8
0
File: api.py Progetto: niczy/Memegen
 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))
Esempio n. 9
0
File: api.py Progetto: niczy/Memegen
 def get(self, type):
     if not type: type = 'popular'
     if type == 'popular':
         templates = obj_list(meme.get_popular_templates())
         response_json(self, templates)
     return