def test_should_add_venue_id_when_algolia_feature_is_enabled(self): # Given client = MagicMock() client.rpush = MagicMock() # When add_venue_id(client=client, venue_id=1) # Then client.rpush.assert_called_once_with("venue_ids", 1)
def activate_venue_offers(venue_id): venue = load_or_404(Venue, venue_id) check_user_has_access_to_offerer(current_user, venue.managingOffererId) offers = venue.offers activated_offers = update_is_active_status(offers, True) repository.save(*activated_offers) if feature_queries.is_active(FeatureToggle.SYNCHRONIZE_ALGOLIA): redis.add_venue_id(client=app.redis_client, venue_id=venue.id) return jsonify([ as_dict(offer, includes=OFFER_INCLUDES) for offer in activated_offers ]), 200
def deactivate_venue_offers(venue_id): venue = load_or_404(VenueSQLEntity, venue_id) ensure_current_user_has_rights(RightsType.editor, venue.managingOffererId) offers = venue.offers deactivated_offers = update_is_active_status(offers, False) repository.save(*deactivated_offers) if feature_queries.is_active(FeatureToggle.SYNCHRONIZE_ALGOLIA): redis.add_venue_id(client=app.redis_client, venue_id=venue.id) return jsonify([ as_dict(offer, includes=OFFER_INCLUDES) for offer in deactivated_offers ]), 200
def edit_venue(venue_id): venue = load_or_404(Venue, venue_id) previous_venue = copy.deepcopy(venue) check_valid_edition(request, venue) validate_coordinates(request.json.get("latitude", None), request.json.get("longitude", None)) check_user_has_access_to_offerer(current_user, venue.managingOffererId) venue.populate_from_dict(request.json) if not venue.isVirtual: delete_venue_from_iris_venues(venue.id) repository.save(venue) link_valid_venue_to_irises(venue) if is_algolia_indexing(previous_venue, request.json): if feature_queries.is_active(FeatureToggle.SYNCHRONIZE_ALGOLIA): redis.add_venue_id(client=app.redis_client, venue_id=dehumanize(venue_id)) return jsonify(as_dict(venue, includes=VENUE_INCLUDES)), 200
def validate_new_offerer(token): check_validation_request(token) offerer = Offerer.query.filter_by(validationToken=token).first() check_validation_token_has_been_already_used(offerer) offerer.validationToken = None managed_venues = offerer.managedVenues for venue in managed_venues: link_valid_venue_to_irises(venue) repository.save(offerer) if feature_queries.is_active(FeatureToggle.SYNCHRONIZE_ALGOLIA): venue_ids = map(lambda managed_venue: managed_venue.id, managed_venues) sorted_venue_ids = sorted(venue_ids, key=int) for venue_id in sorted_venue_ids: redis.add_venue_id(client=app.redis_client, venue_id=venue_id) try: send_validation_confirmation_email_to_pro(offerer, send_raw_email) except MailServiceException as mail_service_exception: app.logger.exception("Email service failure", mail_service_exception) return "Validation effectuée", 202