Event editing
This commit is contained in:
parent
ca8a655731
commit
59c9f79d13
|
@ -3,6 +3,11 @@ module Public
|
||||||
before_filter :authenticate_user!
|
before_filter :authenticate_user!
|
||||||
|
|
||||||
def index
|
def index
|
||||||
|
@events = Event.joins(:proposition, :participations).where('propositions.proposer_id = ? OR participations.participant_id = ?', current_user.id, current_user.id)
|
||||||
|
end
|
||||||
|
|
||||||
|
def edit
|
||||||
|
@event = current_user.events.find(params[:id])
|
||||||
end
|
end
|
||||||
|
|
||||||
def new
|
def new
|
||||||
|
@ -17,12 +22,24 @@ module Public
|
||||||
@event.participations.build participant: current_user, approved: true
|
@event.participations.build participant: current_user, approved: true
|
||||||
|
|
||||||
if @event.save
|
if @event.save
|
||||||
|
flash[:notice] = I18n.t('views.events.event_successfully_created', event_type: @event.event_type.name.mb_chars.downcase)
|
||||||
after_save_redirect
|
after_save_redirect
|
||||||
else
|
else
|
||||||
render action: :new
|
render action: :new
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def update
|
||||||
|
@event = current_user.events.find(params[:id])
|
||||||
|
|
||||||
|
if @event.update(event_params)
|
||||||
|
flash[:notice] = I18n.t('views.events.event_successfully_updated', event_type: @event.event_type.name.mb_chars.downcase)
|
||||||
|
after_save_redirect
|
||||||
|
else
|
||||||
|
render action: :edit
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def event_params
|
def event_params
|
||||||
|
@ -35,7 +52,7 @@ module Public
|
||||||
|
|
||||||
def after_save_redirect
|
def after_save_redirect
|
||||||
if current_user.personal_profile(current_conference).present?
|
if current_user.personal_profile(current_conference).present?
|
||||||
redirect_to root_path
|
redirect_to events_path
|
||||||
else
|
else
|
||||||
redirect_to edit_personal_profile_path, alert: I18n.t(:please_fill_in_your_speaker_profile)
|
redirect_to edit_personal_profile_path, alert: I18n.t(:please_fill_in_your_speaker_profile)
|
||||||
end
|
end
|
||||||
|
|
|
@ -7,7 +7,8 @@ class User < ActiveRecord::Base
|
||||||
has_many :personal_profiles, dependent: :destroy
|
has_many :personal_profiles, dependent: :destroy
|
||||||
has_many :lectures
|
has_many :lectures
|
||||||
has_many :workshops
|
has_many :workshops
|
||||||
has_many :events
|
has_many :propositions, foreign_key: :proposer_id
|
||||||
|
has_many :events, through: :propositions, source: :proposable, source_type: 'Event'
|
||||||
|
|
||||||
def find_or_build_personal_profile(conference, params = {})
|
def find_or_build_personal_profile(conference, params = {})
|
||||||
current_profile = personal_profile(conference)
|
current_profile = personal_profile(conference)
|
||||||
|
|
|
@ -9,10 +9,16 @@ bg:
|
||||||
submit_event: "Предложи %{event_type}"
|
submit_event: "Предложи %{event_type}"
|
||||||
navigation:
|
navigation:
|
||||||
my_submissions: "Моите предложения"
|
my_submissions: "Моите предложения"
|
||||||
|
events:
|
||||||
|
no_events: Все още не сте предложили събитие
|
||||||
|
event_successfully_created: "Предложението Ви за %{event_type} беше създадено успешно"
|
||||||
|
event_successfully_updated: "Предложението Ви за %{event_type} беше обновено успешно"
|
||||||
|
submit_event: "Предлагане на %{event_type}"
|
||||||
|
edit_event: "Редактиране на %{event_type} %{title}"
|
||||||
|
|
||||||
home_title: "%{conference} - зов за лектори"
|
home_title: "%{conference} - зов за лектори"
|
||||||
what_we_ask: 'Бихме искали да получим предложенията Ви за лекции и уъркшопи, принадлежащи към следните категории до 30 септември 2015г.:'
|
what_we_ask: 'Бихме искали да получим предложенията Ви за лекции и уъркшопи, принадлежащи към следните категории до 30 септември 2015г.:'
|
||||||
license_notice: 'Имайте предвид, че презентациите ви впоследствие ще бъдат публикувани с лиценз CC-BY-ND (Creative Commons – Attribution – No derivatives).'
|
license_notice: 'Имайте предвид, че презентациите ви впоследствие ще бъдат публикувани с лиценз CC-BY-ND (Creative Commons – Attribution – No derivatives).'
|
||||||
submit_event: Предложи %{event_type}
|
|
||||||
resend_instructions_header: Повторно изпращане на инструкции за потвърждаване на акаунт
|
resend_instructions_header: Повторно изпращане на инструкции за потвърждаване на акаунт
|
||||||
resend_instructions_btn: Изпрати отново инструкциите
|
resend_instructions_btn: Изпрати отново инструкциите
|
||||||
|
|
||||||
|
|
|
@ -25,3 +25,7 @@ footer {
|
||||||
height: 120px;
|
height: 120px;
|
||||||
background-color: white;
|
background-color: white;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.my_submissions {
|
||||||
|
font-size: 1.7em;
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
li = link_to edit_event_path(event) do
|
||||||
|
=> event.event_type.name
|
||||||
|
| "
|
||||||
|
= event.title
|
||||||
|
| "
|
|
@ -0,0 +1,22 @@
|
||||||
|
= simple_form_for @event, wrapper: :default do |form|
|
||||||
|
= form.input :event_type_id, as: :hidden, wrapper: false
|
||||||
|
|
||||||
|
p
|
||||||
|
= form.error_notification
|
||||||
|
|
||||||
|
.form-inputs
|
||||||
|
= form.input :title, autofocus: true
|
||||||
|
= form.input :subtitle
|
||||||
|
= form.association :track, wrapper: :default, collection: current_conference.tracks
|
||||||
|
|
||||||
|
-# TODO length is different for different types of events (translation problem)
|
||||||
|
= form.input :length
|
||||||
|
|
||||||
|
= form.input :language, as: :radio_buttons, collection: locale_collection, include_blank: false, wrapper: :default, checked: current_user.language
|
||||||
|
= form.input :abstract
|
||||||
|
= form.input :description
|
||||||
|
= form.input :notes
|
||||||
|
|
||||||
|
= form.input :agreement, as: :boolean, wrapper: :default
|
||||||
|
|
||||||
|
= form.button :submit
|
|
@ -0,0 +1,3 @@
|
||||||
|
h2= t('views.events.edit_event', event_type: @event.event_type.name.mb_chars.downcase, title: @event.title)
|
||||||
|
|
||||||
|
= render 'form'
|
|
@ -1,14 +1,11 @@
|
||||||
h1.entry-title = t :home_title, conference: current_conference.title
|
h1.entry-title = t 'views.navigation.my_submissions'
|
||||||
|
|
||||||
= simple_format current_conference.description
|
ul.my_submissions
|
||||||
|
- if @events.any?
|
||||||
p = t :what_we_ask
|
= render @events
|
||||||
|
- else
|
||||||
ul
|
li = t 'views.events.no_events'
|
||||||
= render partial: 'track', collection: current_conference.tracks
|
|
||||||
|
|
||||||
p = t :license_notice
|
|
||||||
|
|
||||||
- if current_conference.call_for_participation.in_progress?
|
- if current_conference.call_for_participation.in_progress?
|
||||||
.centered.large
|
.centered.large
|
||||||
= render partial: 'event_type', collection: current_conference.event_types
|
= render partial: '/public/home/event_type', collection: current_conference.event_types
|
||||||
|
|
|
@ -1,24 +1,3 @@
|
||||||
= simple_form_for @event, wrapper: :default do |form|
|
h2= t('views.events.submit_event', event_type: @event.event_type.name.mb_chars.downcase)
|
||||||
= form.input :event_type_id, as: :hidden, wrapper: false
|
|
||||||
|
|
||||||
h2= t('submit_event', event_type: @event.event_type.name)
|
= render 'form'
|
||||||
|
|
||||||
p
|
|
||||||
= form.error_notification
|
|
||||||
|
|
||||||
.form-inputs
|
|
||||||
= form.input :title, autofocus: true
|
|
||||||
= form.input :subtitle
|
|
||||||
= form.association :track, wrapper: :default, collection: current_conference.tracks
|
|
||||||
|
|
||||||
-# TODO length is different for different types of events (translation problem)
|
|
||||||
= form.input :length
|
|
||||||
|
|
||||||
= form.input :language, as: :radio_buttons, collection: locale_collection, include_blank: false, wrapper: :default, checked: current_user.language
|
|
||||||
= form.input :abstract
|
|
||||||
= form.input :description
|
|
||||||
= form.input :notes
|
|
||||||
|
|
||||||
= form.input :agreement, as: :boolean, wrapper: :default
|
|
||||||
|
|
||||||
= form.button :submit
|
|
||||||
|
|
Loading…
Reference in New Issue