diff --git a/Gemfile.lock b/Gemfile.lock index 696b692..ec3a046 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,8 +1,8 @@ PATH remote: . specs: - refinerycms-calendar (2.0.1) - refinerycms-core (~> 2.0.3) + refinerycms-calendar (2.0.2) + refinerycms-core (~> 2.0) GEM remote: http://rubygems.org/ @@ -84,7 +84,6 @@ GEM activemodel (>= 3.0.0) activerecord (>= 3.0.0) paper_trail (~> 2) - growl (1.0.3) guard (1.0.3) ffi (>= 0.5.0) thor (>= 0.14.6) @@ -98,6 +97,8 @@ GEM railties (>= 3.2.0, < 5.0) thor (~> 0.14) json (1.7.3) + libnotify (0.1.4) + ffi (>= 0.6.2) libwebsocket (0.1.3) addressable mail (2.4.4) @@ -137,7 +138,8 @@ GEM rdoc (~> 3.4) thor (~> 0.14.6) rake (0.9.2.2) - rb-fsevent (0.9.1) + rb-inotify (0.8.8) + ffi (>= 0.5.0) rdoc (3.12) json (~> 1.4) refinerycms (2.0.3) @@ -245,14 +247,14 @@ DEPENDENCIES coffee-rails factory_girl_rails generator_spec - growl (~> 1.0.3) guard-spork jquery-rails jruby-openssl + libnotify (~> 0.1.3) mysql2 pg rb-fchange (~> 0.0.5) - rb-fsevent (>= 0.3.9) + rb-inotify (>= 0.5.1) rb-notifu (~> 0.0.4) refinerycms (~> 2.0.0) refinerycms-calendar! diff --git a/Rakefile b/Rakefile index 3e2480d..bff8dd7 100644 --- a/Rakefile +++ b/Rakefile @@ -8,9 +8,7 @@ end ENGINE_PATH = File.dirname(__FILE__) APP_RAKEFILE = File.expand_path("../spec/dummy/Rakefile", __FILE__) -if File.exists?(APP_RAKEFILE) - load 'rails/tasks/engine.rake' -end +load 'rails/tasks/engine.rake' if File.exists?(APP_RAKEFILE) require "refinerycms-testing" Refinery::Testing::Railtie.load_tasks diff --git a/app/controllers/refinery/calendar/admin/events_controller.rb b/app/controllers/refinery/calendar/admin/events_controller.rb index 19a1e3d..4df5695 100644 --- a/app/controllers/refinery/calendar/admin/events_controller.rb +++ b/app/controllers/refinery/calendar/admin/events_controller.rb @@ -7,7 +7,7 @@ class EventsController < ::Refinery::AdminController crudify :'refinery/calendar/event', :xhr_paging => true, :sortable => false, - :order => "'from' DESC" + :order => "start_at DESC" private def find_venues diff --git a/app/controllers/refinery/calendar/events_controller.rb b/app/controllers/refinery/calendar/events_controller.rb index 770e6cf..e00e0e9 100644 --- a/app/controllers/refinery/calendar/events_controller.rb +++ b/app/controllers/refinery/calendar/events_controller.rb @@ -2,7 +2,7 @@ module Refinery module Calendar class EventsController < ::ApplicationController def index - @events = Event.upcoming.order('refinery_calendar_events.from DESC') + @events = Event.upcoming.order('refinery_calendar_events.start_at DESC') # you can use meta fields from your model instead (e.g. browser_title) # by swapping @page for @event in the line below: @@ -18,13 +18,13 @@ def show end def archive - @events = Event.archive.order('refinery_calendar_events.from DESC') + @events = Event.archive.order('refinery_calendar_events.start_at DESC') render :template => 'refinery/calendar/events/index' end protected def find_page - @page = ::Refinery::Page.where(:link_url => "/connect/events").first + @page = ::Refinery::Page.where(:link_url => "/events").first end end diff --git a/app/decorators/controllers/refinery/.gitkeep b/app/decorators/controllers/refinery/.gitkeep deleted file mode 100644 index e69de29..0000000 diff --git a/app/decorators/models/refinery/.gitkeep b/app/decorators/models/refinery/.gitkeep deleted file mode 100644 index e69de29..0000000 diff --git a/app/models/refinery/calendar/event.rb b/app/models/refinery/calendar/event.rb index 93f02bd..aa5fed2 100644 --- a/app/models/refinery/calendar/event.rb +++ b/app/models/refinery/calendar/event.rb @@ -7,9 +7,11 @@ class Event < Refinery::Core::BaseModel belongs_to :venue - validates :title, :presence => true, :uniqueness => true + validates :title, :start_at, :end_at, :presence => true - attr_accessible :title, :from, :to, :registration_link, + validate :ends_after_it_starts + + attr_accessible :title, :start_at, :end_at, :registration_link, :venue_id, :excerpt, :description, :featured, :position @@ -18,9 +20,15 @@ class Event < Refinery::Core::BaseModel :prefix => true, :allow_nil => true + def ends_after_it_starts + if start_at && end_at && start_at > end_at + errors.add(:start_at, 'must come before the end date') + end + end + class << self def upcoming - where('refinery_calendar_events.from >= ?', Time.now) + where('refinery_calendar_events.start_at >= ?', Time.now) end def featured @@ -28,7 +36,7 @@ def featured end def archive - where('refinery_calendar_events.from < ?', Time.now) + where('refinery_calendar_events.start_at < ?', Time.now) end end end diff --git a/app/views/refinery/calendar/admin/events/_form.html.erb b/app/views/refinery/calendar/admin/events/_form.html.erb index 2127ca9..d75f789 100644 --- a/app/views/refinery/calendar/admin/events/_form.html.erb +++ b/app/views/refinery/calendar/admin/events/_form.html.erb @@ -17,13 +17,13 @@
- <%= f.label :from -%> - <%= f.text_field :from, :class => 'datetime_range' -%> + <%= f.label :start_at -%> + <%= f.text_field :start_at, :class => 'datetime_range' -%>
- <%= f.label :to -%> - <%= f.text_field :to, :class => 'datetime_range' -%> + <%= f.label :end_at -%> + <%= f.text_field :end_at, :class => 'datetime_range' -%>
@@ -32,8 +32,8 @@
- <%= f.label :venue_id, 'Venue' %> - <%= f.collection_select :venue_id, @venues, :id, :name, { :include_blank => 'None' }, :class => 'chzn-select', :'data-placeholder' => 'Search Venues', :style => 'width: 300px;' %> + <%= f.label :venue_id, t('venue', :scope => "activerecord.attributes.refinery/calendar/event") %> + <%= f.collection_select :venue_id, @venues, :id, :name, { :include_blank => t('venue_none', :scope => "activerecord.attributes.refinery/calendar/event") }, :class => 'chzn-select', :'data-placeholder' => 'Search Venues', :style => 'width: 300px;' %>
diff --git a/app/views/refinery/calendar/admin/events/_records.html.erb b/app/views/refinery/calendar/admin/events/_records.html.erb index f6806b4..a005704 100644 --- a/app/views/refinery/calendar/admin/events/_records.html.erb +++ b/app/views/refinery/calendar/admin/events/_records.html.erb @@ -8,7 +8,7 @@

<% unless searching? %> - <%= t('.no_items_yet') %> + <%= t('.no_items_yet', :create => t('create_new', :scope => 'refinery.calendar.admin.events.actions')) %> <% else %> <%= t('no_results', :scope => 'refinery.admin.search') %> diff --git a/app/views/refinery/calendar/admin/events/index.html.erb b/app/views/refinery/calendar/admin/events/index.html.erb index 5b8c5bf..8d6b69a 100644 --- a/app/views/refinery/calendar/admin/events/index.html.erb +++ b/app/views/refinery/calendar/admin/events/index.html.erb @@ -1,5 +1,5 @@

-

Calendar: Events

+

<%= t('title', :scope => 'refinery.calendar.admin.events.records') %>

<%= render 'records' %>