def postquestions(): '''report questions from bulletin board''' try: questions = bulletin.report_questions() return jsonify({'status': questions['bodies']}) except Error as e: return jsonify({'error': e.message})
def postanswer(): '''post answer to bulletin board''' try: now = utils.bb_dt() payload = json.loads(request.data) payload['modified'] = now payload['posted'] = now payload['studentid'] = user.email payload['name'] = user.full_name payload['rating'] = 0 question = bulletin.report_questions(id=payload['questionid']) answers = question['bodies'][0]['answers'] bulletin.post_answer(**payload) bulletin.edit_question(**{'answers': answers+1, 'id': payload['questionid']}) return jsonify({'status': 'answer posted'}) except Exception as e: return jsonify({'error': e.message})