Class: MusicMetadataEnrichment::GroupArtistConnectionsController

Inherits:
ApplicationController
  • Object
show all
Includes:
Applicat::Mvc::Controller::Resource, ArtistConfirmation, BaseController
Defined in:
app/controllers/music_metadata_enrichment/group_artist_connections_controller.rb

Instance Method Summary collapse

Methods included from ArtistConfirmation

#artist_selection, #build_artist, #confirm_artist, #create_artist, #redirect_after_artist_available, #render_modal_javascript_response, #set_template_name_for_xhr_or_render

Methods included from BaseController

#application_navigation, #navigation_product_name, #navigation_product_path

Instance Method Details

#creationObject



39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'app/controllers/music_metadata_enrichment/group_artist_connections_controller.rb', line 39

def creation
  if MusicMetadataEnrichment::GroupArtistConnection.where(
    group_id: params[:group_artist_connection][:group_id], artist_id: params[:group_artist_connection][:artist_id]
  ).any?
    flash[:alert] = I18n.t('music_metadata_enrichment_group_artist_connections.creation.already_created')
    redirect_to music_group_path(params[:group_artist_connection][:group_id])
  else
    @group_artist_connection = MusicMetadataEnrichment::GroupArtistConnection.new(
      group_id: params[:group_artist_connection][:group_id], artist_id: params[:group_artist_connection][:artist_id]
    )
    
    if @group_artist_connection.save
      flash[:notice] = I18n.t('music_metadata_enrichment_group_artist_connections.creation.success')
    else
      flash[:alert] = @group_artist_connection.errors.full_messages.join('. ')
    end
    
    redirect_to music_group_path(@group_artist_connection.group_id)
  end
end

#importObject



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'app/controllers/music_metadata_enrichment/group_artist_connections_controller.rb', line 8

def import
  @group = MusicMetadataEnrichment::Group.find(params[:group_id])
  
  if params[:music_metadata_enrichment_group].present?
    @group.artist_connections_text = params[:music_metadata_enrichment_group][:artist_connections_text]
    artist_names_without_mbid = @group.import_artist_connections
    
    if artist_names_without_mbid.any?
      flash[:notice] = I18n.t(
        'music_metadata_enrichment_group_artist_connections.import.success_with_missing_artist_mbids', artist_names: artist_names_without_mbid.join(', ')
      )
    else
      flash[:notice] = I18n.t('music_metadata_enrichment_group_artist_connections.import.success')
    end
    
    redirect_to music_group_path(@group.id)
  end
end

#name_confirmationObject



31
32
33
# File 'app/controllers/music_metadata_enrichment/group_artist_connections_controller.rb', line 31

def name_confirmation
  confirm_artist('new_group_artist_connection')
end

#newObject



27
28
29
# File 'app/controllers/music_metadata_enrichment/group_artist_connections_controller.rb', line 27

def new
  build_artist
end

#resourceObject



60
61
62
# File 'app/controllers/music_metadata_enrichment/group_artist_connections_controller.rb', line 60

def resource
  @group_artist_connection
end

#select_artistObject



35
36
37
# File 'app/controllers/music_metadata_enrichment/group_artist_connections_controller.rb', line 35

def select_artist
  artist_selection('new_group_artist_connection')
end