diff --git a/app/controllers/admin/conference_controller.rb b/app/controllers/admin/conference_controller.rb index 6b815f3c..89347905 100644 --- a/app/controllers/admin/conference_controller.rb +++ b/app/controllers/admin/conference_controller.rb @@ -30,16 +30,24 @@ class Admin::ConferenceController < ApplicationController @conference = Conference.find_by(short_title: params[:id]) short_title = @conference.short_title if @conference.update_attributes(params[:conference]) - redirect_to(admin_conference_path(id: @conference.short_title), + redirect_to(edit_admin_conference_path(id: @conference.short_title), notice: 'Conference was successfully updated.') else - redirect_to(admin_conference_path(id: short_title), + redirect_to(edit_admin_conference_path(id: short_title), alert: 'Updating conference failed. ' \ "#{@conference.errors.full_messages.join('. ')}.") end end def show + @conference = Conference.find_by(short_title: params[:id]) + respond_to do |format| + format.html + format.json { render json: @conference.to_json } + end + end + + def edit @conferences = Conference.all @conference = Conference.find_by(short_title: params[:id]) respond_to do |format| diff --git a/app/views/admin/conference/edit.html.haml b/app/views/admin/conference/edit.html.haml new file mode 100644 index 00000000..0176180c --- /dev/null +++ b/app/views/admin/conference/edit.html.haml @@ -0,0 +1,28 @@ +.row + .col-md-8 + = semantic_form_for(@conference, :url => admin_conference_path(@conference.short_title),:html => {:multipart => true}) do |f| + = f.input :title, :hint => "The full name of the conference, such as 'OpenSUSE Conference 2013'" + = f.input :short_title, :hint => "A short title, such as 'osc2013', to be used in URLs" + = f.input :social_tag, :hint => "The hashtag you'll use on Twitter and Google+. Don't include the '#' sign!'" + = f.input :contact_email, :hint => "Contact email address for your conference. Will be used as reply-to address in emails sent out by the system." + + = f.inputs :name => "Scheduling" do + = f.input :timezone, :as => :time_zone, :hint => "The conference time zone" + = f.input :start_date, :as => :string, :input_html => { :id => "conference-start-datepicker", :readonly => "readonly" } + = f.input :end_date, :as => :string, :input_html => { :id => "conference-end-datepicker", :readonly => "readonly" } + = f.input :registration_start_date, :as => :string, :input_html => { :id => "conference-reg-start-datepicker", :readonly => "readonly" } + = f.input :registration_end_date, :as => :string, :input_html => { :id => "conference-reg-end-datepicker", :readonly => "readonly" } + + = f.inputs :name => "Media" do + - if !@conference.logo.blank? + = image_tag @conference.logo(:thumb) + = f.input :logo, :label => "Conference Logo", :hint => "This will be displayed on the front page." + = f.input :media_type, :as => :select, :label => "Conference Promo Media Type", :class=>"form-control", :collection => Conference.media_types.values, :include_blank => false, :hint => "This media-item will be used to represent this conference at various places in OSEM." + = f.input :media_id, :label => "Conference Promo Media ID", :as => :string + %p{:class => "help-block media-type", :id => "youtube-help"} Go to your YouTube video, click on "share" and copy everything behind http://youtu.be/" + %p{:class => "help-block media-type", :id => "slideshare-help", :style => "display:none"} Go to your SlideShare, click on "share" -> "embed" and copy the id + %p{:class => "help-block media-type", :id => "flickr-help", :style => "display:none"} Go to your flickr image, click on "Grab the link" -> "Show short url" and copy everything behind https://flic.kr/p/ + %p{:class => "help-block media-type", :id => "vimeo-help", :style => "display:none"} Go to your vimeo video, click on "share" and copy everything behind http://vimeo.com/ + %p{:class => "help-block media-type", :id => "speakerdeck-help", :style => "display:none"} Go to your SpeakerDeck, click on "share" -> "embed" and copy the data-id + %p{:class => "help-block media-type", :id => "instagram-help", :style => "display:none"} Go to your Instagram photo page and copy everything behind instagram.com/p/ (without trailing /# hash symbol) + = f.action :submit, :as => :button, :button_html => {:class => "btn btn-primary"} diff --git a/app/views/admin/conference/index.html.haml b/app/views/admin/conference/index.html.haml index 737680e7..727472f8 100644 --- a/app/views/admin/conference/index.html.haml +++ b/app/views/admin/conference/index.html.haml @@ -1,3 +1,7 @@ -%ul - - @conferences.each do |conference| - %li= link_to conference.title, admin_conference_path(conference.short_title) +.row + %h1 Global Dashboard + %hr +.row + %ul + - @conferences.each do |conference| + %li= link_to conference.title, admin_conference_path(conference.short_title) diff --git a/app/views/admin/conference/show.html.haml b/app/views/admin/conference/show.html.haml index 0176180c..f78d0597 100644 --- a/app/views/admin/conference/show.html.haml +++ b/app/views/admin/conference/show.html.haml @@ -1,28 +1,3 @@ .row .col-md-8 - = semantic_form_for(@conference, :url => admin_conference_path(@conference.short_title),:html => {:multipart => true}) do |f| - = f.input :title, :hint => "The full name of the conference, such as 'OpenSUSE Conference 2013'" - = f.input :short_title, :hint => "A short title, such as 'osc2013', to be used in URLs" - = f.input :social_tag, :hint => "The hashtag you'll use on Twitter and Google+. Don't include the '#' sign!'" - = f.input :contact_email, :hint => "Contact email address for your conference. Will be used as reply-to address in emails sent out by the system." - - = f.inputs :name => "Scheduling" do - = f.input :timezone, :as => :time_zone, :hint => "The conference time zone" - = f.input :start_date, :as => :string, :input_html => { :id => "conference-start-datepicker", :readonly => "readonly" } - = f.input :end_date, :as => :string, :input_html => { :id => "conference-end-datepicker", :readonly => "readonly" } - = f.input :registration_start_date, :as => :string, :input_html => { :id => "conference-reg-start-datepicker", :readonly => "readonly" } - = f.input :registration_end_date, :as => :string, :input_html => { :id => "conference-reg-end-datepicker", :readonly => "readonly" } - - = f.inputs :name => "Media" do - - if !@conference.logo.blank? - = image_tag @conference.logo(:thumb) - = f.input :logo, :label => "Conference Logo", :hint => "This will be displayed on the front page." - = f.input :media_type, :as => :select, :label => "Conference Promo Media Type", :class=>"form-control", :collection => Conference.media_types.values, :include_blank => false, :hint => "This media-item will be used to represent this conference at various places in OSEM." - = f.input :media_id, :label => "Conference Promo Media ID", :as => :string - %p{:class => "help-block media-type", :id => "youtube-help"} Go to your YouTube video, click on "share" and copy everything behind http://youtu.be/" - %p{:class => "help-block media-type", :id => "slideshare-help", :style => "display:none"} Go to your SlideShare, click on "share" -> "embed" and copy the id - %p{:class => "help-block media-type", :id => "flickr-help", :style => "display:none"} Go to your flickr image, click on "Grab the link" -> "Show short url" and copy everything behind https://flic.kr/p/ - %p{:class => "help-block media-type", :id => "vimeo-help", :style => "display:none"} Go to your vimeo video, click on "share" and copy everything behind http://vimeo.com/ - %p{:class => "help-block media-type", :id => "speakerdeck-help", :style => "display:none"} Go to your SpeakerDeck, click on "share" -> "embed" and copy the data-id - %p{:class => "help-block media-type", :id => "instagram-help", :style => "display:none"} Go to your Instagram photo page and copy everything behind instagram.com/p/ (without trailing /# hash symbol) - = f.action :submit, :as => :button, :button_html => {:class => "btn btn-primary"} + %h1 Dashboard for #{@conference.title} \ No newline at end of file diff --git a/app/views/layouts/_admin_sidebar.html.haml b/app/views/layouts/_admin_sidebar.html.haml index d3109a49..a185f52e 100644 --- a/app/views/layouts/_admin_sidebar.html.haml +++ b/app/views/layouts/_admin_sidebar.html.haml @@ -1,4 +1,4 @@ -%ul.nav.nav-stacked.mySidebar +%ul.nav.nav-stacked.nav-pills.mySidebar .btn-group %button{type:'button', class:'btn btn-default btn-link dropdown-toggle', 'data-toggle'=>'dropdown'} %span.glyphicon.glyphicon-home @@ -37,8 +37,8 @@ %a %span.glyphicon.glyphicon-wrench Settings - %li{:class=> active_nav_li(admin_conference_path(@conference.short_title))} - = link_to(admin_conference_path(@conference.short_title)) do + %li{:class=> active_nav_li(edit_admin_conference_path(@conference.short_title))} + = link_to(edit_admin_conference_path(@conference.short_title)) do %span.glyphicon.glyphicon-cog Conference %li{:class=> "#{active_nav_li(admin_conference_venue_info_path(@conference.short_title))} myAccordion"} @@ -46,7 +46,7 @@ %span.glyphicon.glyphicon-calendar Venue %span.small.glyphicon.glyphicon-chevron-right - %ul.nav.nav-stacked.small.collapse.subNav + %ul.nav.nav-stacked.nav-pills.small.collapse.subNav %li{:class=> active_nav_li(admin_conference_rooms_path(@conference.short_title))} = link_to 'Rooms', admin_conference_rooms_path(@conference.short_title) %li{:class=> active_nav_li(admin_conference_emails_path(@conference.short_title))} @@ -58,7 +58,7 @@ %span.glyphicon.glyphicon-comment Call for papers %span.small.glyphicon.glyphicon-chevron-right - %ul.nav.nav-stacked.small.collapse.subNav + %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))} diff --git a/spec/controllers/conferences_controller_spec.rb b/spec/controllers/conferences_controller_spec.rb index df536f20..2fc25a23 100644 --- a/spec/controllers/conferences_controller_spec.rb +++ b/spec/controllers/conferences_controller_spec.rb @@ -36,7 +36,7 @@ describe Admin::ConferenceController do patch :update, id: conference.short_title, conference: attributes_for(:conference, title: 'Example Con') conference.reload - expect(response).to redirect_to admin_conference_path( + expect(response).to redirect_to edit_admin_conference_path( conference.short_title) end end @@ -61,7 +61,7 @@ describe Admin::ConferenceController do expect(flash[:alert]). to eq("Updating conference failed. Short title can't be blank.") - expect(response).to redirect_to admin_conference_path( + expect(response).to redirect_to edit_admin_conference_path( conference.short_title) end end @@ -120,6 +120,18 @@ describe Admin::ConferenceController do end end + describe 'GET #edit' do + it 'assigns the requested conference to conference' do + get :show, id: conference.short_title + expect(assigns(:conference)).to eq conference + end + + it 'renders the show template' do + get :show, id: conference.short_title + expect(response).to render_template :show + end + end + describe 'GET #show' do it 'assigns the requested conference to conference' do get :show, id: conference.short_title diff --git a/spec/features/conference_spec.rb b/spec/features/conference_spec.rb index 90f35f0f..06fb21dc 100644 --- a/spec/features/conference_spec.rb +++ b/spec/features/conference_spec.rb @@ -39,7 +39,7 @@ feature Conference do expected_count = Conference.count sign_in create(user) - visit admin_conference_path(conference.short_title) + visit edit_admin_conference_path(conference.short_title) fill_in 'conference_title', with: 'New Con' fill_in 'conference_short_title', with: 'NewCon' fill_in 'conference_social_tag', with: 'NewCon' diff --git a/spec/views/admin/conference/edit.html.haml_spec.rb b/spec/views/admin/conference/edit.html.haml_spec.rb new file mode 100644 index 00000000..d9b20a42 --- /dev/null +++ b/spec/views/admin/conference/edit.html.haml_spec.rb @@ -0,0 +1,12 @@ +require 'spec_helper' + +describe 'admin/conference/edit' do + + it 'renders conference details which are editable' do + @conference = create(:conference, title: 'OpenSUSE') + assign :conference, @conference + render template: 'admin/conference/edit.html.haml' + expect(rendered).to include('OpenSUSE') + expect(rendered).to include("#{@conference.contact_email}") + end +end diff --git a/spec/views/admin/conference/show.html.haml_spec.rb b/spec/views/admin/conference/show.html.haml_spec.rb index e0710e7c..6c0be344 100644 --- a/spec/views/admin/conference/show.html.haml_spec.rb +++ b/spec/views/admin/conference/show.html.haml_spec.rb @@ -2,11 +2,10 @@ require 'spec_helper' describe 'admin/conference/show' do - it 'renders conference details which are editable' do + it 'renders conference dashboard' do @conference = create(:conference, title: 'OpenSUSE') assign :conference, @conference render - expect(rendered).to include('OpenSUSE') - expect(rendered).to include("#{@conference.contact_email}") + expect(rendered).to include("Dashboard for #{@conference.title}") end end