def send_tilbake_til_saksbehandling_strategy(soknad, action, data): errors = soknad.validate_soknad_for_innsending() if errors: abort(400, __error__=errors) soknad.status = action.get_end_state().id SoknadRepo.save(soknad, autocommit=False) # Arkivering ############ organisation = get_organisation(soknad.organisation_id, request.cookies) person = get_person(soknad.person_id, request.cookies) csv_file_content = ExportSoknaderResource().get(soknad_id=soknad.id).data save_journalpost_for_soknad(soknad, organisation, person, csv_file_content, u"soknad-%s-%s.pdf" % (soknad.id, datetime.now().isoformat())) current_app.db_session.commit() # Sending mail after save to avoid that mail integration errors make it impossible to perform action. # It also makes sense to send mail only when we know that the action is successful send_email_to_soker_on_action_send_inn(soknad) if not soknad.tilskuddsordning.soknadsfrist: send_email_to_saksbehandlere_on_action_send_inn(soknad)
def behandle_action_strategy(soknad, action, data): if not data or not data.get("saksbehandler"): abort(400, __error__={'saksbehandler': u'Saksbehandler må være satt'}) soknad.saksbehandler_id = data.get("saksbehandler") soknad.status = action.get_end_state().id SoknadRepo.save(soknad, autocommit=False) # Arkivering # ########### organisation = get_organisation(soknad.organisation_id, request.cookies) person = get_person(soknad.person_id, request.cookies) csv_file_content = ExportSoknaderResource().get(soknad_id=soknad.id).data save_sak(soknad) save_journalpost_for_soknad(soknad, organisation, person, csv_file_content, u"soknad-%s-%s.pdf" % (soknad.id, datetime.now().isoformat())) current_app.db_session.commit()