| @@ 695-735 (lines=41) @@ | ||
| 692 | except (POSKeyError, TypeError): |
|
| 693 | return None |
|
| 694 | ||
| 695 | def get_recipients(self, ar): |
|
| 696 | """Return the AR recipients in the same format like the AR Report |
|
| 697 | expects in the records field `Recipients` |
|
| 698 | """ |
|
| 699 | plone_utils = api.get_tool("plone_utils") |
|
| 700 | ||
| 701 | def is_email(email): |
|
| 702 | if not plone_utils.validateSingleEmailAddress(email): |
|
| 703 | return False |
|
| 704 | return True |
|
| 705 | ||
| 706 | def recipient_from_contact(contact): |
|
| 707 | if not contact: |
|
| 708 | return None |
|
| 709 | email = contact.getEmailAddress() |
|
| 710 | return { |
|
| 711 | "UID": api.get_uid(contact), |
|
| 712 | "Username": contact.getUsername(), |
|
| 713 | "Fullname": to_utf8(contact.Title()), |
|
| 714 | "EmailAddress": email, |
|
| 715 | } |
|
| 716 | ||
| 717 | def recipient_from_email(email): |
|
| 718 | if not is_email(email): |
|
| 719 | return None |
|
| 720 | return { |
|
| 721 | "UID": "", |
|
| 722 | "Username": "", |
|
| 723 | "Fullname": email, |
|
| 724 | "EmailAddress": email, |
|
| 725 | } |
|
| 726 | ||
| 727 | # Primary Contacts |
|
| 728 | to = filter(None, [recipient_from_contact(ar.getContact())]) |
|
| 729 | # CC Contacts |
|
| 730 | cc = filter(None, map(recipient_from_contact, ar.getCCContact())) |
|
| 731 | # CC Emails |
|
| 732 | cc_emails = ar.getCCEmails(as_list=True) |
|
| 733 | cc_emails = filter(None, map(recipient_from_email, cc_emails)) |
|
| 734 | ||
| 735 | return to + cc + cc_emails |
|
| 736 | ||
| 737 | def ajax_recalculate_size(self): |
|
| 738 | """Recalculate the total size of the selected attachments |
|
| @@ 209-249 (lines=41) @@ | ||
| 206 | ||
| 207 | return item |
|
| 208 | ||
| 209 | def get_recipients(self, ar): |
|
| 210 | """Return the AR recipients in the same format like the AR Report |
|
| 211 | expects in the records field `Recipients` |
|
| 212 | """ |
|
| 213 | plone_utils = api.get_tool("plone_utils") |
|
| 214 | ||
| 215 | def is_email(email): |
|
| 216 | if not plone_utils.validateSingleEmailAddress(email): |
|
| 217 | return False |
|
| 218 | return True |
|
| 219 | ||
| 220 | def recipient_from_contact(contact): |
|
| 221 | if not contact: |
|
| 222 | return None |
|
| 223 | email = contact.getEmailAddress() |
|
| 224 | return { |
|
| 225 | "UID": api.get_uid(contact), |
|
| 226 | "Username": contact.getUsername(), |
|
| 227 | "Fullname": to_utf8(contact.Title()), |
|
| 228 | "EmailAddress": email, |
|
| 229 | } |
|
| 230 | ||
| 231 | def recipient_from_email(email): |
|
| 232 | if not is_email(email): |
|
| 233 | return None |
|
| 234 | return { |
|
| 235 | "UID": "", |
|
| 236 | "Username": "", |
|
| 237 | "Fullname": email, |
|
| 238 | "EmailAddress": email, |
|
| 239 | } |
|
| 240 | ||
| 241 | # Primary Contacts |
|
| 242 | to = filter(None, [recipient_from_contact(ar.getContact())]) |
|
| 243 | # CC Contacts |
|
| 244 | cc = filter(None, map(recipient_from_contact, ar.getCCContact())) |
|
| 245 | # CC Emails |
|
| 246 | cc_emails = ar.getCCEmails(as_list=True) |
|
| 247 | cc_emails = filter(None, map(recipient_from_email, cc_emails)) |
|
| 248 | ||
| 249 | return to + cc + cc_emails |
|
| 250 | ||