Management interface for Event Suggestions

This commit is contained in:
Petko Bordjukov 2014-09-30 13:34:09 +03:00
parent 2f711637fc
commit 62649edb67
20 changed files with 173 additions and 64 deletions

View File

@ -1,4 +1,4 @@
.user-details { .model-details {
@extend .modal; @extend .modal;
@extend .fade; @extend .fade;
.center { .center {

View File

@ -1,5 +1,6 @@
.record-table { .record-table {
@extend .table; @extend .table;
@extend .table-striped;
td { td {
vertical-align: middle !important; vertical-align: middle !important;
@ -18,17 +19,6 @@
width: 120px; width: 120px;
} }
.picture-placeholder {
@extend .img-thumbnail;
.glyphicon {
width: 50px;
height: 50px;
font-size: 48px;
text-align: center;
}
}
.actions div { .actions div {
@extend .pull-right; @extend .pull-right;
@extend .btn-group; @extend .btn-group;
@ -53,4 +43,20 @@
@extend .btn-primary; @extend .btn-primary;
} }
} }
}
.subtitle {
font-size: 0.9em;
font-style: italic;
}
}
.picture-placeholder {
@extend .img-thumbnail;
.glyphicon {
width: 50px;
height: 50px;
font-size: 48px;
text-align: center;
}
}

View File

@ -5,4 +5,4 @@
@import "font-awesome"; @import "font-awesome";
@import "navbar"; @import "navbar";
@import "record_table"; @import "record_table";
@import "user_details"; @import "model_details";

View File

@ -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

View File

@ -10,6 +10,7 @@ class Conference < ActiveRecord::Base
has_many :tracks, -> { order('id asc') } has_many :tracks, -> { order('id asc') }
has_many :events, through: :tracks has_many :events, through: :tracks
has_many :candidate_speakers, through: :events
scope :future, -> { where('start_date >= ?', Date.today).order('start_date ASC') } scope :future, -> { where('start_date >= ?', Date.today).order('start_date ASC') }

View File

@ -8,7 +8,8 @@ class Event < ActiveRecord::Base
belongs_to :track belongs_to :track
has_one :conference, through: :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 after_create :send_new_event_notification

View File

@ -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

View File

@ -7,6 +7,7 @@ class User < ActiveRecord::Base
has_one :speaker_profile has_one :speaker_profile
has_many :lectures has_many :lectures
has_many :workshops has_many :workshops
has_many :events
accepts_nested_attributes_for :speaker_profile, update_only: true accepts_nested_attributes_for :speaker_profile, update_only: true

View File

@ -20,10 +20,10 @@ html
= link_to 'Clarion', root_path, class: 'navbar-brand' = link_to 'Clarion', root_path, class: 'navbar-brand'
.navbar-collapse.collapse .navbar-collapse.collapse
ul.nav.navbar-nav ul.nav.navbar-nav
li class="#{'active' if controller_name == 'home'}"
= link_to t(:home), management_path
li class="#{'active' if controller_name == 'users'}" li class="#{'active' if controller_name == 'users'}"
= link_to User.model_name.human(count: 2), management_users_path = 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 div.container
== yield == yield
= javascript_include_tag "management/application" = javascript_include_tag "management/application"

View File

@ -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)

View File

@ -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)

View File

@ -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

View File

@ -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');

View File

@ -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-dialog
.modal-content .modal-content
.modal-header .modal-header

View File

@ -1,23 +0,0 @@
<!-- Button trigger modal -->
<button class="btn btn-primary btn-lg" data-toggle="modal" data-target="#myModal">
Launch demo modal
</button>
<!-- Modal -->
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
<h4 class="modal-title" id="myModalLabel">Modal title</h4>
</div>
<div class="modal-body">
...
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
<button type="button" class="btn btn-primary">Save changes</button>
</div>
</div>
</div>
</div>

View File

@ -31,6 +31,9 @@ bg:
workshop: workshop:
one: Уъркшоп one: Уъркшоп
other: Уъркшопи other: Уъркшопи
event:
one: Предложение
other: Предложения
track: Поток от лекции track: Поток от лекции
attributes: attributes:
user: user:
@ -49,7 +52,7 @@ bg:
biography: Биография biography: Биография
github: Github акаунт github: Github акаунт
twitter: Twitter акаунт twitter: Twitter акаунт
lecture: event:
title: Заглавие title: Заглавие
subtitle: Подзаглавие subtitle: Подзаглавие
length: Продължителност length: Продължителност
@ -59,16 +62,7 @@ bg:
notes: Забележки notes: Забележки
track_id: Поток от лекции track_id: Поток от лекции
agreement: Съгласен(на) съм agreement: Съгласен(на) съм
workshop: user: Лектор
title: Заглавие
subtitle: Подзаглавие
length: Продължителност
language: Език
abstract: Резюме
description: Описание
notes: Забележки
track_id: Поток от уъркшопи
agreement: Съгласен(на) съм
errors: errors:
models: models:
user: user:

View File

@ -32,6 +32,9 @@ en:
one: Workshop one: Workshop
other: Workshops other: Workshops
track: track track: track
event:
one: Suggestion
other: Suggestions
attributes: attributes:
user: user:
email: E-mail email: E-mail
@ -49,7 +52,7 @@ en:
biography: Short bography biography: Short bography
github: Github account github: Github account
twitter: Twitter account twitter: Twitter account
lecture: event:
title: Title title: Title
subtitle: Sub-title subtitle: Sub-title
length: Length (should be between 40 and 45 minutes) length: Length (should be between 40 and 45 minutes)
@ -59,16 +62,7 @@ en:
notes: Notes notes: Notes
track: Track track: Track
agreement: I accept agreement: I accept
workshop: user: Speaker
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
errors: errors:
models: models:
user: user:

View File

@ -66,3 +66,5 @@ bg:
logout: Изход logout: Изход
of_motto: да споделим свободата of_motto: да споделим свободата
meta_data: "Език: %{language}, поток: „%{track}“, продължителност: %{length} мин."

View File

@ -65,3 +65,4 @@ en:
logout: Logout logout: Logout
of_motto: share the freedom of_motto: share the freedom
meta_data: "Language: %{language}, track: \"%{track}\", length: %{length} min."

View File

@ -5,12 +5,15 @@ Rails.application.routes.draw do
devise_for :users, controllers: {registrations: 'registrations', sessions: 'sessions'} devise_for :users, controllers: {registrations: 'registrations', sessions: 'sessions'}
namespace :management do namespace :management do
get '/', to: 'home#index' get '/', to: 'events#index'
resources :users do resources :users do
member do member do
post 'toggle_admin' post 'toggle_admin'
end end
end end
resources :events
end end
root 'home#index' root 'home#index'