예제 #1
0
def create_venue(venue_properties: Dict, save: Callable) -> Venue:
    venue = Venue(from_dict=venue_properties)

    save(venue)

    link_valid_venue_to_irises(venue=venue)

    return venue
예제 #2
0
    def test_should_not_link_venue_to_iris_when_venue_is_validated_and_offerer_is_not_validated(self):
        # Given
        mock_link_to_irises = MagicMock()
        venue = MagicMock()
        venue.isValidated = True
        venue.managingOfferer = MagicMock()
        venue.managingOfferer.isValidated = False

        # When
        link_valid_venue_to_irises(venue, mock_link_to_irises)

        # Then
        mock_link_to_irises.assert_not_called()
예제 #3
0
    def test_should_link_venue_to_iris_when_venue_and_offerer_are_validated(self):
        # Given
        mock_link_to_irises = MagicMock()
        venue = MagicMock()
        venue.isValidated = True
        venue.managingOfferer = MagicMock()
        venue.managingOfferer.isValidated = True

        # When
        link_valid_venue_to_irises(venue, mock_link_to_irises)

        # Then
        mock_link_to_irises.assert_called_once_with(venue)
예제 #4
0
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
예제 #5
0
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