Event status management
This commit is contained in:
parent
60d84ffc7c
commit
646d61bb22
|
@ -2,7 +2,7 @@ module Management
|
|||
class EventsController < ManagementController
|
||||
def index
|
||||
@conference = find_conference
|
||||
@events = @conference.events.approved
|
||||
@events = @conference.events.order(:title)
|
||||
end
|
||||
|
||||
def show
|
||||
|
|
|
@ -5,8 +5,20 @@ module Management
|
|||
@events_by_proposer = @conference.events.undecided.group_by(&:proposer)
|
||||
end
|
||||
|
||||
def update
|
||||
@proposition = Proposition.find(params[:id])
|
||||
|
||||
@proposition.update(proposition_params)
|
||||
|
||||
redirect_to :back
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def proposition_params
|
||||
params.require(:proposition).permit(:status)
|
||||
end
|
||||
|
||||
def find_conference
|
||||
Conference.find(params[:conference_id])
|
||||
end
|
||||
|
|
|
@ -5,6 +5,34 @@ module ApplicationHelper
|
|||
end
|
||||
end
|
||||
|
||||
def proposition_status_class(status)
|
||||
{
|
||||
"undecided" => "default",
|
||||
"approved" => "info",
|
||||
"rejected" => "danger",
|
||||
"backup" => "warning"
|
||||
}.with_indifferent_access[status]
|
||||
end
|
||||
|
||||
def proposition_status_glyph(status)
|
||||
{
|
||||
"undecided" => "question",
|
||||
"approved" => "thumbs-up",
|
||||
"rejected" => "thumbs-down",
|
||||
"backup" => "refresh"
|
||||
}.with_indifferent_access[status]
|
||||
end
|
||||
|
||||
def proposition_status_icon(status)
|
||||
icon(proposition_status_glyph(status))
|
||||
end
|
||||
|
||||
def proposition_status(record)
|
||||
klass = record.class
|
||||
output = ''
|
||||
|
||||
end
|
||||
|
||||
def action_buttons(conference, record, actions = [:index, :show, :edit, :destroy])
|
||||
klass = record.class
|
||||
output = ''
|
||||
|
@ -34,7 +62,7 @@ module ApplicationHelper
|
|||
output += link_to(icon(:trash), [:management, conference, record], {
|
||||
method: :delete,
|
||||
data: {confirm: t('actions.are_you_sure')},
|
||||
title: t('actions.edit.button', model: klass.model_name.human),
|
||||
title: t('actions.destroy.button', model: klass.model_name.human),
|
||||
class: 'btn btn-danger'
|
||||
})
|
||||
end
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
module EventsHelper
|
||||
def participant_names_or_emails(event)
|
||||
event.participants.map do |participant|
|
||||
participant.try(:personal_profile, current_conference).try(:name) ||
|
||||
participant.personal_profiles.last.try(:name) ||
|
||||
participant.email
|
||||
end
|
||||
end
|
||||
end
|
|
@ -26,6 +26,8 @@ class Event < ActiveRecord::Base
|
|||
|
||||
scope :confirmed, -> { where.not confirmed_at: nil }
|
||||
|
||||
delegate :status, to: :proposition
|
||||
|
||||
def proposer_profile
|
||||
proposer.personal_profile(conference)
|
||||
end
|
||||
|
|
|
@ -0,0 +1,29 @@
|
|||
tr
|
||||
td
|
||||
= event.title
|
||||
- if event.subtitle.present?
|
||||
br
|
||||
span.small = event.subtitle
|
||||
td
|
||||
= participant_names_or_emails(event).join(', ')
|
||||
td
|
||||
= t("locales.#{event.language}")
|
||||
td
|
||||
= event.track.name
|
||||
td
|
||||
= event.event_type.name
|
||||
td.action
|
||||
.dropdown
|
||||
button class="btn btn-sm dropdown-toggle btn-#{proposition_status_class(event.status)}" type="button" data-toggle="dropdown" title="#{t "status.#{event.status}"}"
|
||||
= icon(proposition_status_glyph(event.status))
|
||||
span.caret<
|
||||
ul.dropdown-menu
|
||||
- Proposition.statuses.each do |(status, _)|
|
||||
- next if status == event.status
|
||||
li
|
||||
= link_to [:management, @conference, event.proposition, proposition: {status: status}], method: :patch do
|
||||
= proposition_status_icon(status)
|
||||
=< t "status.#{status}"
|
||||
td.actions
|
||||
.btn-group.btn-group-sm
|
||||
= action_buttons(@conference, event, [:show, :edit])
|
|
@ -1,36 +1,18 @@
|
|||
.row
|
||||
.col-lg-12
|
||||
.panel.panel-default
|
||||
.panel-heading
|
||||
h2.panel-title= Event.model_name.human(count: 2).mb_chars.capitalize
|
||||
|
||||
.panel-body
|
||||
table.table.table-striped.table-hover.record-table
|
||||
thead
|
||||
tr
|
||||
th = Event.human_attribute_name :title
|
||||
th = Event.human_attribute_name :subtitle
|
||||
th = Event.human_attribute_name :user
|
||||
th = Event.human_attribute_name :length
|
||||
th = Event.human_attribute_name :language
|
||||
th.actions
|
||||
tbody
|
||||
- @events.each do |event|
|
||||
- proposer = event.proposer
|
||||
- proposer_profile = event.proposer_profile
|
||||
|
||||
tr
|
||||
td= event.title
|
||||
td= event.subtitle
|
||||
td
|
||||
- if proposer_profile
|
||||
= link_to proposer_profile.name, [:management, @conference, proposer_profile]
|
||||
- else
|
||||
| No profile for user #{proposer.email}
|
||||
|
||||
td #{event.length} minutes
|
||||
td= event.language
|
||||
|
||||
td.actions
|
||||
div.btn-group.btn-group-sm
|
||||
= action_buttons(@conference, event, [:show, :edit, :destroy])
|
||||
h1.page-header
|
||||
= Event.model_name.human(count: 2).mb_chars.titleize
|
||||
.row
|
||||
.panel.panel-default
|
||||
table.table
|
||||
thead
|
||||
tr
|
||||
th = Event.human_attribute_name(:title)
|
||||
th = Event.human_attribute_name(:user)
|
||||
th = Event.human_attribute_name(:language)
|
||||
th = Track.model_name.human
|
||||
th = Event.human_attribute_name(:type)
|
||||
th.action
|
||||
= Event.human_attribute_name(:status)
|
||||
th.actions
|
||||
tbody
|
||||
= render partial: 'event', collection: @events
|
||||
|
|
|
@ -3,3 +3,8 @@ bg:
|
|||
view: Преглед
|
||||
home: Начало
|
||||
more_about_user: "Повече информация за %{user}"
|
||||
status:
|
||||
undecided: Неопределен
|
||||
approved: Одобрен
|
||||
rejected: Отхвърлен
|
||||
backup: Резерва
|
|
@ -2,3 +2,8 @@ en:
|
|||
are_you_sure: Are you sure?
|
||||
view: View
|
||||
home: Home
|
||||
status:
|
||||
undecided: Undecided
|
||||
approved: Approved
|
||||
rejected: Rejected
|
||||
backup: Back-up
|
Loading…
Reference in New Issue