def perform_request_display_msg(uid, msgid, ln=CFG_SITE_LANG): """ Displays a specific message @param uid: user id @param msgid: message id @return: a (body, errors[], warnings[]) formed tuple """ errors = [] warnings = [] body = "" if (db.check_user_owns_message(uid, msgid) == 0): # The user doesn't own this message errors.append(('ERR_WEBMESSAGE_NOTOWNER', )) else: (msg_id, msg_from_id, msg_from_nickname, msg_sent_to, msg_sent_to_group, msg_subject, msg_body, msg_sent_date, msg_received_date, msg_status) = db.get_message(uid, msgid) if (msg_id == ""): # The message exists in table user_msgMESSAGE # but not in table msgMESSAGE => table inconsistency errors.append(('ERR_WEBMESSAGE_NOMESSAGE', )) else: if (msg_status == CFG_WEBMESSAGE_STATUS_CODE['NEW']): db.set_message_status(uid, msgid, CFG_WEBMESSAGE_STATUS_CODE['READ']) body = webmessage_templates.tmpl_display_msg( msg_id, msg_from_id, msg_from_nickname, msg_sent_to, msg_sent_to_group, msg_subject, msg_body, msg_sent_date, msg_received_date, ln) return (body, errors, warnings)
def test_setting_message_status(self): """webmessage - status from "new" to "read" """ # juliet writes the message to romeo webmessage.perform_request_send(6, msg_to_user="******", msg_to_group="", msg_subject="Hi romeo", msg_body="hello romeo how are you?", ln=CFG_SITE_LANG) msgid = get_all_messages_for_user(5)[0][0] # status is changed set_message_status(5, msgid, 'R') msgstatus = get_all_messages_for_user(5)[0][5] self.assertEqual(msgstatus, 'R') webmessage.perform_request_delete_msg(5, msgid, ln=CFG_SITE_LANG)
def test_getting_nb_readable_messages(self): """webmessage - get the nb of readable messages""" delete_all_messages(5) # juliet writes the message to romeo webmessage.perform_request_send(6, msg_to_user="******", msg_to_group="", msg_subject="Hi romeo", msg_body="hello romeo how are you?", ln=CFG_SITE_LANG) msgid = get_all_messages_for_user(5)[0][0] # status is changed set_message_status(5, msgid, 'R') self.assertEqual(get_nb_readable_messages_for_user(5), 1) webmessage.perform_request_delete_msg(5, msgid, ln=CFG_SITE_LANG)
def perform_request_display_msg(uid, msgid, ln=CFG_SITE_LANG): """ Displays a specific message @param uid: user id @param msgid: message id @return: a (body, errors[], warnings[]) formed tuple """ errors = [] warnings = [] body = "" if (db.check_user_owns_message(uid, msgid) == 0): # The user doesn't own this message errors.append(('ERR_WEBMESSAGE_NOTOWNER',)) else: (msg_id, msg_from_id, msg_from_nickname, msg_sent_to, msg_sent_to_group, msg_subject, msg_body, msg_sent_date, msg_received_date, msg_status) = db.get_message(uid, msgid) if (msg_id == ""): # The message exists in table user_msgMESSAGE # but not in table msgMESSAGE => table inconsistency errors.append(('ERR_WEBMESSAGE_NOMESSAGE',)) else: if (msg_status == CFG_WEBMESSAGE_STATUS_CODE['NEW']): db.set_message_status(uid, msgid, CFG_WEBMESSAGE_STATUS_CODE['READ']) body = webmessage_templates.tmpl_display_msg( msg_id, msg_from_id, msg_from_nickname, msg_sent_to, msg_sent_to_group, msg_subject, msg_body, msg_sent_date, msg_received_date, ln) return (body, errors, warnings)
msg_subject, msg_body, msg_sent_date, msg_received_date, msg_status) = db.get_message(uid, msgid) if (msg_id == ""): # The message exists in table user_msgMESSAGE # but not in table msgMESSAGE => table inconsistency try: raise InvenioWebMessageError(_('This message does not exist.')) except InvenioWebMessageError, exc: register_exception() body = webmessage_templates.tmpl_error(exc.message, ln) return body else: if (msg_status == CFG_WEBMESSAGE_STATUS_CODE['NEW']): db.set_message_status(uid, msgid, CFG_WEBMESSAGE_STATUS_CODE['READ']) body = webmessage_templates.tmpl_display_msg( msg_id, msg_from_id, msg_from_nickname, msg_sent_to, msg_sent_to_group, msg_subject, msg_body, msg_sent_date, msg_received_date, ln) return body def perform_request_display(uid, warnings=[], infos=[], ln=CFG_SITE_LANG): """
(msg_id, msg_from_id, msg_from_nickname, msg_sent_to, msg_sent_to_group, msg_subject, msg_body, msg_sent_date, msg_received_date, msg_status) = db.get_message(uid, msgid) if (msg_id == ""): # The message exists in table user_msgMESSAGE # but not in table msgMESSAGE => table inconsistency try: raise InvenioWebMessageError(_('This message does not exist.')) except InvenioWebMessageError, exc: register_exception() body = webmessage_templates.tmpl_error(exc.message, ln) return body else: if (msg_status == CFG_WEBMESSAGE_STATUS_CODE['NEW']): db.set_message_status(uid, msgid, CFG_WEBMESSAGE_STATUS_CODE['READ']) body = webmessage_templates.tmpl_display_msg( msg_id, msg_from_id, msg_from_nickname, msg_sent_to, msg_sent_to_group, msg_subject, msg_body, msg_sent_date, msg_received_date, ln) return body def perform_request_display(uid, warnings=[], infos=[], ln=CFG_SITE_LANG): """ Displays the user's Inbox @param uid: user id @return: body with warnings """ body = ""