def transfer_application(author, application, to_organization, reason): """Transfers an application from one organization to another. Returns three things as a tuple: - a new ApplicationTransfer instance - a new StatusUpdate instance - a new Application instance for the to_organization """ transferred_status_type = models.StatusType.objects.get(slug='transferred') transfer_status_update = models.StatusUpdate( status_type=transferred_status_type, author_id=author.id, application=application) transfer_status_update.save() new_application = models.Application( form_submission_id=application.form_submission_id, organization=to_organization) new_application.save() transfer = models.ApplicationTransfer( status_update=transfer_status_update, new_application=new_application, reason=reason) transfer.save() application.was_transferred_out = True application.save() EventsService.app_transferred(application, new_application, author) EventsService.user_app_transferred(application, new_application, author) return transfer, transfer_status_update, new_application
def send_and_save_new_status(request, notification_data, status_update_data): next_steps = status_update_data.pop('next_steps', []) status_update = models.StatusUpdate(**status_update_data) status_update.save() status_update.next_steps.add(*next_steps) save_and_send_status_notification(request, notification_data, status_update) success_message = get_status_update_success_message( status_update.application.form_submission.get_full_name(), status_update.status_type) messages.success(request, success_message)
def transfer_application(author, application, to_organization, reason): """Transfers an application from one organization to another. Returns three things as a tuple: - a new ApplicationTransfer instance - a new StatusUpdate instance - a new Application instance for the to_organization """ transfer_status_update = models.StatusUpdate( status_type_id=models.status_type.TRANSFERRED, author_id=author.id, application=application) transfer_status_update.save() new_application = models.Application( form_submission_id=application.form_submission_id, organization=to_organization) new_application.save() transfer = models.ApplicationTransfer(status_update=transfer_status_update, new_application=new_application, reason=reason) transfer.save() application.was_transferred_out = True application.save() return transfer, transfer_status_update, new_application