def apply_message_redaction(self, content, replacements=None): if replacements is None: replacements = {} if self.address and replacements.get('address') is not False: for line in self.address.splitlines(): if line.strip(): content = content.replace( line, replacements.get('address', str(_("<< Address removed >>")))) if self.email and replacements.get('email') is not False: content = content.replace( self.email, replacements.get('email', str(_("<< Email removed >>")))) if not self.private or replacements.get('name') is False: return content name_replacement = replacements.get('name', str(_("<< Name removed >>"))) content = replace_custom(settings.FROIDE_CONFIG['greetings'], name_replacement, content) content = replace_word(self.last_name, name_replacement, content) content = replace_word(self.first_name, name_replacement, content) content = replace_word(self.get_full_name(), name_replacement, content) if self.organization: content = replace_word(self.organization, name_replacement, content) return content
def apply_message_redaction(self, content, replacements=None): if replacements is None: replacements = {} if self.address and replacements.get('address') is not False: for line in self.address.splitlines(): if line.strip(): content = content.replace(line, replacements.get('address', str(_("<< Address removed >>"))) ) if self.email and replacements.get('email') is not False: content = content.replace(self.email, replacements.get('email', str(_("<< Email removed >>"))) ) if not self.private or replacements.get('name') is False: return content name_replacement = replacements.get('name', str(_("<< Name removed >>"))) content = replace_custom(settings.FROIDE_CONFIG['greetings'], name_replacement, content) content = replace_word(self.last_name, name_replacement, content) content = replace_word(self.first_name, name_replacement, content) content = replace_word(self.get_full_name(), name_replacement, content) if self.organization: content = replace_word(self.organization, name_replacement, content) return content
def redact_plaintext(self): content = self.plaintext content = redact_content(content) greeting_replacement = str(_("<< Greeting >>")) if not settings.FROIDE_CONFIG.get('public_body_officials_public'): if self.is_response: if settings.FROIDE_CONFIG.get('closings'): content = remove_closing( settings.FROIDE_CONFIG['closings'], content) else: if settings.FROIDE_CONFIG.get('greetings'): content = replace_custom( settings.FROIDE_CONFIG['greetings'], greeting_replacement, content) if self.request.user: content = self.request.user.apply_message_redaction(content) return content