| @@ 240-280 (lines=41) @@ | ||
| 237 | ||
| 238 | return item |
|
| 239 | ||
| 240 | def get_recipients(self, ar): |
|
| 241 | """Return the AR recipients in the same format like the AR Report |
|
| 242 | expects in the records field `Recipients` |
|
| 243 | """ |
|
| 244 | plone_utils = api.get_tool("plone_utils") |
|
| 245 | ||
| 246 | def is_email(email): |
|
| 247 | if not plone_utils.validateSingleEmailAddress(email): |
|
| 248 | return False |
|
| 249 | return True |
|
| 250 | ||
| 251 | def recipient_from_contact(contact): |
|
| 252 | if not contact: |
|
| 253 | return None |
|
| 254 | email = contact.getEmailAddress() |
|
| 255 | return { |
|
| 256 | "UID": api.get_uid(contact), |
|
| 257 | "Username": contact.getUsername(), |
|
| 258 | "Fullname": to_utf8(contact.Title()), |
|
| 259 | "EmailAddress": email, |
|
| 260 | } |
|
| 261 | ||
| 262 | def recipient_from_email(email): |
|
| 263 | if not is_email(email): |
|
| 264 | return None |
|
| 265 | return { |
|
| 266 | "UID": "", |
|
| 267 | "Username": "", |
|
| 268 | "Fullname": email, |
|
| 269 | "EmailAddress": email, |
|
| 270 | } |
|
| 271 | ||
| 272 | # Primary Contacts |
|
| 273 | to = filter(None, [recipient_from_contact(ar.getContact())]) |
|
| 274 | # CC Contacts |
|
| 275 | cc = filter(None, map(recipient_from_contact, ar.getCCContact())) |
|
| 276 | # CC Emails |
|
| 277 | cc_emails = ar.getCCEmails(as_list=True) |
|
| 278 | cc_emails = filter(None, map(recipient_from_email, cc_emails)) |
|
| 279 | ||
| 280 | return to + cc + cc_emails |
|
| 281 | ||
| @@ 765-805 (lines=41) @@ | ||
| 762 | except (POSKeyError, TypeError): |
|
| 763 | return None |
|
| 764 | ||
| 765 | def get_recipients(self, ar): |
|
| 766 | """Return the AR recipients in the same format like the AR Report |
|
| 767 | expects in the records field `Recipients` |
|
| 768 | """ |
|
| 769 | plone_utils = api.get_tool("plone_utils") |
|
| 770 | ||
| 771 | def is_email(email): |
|
| 772 | if not plone_utils.validateSingleEmailAddress(email): |
|
| 773 | return False |
|
| 774 | return True |
|
| 775 | ||
| 776 | def recipient_from_contact(contact): |
|
| 777 | if not contact: |
|
| 778 | return None |
|
| 779 | email = contact.getEmailAddress() |
|
| 780 | return { |
|
| 781 | "UID": api.get_uid(contact), |
|
| 782 | "Username": contact.getUsername(), |
|
| 783 | "Fullname": to_utf8(contact.Title()), |
|
| 784 | "EmailAddress": email, |
|
| 785 | } |
|
| 786 | ||
| 787 | def recipient_from_email(email): |
|
| 788 | if not is_email(email): |
|
| 789 | return None |
|
| 790 | return { |
|
| 791 | "UID": "", |
|
| 792 | "Username": "", |
|
| 793 | "Fullname": email, |
|
| 794 | "EmailAddress": email, |
|
| 795 | } |
|
| 796 | ||
| 797 | # Primary Contacts |
|
| 798 | to = filter(None, [recipient_from_contact(ar.getContact())]) |
|
| 799 | # CC Contacts |
|
| 800 | cc = filter(None, map(recipient_from_contact, ar.getCCContact())) |
|
| 801 | # CC Emails |
|
| 802 | cc_emails = ar.getCCEmails(as_list=True) |
|
| 803 | cc_emails = filter(None, map(recipient_from_email, cc_emails)) |
|
| 804 | ||
| 805 | return to + cc + cc_emails |
|
| 806 | ||
| 807 | def ajax_recalculate_size(self): |
|
| 808 | """Recalculate the total size of the selected attachments |
|