Exemplo n.º 1
0
    def post(self, *args):
        category = self.get_argument('category')

        try:
          cid = Category.new(category)
        except Exception as e:
          print str(e)

        if cid:
          self.write(json.dumps({'success': 'true', 'cid': cid}))
        else:
          self.write(json.dumps({'success': 'false'}))
Exemplo n.º 2
0
    def post(self, *args):
        
        try:
            did = self.get_argument('did')
            title = self.get_argument('title')
            content = self.get_argument('content')
            c_name = self.get_argument('category_name')
            c_id = self.get_argument('c_id')
        except Exception as e:
            refer = self.request.headers.get('Referer')
            self.redirect(refer)
        
        try:
            tags = self.get_argument('tags')
        except:
            tags = None

        if tags:
            splited_tags = tags.split(',')
        else:
            splited_tags = None

        """" determin whether there is a exist undefine category
             if there is not, create it
             else use its c_id
        """
        if c_id == 'none':
            detail = Category.find_by_name(c_name)
            try:
                c_id = detail.get('_id')
            except:
                c_id = Category.new(c_name) 
        try:
            Diary.update(did, title, content, c_name, c_id, splited_tags)
        except Exception as e:
            print str(e)

        self.redirect('/admin/all-post/1')