From 6ac6f91d8fc91a0e9a020d10bf357de1345baaaf Mon Sep 17 00:00:00 2001 From: Nicolas Bally Date: Wed, 21 Oct 2015 15:06:43 +0200 Subject: [PATCH] agenda --- app/controllers/admin/events_controller.rb | 114 ++++++++++ app/controllers/public/events_controller.rb | 69 ++++-- app/helpers/events_helper.rb | 27 +++ app/models/event.rb | 116 ++++++++++ app/views/admin/events/_event.html.haml | 13 ++ app/views/admin/events/_form.html.haml | 50 +++++ app/views/admin/events/_index_block.html.haml | 28 +++ app/views/admin/events/_show.html.haml | 6 + app/views/admin/events/cible.html.haml | 6 + app/views/admin/events/create.js.erb | 4 + app/views/admin/events/destroy.js.erb | 1 + app/views/admin/events/edit.html.haml | 60 +++++ app/views/admin/events/edit.js.erb | 1 + app/views/admin/events/index.html.haml | 8 + app/views/admin/events/index.js.erb | 1 + app/views/admin/events/new.js.erb | 2 + app/views/admin/events/update.js.erb | 5 + app/views/public/events/_event.haml | 9 - app/views/public/events/_event.html.haml | 15 ++ .../public/events/_small_calendar.html.haml | 119 ++++++++++ .../public/events/_small_event.html.haml | 14 ++ app/views/public/events/index.html.haml | 29 ++- app/views/public/events/show.html.haml | 15 +- config/locales/fr.old.yml | 207 ++++++++++++++++++ config/locales/fr.yml | 113 +++++++--- db/migrate/20150309094403_create_events.rb | 15 ++ db/schema.rb | 14 +- 27 files changed, 996 insertions(+), 65 deletions(-) create mode 100644 app/controllers/admin/events_controller.rb create mode 100644 app/helpers/events_helper.rb create mode 100644 app/models/event.rb create mode 100644 app/views/admin/events/_event.html.haml create mode 100644 app/views/admin/events/_form.html.haml create mode 100644 app/views/admin/events/_index_block.html.haml create mode 100644 app/views/admin/events/_show.html.haml create mode 100644 app/views/admin/events/cible.html.haml create mode 100644 app/views/admin/events/create.js.erb create mode 100644 app/views/admin/events/destroy.js.erb create mode 100644 app/views/admin/events/edit.html.haml create mode 100644 app/views/admin/events/edit.js.erb create mode 100644 app/views/admin/events/index.html.haml create mode 100644 app/views/admin/events/index.js.erb create mode 100644 app/views/admin/events/new.js.erb create mode 100644 app/views/admin/events/update.js.erb delete mode 100644 app/views/public/events/_event.haml create mode 100644 app/views/public/events/_event.html.haml create mode 100644 app/views/public/events/_small_calendar.html.haml create mode 100644 app/views/public/events/_small_event.html.haml create mode 100644 config/locales/fr.old.yml create mode 100644 db/migrate/20150309094403_create_events.rb diff --git a/app/controllers/admin/events_controller.rb b/app/controllers/admin/events_controller.rb new file mode 100644 index 0000000..58f15a3 --- /dev/null +++ b/app/controllers/admin/events_controller.rb @@ -0,0 +1,114 @@ +# -*- encoding : utf-8 -*- + +class Admin::EventsController < ApplicationController + before_filter :auth_admin + + + layout "admin" + + before_filter :find_events + + + def index + + end + + + def cible + @events = Event.all + + render :layout => false + end + + + def new + if params[:event_id] and Event.find(params[:event_id]) + @event = Event.find(params[:event_id]).dup + @event.event_id = params[:event_id] + else + @event = Event.new(:start_at_date =>[ Date.today.day, Date.today.month, Date.today.year].join("/"), :start_at_time => "20:00") + + end + + end + + def edit + @event = Event.find(params[:id]) + + + end + + + def create + @event = Event.new(params.require(:event).permit!) + + + if @event.save + + + flash[:notice] = "L'événement à été ajouté avec succès." + + self.find_events #reload events to show new events in the list sort by date. + + else + render :action => "new" + + end + + end + + + def update + @event = Event.find(params[:id]) + + if @event.update_attributes(params.require(:event).permit!) + flash[:notice] = "L'événement à été modifié avec succès." + else + render :action => "edit" + + end + + end + + + def destroy + @event = Event.find(params[:id]) + @event.destroy + + end + + + protected + + def find_events + date_regex = /^(0[1-9]|[12][0-9]|3[01])[\/](0[1-9]|1[012])[\/](19|20)\d\d$/i + if params[:start] and params[:start] =~ date_regex + start = Date.parse(params[:start]).beginning_of_day + params[:start]= start.strftime('%d/%m/%Y') + else + params[:start] = "Début" + end + if params[:stop] and params[:stop] =~ date_regex + stop = Date.parse(params[:stop]).end_of_day + params[:stop]= stop.strftime('%d/%m/%Y') + else + params[:stop] = "Fin" + end + + @events = Event.order('start_at, stop_at') + @events = @events.after(start) if start + @events = @events.before(stop) if stop + per_page = (params[:per_page] and params[:per_page] != "") ? params[:per_page] : 20 + page = (params[:page] and params[:page] != "") ? params[:page] : 1 + #@events = Event.all.page(page).per(per_page) + + @events = Event.order('start_at DESC, stop_at DESC') + @events = @events.after(start) if start + @events = @events.before(stop) if stop + + + + + @events = @events.page(page).per(per_page) + end +end diff --git a/app/controllers/public/events_controller.rb b/app/controllers/public/events_controller.rb index 09e75dc..d1c61f4 100644 --- a/app/controllers/public/events_controller.rb +++ b/app/controllers/public/events_controller.rb @@ -4,35 +4,64 @@ class Public::EventsController < ApplicationController layout "public" - def archive - - end - def index - @events = Event.before(Date.today).recents - @events = @events.page(params[:page]).per(3) + + if params[:month] and params[:year] + + @start_list_date = Date.new(params[:year].to_i, params[:month].to_i).beginning_of_month + @end_list_date = @start_list_date + + + + + else + @start_list_date = Time.now.beginning_of_month + @end_list_date = @start_list_date + 2.month + + + + + end + - @title = "Events du blog" + + @title = "Agenda" + end + + def category + + + + + @category = Category.find_by_slug(params[:slug]) + @articles = @category.articles.recents + @articles = @articles.page(params[:page]).per(10) + @title = "Articles du blog" + @index_title = 'Articles de la catégorie "'+@category.name+'"' + render :action => :index + + end + + def archives + @month = Date.parse("#{params[:year]}/#{params[:month]}").beginning_of_month + @articles = Article.where("enabled = ? and published_at > ? and published_at < ?", true, @month, @month.end_of_month ) + @articles = @articles.page(params[:page]).per(10) + @title = "Articles du blog" + if [4,8].include?(@month.month) + @index_title = 'Articles du mois d\''+l(@month, :format => "%B %Y")+'' + else + @index_title = 'Articles du mois de '+l(@month, :format => "%B %Y")+'' + end + + render :action => :index end - def show - @event = Event.find_by_slug(params[:id]) - - if @event# and @event.enabled - - @title = @event.title - @thumbnail_image = @event.image_file.file.large.medium.small.thumb.url if @event.image_file - - else - redirect_to "/", :notice => "La page que vous demandez n'a pas pu être trouvée.

