diff --git a/app/assets/stylesheets/management/_user_details.css.scss b/app/assets/stylesheets/management/_model_details.css.scss similarity index 95% rename from app/assets/stylesheets/management/_user_details.css.scss rename to app/assets/stylesheets/management/_model_details.css.scss index 9da4982..5f11cae 100644 --- a/app/assets/stylesheets/management/_user_details.css.scss +++ b/app/assets/stylesheets/management/_model_details.css.scss @@ -1,4 +1,4 @@ -.user-details { +.model-details { @extend .modal; @extend .fade; .center { diff --git a/app/assets/stylesheets/management/_record_table.css.scss b/app/assets/stylesheets/management/_record_table.css.scss index b87db34..4efd78e 100644 --- a/app/assets/stylesheets/management/_record_table.css.scss +++ b/app/assets/stylesheets/management/_record_table.css.scss @@ -1,5 +1,6 @@ .record-table { @extend .table; + @extend .table-striped; td { vertical-align: middle !important; @@ -18,17 +19,6 @@ width: 120px; } - .picture-placeholder { - @extend .img-thumbnail; - - .glyphicon { - width: 50px; - height: 50px; - font-size: 48px; - text-align: center; - } - } - .actions div { @extend .pull-right; @extend .btn-group; @@ -53,4 +43,20 @@ @extend .btn-primary; } } -} \ No newline at end of file + + .subtitle { + font-size: 0.9em; + font-style: italic; + } +} + +.picture-placeholder { + @extend .img-thumbnail; + + .glyphicon { + width: 50px; + height: 50px; + font-size: 48px; + text-align: center; + } +} diff --git a/app/assets/stylesheets/management/application.css.scss b/app/assets/stylesheets/management/application.css.scss index ce3bd28..6d33057 100644 --- a/app/assets/stylesheets/management/application.css.scss +++ b/app/assets/stylesheets/management/application.css.scss @@ -5,4 +5,4 @@ @import "font-awesome"; @import "navbar"; @import "record_table"; -@import "user_details"; \ No newline at end of file +@import "model_details"; \ No newline at end of file diff --git a/app/controllers/management/events_controller.rb b/app/controllers/management/events_controller.rb new file mode 100644 index 0000000..36fb081 --- /dev/null +++ b/app/controllers/management/events_controller.rb @@ -0,0 +1,18 @@ +module Management + class EventsController < ManagementController + before_action :assign_suggestion, only: [:show] + + def index + @suggestion_groups = SuggestionGroup.for_conference Conference.current + end + + def show + end + + private + + def assign_suggestion + @suggestion = Event.find params[:id] + end + end +end diff --git a/app/models/conference.rb b/app/models/conference.rb index d93d3f3..224a408 100644 --- a/app/models/conference.rb +++ b/app/models/conference.rb @@ -10,6 +10,7 @@ class Conference < ActiveRecord::Base has_many :tracks, -> { order('id asc') } has_many :events, through: :tracks + has_many :candidate_speakers, through: :events scope :future, -> { where('start_date >= ?', Date.today).order('start_date ASC') } diff --git a/app/models/event.rb b/app/models/event.rb index 80460aa..7693a0f 100644 --- a/app/models/event.rb +++ b/app/models/event.rb @@ -8,7 +8,8 @@ class Event < ActiveRecord::Base belongs_to :track has_one :conference, through: :track - belongs_to :user + belongs_to :user # XXX: Transition to candidate_speaker + belongs_to :candidate_speaker, class_name: 'User', foreign_key: 'user_id' after_create :send_new_event_notification diff --git a/app/models/suggestion_group.rb b/app/models/suggestion_group.rb new file mode 100644 index 0000000..8d09f16 --- /dev/null +++ b/app/models/suggestion_group.rb @@ -0,0 +1,14 @@ +class SuggestionGroup + include ActiveModel::Model + attr_accessor :speaker, :suggestions + + def self.where(conditions = {}) + Event.joins(:track).includes(:user).where(conditions).group_by(&:user).map do |speaker, suggestions| + SuggestionGroup.new speaker: speaker, suggestions: suggestions + end + end + + def self.for_conference(conference) + where tracks: {conference_id: conference.id} + end +end diff --git a/app/models/user.rb b/app/models/user.rb index b910966..0ecaa45 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -7,6 +7,7 @@ class User < ActiveRecord::Base has_one :speaker_profile has_many :lectures has_many :workshops + has_many :events accepts_nested_attributes_for :speaker_profile, update_only: true diff --git a/app/views/layouts/management.html.slim b/app/views/layouts/management.html.slim index 99d5d8c..da5f01f 100644 --- a/app/views/layouts/management.html.slim +++ b/app/views/layouts/management.html.slim @@ -20,10 +20,10 @@ html = link_to 'Clarion', root_path, class: 'navbar-brand' .navbar-collapse.collapse ul.nav.navbar-nav - li class="#{'active' if controller_name == 'home'}" - = link_to t(:home), management_path li class="#{'active' if controller_name == 'users'}" = link_to User.model_name.human(count: 2), management_users_path + li class="#{'active' if controller_name == 'events'}" + = link_to Event.model_name.human(count: 2), management_events_path div.container == yield = javascript_include_tag "management/application" diff --git a/app/views/management/events/_suggestion_details.html.slim b/app/views/management/events/_suggestion_details.html.slim new file mode 100644 index 0000000..204ade7 --- /dev/null +++ b/app/views/management/events/_suggestion_details.html.slim @@ -0,0 +1,54 @@ +.model-details id="suggestion-#{@suggestion.id}-details" tabindex="-1" role="dialog" aria-hidden="true" + .modal-dialog + .modal-content + .modal-header + button type="button" class="close" data-dismiss="modal" aria-hidden="true" + h4.modal-title + = @suggestion.title + small< + = @suggestion.subtitle + br + = t :meta_data, language: @suggestion.language, track: @suggestion.track.name, length: @suggestion.length + + .modal-body + .center + h4 = @suggestion.class.human_attribute_name(:user) + - unless @suggestion.user.speaker_profile.present? + div.picture-placeholder + = glyph(:user) + h3.media-heading + = @suggestion.user.email + + - else + = image_tag @suggestion.user.speaker_profile.picture.medium.url, class: "profile-image" + h3.media-heading + = @suggestion.user.speaker_profile.name + - if @suggestion.user.speaker_profile.organisation.present? + div + => fa_icon(:briefcase) + = @suggestion.user.speaker_profile.organisation + + div.social + = link_to "mailto://#{@suggestion.user.email}" + = fa_icon :envelope + - if @suggestion.user.speaker_profile.github.present? + = link_to "https://github.com/#{@suggestion.user.speaker_profile.github}" + = fa_icon :github + - if @suggestion.user.speaker_profile.twitter.present? + = link_to "https://twitter.com/#{@suggestion.user.speaker_profile.twitter}" + = fa_icon :twitter + + h4 = @suggestion.class.human_attribute_name(:abstract) + = simple_format @suggestion.abstract + + h4 = @suggestion.class.human_attribute_name(:description) + = simple_format @suggestion.description + + + - if @suggestion.notes.present? + h4 = @suggestion.class.human_attribute_name(:notes) + = simple_format @suggestion.notes + + .modal-footer + button type="button" class="btn btn-default" data-dismiss="modal" + = t(:close) diff --git a/app/views/management/events/_suggestion_group.html.slim b/app/views/management/events/_suggestion_group.html.slim new file mode 100644 index 0000000..fccc257 --- /dev/null +++ b/app/views/management/events/_suggestion_group.html.slim @@ -0,0 +1,27 @@ +- suggestion_group.suggestions.each_with_index do |suggestion, index| + tr + - if index == 0 + td.picture rowspan="#{suggestion_group.suggestions.count}" + - if suggestion_group.speaker.speaker_profile.present? + = link_to management_user_path(suggestion_group.speaker), remote: true + = image_tag suggestion_group.speaker.speaker_profile.picture.thumb.url, class: 'img-thumbnail' + br + = suggestion_group.speaker.speaker_profile.name + - else + .picture-placeholder + = glyph(:user) + = suggestion_group.speaker.email + + td + span.title + = link_to management_event_path(suggestion), title: t(:view), remote: true + = suggestion.title + br + span.subtitle + = suggestion.subtitle + td = suggestion.track.name + td = suggestion.class.model_name.human + td.actions + div + = link_to management_event_path(suggestion), title: t(:view), remote: true + = glyph(:share) diff --git a/app/views/management/events/index.html.slim b/app/views/management/events/index.html.slim new file mode 100644 index 0000000..f13c734 --- /dev/null +++ b/app/views/management/events/index.html.slim @@ -0,0 +1,11 @@ +.row + table.record-table + thead + tr + th.picture = Event.human_attribute_name(:user) + th = Event.human_attribute_name(:title) + th = Track.model_name.human + th = Event.human_attribute_name(:type) + th.actions + tbody + = render partial: 'suggestion_group', collection: @suggestion_groups diff --git a/app/views/management/events/show.js.erb b/app/views/management/events/show.js.erb new file mode 100644 index 0000000..6a007da --- /dev/null +++ b/app/views/management/events/show.js.erb @@ -0,0 +1,5 @@ +$('body').append('<%= j render 'suggestion_details' %>'); +$('#suggestion-<%= @suggestion.id %>-details').on('hidden.bs.modal', function () { + $(this).remove(); +}); +$('#suggestion-<%= @suggestion.id %>-details').modal('show'); diff --git a/app/views/management/users/_about_user.html.slim b/app/views/management/users/_about_user.html.slim index 2bc8704..a10ede9 100644 --- a/app/views/management/users/_about_user.html.slim +++ b/app/views/management/users/_about_user.html.slim @@ -1,4 +1,4 @@ -.user-details id="about-user-#{@user.id}" tabindex="-1" role="dialog" aria-hidden="true" +.model-details id="about-user-#{@user.id}" tabindex="-1" role="dialog" aria-hidden="true" .modal-dialog .modal-content .modal-header diff --git a/app/views/management/users/_modal_test.html.erb b/app/views/management/users/_modal_test.html.erb deleted file mode 100644 index 0ecac57..0000000 --- a/app/views/management/users/_modal_test.html.erb +++ /dev/null @@ -1,23 +0,0 @@ - - - - -
diff --git a/config/locales/bg.yml b/config/locales/bg.yml index 58f9c63..e50a402 100644 --- a/config/locales/bg.yml +++ b/config/locales/bg.yml @@ -31,6 +31,9 @@ bg: workshop: one: Уъркшоп other: Уъркшопи + event: + one: Предложение + other: Предложения track: Поток от лекции attributes: user: @@ -49,7 +52,7 @@ bg: biography: Биография github: Github акаунт twitter: Twitter акаунт - lecture: + event: title: Заглавие subtitle: Подзаглавие length: Продължителност @@ -59,16 +62,7 @@ bg: notes: Забележки track_id: Поток от лекции agreement: Съгласен(на) съм - workshop: - title: Заглавие - subtitle: Подзаглавие - length: Продължителност - language: Език - abstract: Резюме - description: Описание - notes: Забележки - track_id: Поток от уъркшопи - agreement: Съгласен(на) съм + user: Лектор errors: models: user: diff --git a/config/locales/en.yml b/config/locales/en.yml index 71ef1cf..ad0d7ca 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -32,6 +32,9 @@ en: one: Workshop other: Workshops track: track + event: + one: Suggestion + other: Suggestions attributes: user: email: E-mail @@ -49,7 +52,7 @@ en: biography: Short bography github: Github account twitter: Twitter account - lecture: + event: title: Title subtitle: Sub-title length: Length (should be between 40 and 45 minutes) @@ -59,16 +62,7 @@ en: notes: Notes track: Track agreement: I accept - workshop: - title: Title - subtitle: Sub-title - length: Length (should be between 30 and 120 minutes) - language: Language - abstract: Abstract (one paragraph) - description: Description (3-4 paragraphs) - notes: Notes - track: Track - agreement: I accept + user: Speaker errors: models: user: diff --git a/config/locales/views.bg.yml b/config/locales/views.bg.yml index 598f2c7..a025e6c 100644 --- a/config/locales/views.bg.yml +++ b/config/locales/views.bg.yml @@ -66,3 +66,5 @@ bg: logout: Изход of_motto: да споделим свободата + + meta_data: "Език: %{language}, поток: „%{track}“, продължителност: %{length} мин." \ No newline at end of file diff --git a/config/locales/views.en.yml b/config/locales/views.en.yml index 51a15af..26b7360 100644 --- a/config/locales/views.en.yml +++ b/config/locales/views.en.yml @@ -65,3 +65,4 @@ en: logout: Logout of_motto: share the freedom + meta_data: "Language: %{language}, track: \"%{track}\", length: %{length} min." \ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index 91f348c..3057924 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -5,12 +5,15 @@ Rails.application.routes.draw do devise_for :users, controllers: {registrations: 'registrations', sessions: 'sessions'} namespace :management do - get '/', to: 'home#index' + get '/', to: 'events#index' + resources :users do member do post 'toggle_admin' end end + + resources :events end root 'home#index'