From ded7d691695d0633575531c403713c7d778c3216 Mon Sep 17 00:00:00 2001 From: Andrew Radev Date: Mon, 10 Aug 2015 14:52:45 +0300 Subject: [PATCH] Submitting events --- .../assets/stylesheets/open_fest/_forms.scss | 2 +- .../open_fest/events_controller.rb | 35 ++++++++++++++++ .../open_fest/welcome_controller.rb | 8 ---- .../views/open_fest/events/_event_type.slim | 1 + .../open_fest/{welcome => events}/_track.slim | 0 .../open_fest/{welcome => events}/index.slim | 0 .../app/views/open_fest/events/new.slim | 23 ++++++++++ .../views/open_fest/welcome/_event_type.slim | 1 - .../config/locales/simple_form.bg.yml | 42 +++++++++++++++++++ .../config/locales/simple_form.en.yml | 42 +++++++++++++++++++ lib/open_fest/config/routes.rb | 5 +-- 11 files changed, 146 insertions(+), 13 deletions(-) create mode 100644 lib/open_fest/app/controllers/open_fest/events_controller.rb delete mode 100644 lib/open_fest/app/controllers/open_fest/welcome_controller.rb create mode 100644 lib/open_fest/app/views/open_fest/events/_event_type.slim rename lib/open_fest/app/views/open_fest/{welcome => events}/_track.slim (100%) rename lib/open_fest/app/views/open_fest/{welcome => events}/index.slim (100%) create mode 100644 lib/open_fest/app/views/open_fest/events/new.slim delete mode 100644 lib/open_fest/app/views/open_fest/welcome/_event_type.slim create mode 100644 lib/open_fest/config/locales/simple_form.bg.yml create mode 100644 lib/open_fest/config/locales/simple_form.en.yml diff --git a/lib/open_fest/app/assets/stylesheets/open_fest/_forms.scss b/lib/open_fest/app/assets/stylesheets/open_fest/_forms.scss index f5645af..40371f0 100644 --- a/lib/open_fest/app/assets/stylesheets/open_fest/_forms.scss +++ b/lib/open_fest/app/assets/stylesheets/open_fest/_forms.scss @@ -25,7 +25,7 @@ textarea { height: 15em; - width: 50em; + width: 45em; } img { diff --git a/lib/open_fest/app/controllers/open_fest/events_controller.rb b/lib/open_fest/app/controllers/open_fest/events_controller.rb new file mode 100644 index 0000000..1e77dfb --- /dev/null +++ b/lib/open_fest/app/controllers/open_fest/events_controller.rb @@ -0,0 +1,35 @@ +require_dependency "open_fest/application_controller" + +module OpenFest + class EventsController < ApplicationController + def index + end + + def new + @event_type = current_conference.event_types.find(params[:type]) + @event = Event.new(event_type: @event_type) + end + + def create + @event = Event.new(event_params) + + if @event.save + # TODO (2015-08-10) Flash message? + flash[:notice] = 'Event was successfully created.' + redirect_to action: :index + else + render action: :new + end + end + + private + + def event_params + params.require(:event).permit( + :title, :subtitle, :length, :language, + :abstract, :description, :notes, :agreement, + :event_type_id + ) + end + end +end diff --git a/lib/open_fest/app/controllers/open_fest/welcome_controller.rb b/lib/open_fest/app/controllers/open_fest/welcome_controller.rb deleted file mode 100644 index a09aebc..0000000 --- a/lib/open_fest/app/controllers/open_fest/welcome_controller.rb +++ /dev/null @@ -1,8 +0,0 @@ -require_dependency "open_fest/application_controller" - -module OpenFest - class WelcomeController < ApplicationController - def index - end - end -end diff --git a/lib/open_fest/app/views/open_fest/events/_event_type.slim b/lib/open_fest/app/views/open_fest/events/_event_type.slim new file mode 100644 index 0000000..8c51604 --- /dev/null +++ b/lib/open_fest/app/views/open_fest/events/_event_type.slim @@ -0,0 +1 @@ +=> link_to t('views.welcome.submit_event', event_type: event_type.name.mb_chars.downcase), new_event_path(type: event_type.id), class: 'btn-link btn-link-large' diff --git a/lib/open_fest/app/views/open_fest/welcome/_track.slim b/lib/open_fest/app/views/open_fest/events/_track.slim similarity index 100% rename from lib/open_fest/app/views/open_fest/welcome/_track.slim rename to lib/open_fest/app/views/open_fest/events/_track.slim diff --git a/lib/open_fest/app/views/open_fest/welcome/index.slim b/lib/open_fest/app/views/open_fest/events/index.slim similarity index 100% rename from lib/open_fest/app/views/open_fest/welcome/index.slim rename to lib/open_fest/app/views/open_fest/events/index.slim diff --git a/lib/open_fest/app/views/open_fest/events/new.slim b/lib/open_fest/app/views/open_fest/events/new.slim new file mode 100644 index 0000000..a329a4b --- /dev/null +++ b/lib/open_fest/app/views/open_fest/events/new.slim @@ -0,0 +1,23 @@ += simple_form_for @event, wrapper: :default do |form| + p + = form.error_notification + + .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.input :length + = form.input :language, collection: I18n.available_locales, include_blank: false, default: I18n.locale + = form.input :abstract + = form.input :description + = form.input :notes + + -# TODO boolean hint CSS, missing divider + -# TODO error message? + = form.input :agreement, as: :boolean, wrapper_html: {class: 'input'} + + = form.button :submit diff --git a/lib/open_fest/app/views/open_fest/welcome/_event_type.slim b/lib/open_fest/app/views/open_fest/welcome/_event_type.slim deleted file mode 100644 index e8646be..0000000 --- a/lib/open_fest/app/views/open_fest/welcome/_event_type.slim +++ /dev/null @@ -1 +0,0 @@ -=> link_to t('views.welcome.submit_event', event_type: event_type.name.mb_chars.downcase), '#', class: 'btn-link btn-link-large' diff --git a/lib/open_fest/config/locales/simple_form.bg.yml b/lib/open_fest/config/locales/simple_form.bg.yml new file mode 100644 index 0000000..4162687 --- /dev/null +++ b/lib/open_fest/config/locales/simple_form.bg.yml @@ -0,0 +1,42 @@ +bg: + simple_form: + "yes": Да + "no": Не + required: + text: Задължително поле + mark: '*' + error_notification: + default_message: 'Моля, разгледайте посочените грешки във формуляра:' + hints: + user: + email: e-mail адресът Ви. Ще бъде видим само от организаторите + password: Парола с дължина между 8 и 128 символа + password_confirmation: Отново въведената отгоре парола + speaker_profile: + picture: Ваша снимка + organisation: Организацията, която представлявате + public_email: E-mail адрес, който ще бъде видим за посетителите + mobile_phone: Мобилен телефон, който ще бъде видим само за организаторите + biography: Опишете се с няколко изречения, говорейки за себе си в трето лице :) + github: Потребителското Ви име в Github + twitter: Потребителското Ви име в Twitter + event: + title: Заглавието на лекцията Ви + subtitle: Подзаглавието на лекцията Ви (ако има такова) + track_id: Потокът от лекции, в който искате да попадне лекцията Ви + length: Продължителността на лекция може да бъде от 40 до 45 минути + language: Език, на който ще бъде водена лекцията + abstract: Резюме на лекцията, което да може да бъде прочетено от посетителите (1 абзац) + description: Подробно описание на лекцията (няколко абзаца) + notes: Забележки, които искате да споделите с организаторския екип + agreement: Отбележете съгласни ли сте с това лекцията Ви да бъде записана и публикувана под лиценз CC-BY-ND (Creative Commons – Attribution – No Derivatives) + workshop: + title: Заглавието на уъркшопа Ви + subtitle: Подзаглавието на уъркшопа Ви (ако има такова) + track_id: Потокът от уъркшопи, в който искате да попадне уъркшопа Ви + length: Продължителността на всеки уъркшоп може да бъде от 30 до 120 минути + language: Език, на който ще бъде воден уъркшопа + abstract: Резюме на уъркшопа, което да може да бъде прочетено от посетителите (1 абзац) + description: Подробно описание на уъркшопа (няколко абзаца) + notes: Забележки, които искате да споделите с организаторския екип + agreement: Отбележете съгласни ли сте с това уъркшопът Ви да бъде записан и публикуван под лиценз CC-BY-ND (Creative Commons – Attribution – No Derivatives) diff --git a/lib/open_fest/config/locales/simple_form.en.yml b/lib/open_fest/config/locales/simple_form.en.yml new file mode 100644 index 0000000..227fe0c --- /dev/null +++ b/lib/open_fest/config/locales/simple_form.en.yml @@ -0,0 +1,42 @@ +en: + simple_form: + "yes": Yes + "no": No + required: + text: Required field + mark: '*' + error_notification: + default_message: 'Please see the errors below:' + hints: + user: + email: Your e-mail address. Will be visible to the organizers only. + password: Password with length between 8 and 128 symbols + password_confirmation: Repeat the password + speaker_profile: + picture: Your photo + organisation: Your organization + public_email: E-mail address, visible to the visitors + mobile_phone: Mobile phone, visible for the organizers only + biography: Describe yourself in a few sentences in third person :) + github: Your Github username + twitter: Your Twitter username + lecture: + title: Title of your talk + subtitle: Sub-title of your talk (if applicable) + track_id: Track for your talk + length: The length of your talk can be from 40 to 45 minutes + language: Language in which the talk will be presented + abstract: Abstract of the talk, for the visitors + description: Detailed description of the talk, visible to the visitors + notes: Notes on your talk, visible only to the organizers + agreement: Indicate if you accept your lecture to be recorded and published under the CC-BY-ND (Creative Commons – Attribution – No Derivatives) license + workshop: + title: Title of your workshop + subtitle: Sub-title of your workshop (if applicable) + track_id: Track for your workshop + length: The length of the workshop can be from 30 to 120 minutes + language: Language in which the workshop will be conducted + abstract: Abstract of the workshop, visible to the visitors + description: Detailed description of the workshop, visible to the visitors + notes: Notes, visible only to the organizers + agreement: Indicate if you accept your workshop to be recorded and published under the CC-BY-ND (Creative Commons – Attribution – No Derivatives) license diff --git a/lib/open_fest/config/routes.rb b/lib/open_fest/config/routes.rb index de7313c..bbc9bc7 100644 --- a/lib/open_fest/config/routes.rb +++ b/lib/open_fest/config/routes.rb @@ -1,9 +1,8 @@ OpenFest::Engine.routes.draw do - get 'welcome/index' - - root to: 'welcome#index' + root to: 'events#index' devise_for :users, module: 'open_fest/users' resource :personal_profile, path: 'profile' + resources :events end