diff --git a/app/assets/javascripts/osem.js b/app/assets/javascripts/osem.js
index 5d3d4428..21dd66c8 100644
--- a/app/assets/javascripts/osem.js
+++ b/app/assets/javascripts/osem.js
@@ -242,3 +242,13 @@ $.extend( $.fn.dataTableExt.oPagination, {
}
} );
+/* Commodity function for modal windows */
+
+window.build_dialog = function(selector, content) {
+ // Close it and remove content if it's already open
+ $("#" + selector).modal('hide');
+ $("#" + selector).remove();
+ // Add new content and pops it up
+ $("body").append("
\n" + content + "
");
+ $("#" + selector).modal();
+}
diff --git a/app/controllers/admin/people_controller.rb b/app/controllers/admin/people_controller.rb
index b1ceeafb..4b25c683 100644
--- a/app/controllers/admin/people_controller.rb
+++ b/app/controllers/admin/people_controller.rb
@@ -1,5 +1,6 @@
class Admin::PeopleController < ApplicationController
before_filter :verify_organizer
+ respond_to :html
def index
@people = Person.all
@@ -15,16 +16,28 @@ class Admin::PeopleController < ApplicationController
end
end
- def create
+ def new
+ @person = Person.new
+ end
+ def create
+ @person = Person.new(params[:person])
+ flash[:notice] = 'Person was successfully created.' if @person.save
+ respond_with @person, :location => admin_people_path
end
def show
@person = Person.find(params[:id])
end
- def update
+ def edit
+ @person = Person.find(params[:id])
+ end
+ def update
+ @person = Person.find(params[:id])
+ flash[:notice] = 'Person was successfully updated' if @person.update_attributes(params[:person])
+ respond_with @person, :location => admin_people_path
end
def delete
diff --git a/app/controllers/admin/speakers_controller.rb b/app/controllers/admin/speakers_controller.rb
new file mode 100644
index 00000000..e80a2f9f
--- /dev/null
+++ b/app/controllers/admin/speakers_controller.rb
@@ -0,0 +1,17 @@
+class Admin::SpeakersController < ApplicationController
+ before_filter :verify_organizer
+ respond_to :js, :html
+
+ def edit
+ @event = @conference.events.find(params[:event_id])
+ @speaker = @event.event_people.where(:event_role => "speaker").first
+ end
+
+ def update
+ @event = @conference.events.find(params[:event_id])
+ @speaker = @event.event_people.where(:event_role => "speaker").first
+ @speaker.person_id = params[:speaker][:person_id]
+ @speaker.save
+ respond_with @speaker, :location => admin_conference_events_path(@conference.short_title)
+ end
+end
diff --git a/app/controllers/proposal_controller.rb b/app/controllers/proposal_controller.rb
index 80d046df..6d252830 100644
--- a/app/controllers/proposal_controller.rb
+++ b/app/controllers/proposal_controller.rb
@@ -138,6 +138,7 @@ class ProposalController < ApplicationController
def show
@event = Event.find(params[:id])
+ @speaker = @event.speakers.first || @event.submitter
end
def confirm
diff --git a/app/models/event.rb b/app/models/event.rb
index 78344279..ff7369ee 100644
--- a/app/models/event.rb
+++ b/app/models/event.rb
@@ -8,6 +8,7 @@ class Event < ActiveRecord::Base
has_many :event_people, :dependent => :destroy
has_many :event_attachments, :dependent => :destroy
has_many :people, :through => :event_people
+ has_many :speakers, :through => :event_people, :source => :person, :conditions => {"event_people.event_role" => "speaker"}
belongs_to :event_type
belongs_to :track
diff --git a/app/models/person.rb b/app/models/person.rb
index 05470c6a..5d7fb5fa 100644
--- a/app/models/person.rb
+++ b/app/models/person.rb
@@ -10,6 +10,7 @@ class Person < ActiveRecord::Base
validates :first_name, :presence => true
validates :last_name, :presence => true
+ validates :email, :presence => true
validate :biography_limit
before_create :generate_guid
diff --git a/app/views/admin/events/index.html.haml b/app/views/admin/events/index.html.haml
index 9b6401f3..e5b7e47b 100644
--- a/app/views/admin/events/index.html.haml
+++ b/app/views/admin/events/index.html.haml
@@ -101,12 +101,15 @@
%b Title
%th
%b Submitter
+ %th
+ %b Speaker
%th
%b Type
%th
%b Track
%th
%b State
+ %th
- @events.each do |event|
%tr
%td
@@ -124,6 +127,13 @@
(Unregistered!)
- else
Unknown submitter
+ %td
+ - if speaker = event.speakers.first
+ = link_to speaker.public_name, admin_person_path(speaker)
+ - else
+ Unknown speaker
+ - l = link_to "Change", edit_admin_conference_event_speaker_path(@conference.short_title, event), :remote => true
+ = "(#{l})".html_safe
%td
= event.event_type.title
%td
@@ -180,4 +190,4 @@
$("#events-stats1-link").click(function() {
$("#events-stats1").toggle();
});
- });
\ No newline at end of file
+ });
diff --git a/app/views/admin/people/_form.html.haml b/app/views/admin/people/_form.html.haml
new file mode 100644
index 00000000..a4c5d045
--- /dev/null
+++ b/app/views/admin/people/_form.html.haml
@@ -0,0 +1,10 @@
+= semantic_form_for [:admin, @person] do |f|
+ = f.inputs "Basic Information" do
+ = f.input :first_name, :as => :string
+ = f.input :last_name, :as => :string
+ = f.input :public_name, :as => :string
+ = f.input :email
+ = f.input :company, :as => :string
+ = f.input :biography, :input_html => {:rows => 10}
+ = f.actions do
+ = f.action :submit, :button_html => {:class => "btn primary"}
diff --git a/app/views/admin/people/index.html.haml b/app/views/admin/people/index.html.haml
index 5b62382e..b98df39e 100644
--- a/app/views/admin/people/index.html.haml
+++ b/app/views/admin/people/index.html.haml
@@ -1,29 +1,39 @@
-%h2
- People
- - if @people
- = "(#{@people.length})"
-.well
- %table.table.table-striped.table-bordered.table-hover#people
- %thead
- %th
- %b Email
- %th
- %b Last Name
- %th
- %b First Name
- %th
- %b Public Name
- %th
- %b # of Conference Registrations
- %th
- - @people.each do |person|
- %tr
- %td= person.email
- %td= person.last_name
- %td= person.first_name
- %td= person.public_name
- %td= person.registrations.count
- %td= link_to "View", admin_person_path(person)
+.row-fluid
+ .span6
+ %h2
+ People
+ - if @people
+ = "(#{@people.length})"
+ .span6
+ .pull-right{:style=>"margin-top:20px; margin-bottom:20px;"}
+ = link_to "New person", new_admin_person_path, :class => "btn btn-success"
+
+.row-fluid
+ .span12
+ .well
+ %table.table.table-striped.table-bordered.table-hover#people
+ %thead
+ %th
+ %b Email
+ %th
+ %b Last Name
+ %th
+ %b First Name
+ %th
+ %b Public Name
+ %th
+ %b # of Conference Registrations
+ %th
+ %th
+ - @people.each do |person|
+ %tr
+ %td= person.email
+ %td= person.last_name
+ %td= person.first_name
+ %td= person.public_name
+ %td= person.registrations.count
+ %td= link_to "Edit", edit_admin_person_path(person)
+ %td= link_to "View", admin_person_path(person)
:javascript
$(document).ready(function() {
diff --git a/app/views/admin/speakers/_form.html.haml b/app/views/admin/speakers/_form.html.haml
new file mode 100644
index 00000000..56c3b738
--- /dev/null
+++ b/app/views/admin/speakers/_form.html.haml
@@ -0,0 +1,11 @@
+.modal-header
+ %button.close{:type => "button", :data => {:dismiss => "modal"}} ×
+ %h3
+ Assign speaker
+= semantic_form_for @speaker, :as => :speaker, :url => admin_conference_event_speaker_path(@conference.short_title, @event), :method => :put do |f|
+ .form-inputs.form-horizontal.modal-body
+ = f.collection_select(:person_id, Person.order(:public_name), :id, :public_name)
+
+ .modal-footer
+ = link_to "Close", "#", :data => {:dismiss => "modal"}, :class => 'btn'
+ = f.button "Assign", :class => 'btn btn-primary'
diff --git a/app/views/admin/speakers/edit.js.erb b/app/views/admin/speakers/edit.js.erb
new file mode 100644
index 00000000..0c28c11f
--- /dev/null
+++ b/app/views/admin/speakers/edit.js.erb
@@ -0,0 +1,2 @@
+build_dialog('edit_speaker', '<%= j render :partial => 'form' %>');
+
diff --git a/app/views/application/edit.html.haml b/app/views/application/edit.html.haml
new file mode 100644
index 00000000..f3a2592b
--- /dev/null
+++ b/app/views/application/edit.html.haml
@@ -0,0 +1 @@
+= render :partial => "form"
diff --git a/app/views/application/new.html.haml b/app/views/application/new.html.haml
new file mode 100644
index 00000000..f3a2592b
--- /dev/null
+++ b/app/views/application/new.html.haml
@@ -0,0 +1 @@
+= render :partial => "form"
diff --git a/app/views/proposal/show.html.haml b/app/views/proposal/show.html.haml
index 056712f3..f1bd4a28 100644
--- a/app/views/proposal/show.html.haml
+++ b/app/views/proposal/show.html.haml
@@ -38,15 +38,15 @@
.span8
%h3
by
- = @event.submitter.public_name
- - if @event.submitter.company
+ = @speaker.public_name
+ - if @speaker.company
%br
%span.muted
from
- = @event.submitter.company
- -if @event.submitter.biography
- = simple_format(@event.submitter.biography)
+ = @speaker.company
+ -if @speaker.biography
+ = simple_format(@speaker.biography)
.span4
- = image_tag @event.submitter.gravatar_url(:size => 200), :class => "img-rounded pull-right", :style => "margin: 8px;"
+ = image_tag @speaker.gravatar_url(:size => 200), :class => "img-rounded pull-right", :style => "margin: 8px;"
diff --git a/app/views/schedule/index.html.erb b/app/views/schedule/index.html.erb
index 08c1b76d..fb05a202 100644
--- a/app/views/schedule/index.html.erb
+++ b/app/views/schedule/index.html.erb
@@ -44,14 +44,15 @@
class="event" role="button"
data-href="<%= url_for(conference_proposal_path(@conference.short_title, event[0].id)) %>">
- <%= image_tag event[0].submitter.gravatar_url, :class => "img-circle pull-right", :alt => event[0].submitter.public_name, :title => event[0].submitter.public_name, :style => "padding:8px;" %>
+ <%- speaker = event[0].speakers.first || event[0].submitter %>
+ <%= image_tag speaker.gravatar_url, :class => "img-circle pull-right", :alt => speaker.public_name, :title => speaker.public_name, :style => "padding:8px;" %>
<%= event[0].title %>
<% unless event[0].subtitle.empty? %>
<%= event[0].subtitle %>
<% end %>
- <%= event[0].submitter.public_name %>
+ <%= speaker.public_name %>
<% if event[0].track%>
<%= event[0].track.name %>
@@ -112,4 +113,4 @@ $(function() {
hash && $('ul.nav a[href="' + hash + '"]').tab('show');
});
-<% end %>
\ No newline at end of file
+<% end %>
diff --git a/config/routes.rb b/config/routes.rb
index f0221624..4fc2797d 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -34,6 +34,7 @@ Osem::Application.routes.draw do
put :update_state
put :update_track
end
+ resource :speaker, :only => [:edit, :update]
end
resources :supporters
end