Vous avez donc été redirigé sur notre page d'accueil" - - end - end + end end diff --git a/app/helpers/events_helper.rb b/app/helpers/events_helper.rb new file mode 100644 index 0000000..f6846f5 --- /dev/null +++ b/app/helpers/events_helper.rb @@ -0,0 +1,27 @@ +module EventsHelper + def event_human_date(event, date_format = "%A %e %B %Y", time_format = "%kh%M") + + if event.entire_day? + if event.stop_date? + if event.start_at.strftime('%d/%m/%Y') == event.stop_at.strftime('%d/%m/%Y') + "le #{l(event.start_at, :format => date_format)}" + else + "du #{l(event.start_at, :format => date_format)} au #{l(event.stop_at, :format => date_format)}" + end + else + "le #{l(event.start_at, :format => date_format)}" + end + else + if event.stop_date? + if event.start_at.strftime('%d/%m/%Y') == event.stop_at.strftime('%d/%m/%Y') + "le #{l(event.start_at, :format => date_format)} de #{l(event.start_at, :format => time_format)} à #{l(event.stop_at, :format => time_format)} " + else + "du #{l(event.start_at, :format => date_format)} à #{l(event.start_at, :format => time_format)} au #{l(event.stop_at, :format => date_format)} à #{l(event.stop_at, :format => time_format)} " + end + else + "le #{l(event.start_at, :format => date_format)} à #{l(event.start_at, :format => time_format)}" + end + end + + end +end diff --git a/app/models/event.rb b/app/models/event.rb new file mode 100644 index 0000000..dea6992 --- /dev/null +++ b/app/models/event.rb @@ -0,0 +1,116 @@ +class Event < ActiveRecord::Base + date_format = /\A(0[1-9]|[12][0-9]|3[01])[\/](0[1-9]|1[012])[\/](19|20)\d\d\z/i + hour_format = /\A([0-1]?[0-9]|2[0-3]):([0-5][0-9])(:[0-5][0-9])?\z/i + validates :title, :presence => true + +# validates :start_at_date, :presence => true, :format => { :with => date_format } +# validates :start_at_time, :presence => true, :format => { :with => hour_format }, :if => :with_time? +# validates :stop_at_date, :presence => true, :format => { :with => date_format }, :if => :stop_date +# validates :stop_at_time, :presence => true, :format => { :with => hour_format }, :if => [:with_time?,:stop_date] + + attr_accessor :start_at_date, :start_at_time, :stop_at_date, :stop_at_time, :event_id, :skip_date + + has_one :block, :as => :blockable + + + scope :between, lambda { |start, stop| + after(start).before(stop) + } + + scope :after, lambda { |date| + where("(start_at >= ? or stop_at >= ?)", date, date ) + } + scope :before, lambda { |date| + where("(stop_at <= ?) or (start_at <= ?)", date, date ) + } + + def alloweds_types + self.block.allow_types :TitleContent, :TextContent, :ImageContent, :LinkContent, :GalleryContent, :HtmlContent + + end + + after_create do + if self.event_id and Event.where(:id => self.event_id).exists? + + event = Event.find(self.event_id) + + @block = event.block.dup + @block.blockable = self + @block.save + + else + @block = Block.new(:block_name => "general") + @block.blockable = self + @block.save + end + + + end + + def create_block(event_id=nil) + if event_id + + else + + + + end + end + + before_validation do + + if !self.skip_date + self.stop_at_date, self.stop_at_time = nil, nil if !self.stop_date + self.start_at_time, self.stop_at_time = nil, nil if self.entire_day + + if self.entire_day + self.start_at = self.start_at_date.to_s + self.stop_at = self.stop_at_date.to_s + else + self.start_at = self.start_at_date.to_s+" "+self.start_at_time.to_s + self.stop_at = self.stop_at_date.to_s+" "+self.stop_at_time.to_s + + end + + end + + if self.stop_date and self.start_at and (self.stop_at.beginning_of_day != self.start_at.beginning_of_day) + self.many_days = true + else + self.many_days = false + end + + true + + end + + def with_time? + true if !self.entire_day + end + + after_initialize do + if self.start_at + if self.entire_day + self.start_at_date = self.start_at.strftime('%d/%m/%Y') + else + self.start_at_date = self.start_at.strftime('%d/%m/%Y') + self.start_at_time = self.start_at.strftime('%H:%M') + end + end + + if self.stop_at + if self.entire_day + self.stop_at_date = self.stop_at.strftime('%d/%m/%Y') + else + self.stop_at_date = self.stop_at.strftime('%d/%m/%Y') + self.stop_at_time = self.stop_at.strftime('%H:%M') + end + end + end + + def human_date + + + + end +end diff --git a/app/views/admin/events/_event.html.haml b/app/views/admin/events/_event.html.haml new file mode 100644 index 0000000..f95ae85 --- /dev/null +++ b/app/views/admin/events/_event.html.haml @@ -0,0 +1,13 @@ +%tr#event_row.event_row{:id => event.id} + + %td{:style => "width:400px"}= event_human_date(event) + %td=event.title + + + %td.actions{:style => "width:200px;text-align:right;"} + = link_to i(:copy), new_admin_event_path(:event_id => event), :remote => true, :style => "padding-right:5px;" + = link_to i(:trash), [:admin, event], :confirm => 'Voulez-vous vraiment supprimer cet événement ?', :method => :delete, :remote => true + = link_to i(:pencil), edit_admin_event_path(event), :remote => true + = link_to i(:plus), edit_admin_event_path(event), :style => "padding:5px;", :class => "show_details" + + diff --git a/app/views/admin/events/_form.html.haml b/app/views/admin/events/_form.html.haml new file mode 100644 index 0000000..9c8ca5d --- /dev/null +++ b/app/views/admin/events/_form.html.haml @@ -0,0 +1,50 @@ += semantic_form_for [:admin,@event], :remote => true do |form| + .content + = form.inputs do + = form.input :title, :label => "Titre :" + = form.hidden_field :event_id + + .event_date_form + -if form.object.errors.messages[:start_at_date] or form.object.errors.messages[:start_at_time] or form.object.errors.messages[:stop_at_date] or form.object.errors.messages[:stop_at_time] + %p.errors + Tout les champs doivent être remplis. Les dates doivent être au format jj/mm/yyyy et les heures au format hh:mm. + .div + =form.label :start_at_date, "Début :", :style=>"display:inline-block;width:50px" + =form.text_field :start_at_date, :id => "event_start_at_date", :class => "datepicker" + .event_time{:style => "display:inline;"} + =form.label :start_at_time, "heure :" + .input-append.bootstrap-timepicke{:style => "display:inline-block;"} + =form.text_field :start_at_time, :id => "event_start_at_time", :class => "timepicker input-small", :style => "width:50px" + %span.add-on + %i.icon-time + + + =form.check_box :entire_day, :id => "event_entire_day" + =form.label :entire_day, "jour entier ?" + .div + %span.stop_at + =form.label :stop_at_date, "Fin :", :style=>"display:inline-block;width:50px" + =form.text_field :stop_at_date, :id => "event_stop_at_date", :class => "datepicker" + .event_time{:style => "display:inline;"} + =form.label :stop_at_time, "heure :" + .input-append.bootstrap-timepicke{:style => "display:inline-block;"} + =form.text_field :stop_at_time, :id => "event_stop_at_time", :class => "timepicker input-small", :style => "width:50px" + %span.add-on + %i.icon-time + + + =form.check_box :stop_date, :id => "event_stop_date" + =form.label :stop_date, "fin précisée ?" + + + = form.inputs do + = form.input :description, :label => "Description courte :", :as => :text + + + + + .actions + = form.submit "Sauvegarder", :class => "btn" + + :javascript + update_event_form(); \ No newline at end of file diff --git a/app/views/admin/events/_index_block.html.haml b/app/views/admin/events/_index_block.html.haml new file mode 100644 index 0000000..b41a012 --- /dev/null +++ b/app/views/admin/events/_index_block.html.haml @@ -0,0 +1,28 @@ + +.search_pannel + + =form_tag "", :method => "get", :remote => true do + .input-append + =text_field_tag :start, params[:start],:class => "datepicker", :placeholder => "Début" + %button.btn{:onclick => "$(this).prev('input').val('');"} + =i(:remove, :icon => false) + + .input-append + =text_field_tag :stop, params[:stop],:class => "datepicker", :placeholder => "Fin" + %button.btn + =i(:remove, :icon => false) + + + + =submit_tag "filtrer", :class => "btn", :style => "margin-bottom: 10px;" + + + + + +%table#events.table.table-hover + =render @events + #pagination + = paginate @events, :remote => true + + diff --git a/app/views/admin/events/_show.html.haml b/app/views/admin/events/_show.html.haml new file mode 100644 index 0000000..25bd2b6 --- /dev/null +++ b/app/views/admin/events/_show.html.haml @@ -0,0 +1,6 @@ +#event_show + %h1 + =@event.title + %em=event_human_date(@event) + + .desc=simple_format @event.description \ No newline at end of file diff --git a/app/views/admin/events/cible.html.haml b/app/views/admin/events/cible.html.haml new file mode 100644 index 0000000..dc7582c --- /dev/null +++ b/app/views/admin/events/cible.html.haml @@ -0,0 +1,6 @@ + +-Event.all.each do |actuality| + + %h4 + =actuality.title + = link_to i(:check_alt, :gray_light,12), "#",:onclick => "manager_send_cible("+actuality.id.to_s+", 'Folder', '#{escape_javascript(actuality.cible_name)}');return false;" if params[:manager] diff --git a/app/views/admin/events/create.js.erb b/app/views/admin/events/create.js.erb new file mode 100644 index 0000000..9b55c26 --- /dev/null +++ b/app/views/admin/events/create.js.erb @@ -0,0 +1,4 @@ +close_pane_hover(); + +$('#events').html("<%= escape_javascript(render(@events))%>"); +$('#event_row_<%= @event.id %>').effect("highlight", {}, 3000); diff --git a/app/views/admin/events/destroy.js.erb b/app/views/admin/events/destroy.js.erb new file mode 100644 index 0000000..0cb6a02 --- /dev/null +++ b/app/views/admin/events/destroy.js.erb @@ -0,0 +1 @@ +$('#event_row_<%=@event.id%>').remove(); diff --git a/app/views/admin/events/edit.html.haml b/app/views/admin/events/edit.html.haml new file mode 100644 index 0000000..5465357 --- /dev/null +++ b/app/views/admin/events/edit.html.haml @@ -0,0 +1,60 @@ + +#toolbar-text + + + + +#event_block_edit{:style => "margin-right:330px;margin-top:45px;"} + + =render :partial => "admin/blocks/block", :locals => {:block => @event.block, :sortable => true} + + + +#menu_item_inspector_container + .accordion#menu_item_informations + + .accordion-group + .inspector_handle + .accordion-heading.navbar-inner.navbar-inverse + %a.accordion-toggle{:href => "#collapseOne",:data => {:toggle => "collapse", :parent => "#menu_item_informations"}} + Infos sur l'event + + + #collapseOne.accordion-body.collapse + .accordion-inner + =link_to "modifier", edit_admin_event_path(@event), :remote => true,:class => "btn" + =render :partial => "show" + + + .accordion-heading.navbar-inner.navbar-inverse + %a.accordion-toggle{:href => "#collapse2",:data => {:toggle => "collapse", :parent => "#menu_item_informations"}} + éléments + + + #collapse2.accordion-body.collapse.in + .accordion-inner + .block_portlets_sortable#content_types + -@event.alloweds_types.each do |slug, name| + + .portlet{:id => slug, :data_type => slug} + =image_tag("admin/content_type/type_"+slug.to_s+".png", :alt => name, :class => "handle") + + + + .accordion-heading.navbar-inner.navbar-inverse + %a.accordion-toggle{:href => "#collapse3",:data => {:toggle => "collapse", :parent => "#menu_item_informations"}} + Modifier l'élément + + + #collapse3.accordion-body.collapse +   + #element_form + + + + + + + + + diff --git a/app/views/admin/events/edit.js.erb b/app/views/admin/events/edit.js.erb new file mode 100644 index 0000000..61c7a6f --- /dev/null +++ b/app/views/admin/events/edit.js.erb @@ -0,0 +1 @@ +show_pane_hover("<%= escape_javascript(render(:partial => "form"))%>",850,600); \ No newline at end of file diff --git a/app/views/admin/events/index.html.haml b/app/views/admin/events/index.html.haml new file mode 100644 index 0000000..a0bbac2 --- /dev/null +++ b/app/views/admin/events/index.html.haml @@ -0,0 +1,8 @@ +.header + .right= link_to 'Ajouter un événement', new_admin_event_path, :class => "btn", :remote => true + %h1 Agenda + +#events_index=render :partial => "index_block" + +#event_detail + diff --git a/app/views/admin/events/index.js.erb b/app/views/admin/events/index.js.erb new file mode 100644 index 0000000..3a8ebdc --- /dev/null +++ b/app/views/admin/events/index.js.erb @@ -0,0 +1 @@ +$('#events_index').html("<%= escape_javascript(render(:partial => "index_block"))%>"); diff --git a/app/views/admin/events/new.js.erb b/app/views/admin/events/new.js.erb new file mode 100644 index 0000000..fe50966 --- /dev/null +++ b/app/views/admin/events/new.js.erb @@ -0,0 +1,2 @@ +show_pane_hover("<%= escape_javascript(render(:partial => "form"))%>",850,600); + diff --git a/app/views/admin/events/update.js.erb b/app/views/admin/events/update.js.erb new file mode 100644 index 0000000..64de6b8 --- /dev/null +++ b/app/views/admin/events/update.js.erb @@ -0,0 +1,5 @@ +close_pane_hover(); + +$('#event_show').replaceWith("<%= escape_javascript(render(:partial => "show"))%>"); +$('#events').html("<%= escape_javascript(render(@events))%>"); +$('#event_row_<%= @event.id %>').effect("highlight", {}, 3000); \ No newline at end of file diff --git a/app/views/public/events/_event.haml b/app/views/public/events/_event.haml deleted file mode 100644 index d979e80..0000000 --- a/app/views/public/events/_event.haml +++ /dev/null @@ -1,9 +0,0 @@ -%a{:href => public_event_path(event.slug)} - .event - =image_tag event.image_file.file.large.medium.small.url if event.image_file - .date - =l event.start_at, :format => :date if event.start_at - %h3= event.title - =simple_format event.description - .clear - \ No newline at end of file diff --git a/app/views/public/events/_event.html.haml b/app/views/public/events/_event.html.haml new file mode 100644 index 0000000..0e02b87 --- /dev/null +++ b/app/views/public/events/_event.html.haml @@ -0,0 +1,15 @@ += event_human_date(event) + +%ul + %li + %strong=event.title + + + -if event.description and event.description != "" + =":" + = truncate(event.description, :length => 150) + + -if event.block.portlets.size > 0 + %br=link_to "En savoir plus", public_event_path(event) + + diff --git a/app/views/public/events/_small_calendar.html.haml b/app/views/public/events/_small_calendar.html.haml new file mode 100644 index 0000000..50434e6 --- /dev/null +++ b/app/views/public/events/_small_calendar.html.haml @@ -0,0 +1,119 @@ +-if params[:year] and params[:month] + -@date = Date.new(params[:year].to_i,params[:month].to_i) +-else + -@date = Time.now + + + + +-@start_date = @date + +-@end_date = @start_date + 1.month + + + + +- @start_month_date = @start_date.beginning_of_month + +- @end_month_date = @start_month_date.end_of_month + +- @start_week_date = @start_month_date.beginning_of_week + +-date_actu = @start_week_date +-@compteur = 0 + +-if params[:year] and params[:month] + %h2 + Agenda + =l @date, :format => :month_and_year +-else + %h2 + Agenda + =l @date, :format => :month_and_year + + + + +%table + %tr + %th Lu + %th Ma + %th Me + %th Je + %th Ve + %th Sa + %th Di + + + %tr + -while date_actu < @start_month_date + -events = Event.where('start_at < ? AND stop_at > ?',date_actu.end_of_day, date_actu.beginning_of_day) + + -if events.size > 0 + %td.event.no=date_actu.day + -else + %td.no=date_actu.day + -date_actu = date_actu + 1.day + -@compteur += 1 + -if @compteur == 7 + =raw "" + -@compteur = 0 + + -while date_actu <= @end_month_date + -events = Event.where('start_at < ? AND stop_at > ?',date_actu.end_of_day, date_actu.beginning_of_day) + + -if events.size > 0 + %td.event + %a.thickbox{:title => l( date_actu, :format => :only_date), :rel => "event", :href => "#TB_inline?height=500&width=500&inlineId=calendar_event_"+date_actu.year.to_s+"-"+date_actu.month.to_s+"-"+date_actu.day.to_s} + -if date_actu.to_date == Time.now.to_date + %strong=date_actu.day + -else + =date_actu.day + #calendar_event.small_calendar_event{:id =>date_actu.year.to_s+"-"+date_actu.month.to_s+"-"+date_actu.day.to_s } + -events_day = Event.where('start_at < ? AND stop_at > ?',date_actu.end_of_day, date_actu.beginning_of_day ).where(:many_days => true).order("stop_at DESC") + + -events_day.each do |event| + .event_day + =render :object => event, :partial => "public/events/small_event", :as => :event + +
+ -events_time = Event.where('start_at < ? AND stop_at > ?',date_actu.end_of_day, date_actu.beginning_of_day).where(:many_days => false) + -events_time.each do |event| + .event_day + =render :object => event, :partial => "public/events/small_event", :as => :event + + + + + + + -else + %td + -if date_actu.to_date == Time.now.to_date + %strong=date_actu.day + -else + =date_actu.day + + -date_actu = date_actu + 1.day + -@compteur += 1 + -if @compteur == 7 + =raw "" + -@compteur = 0 + + + -while date_actu <= @end_month_date.end_of_week + -events = Event.where('start_at < ? AND stop_at > ?',date_actu.end_of_day, date_actu.beginning_of_day) + + -if events.size > 0 + %td.event.no + =date_actu.day + .small_calendar_event + + + -else + %td.no=date_actu.day + -date_actu = date_actu + 1.day + -@compteur += 1 + -if @compteur == 7 + =raw "" + -@compteur = 0 \ No newline at end of file diff --git a/app/views/public/events/_small_event.html.haml b/app/views/public/events/_small_event.html.haml new file mode 100644 index 0000000..8ef885e --- /dev/null +++ b/app/views/public/events/_small_event.html.haml @@ -0,0 +1,14 @@ + + +%h3=event.title +%p + = event_human_date(event) +-if event.description and event.description != "" + %p=simple_format(event.description) + +=link_to "En savoir plus", public_event_path(event) +%br +%br + + + diff --git a/app/views/public/events/index.html.haml b/app/views/public/events/index.html.haml index c6823f2..c751a9d 100644 --- a/app/views/public/events/index.html.haml +++ b/app/views/public/events/index.html.haml @@ -1,2 +1,27 @@ -%h1 Liste des événements -=render @events \ No newline at end of file +%p + + -first_month = @start_list_date.beginning_of_month + -last_month = @end_list_date.beginning_of_month + -the_month = first_month + + + -while the_month <= last_month + %h2{:class => "month_title"}=l(the_month.to_date, :format => :month_and_year) + .month_content + =render :partial => "public/events/event", :collection =>Event.where('start_at < ? AND stop_at > ?',the_month.next_month, the_month.beginning_of_month).order(:start_at) + + -the_month = the_month.next_month + + + + + + +%h2{:class => "month_title"} Agenda par mois +%ul + -first_month = Event.order(:start_at).first.start_at.beginning_of_month + -last_month = Event.order(:start_at).last.start_at.beginning_of_month + -the_month = last_month + -while the_month >= first_month + %li=link_to l(the_month.to_date, :format => :month_and_year), public_events_path(:year => the_month.year, :month => the_month.month) + -the_month = the_month.last_month diff --git a/app/views/public/events/show.html.haml b/app/views/public/events/show.html.haml index d892f5e..de97d4c 100644 --- a/app/views/public/events/show.html.haml +++ b/app/views/public/events/show.html.haml @@ -1,2 +1,15 @@ -=render @event + + +-@event = Event.find(params[:id]) + + +%h2=@event.title += event_human_date(@event) + +.agenda_description + =simple_format @event.description + + =render @event.block + + diff --git a/config/locales/fr.old.yml b/config/locales/fr.old.yml new file mode 100644 index 0000000..faafece --- /dev/null +++ b/config/locales/fr.old.yml @@ -0,0 +1,207 @@ +# French translations for Ruby on Rails +# by Christian Lescuyer (christian@flyingcoders.com) +# contributors: +# - Sebastien Grosjean - ZenCocoon.com +# - Bruno Michel - http://github.com/nono +# - Tsutomu Kuroda - http://github.com/kuroda (t-kuroda@oiax.jp) + +fr: + views: + pagination: + first: "«" + last: "»" + previous: "‹ " + next: " ›" + truncate: "…" + helpers: + page_entries_info: + one_page: + display_entries: + zero: "No %{entry_name} found" + one: "Displaying 1 %{entry_name}" + other: "Displaying all %{count} %{entry_name}" + more_pages: + display_entries: "Displaying %{entry_name} %{first} - %{last} of %{total} in total" + + + date: + formats: + default: "%d/%m/%Y" + short: "%e %b" + long: "%e %B %Y" + only_month: "%B %Y" + only_month_name: "%B" + human_date: "%A %-d %B %Y" + day_names: [dimanche, lundi, mardi, mercredi, jeudi, vendredi, samedi] + abbr_day_names: [dim, lun, mar, mer, jeu, ven, sam] + month_names: [~, janvier, février, mars, avril, mai, juin, juillet, août, septembre, octobre, novembre, décembre] + abbr_month_names: [~, jan., fév., mar., avr., mai, juin, juil., août, sept., oct., nov., déc.] + order: + - :day + - :month + - :year + + time: + formats: + default: "%d %B %Y %H:%M:%S" + date: "%d %B %Y" + short: "%d %b %H:%M" + long: "%A %d %B %Y %H:%M" + human: "le %A %d %B %Y à %Hh%M" + human_date: "%A %-d %B %Y" + am: 'am' + pm: 'pm' + + datetime: + distance_in_words: + half_a_minute: "une demi-minute" + less_than_x_seconds: + zero: "moins d'une seconde" + one: "moins d'une seconde" + other: "moins de %{count} secondes" + x_seconds: + one: "1 seconde" + other: "%{count} secondes" + less_than_x_minutes: + zero: "moins d'une minute" + one: "moins d'une minute" + other: "moins de %{count} minutes" + x_minutes: + one: "1 minute" + other: "%{count} minutes" + about_x_hours: + one: "environ une heure" + other: "environ %{count} heures" + x_days: + one: "1 jour" + other: "%{count} jours" + about_x_months: + one: "environ un mois" + other: "environ %{count} mois" + x_months: + one: "1 mois" + other: "%{count} mois" + about_x_years: + one: "environ un an" + other: "environ %{count} ans" + over_x_years: + one: "plus d'un an" + other: "plus de %{count} ans" + almost_x_years: + one: "presqu'un an" + other: "presque %{count} ans" + prompts: + year: "Année" + month: "Mois" + day: "Jour" + hour: "Heure" + minute: "Minute" + second: "Seconde" + + number: + format: + separator: "," + delimiter: " " + precision: 3 + significant: false + strip_insignificant_zeros: false + currency: + format: + format: "%n %u" + unit: "€" + separator: "," + delimiter: " " + precision: 2 + significant: false + strip_insignificant_zeros: false + percentage: + format: + delimiter: "" + precision: + format: + delimiter: "" + human: + format: + delimiter: "" + precision: 2 + significant: true + strip_insignificant_zeros: true + storage_units: + format: "%n %u" + units: + byte: + one: "octet" + other: "octets" + kb: "ko" + mb: "Mo" + gb: "Go" + tb: "To" + decimal_units: + format: "%n %u" + units: + unit: "" + thousand: "millier" + million: "million" + billion: "milliard" + trillion: "billion" + quadrillion: "million de milliards" + + support: + array: + words_connector: ", " + two_words_connector: " et " + last_word_connector: " et " + select: + prompt: "Veuillez sélectionner" + + helpers: + select: + prompt: "Veuillez sélectionner" + submit: + create: "Créer un %{model}" + update: "Modifier ce %{model}" + submit: "Enregistrer ce %{model}" + + attributes: + created_at: "Créé le" + updated_at: "Modifié le" + password: "mot de passe" + + errors: + format: "Le %{attribute} %{message}" + messages: &errors_messages + inclusion: "n'est pas inclus(e) dans la liste" + exclusion: "n'est pas disponible" + invalid: "n'est pas valide" + confirmation: "ne concorde pas avec la confirmation" + accepted: "doit être accepté(e)" + empty: "doit être rempli(e)" + blank: "doit être rempli(e)" + too_long: "est trop long (pas plus de %{count} caractères)" + too_short: "est trop court (au moins %{count} caractères)" + wrong_length: "ne fait pas la bonne longueur (doit comporter %{count} caractères)" + not_a_number: "n'est pas un nombre" + not_an_integer: "doit être un nombre entier" + greater_than: "doit être supérieur à %{count}" + greater_than_or_equal_to: "doit être supérieur ou égal à %{count}" + equal_to: "doit être égal à %{count}" + less_than: "doit être inférieur à %{count}" + less_than_or_equal_to: "doit être inférieur ou égal à %{count}" + odd: "doit être impair" + even: "doit être pair" + template: &errors_template + header: + one: "Impossible d'enregistrer ce %{model} : 1 erreur" + other: "Impossible d'enregistrer ce %{model} : %{count} erreurs" + body: "Veuillez vérifier les champs suivants : " + + activerecord: + errors: + messages: + taken: "n'est pas disponible" + record_invalid: "La validation a échoué : %{errors}" + <<: *errors_messages + template: + <<: *errors_template + full_messages: + format: "%{attribute} %{message}" \ No newline at end of file diff --git a/config/locales/fr.yml b/config/locales/fr.yml index faafece..ff89a7b 100644 --- a/config/locales/fr.yml +++ b/config/locales/fr.yml @@ -4,6 +4,8 @@ # - Sebastien Grosjean - ZenCocoon.com # - Bruno Michel - http://github.com/nono # - Tsutomu Kuroda - http://github.com/kuroda (t-kuroda@oiax.jp) +# Emended by Benjamin des Gachons and Patrick Chew : + fr: views: @@ -23,19 +25,61 @@ fr: more_pages: display_entries: "Displaying %{entry_name} %{first} - %{last} of %{total} in total" - date: formats: default: "%d/%m/%Y" short: "%e %b" long: "%e %B %Y" only_month: "%B %Y" + month_and_year : "%B %Y" + only_day: "%e" only_month_name: "%B" - human_date: "%A %-d %B %Y" - day_names: [dimanche, lundi, mardi, mercredi, jeudi, vendredi, samedi] - abbr_day_names: [dim, lun, mar, mer, jeu, ven, sam] - month_names: [~, janvier, février, mars, avril, mai, juin, juillet, août, septembre, octobre, novembre, décembre] - abbr_month_names: [~, jan., fév., mar., avr., mai, juin, juil., août, sept., oct., nov., déc.] + only_year: "%Y" + only_date: "%A %e %B %Y" + day_names: + - dimanche + - lundi + - mardi + - mercredi + - jeudi + - vendredi + - samedi + abbr_day_names: + - dim + - lun + - mar + - mer + - jeu + - ven + - sam + month_names: + - ~ + - janvier + - février + - mars + - avril + - mai + - juin + - juillet + - août + - septembre + - octobre + - novembre + - décembre + abbr_month_names: + - ~ + - jan. + - fév. + - mar. + - avr. + - mai + - juin + - juil. + - août + - sept. + - oct. + - nov. + - déc. order: - :day - :month @@ -48,7 +92,14 @@ fr: short: "%d %b %H:%M" long: "%A %d %B %Y %H:%M" human: "le %A %d %B %Y à %Hh%M" - human_date: "%A %-d %B %Y" + human_date: "%A %d %B %Y" + only_month: "%B %Y" + month_and_year : "%B %Y" + only_day: "%e" + only_month_name: "%B" + only_year: "%Y" + only_date: "%A %e %B %Y" + am: 'am' pm: 'pm' @@ -151,24 +202,17 @@ fr: words_connector: ", " two_words_connector: " et " last_word_connector: " et " - select: - prompt: "Veuillez sélectionner" helpers: select: prompt: "Veuillez sélectionner" submit: - create: "Créer un %{model}" - update: "Modifier ce %{model}" - submit: "Enregistrer ce %{model}" + create: "Créer un(e) %{model}" + update: "Modifier ce(tte) %{model}" + submit: "Enregistrer ce(tte) %{model}" - attributes: - created_at: "Créé le" - updated_at: "Modifié le" - password: "mot de passe" - - errors: - format: "Le %{attribute} %{message}" + errors: &errors + format: "%{attribute} %{message}" messages: &errors_messages inclusion: "n'est pas inclus(e) dans la liste" exclusion: "n'est pas disponible" @@ -177,9 +221,15 @@ fr: accepted: "doit être accepté(e)" empty: "doit être rempli(e)" blank: "doit être rempli(e)" - too_long: "est trop long (pas plus de %{count} caractères)" - too_short: "est trop court (au moins %{count} caractères)" - wrong_length: "ne fait pas la bonne longueur (doit comporter %{count} caractères)" + too_long: + one: "est trop long (pas plus d'un caractère)" + other: "est trop long (pas plus de %{count} caractères)" + too_short: + one: "est trop court (au moins un caractère)" + other: "est trop court (au moins %{count} caractères)" + wrong_length: + one: "ne fait pas la bonne longueur (doit comporter un seul caractère)" + other: "ne fait pas la bonne longueur (doit comporter %{count} caractères)" not_a_number: "n'est pas un nombre" not_an_integer: "doit être un nombre entier" greater_than: "doit être supérieur à %{count}" @@ -189,19 +239,18 @@ fr: less_than_or_equal_to: "doit être inférieur ou égal à %{count}" odd: "doit être impair" even: "doit être pair" + taken: "n'est pas disponible" + record_invalid: "La validation a échoué : %{errors}" + template: &errors_template header: - one: "Impossible d'enregistrer ce %{model} : 1 erreur" - other: "Impossible d'enregistrer ce %{model} : %{count} erreurs" + one: "Impossible d'enregistrer ce(tte) %{model} : 1 erreur" + other: "Impossible d'enregistrer ce(tte) %{model} : %{count} erreurs" body: "Veuillez vérifier les champs suivants : " + activemodel: + errors: + <<: *errors activerecord: errors: - messages: - taken: "n'est pas disponible" - record_invalid: "La validation a échoué : %{errors}" - <<: *errors_messages - template: - <<: *errors_template - full_messages: - format: "%{attribute} %{message}" \ No newline at end of file + <<: *errors \ No newline at end of file diff --git a/db/migrate/20150309094403_create_events.rb b/db/migrate/20150309094403_create_events.rb new file mode 100644 index 0000000..f5435d0 --- /dev/null +++ b/db/migrate/20150309094403_create_events.rb @@ -0,0 +1,15 @@ +class CreateEvents < ActiveRecord::Migration + def change + create_table :events do |t| + t.string :title + t.text :description + t.datetime :start_at + t.boolean :entire_day + t.boolean :stop_date + t.datetime :stop_at + t.boolean :many_days + + t.timestamps + end + end +end diff --git a/db/schema.rb b/db/schema.rb index 128da59..5b70d53 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20150217165331) do +ActiveRecord::Schema.define(version: 20150309094403) do create_table "admins", force: true do |t| t.string "email", default: "", null: false @@ -202,6 +202,18 @@ ActiveRecord::Schema.define(version: 20150217165331) do t.datetime "updated_at" end + create_table "events", force: true do |t| + t.string "title" + t.text "description" + t.datetime "start_at" + t.boolean "entire_day" + t.boolean "stop_date" + t.datetime "stop_at" + t.boolean "many_days" + t.datetime "created_at" + t.datetime "updated_at" + end + create_table "external_links", force: true do |t| t.string "title" t.text "description"