diff --git a/app/controllers/admin/event_types_controller.rb b/app/controllers/admin/event_types_controller.rb new file mode 100644 index 00000000..91e629e2 --- /dev/null +++ b/app/controllers/admin/event_types_controller.rb @@ -0,0 +1,21 @@ +module Admin + class EventTypesController < Admin::BaseController + authorize_resource + load_and_authorize_resource :conference, find_by: :short_title + + def show + render :eventtypes + end + + def update + @conference.update_attributes!(params[:conference]) + redirect_to(admin_conference_event_types_path( + conference_id: @conference.short_title), + notice: 'Event types were successfully updated.') + rescue Exception => e + redirect_to(admin_conference_event_types_path( + conference_id: @conference.short_title), + alert: "Event types update failed: #{e.message}") + end + end +end diff --git a/app/views/admin/conference/_todo_list.html.haml b/app/views/admin/conference/_todo_list.html.haml index 3f87ecbd..06972f0a 100644 --- a/app/views/admin/conference/_todo_list.html.haml +++ b/app/views/admin/conference/_todo_list.html.haml @@ -23,7 +23,7 @@ = link_to 'Add tracks', admin_conference_tracks_path(conference_progress['short_title']) %li{'class'=>class_for_todo(conference_progress['event_types'])} %span{'class'=>icon_for_todo(conference_progress['event_types'])} - = link_to 'Add event types', admin_conference_eventtypes_path(conference_progress['short_title']) + = link_to 'Add event types', admin_conference_event_types_path(conference_progress['short_title']) %li{'class'=>class_for_todo(conference_progress['difficulty_levels'])} %span{'class'=>icon_for_todo(conference_progress['difficulty_levels'])} = link_to 'Add difficulty levels', admin_conference_difficulty_levels_path(conference_progress['short_title']) diff --git a/app/views/admin/eventtypes/_event_type_fields.html.erb b/app/views/admin/event_types/_event_type_fields.html.erb similarity index 100% rename from app/views/admin/eventtypes/_event_type_fields.html.erb rename to app/views/admin/event_types/_event_type_fields.html.erb diff --git a/app/views/admin/eventtypes/index.html.haml b/app/views/admin/event_types/index.html.haml similarity index 76% rename from app/views/admin/eventtypes/index.html.haml rename to app/views/admin/event_types/index.html.haml index ad9256d1..c225bd66 100644 --- a/app/views/admin/eventtypes/index.html.haml +++ b/app/views/admin/event_types/index.html.haml @@ -1,5 +1,5 @@ .row .col-md-8 - = semantic_form_for(@conference, url: admin_conference_eventtypes_path(@conference.short_title, @conference.event_types)) do |f| + = semantic_form_for(@conference, url: admin_conference_event_types_path(@conference.short_title, @conference.event_types)) do |f| = dynamic_association :event_types, "Event Types", f = f.action :submit, :as => :button, :button_html => {:class => "btn btn-primary"} diff --git a/app/views/layouts/_admin_sidebar.html.haml b/app/views/layouts/_admin_sidebar.html.haml index f9eddd03..2b17ba53 100644 --- a/app/views/layouts/_admin_sidebar.html.haml +++ b/app/views/layouts/_admin_sidebar.html.haml @@ -83,8 +83,8 @@ %ul.nav.nav-stacked.nav-pills.small.collapse.subNav %li{:class=> active_nav_li(admin_conference_tracks_path(@conference.short_title))} = link_to 'Tracks', admin_conference_tracks_path(@conference.short_title) - %li{:class=> active_nav_li(admin_conference_eventtypes_path(@conference.short_title))} - = link_to 'Event types', admin_conference_eventtypes_path(@conference.short_title) + %li{:class=> active_nav_li(admin_conference_event_types_path(@conference.short_title))} + = link_to 'Event types', admin_conference_event_types_path(@conference.short_title) %li{:class=> active_nav_li(admin_conference_difficulty_levels_path(@conference.short_title))} = link_to 'Difficulty levels', admin_conference_difficulty_levels_path(@conference.short_title) %li{:class=> active_nav_li(admin_conference_questions_path(@conference.short_title))} diff --git a/config/routes.rb b/config/routes.rb index 20c43a75..ff48b080 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -37,7 +37,7 @@ Osem::Application.routes.draw do resources :campaigns - resources :eventtypes, only: [:show, :index] do + resources :event_types, only: [:show, :index] do collection do patch :update end