Implement missing event submission functionality
This commit is contained in:
parent
d279ab6f0d
commit
9c607b6ccd
|
@ -11,15 +11,28 @@ class Event < ActiveRecord::Base
|
|||
|
||||
belongs_to :event_type
|
||||
|
||||
validates :conference, presence: true
|
||||
validates :title, presence: true
|
||||
validates :length, presence: true, numericality: {only_integer: true, greater_than: 0}
|
||||
validates :abstract, presence: true
|
||||
validates :description, presence: true
|
||||
validates :agreement, acceptance: true
|
||||
validates :track, presence: true
|
||||
validate :track_belongs_to_the_selected_conference
|
||||
validates :language, inclusion: {in: I18n.available_locales.map(&:to_s)}, presence: true
|
||||
|
||||
|
||||
scope :confirmed, -> { where.not confirmed_at: nil }
|
||||
|
||||
def proposer_profile
|
||||
proposer.personal_profile(conference)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def track_belongs_to_the_selected_conference
|
||||
unless conference.present? and conference.tracks.include?(track)
|
||||
errors.add :track, :must_be_a_valid_track
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -136,7 +136,7 @@ bg:
|
|||
abstract: Резюме
|
||||
description: Описание
|
||||
notes: Забележки
|
||||
track_id: Поток от лекции
|
||||
track: Поток от лекции
|
||||
agreement: Съгласен(на) съм
|
||||
user: Лектор
|
||||
event_type:
|
||||
|
@ -144,6 +144,10 @@ bg:
|
|||
description: Описание
|
||||
errors:
|
||||
models:
|
||||
event:
|
||||
attributes:
|
||||
track:
|
||||
must_be_a_valid_track: трябва да е някой от изброените потоци от лекции
|
||||
user:
|
||||
attributes:
|
||||
email:
|
||||
|
|
|
@ -2,20 +2,23 @@ require_dependency "open_fest/application_controller"
|
|||
|
||||
module OpenFest
|
||||
class EventsController < ApplicationController
|
||||
before_filter :authenticate_user!
|
||||
|
||||
def index
|
||||
end
|
||||
|
||||
def new
|
||||
@event_type = current_conference.event_types.find(params[:type])
|
||||
@event = Event.new(event_type: @event_type)
|
||||
event_type = current_conference.event_types.find(params[:type])
|
||||
@event = Event.new event_type: event_type
|
||||
end
|
||||
|
||||
def create
|
||||
@event = Event.new(event_params)
|
||||
@event = Event.new event_params
|
||||
@event.conference = current_conference
|
||||
@event.build_proposition proposer: current_user
|
||||
@event.participations.build participant: current_user, approved: true
|
||||
|
||||
if @event.save
|
||||
# TODO (2015-08-10) Flash message?
|
||||
flash[:notice] = 'Event was successfully created.'
|
||||
redirect_to action: :index
|
||||
else
|
||||
render action: :new
|
||||
|
@ -26,7 +29,7 @@ module OpenFest
|
|||
|
||||
def event_params
|
||||
params.require(:event).permit(
|
||||
:title, :subtitle, :length, :language,
|
||||
:title, :subtitle, :track_id, :length, :language,
|
||||
:abstract, :description, :notes, :agreement,
|
||||
:event_type_id
|
||||
)
|
||||
|
|
|
@ -1,22 +1,20 @@
|
|||
= simple_form_for @event, wrapper: :default do |form|
|
||||
= form.input :event_type_id, as: :hidden, wrapper: false
|
||||
|
||||
h2= t('submit_event', event_type: @event.event_type.name)
|
||||
|
||||
p
|
||||
= form.error_notification
|
||||
|
||||
h2= t('submit_event', event_type: @event_type.name)
|
||||
|
||||
.form-inputs
|
||||
= form.input :event_type_id, as: :hidden
|
||||
|
||||
= form.input :title, autofocus: true
|
||||
= form.input :subtitle
|
||||
|
||||
-# TODO tracks -> indirectly through proposition?
|
||||
-# form.input :track_id, collection: current_conference.tracks.map { |track| [track.name, track.id, {title: track.description}] }, required: true
|
||||
= 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, collection: I18n.available_locales, include_blank: false, default: I18n.locale
|
||||
= form.input :language, as: :radio_buttons, collection: I18n.available_locales, include_blank: false, default: I18n.locale, wrapper: :default
|
||||
= form.input :abstract
|
||||
= form.input :description
|
||||
= form.input :notes
|
||||
|
|
|
@ -23,7 +23,7 @@ bg:
|
|||
event:
|
||||
title: Заглавието на събитието Ви
|
||||
subtitle: Подзаглавието на събитието Ви (ако има такова)
|
||||
track_id: Потокът от лекции, в който искате да попадне събитието Ви
|
||||
track: Потокът от лекции, в който искате да попадне събитието Ви
|
||||
length: Продължителността на събитието може да бъде от 40 до 45 минути
|
||||
language: Език, на който ще бъде водено събитието
|
||||
abstract: Резюме на събитието, което да може да бъде прочетено от посетителите (1 абзац)
|
||||
|
|
Loading…
Reference in New Issue