Browse Source

Un calendrier fonctionnel est en place

recurrent
echarp 8 years ago
parent
commit
8cc52a697d
  1. 2
      Gemfile
  2. 10
      Gemfile.lock
  3. BIN
      app/assets/images/belgique.png
  4. BIN
      app/assets/images/france.png
  5. BIN
      app/assets/images/quebec.png
  6. BIN
      app/assets/images/suisse.png
  7. 3
      app/assets/javascripts/events.js.coffee
  8. 27
      app/assets/stylesheets/all.css.sass
  9. 66
      app/assets/stylesheets/events.css.sass
  10. 12
      app/assets/stylesheets/list.css.sass
  11. 18
      app/controllers/events_controller.rb
  12. 2
      app/helpers/events_helper.rb
  13. 5
      app/models/city.rb
  14. 13
      app/models/event.rb
  15. 64
      app/views/events/_form.html.haml
  16. 7
      app/views/events/edit.html.haml
  17. 11
      app/views/events/index.html.haml
  18. 4
      app/views/events/index.json.jbuilder
  19. 5
      app/views/events/new.html.haml
  20. 60
      app/views/events/show.html.haml
  21. 1
      app/views/events/show.json.jbuilder
  22. 43
      app/views/layouts/application.html.haml
  23. 13
      config/locales/fr.yml
  24. 7
      config/routes.rb
  25. BIN
      public/favicon.ico
  26. 49
      test/controllers/events_controller_test.rb
  27. 41
      test/fixtures/events.yml
  28. 4
      test/helpers/events_helper_test.rb
  29. 7
      test/models/event_test.rb

2
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'

10
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

BIN
app/assets/images/belgique.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 187 B

BIN
app/assets/images/france.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 276 B

BIN
app/assets/images/quebec.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 734 B

BIN
app/assets/images/suisse.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 427 B

3
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/

27
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

66
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

12
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

18
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

2
app/helpers/events_helper.rb

@ -0,0 +1,2 @@
module EventsHelper
end

5
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

13
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

64
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'

7
app/views/events/edit.html.haml

@ -0,0 +1,7 @@
%h1 Editing event
= render 'form'
= link_to 'Show', @event
\|
= link_to 'Back', events_path

11
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

4
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

5
app/views/events/new.html.haml

@ -0,0 +1,5 @@
%h1 New event
= render 'form'
= link_to 'Back', events_path

60
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

1
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

43
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'

13
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

7
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".

BIN
public/favicon.ico

Binary file not shown.

Before

Width:  |  Height:  |  Size: 0 B

After

Width:  |  Height:  |  Size: 4.2 KiB

49
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

41
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

4
test/helpers/events_helper_test.rb

@ -0,0 +1,4 @@
require 'test_helper'
class EventsHelperTest < ActionView::TestCase
end

7
test/models/event_test.rb

@ -0,0 +1,7 @@
require 'test_helper'
class EventTest < ActiveSupport::TestCase
# test "the truth" do
# assert true
# end
end
Loading…
Cancel
Save