diff --git a/Gemfile b/Gemfile index d07eb08c..142f0800 100644 --- a/Gemfile +++ b/Gemfile @@ -50,6 +50,8 @@ gem 'devise-i18n' gem 'jquery-turbolinks' gem 'font-awesome-rails' gem 'compass-rails', "~> 2.0.alpha.0" +gem 'has_scope' +gem 'simple_calendar' group :development do gem 'guard-livereload' diff --git a/Gemfile.lock b/Gemfile.lock index 2e7ab7ef..53fd0e37 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,6 +1,6 @@ GIT remote: git://github.com/gregbell/active_admin.git - revision: 03c7bc771bf7b166de64848f2dae92368dad6b46 + revision: 10105176ff64013e0db6d5464cfed4049edf052b specs: activeadmin (1.0.0.pre) arbre (~> 1.0) @@ -11,7 +11,7 @@ GIT inherited_resources (~> 1.3) jquery-rails jquery-ui-rails - kaminari (~> 0.14) + kaminari (~> 0.14, != 0.15.0) rails (>= 3.2, < 4.1) ransack (~> 1.0) sass-rails @@ -133,7 +133,7 @@ GEM jquery-ui-rails (4.1.1) railties (>= 3.1.0) json (1.8.1) - kaminari (0.15.0) + kaminari (0.14.1) actionpack (>= 3.0.0) activesupport (>= 3.0.0) listen (2.4.0) @@ -196,6 +196,8 @@ GEM sdoc (0.3.20) json (>= 1.1.3) rdoc (~> 3.10) + simple_calendar (0.1.9) + rails (>= 3.0) slop (3.4.7) sprockets (2.10.1) hike (~> 1.2) @@ -236,6 +238,7 @@ DEPENDENCIES guard-livereload guard-minitest haml-rails + has_scope jbuilder jquery-rails jquery-turbolinks @@ -244,5 +247,6 @@ DEPENDENCIES rails-i18n sass-rails sdoc + simple_calendar turbolinks uglifier diff --git a/app/assets/images/belgique.png b/app/assets/images/belgique.png new file mode 100644 index 00000000..2906bd0e Binary files /dev/null and b/app/assets/images/belgique.png differ diff --git a/app/assets/images/france.png b/app/assets/images/france.png new file mode 100644 index 00000000..a79ab94c Binary files /dev/null and b/app/assets/images/france.png differ diff --git a/app/assets/images/quebec.png b/app/assets/images/quebec.png new file mode 100644 index 00000000..e8f4503b Binary files /dev/null and b/app/assets/images/quebec.png differ diff --git a/app/assets/images/suisse.png b/app/assets/images/suisse.png new file mode 100644 index 00000000..12f33427 Binary files /dev/null and b/app/assets/images/suisse.png differ diff --git a/app/assets/javascripts/events.js.coffee b/app/assets/javascripts/events.js.coffee new file mode 100644 index 00000000..24f83d18 --- /dev/null +++ b/app/assets/javascripts/events.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 e915bbfc..04e70b35 100644 --- a/app/assets/stylesheets/all.css.sass +++ b/app/assets/stylesheets/all.css.sass @@ -17,21 +17,16 @@ html color: #000000 line-height: 1.3em font-family: georgia, serif + padding-bottom: 6px background-color: #9CC5EE body + border: 1px solid #68A6E5 margin: 5px 5px 0 padding: 10px text-align: center background: url("baby_gnu_adl.png") no-repeat scroll 30px 10px #FFFFFF - -moz-border-bottom-colors: none - -moz-border-left-colors: none - -moz-border-right-colors: none - -moz-border-top-colors: none - border-image: none - border-width: 1px 1px 0 - border-style: solid solid none - border-color: #68A6E5 #68A6E5 -moz-use-text-color + border-bottom: 0px a:link, a:visited color: #336699 @@ -39,6 +34,7 @@ a:link, a:visited text-decoration: none header.top + position: relative h1 margin: 10px 5px 5px padding: 0 @@ -47,11 +43,24 @@ header.top letter-spacing: 2px h2 font-size: 0.8em - margin-top: 10px + margin-top: 12px font-style: italic font-weight: normal padding-bottom: 5px + ul.countries + top: -8px + right: 0.6em + position: absolute + font-size: 0.7em + list-style-type: none + li + text-align: left + line-height: 1.2em + img + margin-right: 0.6em + vertical-align: middle + main h1 margin-top: 1em diff --git a/app/assets/stylesheets/events.css.sass b/app/assets/stylesheets/events.css.sass new file mode 100644 index 00000000..587cec12 --- /dev/null +++ b/app/assets/stylesheets/events.css.sass @@ -0,0 +1,66 @@ +main h2:first-child + margin-top: 1.1em + a + font-weight: normal + &.previous-month + margin-right: 0.4em + &.next-month + margin-left: 0.4em + +table.calendar + width: 90% + margin: 0 auto + padding: 0 + margin-top: 3.7em + border-spacing: 2px + th + padding: 0 0 5px 0 + text-transform: capitalize + td + width: 14% !important + height: 6em + border: 1px solid #89B7E5 + vertical-align: top + background-color: #A1C3E7 + &.not-current-month + border: none + background-color: #ededed + li + color: #555 + .event + a:link, a:visited + color: #888 + + .day_number + float: left + color: #727070 + margin: 0 1px 3px 1px + font-size: 0.6em + font-weight: bolder + line-height: 1.2em + letter-spacing: 2px + ul + clear: left + margin-left: 0 + padding-left: 15px + list-style-type: circle + li + padding: 0 + margin-bottom: 5px + + .event + font-size: smaller + line-height: 1.1em + strong:after + content: ':' + a:link, a:visited + color: #666 + font-weight: normal + &:hover + color: black + +.formats + width: 99% + font-size: smaller + margin-top: 10px + text-align: right diff --git a/app/assets/stylesheets/list.css.sass b/app/assets/stylesheets/list.css.sass index b7e13f4c..4a499da0 100644 --- a/app/assets/stylesheets/list.css.sass +++ b/app/assets/stylesheets/list.css.sass @@ -4,18 +4,14 @@ table margin: 1em auto padding: 1em border-spacing: 0 - @include border-radius(2em, 2em) - @include box-shadow(2px 2px 4px black, 0 0 1em gray) th padding: 0.3em 0.6em - border-bottom: solid thin grey td - padding: 0.3em 0.6em text-align: left - tr:nth-child(even) td - border-bottom: solid thin #ddf - tr:nth-child(odd) td - border-bottom: solid thin #fdd + //tr:nth-child(even) td + // border-bottom: solid thin #ddf + //tr:nth-child(odd) td + // border-bottom: solid thin #fdd .view_link:link, .edit_link:link, .delete_link:link font-size: 0 diff --git a/app/controllers/events_controller.rb b/app/controllers/events_controller.rb new file mode 100644 index 00000000..3a4f88fb --- /dev/null +++ b/app/controllers/events_controller.rb @@ -0,0 +1,18 @@ +class EventsController < InheritedResources::Base + has_scope :region + + def index + params[:year] ||= Date.today.year + params[:month] ||= Date.today.month + + @events = Event.month(params[:year], params[:month]) + if (params[:region]) + @events = @events.region(params[:region]) + end + end + + private + def permitted_params + params.permit city: [:name, :majname, :postalcode, :inseecode, :regioncode, :latitude, :longitude] + end +end diff --git a/app/helpers/events_helper.rb b/app/helpers/events_helper.rb new file mode 100644 index 00000000..8a9a878c --- /dev/null +++ b/app/helpers/events_helper.rb @@ -0,0 +1,2 @@ +module EventsHelper +end diff --git a/app/models/city.rb b/app/models/city.rb index b188ac23..ceba1d0c 100644 --- a/app/models/city.rb +++ b/app/models/city.rb @@ -1,7 +1,2 @@ class City < ActiveRecord::Base end - -# -# def permitted_params -# params.permit city: [:name, :majname, :postalcode, :inseecode, :regioncode, :latitude, :longitude] -# end diff --git a/app/models/event.rb b/app/models/event.rb new file mode 100644 index 00000000..0f5d32d7 --- /dev/null +++ b/app/models/event.rb @@ -0,0 +1,13 @@ +class Event < ActiveRecord::Base + belongs_to :region, foreign_key: 'region' + + scope :year, -> year { + where "end_time >= ? and start_time < ?", + "#{year}-1-1", "#{year.to_is+1}-1-1" + } + scope :month, -> year, month { + where "end_time >= ? and start_time < ?", + "#{year}-#{month.to_i-1}-1", "#{year}-#{month.to_i+2}-1" + } + scope :region, -> region { where region: region } +end diff --git a/app/views/events/_form.html.haml b/app/views/events/_form.html.haml new file mode 100644 index 00000000..47d5bb27 --- /dev/null +++ b/app/views/events/_form.html.haml @@ -0,0 +1,64 @@ += form_for @event do |f| + - if @event.errors.any? + #error_explanation + %h2= "#{pluralize(@event.errors.count, "error")} prohibited this event from being saved:" + %ul + - @event.errors.full_messages.each do |msg| + %li= msg + + .field + = f.label :title + = f.text_field :title + .field + = f.label :description + = f.text_area :description + .field + = f.label :start_time + = f.datetime_select :start_time + .field + = f.label :end_time + = f.datetime_select :end_time + .field + = f.label :city + = f.text_field :city + .field + = f.label :region + = f.text_field :region + .field + = f.label :locality + = f.number_field :locality + .field + = f.label :url + = f.text_field :url + .field + = f.label :contact + = f.text_field :contact + .field + = f.label :contact + = f.text_field :contact + .field + = f.label :submitter + = f.text_field :submitter + .field + = f.label :moderated + = f.number_field :moderated + .field + = f.label :tags + = f.text_field :tags + .field + = f.label :secret + = f.text_field :secret + .field + = f.label :decision_time + = f.datetime_select :decision_time + .field + = f.label :submission_time + = f.datetime_select :submission_time + .field + = f.label :moderator_mail_id + = f.text_field :moderator_mail_id + .field + = f.label :submitter_mail_id + = f.text_field :submitter_mail_id + .actions + = f.submit 'Save' diff --git a/app/views/events/edit.html.haml b/app/views/events/edit.html.haml new file mode 100644 index 00000000..5828e7af --- /dev/null +++ b/app/views/events/edit.html.haml @@ -0,0 +1,7 @@ +%h1 Editing event + += render 'form' + += link_to 'Show', @event +\| += link_to 'Back', events_path diff --git a/app/views/events/index.html.haml b/app/views/events/index.html.haml new file mode 100644 index 00000000..b912c236 --- /dev/null +++ b/app/views/events/index.html.haml @@ -0,0 +1,11 @@ += calendar @events, { prev_text: '<<', next_text: '>>', start_day: :monday, + params: { region: params[:region] } } do |event| + %ul.events + %li.event + = link_to event.url do + %strong= event.city + = event.title + +.formats + =t '.calendar_in' + rss, iCal ou calendrier Google diff --git a/app/views/events/index.json.jbuilder b/app/views/events/index.json.jbuilder new file mode 100644 index 00000000..6f40589f --- /dev/null +++ b/app/views/events/index.json.jbuilder @@ -0,0 +1,4 @@ +json.array!(@events) do |event| + json.extract! event, :id, :title, :description, :start_time, :end_time, :city, :region_id, :locality, :url, :contact, :contact, :submitter, :moderated, :tags, :secret, :decision_time, :submission_time, :moderator_mail_id, :submitter_mail_id + json.url event_url(event, format: :json) +end diff --git a/app/views/events/new.html.haml b/app/views/events/new.html.haml new file mode 100644 index 00000000..6e0cccfa --- /dev/null +++ b/app/views/events/new.html.haml @@ -0,0 +1,5 @@ +%h1 New event + += render 'form' + += link_to 'Back', events_path diff --git a/app/views/events/show.html.haml b/app/views/events/show.html.haml new file mode 100644 index 00000000..d70bc1c3 --- /dev/null +++ b/app/views/events/show.html.haml @@ -0,0 +1,60 @@ +%p#notice= notice + +%p + %b Title: + = @event.title +%p + %b Description: + = @event.description +%p + %b Start time: + = @event.start_time +%p + %b End time: + = @event.end_time +%p + %b City: + = @event.city +%p + %b Region: + = @event.region +%p + %b Locality: + = @event.locality +%p + %b Url: + = @event.url +%p + %b Contact: + = @event.contact +%p + %b Contact: + = @event.contact +%p + %b Submitter: + = @event.submitter +%p + %b Moderated: + = @event.moderated +%p + %b Tags: + = @event.tags +%p + %b Secret: + = @event.secret +%p + %b Decision time: + = @event.decision_time +%p + %b Submission time: + = @event.submission_time +%p + %b Moderator mail: + = @event.moderator_mail_id +%p + %b Submitter mail: + = @event.submitter_mail_id + += link_to 'Edit', edit_event_path(@event) +\| += link_to 'Back', events_path diff --git a/app/views/events/show.json.jbuilder b/app/views/events/show.json.jbuilder new file mode 100644 index 00000000..10f08211 --- /dev/null +++ b/app/views/events/show.json.jbuilder @@ -0,0 +1 @@ +json.extract! @event, :id, :title, :description, :start_time, :end_time, :city, :region_id, :locality, :url, :contact, :contact, :submitter, :moderated, :tags, :secret, :decision_time, :submission_time, :moderator_mail_id, :submitter_mail_id, :created_at, :updated_at diff --git a/app/views/layouts/application.html.haml b/app/views/layouts/application.html.haml index f26fe334..047524c3 100644 --- a/app/views/layouts/application.html.haml +++ b/app/views/layouts/application.html.haml @@ -15,8 +15,7 @@ %meta(name='dcterms.title' content='Agenda du Libre' lang='fr') %meta(name='dcterms.subject' content='agenda') - -#%link(rel='shortcut icon' href='/assets/favicon.ico') - %link(rel='icon' type='image/png' href='/assets/world.png') + = favicon_link_tag = auto_discovery_link_tag :atom, { format: :atom } = stylesheet_link_tag 'application', media: "all", "data-turbolinks-track" => true @@ -36,19 +35,37 @@ %h1= link_to t('.title'), root_url %h2=t '.subtitle' + %ul.countries + %li + = link_to '/fr' do + = image_tag 'france.png' + France + %li + = link_to 'http://www.agendadulibre.qc.ca' do + = image_tag 'quebec.png' + Québec + %li + = link_to '/be' do + = image_tag 'belgique.png' + Belgique + %li + = link_to '/sw' do + = image_tag 'suisse.png' + Suisse + %main = yield %footer.bottom %nav - = link_to t('.propose'), users_url - = link_to t('.rss'), users_url - = link_to t('.ical'), users_url - = link_to t('.map'), users_url - = link_to t('.tags'), users_url - = link_to t('.infos'), users_url - = link_to t('.stats'), users_url - = link_to t('.contact'), users_url - = link_to t('.moderation'), users_url - = link_to t('.forge'), 'http://rubyforge.org/projects/parlement' - = link_to t('.agpl'), 'http://www.gnu.org/licenses/agpl.html' + = link_to t('.propose'), new_event_path + -#= link_to t('.rss'), users_url + -#= link_to t('.ical'), users_url + -#= link_to t('.map'), users_url + -#= link_to t('.tags'), users_url + -#= link_to t('.infos'), users_url + -#= link_to t('.stats'), users_url + -#= link_to t('.contact'), users_url + -#= link_to t('.moderation'), users_url + -#= link_to t('.forge'), 'http://rubyforge.org/projects/parlement' + -#= link_to t('.agpl'), 'http://www.gnu.org/licenses/agpl.html' diff --git a/config/locales/fr.yml b/config/locales/fr.yml index bfb2f055..3e5db43c 100644 --- a/config/locales/fr.yml +++ b/config/locales/fr.yml @@ -42,6 +42,16 @@ fr: create: "Créer %{model}" update: "Mettre à jour %{model}" + date: + abbr_day_names: + - Dimanche + - Lundi + - Mardi + - Mercredi + - Jeudi + - Vendredi + - Samedi + layouts: application: login: Authentication @@ -56,3 +66,6 @@ fr: stats: Statistiques contact: Contact moderation: Modération + events: + index: + calendar_in: Ce calendrier en diff --git a/config/routes.rb b/config/routes.rb index 7a335324..47b74cf8 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,13 +1,10 @@ AgendaDuLibreRails::Application.routes.draw do - resources :lugs - resources :cities - resources :regions - resources :users + resources :events devise_for :admin_users, ActiveAdmin::Devise.config ActiveAdmin.routes(self) - root to: 'users#index' + root to: 'events#index' # The priority is based upon order of creation: first created -> highest priority. # See how all your routes lay out with "rake routes". diff --git a/public/favicon.ico b/public/favicon.ico index e69de29b..c69addf1 100644 Binary files a/public/favicon.ico and b/public/favicon.ico differ diff --git a/test/controllers/events_controller_test.rb b/test/controllers/events_controller_test.rb new file mode 100644 index 00000000..aa597089 --- /dev/null +++ b/test/controllers/events_controller_test.rb @@ -0,0 +1,49 @@ +require 'test_helper' + +class EventsControllerTest < ActionController::TestCase + setup do + @event = events(:one) + end + + test "should get index" do + get :index + assert_response :success + assert_not_nil assigns(:events) + end + + test "should get new" do + get :new + assert_response :success + end + + test "should create event" do + assert_difference('Event.count') do + post :create, event: { city: @event.city, contact: @event.contact, contact: @event.contact, decision_time: @event.decision_time, description: @event.description, end_time: @event.end_time, locality: @event.locality, moderated: @event.moderated, moderator_mail_id: @event.moderator_mail_id, region_id: @event.region_id, secret: @event.secret, start_time: @event.start_time, submission_time: @event.submission_time, submitter: @event.submitter, submitter_mail_id: @event.submitter_mail_id, tags: @event.tags, title: @event.title, url: @event.url } + end + + assert_redirected_to event_path(assigns(:event)) + end + + test "should show event" do + get :show, id: @event + assert_response :success + end + + test "should get edit" do + get :edit, id: @event + assert_response :success + end + + test "should update event" do + patch :update, id: @event, event: { city: @event.city, contact: @event.contact, contact: @event.contact, decision_time: @event.decision_time, description: @event.description, end_time: @event.end_time, locality: @event.locality, moderated: @event.moderated, moderator_mail_id: @event.moderator_mail_id, region_id: @event.region_id, secret: @event.secret, start_time: @event.start_time, submission_time: @event.submission_time, submitter: @event.submitter, submitter_mail_id: @event.submitter_mail_id, tags: @event.tags, title: @event.title, url: @event.url } + assert_redirected_to event_path(assigns(:event)) + end + + test "should destroy event" do + assert_difference('Event.count', -1) do + delete :destroy, id: @event + end + + assert_redirected_to events_path + end +end diff --git a/test/fixtures/events.yml b/test/fixtures/events.yml new file mode 100644 index 00000000..2f8a3e35 --- /dev/null +++ b/test/fixtures/events.yml @@ -0,0 +1,41 @@ +# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html + +one: + title: MyString + description: MyText + start_time: 2013-12-28 16:04:56 + end_time: 2013-12-28 16:04:56 + city: MyString + region_id: + locality: 1 + url: MyString + contact: MyString + contact: MyString + submitter: MyString + moderated: 1 + tags: MyString + secret: MyString + decision_time: 2013-12-28 16:04:56 + submission_time: 2013-12-28 16:04:56 + moderator_mail_id: MyString + submitter_mail_id: MyString + +two: + title: MyString + description: MyText + start_time: 2013-12-28 16:04:56 + end_time: 2013-12-28 16:04:56 + city: MyString + region_id: + locality: 1 + url: MyString + contact: MyString + contact: MyString + submitter: MyString + moderated: 1 + tags: MyString + secret: MyString + decision_time: 2013-12-28 16:04:56 + submission_time: 2013-12-28 16:04:56 + moderator_mail_id: MyString + submitter_mail_id: MyString diff --git a/test/helpers/events_helper_test.rb b/test/helpers/events_helper_test.rb new file mode 100644 index 00000000..2e7567e0 --- /dev/null +++ b/test/helpers/events_helper_test.rb @@ -0,0 +1,4 @@ +require 'test_helper' + +class EventsHelperTest < ActionView::TestCase +end diff --git a/test/models/event_test.rb b/test/models/event_test.rb new file mode 100644 index 00000000..c6f15668 --- /dev/null +++ b/test/models/event_test.rb @@ -0,0 +1,7 @@ +require 'test_helper' + +class EventTest < ActiveSupport::TestCase + # test "the truth" do + # assert true + # end +end