def create_offerer(): siren = request.json["siren"] offerer = find_by_siren(siren) if offerer is not None: user_offerer = offerer.grant_access(current_user) user_offerer.generate_validation_token() repository.save(user_offerer) try: send_ongoing_offerer_attachment_information_email_to_pro( user_offerer) except MailServiceException as mail_service_exception: app.logger.exception( "[send_ongoing_offerer_attachment_information_email_to_pro] " "Mail service failure", mail_service_exception, ) else: offerer = Offerer() offerer.populate_from_dict(request.json) digital_venue = create_digital_venue(offerer) offerer.generate_validation_token() user_offerer = offerer.grant_access(current_user) repository.save(offerer, digital_venue, user_offerer) user = User.query.filter_by(id=user_offerer.userId).first() _send_to_pro_offer_validation_in_progress_email(user, offerer) _send_to_pc_admin_offerer_to_validate_email(offerer, user_offerer) return jsonify(get_dict_offerer(offerer)), 201
def _generate_offerer(data): offerer = Offerer() offerer.populate_from_dict(data) if not settings.IS_INTEGRATION: offerer.generate_validation_token() return offerer