Event editing

This commit is contained in:
Petko Bordjukov 2015-08-15 08:52:41 +03:00
parent ca8a655731
commit 59c9f79d13
9 changed files with 70 additions and 36 deletions

View File

@ -3,6 +3,11 @@ module Public
before_filter :authenticate_user!
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
def new
@ -17,12 +22,24 @@ module Public
@event.participations.build participant: current_user, approved: true
if @event.save
flash[:notice] = I18n.t('views.events.event_successfully_created', event_type: @event.event_type.name.mb_chars.downcase)
after_save_redirect
else
render action: :new
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
def event_params
@ -35,7 +52,7 @@ module Public
def after_save_redirect
if current_user.personal_profile(current_conference).present?
redirect_to root_path
redirect_to events_path
else
redirect_to edit_personal_profile_path, alert: I18n.t(:please_fill_in_your_speaker_profile)
end

View File

@ -7,7 +7,8 @@ class User < ActiveRecord::Base
has_many :personal_profiles, dependent: :destroy
has_many :lectures
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 = {})
current_profile = personal_profile(conference)

View File

@ -9,10 +9,16 @@ bg:
submit_event: "Предложи %{event_type}"
navigation:
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} - зов за лектори"
what_we_ask: 'Бихме искали да получим предложенията Ви за лекции и уъркшопи, принадлежащи към следните категории до 30 септември 2015г.:'
license_notice: 'Имайте предвид, че презентациите ви впоследствие ще бъдат публикувани с лиценз CC-BY-ND (Creative Commons Attribution No derivatives).'
submit_event: Предложи %{event_type}
resend_instructions_header: Повторно изпращане на инструкции за потвърждаване на акаунт
resend_instructions_btn: Изпрати отново инструкциите

View File

@ -25,3 +25,7 @@ footer {
height: 120px;
background-color: white;
}
.my_submissions {
font-size: 1.7em;
}

View File

@ -0,0 +1,5 @@
li = link_to edit_event_path(event) do
=> event.event_type.name
| &quot;
= event.title
| &quot;

View File

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

View File

@ -0,0 +1,3 @@
h2= t('views.events.edit_event', event_type: @event.event_type.name.mb_chars.downcase, title: @event.title)
= render 'form'

View File

@ -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
p = t :what_we_ask
ul
= render partial: 'track', collection: current_conference.tracks
p = t :license_notice
ul.my_submissions
- if @events.any?
= render @events
- else
li = t 'views.events.no_events'
- if current_conference.call_for_participation.in_progress?
.centered.large
= render partial: 'event_type', collection: current_conference.event_types
= render partial: '/public/home/event_type', collection: current_conference.event_types

View File

@ -1,24 +1,3 @@
= simple_form_for @event, wrapper: :default do |form|
= form.input :event_type_id, as: :hidden, wrapper: false
h2= t('views.events.submit_event', event_type: @event.event_type.name.mb_chars.downcase)
h2= t('submit_event', event_type: @event.event_type.name)
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
= render 'form'