diff --git a/app/controllers/public/events_controller.rb b/app/controllers/public/events_controller.rb index 2262080..2928599 100644 --- a/app/controllers/public/events_controller.rb +++ b/app/controllers/public/events_controller.rb @@ -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 diff --git a/app/models/user.rb b/app/models/user.rb index f39b91b..a9cddd1 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -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) diff --git a/config/locales/views.bg.yml b/config/locales/views.bg.yml index 11c0eb8..8636ddd 100644 --- a/config/locales/views.bg.yml +++ b/config/locales/views.bg.yml @@ -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: Изпрати отново инструкциите diff --git a/lib/initfest/assets/stylesheets/initfest/application.scss b/lib/initfest/assets/stylesheets/initfest/application.scss index 16c6336..11a481a 100644 --- a/lib/initfest/assets/stylesheets/initfest/application.scss +++ b/lib/initfest/assets/stylesheets/initfest/application.scss @@ -25,3 +25,7 @@ footer { height: 120px; background-color: white; } + +.my_submissions { + font-size: 1.7em; +} diff --git a/lib/initfest/views/public/events/_event.slim b/lib/initfest/views/public/events/_event.slim new file mode 100644 index 0000000..c8964ff --- /dev/null +++ b/lib/initfest/views/public/events/_event.slim @@ -0,0 +1,5 @@ +li = link_to edit_event_path(event) do + => event.event_type.name + | " + = event.title + | " diff --git a/lib/initfest/views/public/events/_form.slim b/lib/initfest/views/public/events/_form.slim new file mode 100644 index 0000000..28d1822 --- /dev/null +++ b/lib/initfest/views/public/events/_form.slim @@ -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 diff --git a/lib/initfest/views/public/events/edit.slim b/lib/initfest/views/public/events/edit.slim new file mode 100644 index 0000000..494bc75 --- /dev/null +++ b/lib/initfest/views/public/events/edit.slim @@ -0,0 +1,3 @@ +h2= t('views.events.edit_event', event_type: @event.event_type.name.mb_chars.downcase, title: @event.title) + += render 'form' diff --git a/lib/initfest/views/public/events/index.slim b/lib/initfest/views/public/events/index.slim index a3222a3..112c5c3 100644 --- a/lib/initfest/views/public/events/index.slim +++ b/lib/initfest/views/public/events/index.slim @@ -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 diff --git a/lib/initfest/views/public/events/new.slim b/lib/initfest/views/public/events/new.slim index 6446c7b..ce047f3 100644 --- a/lib/initfest/views/public/events/new.slim +++ b/lib/initfest/views/public/events/new.slim @@ -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'