| @@ 196-236 (lines=41) @@ | ||
| 193 | ||
| 194 | return item |
|
| 195 | ||
| 196 | def get_recipients(self, ar): |
|
| 197 | """Return the AR recipients in the same format like the AR Report |
|
| 198 | expects in the records field `Recipients` |
|
| 199 | """ |
|
| 200 | plone_utils = api.get_tool("plone_utils") |
|
| 201 | ||
| 202 | def is_email(email): |
|
| 203 | if not plone_utils.validateSingleEmailAddress(email): |
|
| 204 | return False |
|
| 205 | return True |
|
| 206 | ||
| 207 | def recipient_from_contact(contact): |
|
| 208 | if not contact: |
|
| 209 | return None |
|
| 210 | email = contact.getEmailAddress() |
|
| 211 | return { |
|
| 212 | "UID": api.get_uid(contact), |
|
| 213 | "Username": contact.getUsername(), |
|
| 214 | "Fullname": to_utf8(contact.Title()), |
|
| 215 | "EmailAddress": email, |
|
| 216 | } |
|
| 217 | ||
| 218 | def recipient_from_email(email): |
|
| 219 | if not is_email(email): |
|
| 220 | return None |
|
| 221 | return { |
|
| 222 | "UID": "", |
|
| 223 | "Username": "", |
|
| 224 | "Fullname": email, |
|
| 225 | "EmailAddress": email, |
|
| 226 | } |
|
| 227 | ||
| 228 | # Primary Contacts |
|
| 229 | to = filter(None, [recipient_from_contact(ar.getContact())]) |
|
| 230 | # CC Contacts |
|
| 231 | cc = filter(None, map(recipient_from_contact, ar.getCCContact())) |
|
| 232 | # CC Emails |
|
| 233 | cc_emails = map(lambda x: x.strip(), ar.getCCEmails().split(",")) |
|
| 234 | cc_emails = filter(None, map(recipient_from_email, cc_emails)) |
|
| 235 | ||
| 236 | return to + cc + cc_emails |
|
| 237 | ||
| @@ 591-631 (lines=41) @@ | ||
| 588 | except (POSKeyError, TypeError): |
|
| 589 | return None |
|
| 590 | ||
| 591 | def get_recipients(self, ar): |
|
| 592 | """Return the AR recipients in the same format like the AR Report |
|
| 593 | expects in the records field `Recipients` |
|
| 594 | """ |
|
| 595 | plone_utils = api.get_tool("plone_utils") |
|
| 596 | ||
| 597 | def is_email(email): |
|
| 598 | if not plone_utils.validateSingleEmailAddress(email): |
|
| 599 | return False |
|
| 600 | return True |
|
| 601 | ||
| 602 | def recipient_from_contact(contact): |
|
| 603 | if not contact: |
|
| 604 | return None |
|
| 605 | email = contact.getEmailAddress() |
|
| 606 | return { |
|
| 607 | "UID": api.get_uid(contact), |
|
| 608 | "Username": contact.getUsername(), |
|
| 609 | "Fullname": to_utf8(contact.Title()), |
|
| 610 | "EmailAddress": email, |
|
| 611 | } |
|
| 612 | ||
| 613 | def recipient_from_email(email): |
|
| 614 | if not is_email(email): |
|
| 615 | return None |
|
| 616 | return { |
|
| 617 | "UID": "", |
|
| 618 | "Username": "", |
|
| 619 | "Fullname": email, |
|
| 620 | "EmailAddress": email, |
|
| 621 | } |
|
| 622 | ||
| 623 | # Primary Contacts |
|
| 624 | to = filter(None, [recipient_from_contact(ar.getContact())]) |
|
| 625 | # CC Contacts |
|
| 626 | cc = filter(None, map(recipient_from_contact, ar.getCCContact())) |
|
| 627 | # CC Emails |
|
| 628 | cc_emails = map(lambda x: x.strip(), ar.getCCEmails().split(",")) |
|
| 629 | cc_emails = filter(None, map(recipient_from_email, cc_emails)) |
|
| 630 | ||
| 631 | return to + cc + cc_emails |
|
| 632 | ||
| 633 | def ajax_recalculate_size(self): |
|
| 634 | """Recalculate the total size of the selected attachments |
|