def my_sended_messages(user_id): try: messages = Message.find_by_sender_id(user_id) user_nickname = User.find_by_id(session['_id']).nick_name return render_template('messages/my_sended_messages.html', messages=messages, user_nickname=user_nickname) except: error_msg = traceback.format_exc().split('\n') Error_obj = Error_( error_msg=''.join(error_msg), error_location='my_sended_messages-during message finding') Error_obj.save_to_mongo() return render_template( 'base_htmls/error_page.html', error_msgr='Crashed during reading your messages')
def delete_user_messages(self): messages = Message.find_by_sender_id(self._id) for message in messages: message.delete_on_elastic() message.delete()