diff --git a/Gemfile b/Gemfile index 412a230a..cf7797d5 100644 --- a/Gemfile +++ b/Gemfile @@ -5,9 +5,6 @@ gem 'rails' # Use mysql as the database for Active Record gem 'mysql2' -# Use SCSS for stylesheets -gem 'sass-rails' - # Use Uglifier as compressor for JavaScript assets gem 'uglifier' @@ -49,11 +46,16 @@ gem 'rails-i18n' gem 'devise-i18n' gem 'jquery-turbolinks' gem 'font-awesome-rails' -gem 'compass-rails', "~> 2.0.alpha.0" gem 'has_scope' gem 'simple_calendar', github: 'echarp/simple_calendar' gem 'redcarpet' +group :assets do + # Use SASS for stylesheets + gem 'sass-rails' + gem 'compass-rails' +end + group :development do gem 'guard-livereload' gem 'guard-bundler' diff --git a/Gemfile.lock b/Gemfile.lock index f3db329d..70afef09 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -7,7 +7,7 @@ GIT GIT remote: git://github.com/gregbell/active_admin.git - revision: 7465eb37877897849a2466a05afd2af4ee7a9338 + revision: d7a26247de866fba5e3d2cce872ba978247f80a2 specs: activeadmin (1.0.0.pre) arbre (~> 1.0) @@ -18,7 +18,7 @@ GIT inherited_resources (~> 1.3) jquery-rails jquery-ui-rails - kaminari (~> 0.14, != 0.15.0) + kaminari (~> 0.15) rails (>= 3.2, < 4.1) ransack (~> 1.0) sass-rails @@ -52,7 +52,7 @@ GEM tzinfo (~> 0.3.37) arbre (1.0.1) activesupport (>= 3.0.0) - arel (4.0.1) + arel (4.0.2) atomic (1.1.14) bcrypt-ruby (3.1.2) bourbon (3.1.8) @@ -61,7 +61,10 @@ GEM builder (3.1.4) celluloid (0.15.2) timers (~> 1.1.0) - chunky_png (1.2.9) + celluloid-io (0.15.0) + celluloid (>= 0.15.0) + nio4r (>= 0.5.0) + chunky_png (1.3.0) coderay (1.1.0) coffee-rails (4.0.1) coffee-script (>= 2.2.0) @@ -69,13 +72,13 @@ GEM coffee-script (2.2.0) coffee-script-source execjs - coffee-script-source (1.6.3) + coffee-script-source (1.7.0) compass (0.12.2) chunky_png (~> 1.2) fssm (>= 0.2.7) sass (~> 3.1) - compass-rails (2.0.alpha.0) - compass (>= 0.12.2, < 0.14) + compass-rails (1.1.4) + compass (>= 0.12.2) devise (3.2.2) bcrypt-ruby (~> 3.0) orm_adapter (~> 0.1) @@ -96,7 +99,7 @@ GEM formtastic (2.3.0.rc2) actionpack (>= 3.0) fssm (0.2.10) - guard (2.2.5) + guard (2.4.0) formatador (>= 0.2.4) listen (~> 2.1) lumberjack (~> 1.0) @@ -105,11 +108,11 @@ GEM guard-bundler (2.0.0) bundler (~> 1.0) guard (~> 2.2) - guard-livereload (2.1.0) + guard-livereload (2.1.1) em-websocket (~> 0.5) guard (~> 2.0) multi_json (~> 1.8) - guard-minitest (2.1.3) + guard-minitest (2.2.0) guard (~> 2.0) minitest (>= 3.0) haml (4.0.5) @@ -128,23 +131,24 @@ GEM inherited_resources (1.4.1) has_scope (~> 0.6.0.rc) responders (~> 1.0.0.rc) - jbuilder (2.0.2) + jbuilder (2.0.3) activesupport (>= 3.0.0) multi_json (>= 1.2.0) - jquery-rails (3.0.4) + jquery-rails (3.1.0) railties (>= 3.0, < 5.0) thor (>= 0.14, < 2.0) - jquery-turbolinks (2.0.1) + jquery-turbolinks (2.0.2) railties (>= 3.1.0) turbolinks jquery-ui-rails (4.1.1) railties (>= 3.1.0) json (1.8.1) - kaminari (0.14.1) + kaminari (0.15.1) actionpack (>= 3.0.0) activesupport (>= 3.0.0) - listen (2.4.0) + listen (2.5.0) celluloid (>= 0.15.2) + celluloid-io (>= 0.15.0) rb-fsevent (>= 0.9.3) rb-inotify (>= 0.9) lumberjack (1.0.4) @@ -155,12 +159,13 @@ GEM mime-types (1.25.1) minitest (4.7.5) multi_json (1.8.4) - mysql2 (0.3.14) + mysql2 (0.3.15) + nio4r (1.0.0) orm_adapter (0.5.0) polyamorous (0.6.4) activerecord (>= 3.0) polyglot (0.3.3) - pry (0.9.12.4) + pry (0.9.12.6) coderay (~> 1.0) method_source (~> 0.8) slop (~> 3.4) @@ -195,10 +200,10 @@ GEM ffi (>= 0.5.0) rdoc (4.1.1) json (~> 1.4) - redcarpet (3.0.0) + redcarpet (3.1.0) responders (1.0.0) railties (>= 3.2, < 5) - sass (3.2.13) + sass (3.2.14) sass-rails (4.0.1) railties (>= 4.0.0, < 5.0) sass (>= 3.1.10) @@ -216,7 +221,7 @@ GEM actionpack (>= 3.0) activesupport (>= 3.0) sprockets (~> 2.8) - thor (0.18.1) + thor (0.18.1.20140116) thread_safe (0.1.3) atomic tilt (1.4.1) @@ -224,7 +229,7 @@ GEM treetop (1.4.15) polyglot polyglot (>= 0.3.1) - turbolinks (2.1.0) + turbolinks (2.2.1) coffee-rails tzinfo (0.3.38) uglifier (2.4.0) @@ -240,7 +245,7 @@ PLATFORMS DEPENDENCIES activeadmin! coffee-rails - compass-rails (~> 2.0.alpha.0) + compass-rails devise-i18n font-awesome-rails guard-bundler diff --git a/app/assets/javascripts/notes.js.coffee b/app/assets/javascripts/notes.js.coffee new file mode 100644 index 00000000..24f83d18 --- /dev/null +++ b/app/assets/javascripts/notes.js.coffee @@ -0,0 +1,3 @@ +# Place all the behaviors and hooks related to the matching controller here. +# All this logic will automatically be available in application.js. +# You can use CoffeeScript in this file: http://coffeescript.org/ diff --git a/app/assets/stylesheets/all.css.sass b/app/assets/stylesheets/all.css.sass index 86b416d6..e2a821c7 100644 --- a/app/assets/stylesheets/all.css.sass +++ b/app/assets/stylesheets/all.css.sass @@ -81,9 +81,36 @@ main margin: 0.95em 0 line-height: 1.3em text-align: justify + &.label + text-align: center hr margin: 10px 20px + input, textarea, select + margin: 3px 0 + border: 1px solid #868686 + &:focus + background-color: #F0F8FF +/* + input, textarea, select + color: black + margin: 3px 0 + border: 1px solid #868686 + padding: 0.2em 0.8em + font-family: georgia, serif + background-color: white + @include border-radius(0.7em) + &:focus + outline: 0 + background-color: #F0F8FF + input[type=submit] + border: none + font-size: x-large + @include box-shadow(0 0 1em lightblue) + @include text-shadow(1px 1px 1px white) + &:hover + @include box-shadow(5px 5px 5px lightblue) + footer.bottom nav margin: 26px auto -3px font-size: smaller diff --git a/app/assets/stylesheets/events.css.sass b/app/assets/stylesheets/events.css.sass index 41b853d2..fec4b5fc 100644 --- a/app/assets/stylesheets/events.css.sass +++ b/app/assets/stylesheets/events.css.sass @@ -160,11 +160,6 @@ table.calendar display: inline-block &:after content: ':' - input, textarea, select - margin: 3px 0 - border: 1px solid #868686 - &:focus - background-color: #F0F8FF .actions margin-left: 6.75em margin-bottom: 10px diff --git a/app/assets/stylesheets/moderations.css.sass b/app/assets/stylesheets/moderations.css.sass index c10dc9e9..04e581d5 100644 --- a/app/assets/stylesheets/moderations.css.sass +++ b/app/assets/stylesheets/moderations.css.sass @@ -1,4 +1,4 @@ -.moderations +.moderations, .notes table.list width: 100% margin-top: 15px diff --git a/app/assets/stylesheets/notes.css.sass b/app/assets/stylesheets/notes.css.sass new file mode 100644 index 00000000..7e05c691 --- /dev/null +++ b/app/assets/stylesheets/notes.css.sass @@ -0,0 +1,4 @@ +.notes + form + label:after + content: ':' diff --git a/app/assets/stylesheets/scaffolds.css.scss b/app/assets/stylesheets/scaffolds.css.scss new file mode 100644 index 00000000..6ec6a8ff --- /dev/null +++ b/app/assets/stylesheets/scaffolds.css.scss @@ -0,0 +1,69 @@ +body { + background-color: #fff; + color: #333; + font-family: verdana, arial, helvetica, sans-serif; + font-size: 13px; + line-height: 18px; +} + +p, ol, ul, td { + font-family: verdana, arial, helvetica, sans-serif; + font-size: 13px; + line-height: 18px; +} + +pre { + background-color: #eee; + padding: 10px; + font-size: 11px; +} + +a { + color: #000; + &:visited { + color: #666; + } + &:hover { + color: #fff; + background-color: #000; + } +} + +div { + &.field, &.actions { + margin-bottom: 10px; + } +} + +#notice { + color: green; +} + +.field_with_errors { + padding: 2px; + background-color: red; + display: table; +} + +#error_explanation { + width: 450px; + border: 2px solid red; + padding: 7px; + padding-bottom: 0; + margin-bottom: 20px; + background-color: #f0f0f0; + h2 { + text-align: left; + font-weight: bold; + padding: 5px 5px 5px 15px; + font-size: 12px; + margin: -7px; + margin-bottom: 0px; + background-color: #c00; + color: #fff; + } + ul li { + font-size: 12px; + list-style: square; + } +} diff --git a/app/assets/stylesheets/sessions.css.sass b/app/assets/stylesheets/sessions.css.sass index 5970a768..2ae6411a 100644 --- a/app/assets/stylesheets/sessions.css.sass +++ b/app/assets/stylesheets/sessions.css.sass @@ -6,8 +6,7 @@ display: inline-block .field, .actions text-align: left - margin-left: 2px - margin-bottom: 2px !important + margin: 0.5em * vertical-align: middle p.helper @@ -16,26 +15,12 @@ label width: 8em display: inline-block - text-align: right &:after content: ':' - input, textarea, select - color: black - margin: 3px 0 - border: 1px solid #868686 - padding: 0.2em 0.8em - font-size: larger - font-family: georgia, serif - background-color: #FFB - @include border-radius(0.8em) - &:focus - outline: 0 - background-color: #F0F8FF !important - input[type=submit] - border: none - font-size: x-large - @include box-shadow(0 0 1em lightblue) - @include text-shadow(1px 1px 1px white) + /* + input, textarea, select + font-size: larger + background-color: #FFB .actions margin-left: 6.75em margin-bottom: 10px diff --git a/app/controllers/notes_controller.rb b/app/controllers/notes_controller.rb new file mode 100644 index 00000000..4083e802 --- /dev/null +++ b/app/controllers/notes_controller.rb @@ -0,0 +1,12 @@ +class NotesController < InheritedResources::Base + belongs_to :event + + private + def begin_of_association_chain + @event = Event.unscoped.find params[:moderation_id] + end + + def permitted_params + params.permit note: [:contents] + end +end diff --git a/app/helpers/notes_helper.rb b/app/helpers/notes_helper.rb new file mode 100644 index 00000000..8078f730 --- /dev/null +++ b/app/helpers/notes_helper.rb @@ -0,0 +1,2 @@ +module NotesHelper +end diff --git a/app/views/events/show.html.haml b/app/views/events/show.html.haml index 1e9aa4e2..fb5fc030 100644 --- a/app/views/events/show.html.haml +++ b/app/views/events/show.html.haml @@ -1,4 +1,4 @@ -- if request.format == 'text/html' && controller.controller_name != 'moderations' +- if request.format == 'text/html' && controller.controller_name != 'moderations' && controller.controller_name != 'notes' %p#notice= notice #lug-list diff --git a/app/views/moderations/index.html.haml b/app/views/moderations/index.html.haml index aadbd8be..903b6493 100644 --- a/app/views/moderations/index.html.haml +++ b/app/views/moderations/index.html.haml @@ -40,7 +40,7 @@ %br/ = link_to t('.askInfos'), edit_moderation_path(event), class: 'fa-bullhorn' %br/ - = link_to t('.createNote'), new_note_path('event.id' => event), class: 'fa-files-o' + = link_to t('.createNote'), new_moderation_note_path(event), class: 'fa-files-o' - event.notes.each do |note| %tr @@ -50,6 +50,6 @@ %em.author =t '.posted_by', author: "#{note.author.firstname} #{note.author.lastname}", - date: l(note.date, format: :at) + date: l(note.date, format: :at) rescue nil .logout= link_to t('logout'), destroy_user_session_path, method: :delete diff --git a/app/views/notes/_form.html.haml b/app/views/notes/_form.html.haml new file mode 100644 index 00000000..6fc401c3 --- /dev/null +++ b/app/views/notes/_form.html.haml @@ -0,0 +1,13 @@ += form_for [:moderation, @note] do |f| + - if @note.errors.any? + #error_explanation + %h2= "#{pluralize(@note.errors.count, "error")} prohibited this note from being saved:" + %ul + - @note.errors.full_messages.each do |msg| + %li= msg + .field + %p.label= f.label Note.human_attribute_name :contents + = f.text_area :contents, cols: 70, rows: 10 + + .actions + = f.submit t('save') diff --git a/app/views/notes/new.html.haml b/app/views/notes/new.html.haml new file mode 100644 index 00000000..ed56de46 --- /dev/null +++ b/app/views/notes/new.html.haml @@ -0,0 +1,8 @@ +%h3 + = link_to t('.back'), moderations_path + >>> + =t '.title' + +.box= render 'form' + +.box= render file: '/events/show' diff --git a/config/locales/fr.yml b/config/locales/fr.yml index 1a657bd4..6245b4e5 100644 --- a/config/locales/fr.yml +++ b/config/locales/fr.yml @@ -1,5 +1,6 @@ fr: show: Voir + save: Enregistrer edit: Éditer validate: Valider refuse: Refuser @@ -56,6 +57,8 @@ fr: region: name_values: all: Toutes les régions + note: + contents: Votre commentaire helpers: submit: @@ -148,6 +151,10 @@ fr: moderation: Modération preview: Prévisualisation de l'évènement edit: Édition de l'évènement + notes: + new: + back: Modération + title: Ajout d'une note de modération users: sign_in: title: Identification diff --git a/config/routes.rb b/config/routes.rb index a754c8a0..658ce72d 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,13 +1,14 @@ AgendaDuLibreRails::Application.routes.draw do + resources :users + resources :events + resources :moderations do + resources :notes, only: [:new, :create] + end resources :regions, only: [ :index ] do get 'icallist', on: :collection get 'stats', on: :collection end - resources :events - resources :notes - resources :users resources :tags, only: [ :index, :show ] - resources :moderations get 'ical.php' => 'events#index', format: :ics get ':format.php' => 'events#index' diff --git a/test/controllers/notes_controller_test.rb b/test/controllers/notes_controller_test.rb new file mode 100644 index 00000000..994d65a1 --- /dev/null +++ b/test/controllers/notes_controller_test.rb @@ -0,0 +1,49 @@ +require 'test_helper' + +class NotesControllerTest < ActionController::TestCase + setup do + @note = notes(:one) + end + + test "should get index" do + get :index + assert_response :success + assert_not_nil assigns(:notes) + end + + test "should get new" do + get :new + assert_response :success + end + + test "should create note" do + assert_difference('Note.count') do + post :create, note: { author: @note.author, contents: @note.contents, date: @note.date, event: @note.event } + end + + assert_redirected_to note_path(assigns(:note)) + end + + test "should show note" do + get :show, id: @note + assert_response :success + end + + test "should get edit" do + get :edit, id: @note + assert_response :success + end + + test "should update note" do + patch :update, id: @note, note: { author: @note.author, contents: @note.contents, date: @note.date, event: @note.event } + assert_redirected_to note_path(assigns(:note)) + end + + test "should destroy note" do + assert_difference('Note.count', -1) do + delete :destroy, id: @note + end + + assert_redirected_to notes_path + end +end diff --git a/test/fixtures/notes.yml b/test/fixtures/notes.yml index bff0a17c..0e6f3493 100644 --- a/test/fixtures/notes.yml +++ b/test/fixtures/notes.yml @@ -1,13 +1,13 @@ # Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html one: + event: one + author: one contents: MyText - date: 2014-01-05 23:34:46 - event_id: - author_id: + date: 2014-01-11 10:55:54 two: + event: one + author: one contents: MyText - date: 2014-01-05 23:34:46 - event_id: - author_id: + date: 2014-01-11 10:55:54 diff --git a/test/helpers/notes_helper_test.rb b/test/helpers/notes_helper_test.rb new file mode 100644 index 00000000..4984103c --- /dev/null +++ b/test/helpers/notes_helper_test.rb @@ -0,0 +1,4 @@ +require 'test_helper' + +class NotesHelperTest < ActionView::TestCase +end