tb_events 1.2.0.beta1 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
- data/Rakefile +2 -2
- data/app/assets/stylesheets/admin/events/calendars.css +11 -2
- data/app/controllers/admin/calendar_events_controller.rb +9 -11
- data/app/controllers/admin/calendars_controller.rb +8 -10
- data/app/controllers/calendar_events_controller.rb +5 -7
- data/app/controllers/calendars_controller.rb +3 -5
- data/app/helpers/admin/calendars_helper.rb +6 -8
- data/app/helpers/calendars_helper.rb +20 -14
- data/app/models/spud_calendar.rb +13 -15
- data/app/models/spud_calendar_event.rb +1 -2
- data/app/models/spud_events/calendar_event_model.rb +31 -0
- data/app/views/admin/calendar_events/_form.html.erb +4 -4
- data/config/routes.rb +7 -9
- data/db/migrate/20120216191833_create_spud_calendars.rb +2 -2
- data/db/migrate/20140730182213_remove_color_from_spud_calendars.rb +1 -0
- data/lib/spud_events/calendar_builder.rb +8 -9
- data/lib/spud_events/engine.rb +14 -10
- data/lib/spud_events/version.rb +1 -1
- data/lib/tb_events.rb +4 -4
- metadata +50 -65
- data/app/models/spud/spud_calendar_event_model.rb +0 -25
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: d8495699ef036385ff906c76c7d34b616b024c3c167f4e543d929d8cc15c95bf
|
4
|
+
data.tar.gz: c384b0864d671436b70da6aedd9877657f95d588227958fcb73569771ac3fa21
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9473623e16c4e10a2184574bf4c5fc9b5e6bc5bf2c18f725dce12dc6696b97a85761b223446ad2b341be0095cc1f04fb99e005da86bddb1a7b1781fb2cb23a7b
|
7
|
+
data.tar.gz: 441459722f410fc0aff5508b49345c359953ad722a3dabdc75f34799b8afaa7cecc6064dacc6335284dda39c4f4d5312084e4c8c7e5718a25b64ff75f02e6888
|
data/Rakefile
CHANGED
@@ -20,9 +20,9 @@ RDoc::Task.new(:rdoc) do |rdoc|
|
|
20
20
|
rdoc.rdoc_files.include('lib/**/*.rb')
|
21
21
|
end
|
22
22
|
|
23
|
-
APP_RAKEFILE = File.expand_path(
|
23
|
+
APP_RAKEFILE = File.expand_path('../spec/dummy/Rakefile', __FILE__)
|
24
24
|
load 'rails/tasks/engine.rake'
|
25
25
|
|
26
26
|
Bundler::GemHelper.install_tasks
|
27
27
|
|
28
|
-
require 'rake'
|
28
|
+
require 'rake'
|
@@ -64,7 +64,7 @@
|
|
64
64
|
margin: 15px 0 0;
|
65
65
|
}
|
66
66
|
#spud_events_admin_calendar th,
|
67
|
-
#spud_events_calendar th {
|
67
|
+
#spud_events_calendar th {
|
68
68
|
text-align: center;
|
69
69
|
}
|
70
70
|
#spud_events_admin_calendar td,
|
@@ -83,9 +83,18 @@
|
|
83
83
|
font-size: 11px;
|
84
84
|
line-height: 11px;
|
85
85
|
}
|
86
|
+
|
87
|
+
.not-month .calendar-day {
|
88
|
+
display: none;
|
89
|
+
}
|
90
|
+
.not-month .calendar-events {
|
91
|
+
display: none;
|
92
|
+
}
|
93
|
+
|
86
94
|
.calendar-events-list{
|
87
95
|
list-style: none;
|
88
|
-
margin:
|
96
|
+
margin: 10px 0 0;
|
97
|
+
padding: 0;
|
89
98
|
}
|
90
99
|
.calendar-events-list li{
|
91
100
|
margin: 4px;
|
@@ -1,10 +1,9 @@
|
|
1
1
|
class Admin::CalendarEventsController < Admin::ApplicationController
|
2
|
-
|
3
|
-
|
4
|
-
belongs_to_spud_app :events
|
2
|
+
add_breadcrumb 'Events', :admin_list_spud_calendar_events_path
|
3
|
+
belongs_to_app :events
|
5
4
|
|
6
5
|
respond_to :html, :xml, :json
|
7
|
-
respond_to :js, :
|
6
|
+
respond_to :js, only: [:index]
|
8
7
|
|
9
8
|
def index
|
10
9
|
if params[:month]
|
@@ -28,7 +27,7 @@ class Admin::CalendarEventsController < Admin::ApplicationController
|
|
28
27
|
@calendars = SpudCalendar.all
|
29
28
|
@current_calendar = params[:spud_calendar] ? params[:spud_calendar] : 0
|
30
29
|
|
31
|
-
respond_with(@calendars, :
|
30
|
+
respond_with(@calendars, include: :events)
|
32
31
|
end
|
33
32
|
|
34
33
|
def new
|
@@ -45,25 +44,24 @@ class Admin::CalendarEventsController < Admin::ApplicationController
|
|
45
44
|
def create
|
46
45
|
@calendar_event = SpudCalendarEvent.new(calendar_event_params)
|
47
46
|
flash[:notice] = 'Calendar event was successfully created.' if @calendar_event.save
|
48
|
-
respond_with(@calendar_event, :
|
47
|
+
respond_with(@calendar_event, location: admin_list_spud_calendar_events_path)
|
49
48
|
end
|
50
49
|
|
51
50
|
def update
|
52
51
|
@calendar_event = SpudCalendarEvent.find(params[:id])
|
53
52
|
flash[:notice] = 'Calendar event was successfully updated.' if @calendar_event.update_attributes(calendar_event_params)
|
54
|
-
respond_with(@calendar_event, :
|
53
|
+
respond_with(@calendar_event, location: admin_list_spud_calendar_events_path)
|
55
54
|
end
|
56
55
|
|
57
56
|
def destroy
|
58
57
|
@calendar_event = SpudCalendarEvent.find(params[:id])
|
59
|
-
@calendar_event.destroy
|
60
|
-
respond_with(@calendar_event, :
|
58
|
+
flash[:notice] = 'Calendar event deleted successfully' if @calendar_event.destroy
|
59
|
+
respond_with(@calendar_event, location: admin_list_spud_calendar_events_path)
|
61
60
|
end
|
62
61
|
|
63
|
-
private
|
62
|
+
private
|
64
63
|
|
65
64
|
def calendar_event_params
|
66
65
|
params.require(:spud_calendar_event).permit(:title, :description, :start_at, :end_at, :all_day, :spud_calendar_id, :spud_calendar, :location, :address, :address_2, :city, :state, :zip)
|
67
66
|
end
|
68
|
-
|
69
67
|
end
|
@@ -1,13 +1,12 @@
|
|
1
1
|
class Admin::CalendarsController < Admin::ApplicationController
|
2
|
+
add_breadcrumb 'Events', :admin_list_spud_calendar_events_path
|
2
3
|
|
3
|
-
|
4
|
-
|
5
|
-
belongs_to_spud_app :events
|
4
|
+
belongs_to_app :events
|
6
5
|
|
7
6
|
respond_to :html, :xml, :json, :js
|
8
7
|
|
9
8
|
def new
|
10
|
-
@page_name =
|
9
|
+
@page_name = 'New Calendar'
|
11
10
|
@calendar = SpudCalendar.new
|
12
11
|
respond_with(@calendar)
|
13
12
|
end
|
@@ -17,12 +16,12 @@ class Admin::CalendarsController < Admin::ApplicationController
|
|
17
16
|
if @calendar.save
|
18
17
|
redirect_to admin_list_spud_calendar_events_path
|
19
18
|
else
|
20
|
-
render :
|
19
|
+
render action: 'new'
|
21
20
|
end
|
22
21
|
end
|
23
22
|
|
24
23
|
def edit
|
25
|
-
@page_name =
|
24
|
+
@page_name = 'Edit Calendar'
|
26
25
|
@calendar = SpudCalendar.find(params[:id])
|
27
26
|
respond_with(@calendar)
|
28
27
|
end
|
@@ -33,7 +32,7 @@ class Admin::CalendarsController < Admin::ApplicationController
|
|
33
32
|
flash[:notice] = 'Calendar was successfully updated.'
|
34
33
|
redirect_to admin_list_spud_calendar_events_path
|
35
34
|
else
|
36
|
-
render :
|
35
|
+
render action: 'edit'
|
37
36
|
end
|
38
37
|
end
|
39
38
|
|
@@ -44,14 +43,13 @@ class Admin::CalendarsController < Admin::ApplicationController
|
|
44
43
|
end
|
45
44
|
@calendar.destroy
|
46
45
|
respond_with(@calendar) do |format|
|
47
|
-
format.js { render(:
|
46
|
+
format.js { render(nothing: true) }
|
48
47
|
end
|
49
48
|
end
|
50
49
|
|
51
|
-
private
|
50
|
+
private
|
52
51
|
|
53
52
|
def calendar_params
|
54
53
|
params.require(:spud_calendar).permit(:title)
|
55
54
|
end
|
56
|
-
|
57
55
|
end
|
@@ -1,16 +1,14 @@
|
|
1
1
|
class CalendarEventsController < ApplicationController
|
2
|
-
|
3
2
|
respond_to :html, :json
|
4
3
|
layout SpudEvents.config.calendar_layout
|
5
|
-
|
4
|
+
|
6
5
|
def index
|
7
|
-
@events = SpudCalendarEvent.ordered.paginate(:
|
6
|
+
@events = SpudCalendarEvent.ordered.paginate(per_page: 10, page: params[:page])
|
8
7
|
respond_with @events
|
9
8
|
end
|
10
9
|
|
11
|
-
|
12
|
-
|
10
|
+
def show
|
11
|
+
@event = SpudCalendarEvent.find(params[:id])
|
13
12
|
respond_with @event
|
14
|
-
|
15
|
-
|
13
|
+
end
|
16
14
|
end
|
@@ -1,8 +1,7 @@
|
|
1
1
|
class CalendarsController < ApplicationController
|
2
|
-
|
3
2
|
respond_to :html, :json
|
4
3
|
layout SpudEvents.config.calendar_layout
|
5
|
-
before_action :
|
4
|
+
before_action :calendar_date
|
6
5
|
|
7
6
|
def show
|
8
7
|
if params[:calendar] && calendar = SpudCalendar.find_by_title(params[:calendar].titleize)
|
@@ -14,9 +13,9 @@ class CalendarsController < ApplicationController
|
|
14
13
|
respond_with @events
|
15
14
|
end
|
16
15
|
|
17
|
-
private
|
16
|
+
private
|
18
17
|
|
19
|
-
def
|
18
|
+
def calendar_date
|
20
19
|
if params[:month]
|
21
20
|
year = params[:year] ? params[:year].to_i : Date.today.year
|
22
21
|
begin
|
@@ -28,5 +27,4 @@ private
|
|
28
27
|
@calendar_date = Date.today
|
29
28
|
end
|
30
29
|
end
|
31
|
-
|
32
30
|
end
|
@@ -1,15 +1,13 @@
|
|
1
1
|
module Admin::CalendarsHelper
|
2
|
-
|
3
|
-
|
4
|
-
date = date.advance(:months => -1)
|
2
|
+
def link_to_previous_admin_calendar_month(date, _url_for_options = {})
|
3
|
+
date = date.advance(months: -1)
|
5
4
|
calendar = params[:calendar] ? params[:calendar] : nil
|
6
|
-
link_to('« Previous Month'.html_safe, admin_list_spud_calendar_events_path(:
|
5
|
+
link_to('« Previous Month'.html_safe, admin_list_spud_calendar_events_path(month: date.month, year: date.year, calendar: calendar), class: 'spud_events_calendar_link previous_calendar btn btn-sm btn-default').html_safe
|
7
6
|
end
|
8
7
|
|
9
|
-
def link_to_next_admin_calendar_month(date,
|
10
|
-
date = date.advance(:
|
8
|
+
def link_to_next_admin_calendar_month(date, _url_for_options = {})
|
9
|
+
date = date.advance(months: 1)
|
11
10
|
calendar = params[:calendar] ? params[:calendar] : nil
|
12
|
-
link_to('Next Month »'.html_safe, admin_list_spud_calendar_events_path(:
|
11
|
+
link_to('Next Month »'.html_safe, admin_list_spud_calendar_events_path(month: date.month, year: date.year, calendar: calendar), class: 'spud_events_calendar_link next_calendar btn btn-sm btn-default pull-right').html_safe
|
13
12
|
end
|
14
|
-
|
15
13
|
end
|
@@ -1,12 +1,11 @@
|
|
1
1
|
module CalendarsHelper
|
2
|
-
|
3
2
|
# Builds a calendar for the given date
|
4
3
|
#
|
5
4
|
# * date: Determines the month to be displayed. Given date will have the "today" css class
|
6
5
|
# * opts:
|
7
6
|
# - headers: Array of weekday headers (optional)
|
8
7
|
#
|
9
|
-
def spud_calendar_for_date(date, opts={}, &block)
|
8
|
+
def spud_calendar_for_date(date, opts = {}, &block)
|
10
9
|
events = SpudCalendarEvent.in_month_of(date)
|
11
10
|
spud_calendar_for_events(events, date, opts, &block)
|
12
11
|
end
|
@@ -18,7 +17,7 @@ module CalendarsHelper
|
|
18
17
|
# * opts:
|
19
18
|
# - headers: Array of weekday headers (optional)
|
20
19
|
#
|
21
|
-
def spud_calendar_for_identifier(identifier, date, opts={}, &block)
|
20
|
+
def spud_calendar_for_identifier(identifier, date, opts = {}, &block)
|
22
21
|
calendar = SpudCalendar.with_identifier(identifier)
|
23
22
|
if calendar.present?
|
24
23
|
events = calendar.spud_calendar_events.in_month_of(date)
|
@@ -36,21 +35,21 @@ module CalendarsHelper
|
|
36
35
|
# * opts:
|
37
36
|
# - headers: Array of weekday headers (optional)
|
38
37
|
#
|
39
|
-
def spud_calendar_for_events(events, date, opts={}, &block)
|
40
|
-
|
38
|
+
def spud_calendar_for_events(events, date, opts = {}, &block)
|
39
|
+
events_array = events.to_a
|
41
40
|
cache(['spud-calendar', date.to_s, events]) do
|
42
41
|
concat(
|
43
42
|
SpudEvents::CalendarBuilder.new(self, date, opts).table do |day|
|
44
|
-
events =
|
43
|
+
events = extract_events_for_date(events_array, day)
|
45
44
|
if block
|
46
45
|
block.call(day, events)
|
47
46
|
else
|
48
|
-
concat content_tag(:span, day.day.to_s, :
|
47
|
+
concat content_tag(:span, day.day.to_s, class: 'calendar-day')
|
49
48
|
if events.length > 0
|
50
|
-
list_items = events.collect
|
49
|
+
list_items = events.collect do |event|
|
51
50
|
'<li>' + link_to(event.title, calendar_event_path(event)) + '</li>'
|
52
|
-
|
53
|
-
concat content_tag(:ul, raw(list_items), :
|
51
|
+
end.join('')
|
52
|
+
concat content_tag(:ul, raw(list_items), class: 'events-list')
|
54
53
|
end
|
55
54
|
end
|
56
55
|
end
|
@@ -59,15 +58,22 @@ module CalendarsHelper
|
|
59
58
|
end
|
60
59
|
|
61
60
|
def link_to_previous_calendar_month(date)
|
62
|
-
date = date.advance(:
|
61
|
+
date = date.advance(months: -1)
|
63
62
|
calendar = params[:calendar] ? params[:calendar] : nil
|
64
|
-
link_to('« Previous Month'.html_safe, calendar_path(:
|
63
|
+
link_to('« Previous Month'.html_safe, calendar_path(month: date.month, year: date.year, calendar: calendar), class: 'spud_events_calendar_link previous_calendar btn').html_safe
|
65
64
|
end
|
66
65
|
|
67
66
|
def link_to_next_calendar_month(date)
|
68
|
-
date = date.advance(:
|
67
|
+
date = date.advance(months: 1)
|
69
68
|
calendar = params[:calendar] ? params[:calendar] : nil
|
70
|
-
link_to('Next Month »'.html_safe, calendar_path(:
|
69
|
+
link_to('Next Month »'.html_safe, calendar_path(month: date.month, year: date.year, calendar: calendar), class: 'spud_events_calendar_link next_calendar btn').html_safe
|
71
70
|
end
|
72
71
|
|
72
|
+
private
|
73
|
+
|
74
|
+
def extract_events_for_date(events, date)
|
75
|
+
events.select do |event|
|
76
|
+
date >= event.start_date && date <= event.end_date
|
77
|
+
end
|
78
|
+
end
|
73
79
|
end
|
data/app/models/spud_calendar.rb
CHANGED
@@ -1,34 +1,32 @@
|
|
1
1
|
class SpudCalendar < ActiveRecord::Base
|
2
|
-
has_many :spud_calendar_events, :
|
2
|
+
has_many :spud_calendar_events, dependent: :destroy
|
3
3
|
validates_presence_of :title
|
4
|
-
validates :identifier, :
|
4
|
+
validates :identifier, presence: true, uniqueness: true
|
5
5
|
|
6
6
|
before_validation :set_identifier
|
7
7
|
|
8
8
|
def self.with_identifier(identifier)
|
9
|
-
where(:
|
9
|
+
where(identifier: identifier).first
|
10
10
|
end
|
11
11
|
|
12
12
|
def color
|
13
|
-
modulo = (
|
14
|
-
|
13
|
+
modulo = (id - 1) % COLORS.length
|
14
|
+
COLORS[modulo]
|
15
15
|
end
|
16
16
|
|
17
|
-
COLORS =
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
]
|
17
|
+
COLORS = %w(
|
18
|
+
4D854B
|
19
|
+
f89406
|
20
|
+
b94a48
|
21
|
+
3a87ad
|
22
|
+
999999
|
23
|
+
333333)
|
25
24
|
|
26
|
-
private
|
25
|
+
private
|
27
26
|
|
28
27
|
def set_identifier
|
29
28
|
if identifier.nil? && title.present?
|
30
29
|
self.identifier = title.parameterize.underscore
|
31
30
|
end
|
32
31
|
end
|
33
|
-
|
34
32
|
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
class SpudEvents::CalendarEventModel < ActiveRecord::Base
|
2
|
+
self.table_name = 'spud_calendar_events'
|
3
|
+
|
4
|
+
belongs_to :spud_calendar
|
5
|
+
validates_presence_of :title, :start_at, :end_at, :spud_calendar_id
|
6
|
+
|
7
|
+
scope :ordered, -> { order('start_at desc') }
|
8
|
+
scope :in_month_of, lambda { |date|
|
9
|
+
where('start_at BETWEEN ? AND ? OR end_at BETWEEN ? AND ?', date.beginning_of_month, date.end_of_month, date.beginning_of_month, date.end_of_month).order('start_at asc')
|
10
|
+
# where(:start_at => date.beginning_of_month...date.end_of_month)
|
11
|
+
}
|
12
|
+
scope :upcoming, ->(limit = false) { where('start_at >= ?', Date.today).order('start_at asc').limit(limit) }
|
13
|
+
|
14
|
+
def start_date
|
15
|
+
start_at.to_date
|
16
|
+
end
|
17
|
+
|
18
|
+
def end_date
|
19
|
+
end_at.to_date
|
20
|
+
end
|
21
|
+
|
22
|
+
def days_span
|
23
|
+
(end_at.to_date - start_at.to_date).to_i + 1
|
24
|
+
end
|
25
|
+
|
26
|
+
def falls_on?(day)
|
27
|
+
start_date = start_at.beginning_of_day.to_date
|
28
|
+
end_date = end_at.end_of_day.to_date
|
29
|
+
day >= start_date && day <= end_date
|
30
|
+
end
|
31
|
+
end
|
@@ -4,8 +4,8 @@
|
|
4
4
|
<%= f.tb_select :spud_calendar_id, options_from_collection_for_select(SpudCalendar.all, :id, :title, @calendar_event.spud_calendar_id) %>
|
5
5
|
|
6
6
|
<%= f.tb_text_field :title %>
|
7
|
-
<%= f.tb_text_area :description %>
|
8
|
-
|
7
|
+
<%= f.tb_text_area :description, :style => "width:100%;", :class => 'tinymce full-width' %>
|
8
|
+
|
9
9
|
<%= f.tb_datetime_select :start_at, :ampm => true, :minute_step => 5 %>
|
10
10
|
<%= f.tb_datetime_select :end_at, :ampm => true, :minute_step => 5 %>
|
11
11
|
|
@@ -16,6 +16,6 @@
|
|
16
16
|
<%= f.tb_text_field :state %>
|
17
17
|
<%= f.tb_text_field :zip %>
|
18
18
|
|
19
|
-
<%= f.tb_save_buttons 'Event', admin_list_spud_calendar_events_path %>
|
19
|
+
<%= f.tb_save_buttons 'Event', admin_list_spud_calendar_events_path, @calendar_event.id ? admin_calendar_event_path(@calendar_event) : nil %>
|
20
20
|
|
21
|
-
<% end %>
|
21
|
+
<% end %>
|
data/config/routes.rb
CHANGED
@@ -1,13 +1,11 @@
|
|
1
1
|
Rails.application.routes.draw do
|
2
|
-
|
3
2
|
# Calendar
|
4
|
-
get 'calendar(/:month/:year)' =>
|
5
|
-
resources :calendar_events, :
|
6
|
-
|
7
|
-
namespace :admin do
|
8
|
-
resources :calendar_events, :except => [:index]
|
9
|
-
resources :calendars, :except => [:index]
|
10
|
-
get 'events(/:month(/:year(/:calendar)))' => "calendar_events#index", :as => "list_spud_calendar_events"
|
11
|
-
end
|
3
|
+
get 'calendar(/:month/:year)' => 'calendars#show', :as => :calendar
|
4
|
+
resources :calendar_events, only: [:index, :show], path: '/events'
|
12
5
|
|
6
|
+
namespace :admin do
|
7
|
+
resources :calendar_events, except: [:index]
|
8
|
+
resources :calendars, except: [:index]
|
9
|
+
get 'events(/:month(/:year(/:calendar)))' => 'calendar_events#index', :as => 'list_spud_calendar_events'
|
10
|
+
end
|
13
11
|
end
|
@@ -1,9 +1,8 @@
|
|
1
1
|
class SpudEvents::CalendarBuilder
|
2
|
-
|
3
|
-
DEFAULT_HEADERS = %w[Sunday Monday Tuesday Wednesday Thursday Friday Saturday]
|
2
|
+
DEFAULT_HEADERS = %w(Sunday Monday Tuesday Wednesday Thursday Friday Saturday)
|
4
3
|
START_DAY = :sunday
|
5
4
|
|
6
|
-
delegate :content_tag, :
|
5
|
+
delegate :content_tag, to: :view
|
7
6
|
attr_accessor :view, :date, :callback
|
8
7
|
|
9
8
|
def initialize(view, date, opts)
|
@@ -14,16 +13,16 @@ class SpudEvents::CalendarBuilder
|
|
14
13
|
|
15
14
|
def table(&block)
|
16
15
|
@callback = block
|
17
|
-
content_tag :table, :
|
16
|
+
content_tag :table, class: 'calendar' do
|
18
17
|
header + week_rows
|
19
18
|
end
|
20
19
|
end
|
21
20
|
|
22
|
-
private
|
21
|
+
private
|
23
22
|
|
24
23
|
def header
|
25
24
|
content_tag :tr do
|
26
|
-
@headers.map { |day| content_tag :th, day, :
|
25
|
+
@headers.map { |day| content_tag :th, day, class: 'day-header' }.join.html_safe
|
27
26
|
end
|
28
27
|
end
|
29
28
|
|
@@ -41,9 +40,9 @@ private
|
|
41
40
|
|
42
41
|
def day_classes(day)
|
43
42
|
classes = ['day-cell']
|
44
|
-
classes <<
|
45
|
-
classes <<
|
46
|
-
classes.empty? ? nil : classes.join(
|
43
|
+
classes << 'today' if day == Date.today
|
44
|
+
classes << 'not-month' if day.month != date.month
|
45
|
+
classes.empty? ? nil : classes.join(' ')
|
47
46
|
end
|
48
47
|
|
49
48
|
def weeks
|
data/lib/spud_events/engine.rb
CHANGED
@@ -2,18 +2,22 @@ require 'tb_core'
|
|
2
2
|
|
3
3
|
module SpudEvents
|
4
4
|
class Engine < Rails::Engine
|
5
|
-
|
5
|
+
engine_name :tb_events
|
6
6
|
config.autoload_paths << "#{root}/lib"
|
7
7
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
8
|
+
initializer :admin do
|
9
|
+
TbCore.configure do |config|
|
10
|
+
config.admin_applications += [{ name: 'Events', thumbnail: 'spud/admin/events_thumb.png', url: '/admin/events', order: 10 }]
|
11
|
+
end
|
12
|
+
end
|
13
13
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
14
|
+
initializer :assets do |_config|
|
15
|
+
TbCore.append_admin_stylesheets('admin/events/application')
|
16
|
+
TbCore.append_admin_javascripts('admin/events/application')
|
17
|
+
end
|
18
|
+
|
19
|
+
initializer 'tb_events.assets' do
|
20
|
+
Rails.application.config.assets.precompile += ['spud/admin/events_thumb.png']
|
21
|
+
end
|
18
22
|
end
|
19
23
|
end
|
data/lib/spud_events/version.rb
CHANGED
data/lib/tb_events.rb
CHANGED
metadata
CHANGED
@@ -1,43 +1,43 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tb_events
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
|
-
-
|
8
|
-
autorequire:
|
7
|
+
- Moser Consulting
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-01-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: 5.0.0.1
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - "
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
26
|
+
version: 5.0.0.1
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: tb_core
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - "
|
31
|
+
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '1.
|
33
|
+
version: '1.4'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - "
|
38
|
+
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '1.
|
40
|
+
version: '1.4'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: mysql2
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -52,107 +52,93 @@ dependencies:
|
|
52
52
|
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
|
-
- !ruby/object:Gem::Dependency
|
56
|
-
name: rspec
|
57
|
-
requirement: !ruby/object:Gem::Requirement
|
58
|
-
requirements:
|
59
|
-
- - '='
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: 2.8.0
|
62
|
-
type: :development
|
63
|
-
prerelease: false
|
64
|
-
version_requirements: !ruby/object:Gem::Requirement
|
65
|
-
requirements:
|
66
|
-
- - '='
|
67
|
-
- !ruby/object:Gem::Version
|
68
|
-
version: 2.8.0
|
69
55
|
- !ruby/object:Gem::Dependency
|
70
56
|
name: rspec-rails
|
71
57
|
requirement: !ruby/object:Gem::Requirement
|
72
58
|
requirements:
|
73
|
-
- -
|
59
|
+
- - ">="
|
74
60
|
- !ruby/object:Gem::Version
|
75
|
-
version:
|
61
|
+
version: '0'
|
76
62
|
type: :development
|
77
63
|
prerelease: false
|
78
64
|
version_requirements: !ruby/object:Gem::Requirement
|
79
65
|
requirements:
|
80
|
-
- -
|
66
|
+
- - ">="
|
81
67
|
- !ruby/object:Gem::Version
|
82
|
-
version:
|
68
|
+
version: '0'
|
83
69
|
- !ruby/object:Gem::Dependency
|
84
|
-
name:
|
70
|
+
name: rails-controller-testing
|
85
71
|
requirement: !ruby/object:Gem::Requirement
|
86
72
|
requirements:
|
87
|
-
- - "
|
73
|
+
- - ">="
|
88
74
|
- !ruby/object:Gem::Version
|
89
|
-
version:
|
75
|
+
version: '0'
|
90
76
|
type: :development
|
91
77
|
prerelease: false
|
92
78
|
version_requirements: !ruby/object:Gem::Requirement
|
93
79
|
requirements:
|
94
|
-
- - "
|
80
|
+
- - ">="
|
95
81
|
- !ruby/object:Gem::Version
|
96
|
-
version:
|
82
|
+
version: '0'
|
97
83
|
- !ruby/object:Gem::Dependency
|
98
|
-
name:
|
84
|
+
name: factory_bot_rails
|
99
85
|
requirement: !ruby/object:Gem::Requirement
|
100
86
|
requirements:
|
101
|
-
- -
|
87
|
+
- - ">="
|
102
88
|
- !ruby/object:Gem::Version
|
103
|
-
version:
|
89
|
+
version: '0'
|
104
90
|
type: :development
|
105
91
|
prerelease: false
|
106
92
|
version_requirements: !ruby/object:Gem::Requirement
|
107
93
|
requirements:
|
108
|
-
- -
|
94
|
+
- - ">="
|
109
95
|
- !ruby/object:Gem::Version
|
110
|
-
version:
|
96
|
+
version: '0'
|
111
97
|
- !ruby/object:Gem::Dependency
|
112
|
-
name:
|
98
|
+
name: database_cleaner
|
113
99
|
requirement: !ruby/object:Gem::Requirement
|
114
100
|
requirements:
|
115
|
-
- -
|
101
|
+
- - ">="
|
116
102
|
- !ruby/object:Gem::Version
|
117
|
-
version: 0
|
103
|
+
version: '0'
|
118
104
|
type: :development
|
119
105
|
prerelease: false
|
120
106
|
version_requirements: !ruby/object:Gem::Requirement
|
121
107
|
requirements:
|
122
|
-
- -
|
108
|
+
- - ">="
|
123
109
|
- !ruby/object:Gem::Version
|
124
|
-
version: 0
|
110
|
+
version: '0'
|
125
111
|
- !ruby/object:Gem::Dependency
|
126
|
-
name:
|
112
|
+
name: simplecov
|
127
113
|
requirement: !ruby/object:Gem::Requirement
|
128
114
|
requirements:
|
129
|
-
- - "
|
115
|
+
- - ">="
|
130
116
|
- !ruby/object:Gem::Version
|
131
|
-
version:
|
117
|
+
version: '0'
|
132
118
|
type: :development
|
133
119
|
prerelease: false
|
134
120
|
version_requirements: !ruby/object:Gem::Requirement
|
135
121
|
requirements:
|
136
|
-
- - "
|
122
|
+
- - ">="
|
137
123
|
- !ruby/object:Gem::Version
|
138
|
-
version:
|
124
|
+
version: '0'
|
139
125
|
- !ruby/object:Gem::Dependency
|
140
|
-
name:
|
126
|
+
name: rubocop
|
141
127
|
requirement: !ruby/object:Gem::Requirement
|
142
128
|
requirements:
|
143
|
-
- - "
|
129
|
+
- - ">="
|
144
130
|
- !ruby/object:Gem::Version
|
145
|
-
version: 0
|
131
|
+
version: '0'
|
146
132
|
type: :development
|
147
133
|
prerelease: false
|
148
134
|
version_requirements: !ruby/object:Gem::Requirement
|
149
135
|
requirements:
|
150
|
-
- - "
|
136
|
+
- - ">="
|
151
137
|
- !ruby/object:Gem::Version
|
152
|
-
version: 0
|
153
|
-
description:
|
138
|
+
version: '0'
|
139
|
+
description:
|
154
140
|
email:
|
155
|
-
- greg@
|
141
|
+
- greg.woods@moserit.com
|
156
142
|
executables: []
|
157
143
|
extensions: []
|
158
144
|
extra_rdoc_files: []
|
@@ -173,9 +159,9 @@ files:
|
|
173
159
|
- app/helpers/admin/calendar_events_helper.rb
|
174
160
|
- app/helpers/admin/calendars_helper.rb
|
175
161
|
- app/helpers/calendars_helper.rb
|
176
|
-
- app/models/spud/spud_calendar_event_model.rb
|
177
162
|
- app/models/spud_calendar.rb
|
178
163
|
- app/models/spud_calendar_event.rb
|
164
|
+
- app/models/spud_events/calendar_event_model.rb
|
179
165
|
- app/views/admin/calendar_events/_calendar.html.erb
|
180
166
|
- app/views/admin/calendar_events/_form.html.erb
|
181
167
|
- app/views/admin/calendar_events/edit.html.erb
|
@@ -200,10 +186,10 @@ files:
|
|
200
186
|
- lib/spud_events/engine.rb
|
201
187
|
- lib/spud_events/version.rb
|
202
188
|
- lib/tb_events.rb
|
203
|
-
homepage:
|
189
|
+
homepage:
|
204
190
|
licenses: []
|
205
191
|
metadata: {}
|
206
|
-
post_install_message:
|
192
|
+
post_install_message:
|
207
193
|
rdoc_options: []
|
208
194
|
require_paths:
|
209
195
|
- lib
|
@@ -214,13 +200,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
214
200
|
version: '0'
|
215
201
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
216
202
|
requirements:
|
217
|
-
- - "
|
203
|
+
- - ">="
|
218
204
|
- !ruby/object:Gem::Version
|
219
|
-
version:
|
205
|
+
version: '0'
|
220
206
|
requirements: []
|
221
|
-
|
222
|
-
|
223
|
-
signing_key:
|
207
|
+
rubygems_version: 3.0.8
|
208
|
+
signing_key:
|
224
209
|
specification_version: 4
|
225
210
|
summary: Twice Baked Events engine
|
226
211
|
test_files: []
|
@@ -1,25 +0,0 @@
|
|
1
|
-
class Spud::SpudCalendarEventModel < ActiveRecord::Base
|
2
|
-
self.table_name = 'spud_calendar_events'
|
3
|
-
|
4
|
-
belongs_to :spud_calendar
|
5
|
-
validates_presence_of :title, :start_at, :end_at, :spud_calendar_id
|
6
|
-
|
7
|
-
scope :ordered, ->{ order('start_at desc') }
|
8
|
-
scope :in_month_of, ->(date){ where(:start_at => date.beginning_of_month...date.end_of_month) }
|
9
|
-
scope :upcoming, ->(limit=false){ where('start_at >= ?', Date.today).order('start_at asc').limit(limit) }
|
10
|
-
|
11
|
-
def start_date
|
12
|
-
return start_at.to_date
|
13
|
-
end
|
14
|
-
|
15
|
-
def days_span
|
16
|
-
return (end_at.to_date - start_at.to_date).to_i + 1
|
17
|
-
end
|
18
|
-
|
19
|
-
def falls_on?(day)
|
20
|
-
start_date = start_at.beginning_of_day.to_date
|
21
|
-
end_date = end_at.end_of_day.to_date
|
22
|
-
return day >= start_date && day <= end_date
|
23
|
-
end
|
24
|
-
|
25
|
-
end
|