Exemple #1
0
 def post(self, post_id):
     args = parser.parse_args()
     try:
         modified = Post.add_topic(post_id, args)
         return dict(success=modified > 0)
     except Exception as e:
         return dict(success=False, message=str(e))
Exemple #2
0
 def post(self):
     args = parser.parse_args()
     try:
         modified, last_id = Post.create(args)
         result = dict(success=modified > 0)
         if modified:
             result['post'] = Post.find(last_id[0]['last_id'])
             last_id = last_id[0]['last_id']
             topics = args['topics']
             topic_obj = []
             print(topics)
             for topic in topics.split(','):
                 topic = topic.strip()
                 r = Topic.get_create_new(topic)
                 if r is None:
                     raise Exception("Unable to create topic")
                 topic_obj.append(r)
                 Post.add_topic(last_id, {'topic_id': r['topic_id']})
             result['topics'] = topic_obj
         return result
     except Exception as e:
         return dict(success=False, message=str(e))