Reimplement event editing from the admin interface
This commit is contained in:
parent
e53d4575e6
commit
f6302ea377
|
@ -20,4 +20,11 @@ select.date, select.datetime, select.time {
|
||||||
form .text {
|
form .text {
|
||||||
height: 180px;
|
height: 180px;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.form-horizontal {
|
||||||
|
div.boolean {
|
||||||
|
padding: 10px;
|
||||||
|
@extend .col-sm-offset-3;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -21,9 +21,9 @@ module Management
|
||||||
@conference = find_conference
|
@conference = find_conference
|
||||||
@event = @conference.events.find(params[:id])
|
@event = @conference.events.find(params[:id])
|
||||||
|
|
||||||
if @event.update_attributes(event_params)
|
if @event.update(event_params)
|
||||||
flash[:notice] = 'Event was successfully updated.'
|
flash[:notice] = 'Event was successfully updated.'
|
||||||
redirect_to [:management, @event]
|
redirect_to [:management, @conference, @event]
|
||||||
else
|
else
|
||||||
render action: 'edit'
|
render action: 'edit'
|
||||||
end
|
end
|
||||||
|
@ -45,14 +45,22 @@ module Management
|
||||||
|
|
||||||
def event_params
|
def event_params
|
||||||
params.require(:event).permit(
|
params.require(:event).permit(
|
||||||
:title,
|
:title,
|
||||||
:subtitle,
|
:subtitle,
|
||||||
:length,
|
:length,
|
||||||
:language,
|
:language,
|
||||||
:abstract,
|
:abstract,
|
||||||
:description,
|
:description,
|
||||||
:notes
|
:notes,
|
||||||
)
|
:track_id,
|
||||||
|
:event_type_id,
|
||||||
|
participations_attributes: [
|
||||||
|
:id,
|
||||||
|
:participant_id,
|
||||||
|
:approved,
|
||||||
|
:_destroy
|
||||||
|
]
|
||||||
|
)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -26,6 +26,8 @@ class Event < ActiveRecord::Base
|
||||||
|
|
||||||
delegate :status, to: :proposition
|
delegate :status, to: :proposition
|
||||||
|
|
||||||
|
accepts_nested_attributes_for :participations, allow_destroy: true
|
||||||
|
|
||||||
def all_participants_have_profiles?
|
def all_participants_have_profiles?
|
||||||
participants.all? do |participant|
|
participants.all? do |participant|
|
||||||
participant.personal_profile(conference).present?
|
participant.personal_profile(conference).present?
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
class Participation < ActiveRecord::Base
|
class Participation < ActiveRecord::Base
|
||||||
belongs_to :participant, class_name: User
|
belongs_to :participant, class_name: User
|
||||||
belongs_to :event
|
belongs_to :event
|
||||||
|
validates :participant_id, presence: true
|
||||||
scope :approved, ->() { where approved: true }
|
scope :approved, ->() { where approved: true }
|
||||||
scope :pending, ->() { where.not approved: true }
|
scope :pending, ->() { where.not approved: true }
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,22 +1,31 @@
|
||||||
|
- content_for :title
|
||||||
|
= t('.edit', event_type: @event.event_type.name.mb_chars.downcase, event_title: @event.title)
|
||||||
|
|
||||||
.row
|
.row
|
||||||
|
.col-xs-12
|
||||||
|
h1.page-header
|
||||||
|
= @event.title
|
||||||
|
small<
|
||||||
|
= @event.subtitle
|
||||||
.col-lg-12
|
.col-lg-12
|
||||||
= simple_nested_form_for [:management, @conference, @event], wrapper: :horizontal_form, html: { class: 'form-horizontal' } do |f|
|
= simple_nested_form_for [:management, @conference, @event], wrapper: :horizontal_form, html: { class: 'form-horizontal' } do |f|
|
||||||
.panel.panel-primary
|
= f.input :title
|
||||||
.panel-heading
|
= f.input :subtitle
|
||||||
h1.panel-title
|
= f.association :event_type
|
||||||
= t 'views.user.info'
|
= f.association :track, collection: current_conference.tracks.map { |track| [track.name, track.id, {title: track.description}] }
|
||||||
= link_to icon(:eye), [:management, @conference, @event], class: 'btn btn-xs btn-info pull-right'
|
= f.input :length, hint: t('simple_form.hints.event.length', type: @event.event_type.name.mb_chars.downcase, min: @event.event_type.minimum_length, max: @event.event_type.maximum_length)
|
||||||
|
= f.input :language, collection: locale_collection, include_blank: false
|
||||||
|
= f.input :abstract
|
||||||
|
= f.input :description
|
||||||
|
= f.input :notes
|
||||||
|
hr
|
||||||
|
.row
|
||||||
|
.col-lg-12
|
||||||
|
h2 = Participation.model_name.human(count: 2).mb_chars.capitalize
|
||||||
|
.row
|
||||||
|
= render partial: 'form_participations', locals: {form: f}
|
||||||
|
|
||||||
.panel-body
|
.text-right
|
||||||
.row
|
.btn-group
|
||||||
.col-lg-12
|
= action_buttons(@conference, @event, [:index, :show])
|
||||||
= f.input :title
|
= f.submit class: 'btn btn-warning'
|
||||||
= f.input :subtitle
|
|
||||||
= f.input :length
|
|
||||||
= f.input :language, collection: %w(en bg)
|
|
||||||
= f.input :abstract
|
|
||||||
= f.input :description
|
|
||||||
= f.input :notes
|
|
||||||
|
|
||||||
.panel-footer.text-right
|
|
||||||
= f.submit class: 'btn btn-primary'
|
|
||||||
|
|
|
@ -49,6 +49,9 @@ bg:
|
||||||
title: "Преглед на %{model}"
|
title: "Преглед на %{model}"
|
||||||
activerecord:
|
activerecord:
|
||||||
attributes:
|
attributes:
|
||||||
|
participation:
|
||||||
|
participant: Участник
|
||||||
|
approved: Потвърдено от участника
|
||||||
proposition:
|
proposition:
|
||||||
status: Състояние
|
status: Състояние
|
||||||
statuses:
|
statuses:
|
||||||
|
@ -149,6 +152,9 @@ bg:
|
||||||
volunteer_teams:
|
volunteer_teams:
|
||||||
invalid_volunteer_team: "невалиден екип от доброволци"
|
invalid_volunteer_team: "невалиден екип от доброволци"
|
||||||
models:
|
models:
|
||||||
|
participation:
|
||||||
|
one: Участие
|
||||||
|
other: Участия
|
||||||
volunteership:
|
volunteership:
|
||||||
one: доброволец
|
one: доброволец
|
||||||
other: доброволци
|
other: доброволци
|
||||||
|
|
Loading…
Reference in New Issue