"""E-mail related constants.""" from collections import namedtuple EmailNotifications = namedtuple( 'email_notifications', ('failure_type', 'subject', 'reason', 'fix_text')) NOTIFICATION_TEXT_PATTERNS = { 'verification_failed': ( 'File "{file_name}" validation failed due to ' '{reason_text}.\n{fix_text}.'), 'processing_failed': ( 'File "{file_name}" processing failed due to {reason_text}.\n' '{fix_text}.'), 'processing_succeeded': ( 'File "{file_name}" has been processed successfully. Data from the ' 'file is now available in the DB.' ), 'processing_partially_succeeded': ( 'File "{file_name}" has been partially processed. Data from the file ' 'is now available in the DB.\n\nPlease note that some records ' 'could not be processed and were skipped.\n\n' '{reason_text}\n\n{fix_text}.\n' ) } ERROR_CODE_TEXT_MAPPING = { 'wrong_file_size_error': EmailNotifications( 'verification_failed', 'Uploaded file "{file_name}" validation failed', 'file size limit excess', 'Please split the file into 2 or more of up to 450 MB and try again'), 'wrong_file_type_error': EmailNotifications( 'verification_failed', 'Uploaded file "{file_name}" validation failed', 'invalid file type', 'Supported file types are ".TXT", ".CSV" and ".TSV" only'), 'missing_data': EmailNotifications( 'processing_failed', 'Sales file "{file_name}" processing failed', 'missing data', 'Please make sure that file has a data in it and upload it again'), 'invalid_file_structure': EmailNotifications( 'processing_failed', 'Sales file "{file_name}" processing failed', 'invalid file structure', 'Please make sure that file contains all the necessary fields ' 'and upload it again'), 'encoding_not_identified': EmailNotifications( 'processing_failed', 'Sales file "{file_name}" processing failed', 'encoding issue', 'Please check the file, re-save it with "UTF-8", "windows1252" or ' '"iso-8859-1" encoding, and upload again. If issue persists, ' 'contact IT department'), 'database_error': EmailNotifications( 'processing_failed', 'Sales file "{file_name}" processing failed', 'system issue', 'Please try again. If issue persists, contact IT department'), 'file_processing_error': EmailNotifications( 'processing_failed', 'Sales file "{file_name}" processing failed', 'system issue', 'Please try again. If issue persists, contact IT department'), 'processing_succeeded': EmailNotifications( 'processing_succeeded', 'Sales file "{file_name}" has been processed successfully', '', ''), 'processing_partially_succeeded': EmailNotifications( 'processing_partially_succeeded', 'Sales file "{file_name}" has been processed successfully, ' 'some records were skipped\n', '', 'Correct the records manually and either reupload the file ' '"{file_name}" or create a new file with corrected records only and ' 'upload it with new name (for example, "{file_name_timestamp}" ' 'or "{file_name_1}")'), 'content_does_not_match_headers': EmailNotifications( 'processing_partially_succeeded', '', 'Error: Number of fields in the row doesn\'t match the number of ' 'fields in the header.', ''), 'missing_mandatory_fields': EmailNotifications( 'processing_partially_succeeded', '', 'Error: Mandatory field value is missing.', ''), 'partial_processing_errors': EmailNotifications( 'processing_partially_succeeded', '', 'Error: Unexpected error in the row.', ''), 'data_validation_error': EmailNotifications( 'processing_partially_succeeded', '', 'Error: Invalid value in the field.', ''), }