def format_slots_for_email(slots, application_type): formatted_slots = [] for slot in slots: if application_type == "repeating": formatted_slots.append(format_repeating_slot_for_email(slot)) else: formatted_slots.append(format_slot_for_email(slot)) return formatted_slots
def send_email_to_affected_applications(self, arrangement, affected_applications, message): arrangement_slots = [] for arrangement_slot in arrangement.slots: arrangement_slots.append(format_slot_for_email(arrangement_slot)) for affected_application in affected_applications: if affected_application.slots: resource_details = get_resource_from_web(affected_application.resource.uri) resource_name = resource_details['name'] person_details = get_person_from_web(affected_application.person.uri) email_address = person_details['email_address'] org_name = None if affected_application.organisation is not None: org_details = get_organisation_from_web(affected_application.organisation.uri) org_name = org_details.get('name') application_time = affected_application.application_time.strftime("%Y.%m.%d %H:%M:00") slots = [] # Just create human readable text out of slots for slot in affected_application.slots: if affected_application.get_type() == "repeating": slots.append(format_repeating_slot_for_email(slot)) else: slots.append(format_slot_for_email(slot)) msg = render_template("email_arrangement_notification.txt", org_name=org_name, resource_name=resource_name, application_time=application_time, slots=slots, arrangement_slots=arrangement_slots, message=message) if email_address and msg is not None: send_email_task.delay(u'Arrangement', u'*****@*****.**', [email_address], msg)
def generate_slots(application): if application.type == 'repeating': return [format_repeating_slot_for_email(slot) for slot in application.slots] else: return [format_slot_for_email(slot) for slot in application.slots]