rails_event 0.0.1
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 +7 -0
- data/LICENSE +20 -0
- data/README.md +36 -0
- data/Rakefile +32 -0
- data/app/controllers/eventual/admin/base_controller.rb +4 -0
- data/app/controllers/eventual/admin/bookings_controller.rb +43 -0
- data/app/controllers/eventual/admin/crowd_members_controller.rb +43 -0
- data/app/controllers/eventual/admin/crowds_controller.rb +58 -0
- data/app/controllers/eventual/admin/event_crowds_controller.rb +71 -0
- data/app/controllers/eventual/admin/event_items_controller.rb +58 -0
- data/app/controllers/eventual/admin/event_participants_controller.rb +101 -0
- data/app/controllers/eventual/admin/event_taxons_controller.rb +55 -0
- data/app/controllers/eventual/admin/events_controller.rb +91 -0
- data/app/controllers/eventual/admin/place_taxons_controller.rb +57 -0
- data/app/controllers/eventual/admin/places_controller.rb +59 -0
- data/app/controllers/eventual/admin/plan_attenders_controller.rb +65 -0
- data/app/controllers/eventual/admin/plan_items_controller.rb +84 -0
- data/app/controllers/eventual/admin/plans_controller.rb +127 -0
- data/app/controllers/eventual/admin/seats_controller.rb +58 -0
- data/app/controllers/eventual/admin/time_items_controller.rb +82 -0
- data/app/controllers/eventual/admin/time_lists_controller.rb +72 -0
- data/app/controllers/eventual/base_controller.rb +4 -0
- data/app/controllers/eventual/me/base_controller.rb +4 -0
- data/app/controllers/eventual/me/plan_items_controller.rb +58 -0
- data/app/controllers/eventual/my/base_controller.rb +4 -0
- data/app/controllers/eventual/my/plan_items_controller.rb +55 -0
- data/app/controllers/eventual/places_controller.rb +27 -0
- data/app/controllers/eventual/time_controller.rb +14 -0
- data/app/models/eventual/application_record.rb +5 -0
- data/app/models/eventual/booking.rb +5 -0
- data/app/models/eventual/crowd.rb +5 -0
- data/app/models/eventual/crowd_member.rb +5 -0
- data/app/models/eventual/event.rb +6 -0
- data/app/models/eventual/event_crowd.rb +5 -0
- data/app/models/eventual/event_grant.rb +5 -0
- data/app/models/eventual/event_item.rb +5 -0
- data/app/models/eventual/event_participant.rb +6 -0
- data/app/models/eventual/event_taxon.rb +5 -0
- data/app/models/eventual/ext/recurrence.rb +86 -0
- data/app/models/eventual/model/agency.rb +18 -0
- data/app/models/eventual/model/booked.rb +10 -0
- data/app/models/eventual/model/booker.rb +15 -0
- data/app/models/eventual/model/booking.rb +37 -0
- data/app/models/eventual/model/crowd.rb +21 -0
- data/app/models/eventual/model/crowd_member.rb +20 -0
- data/app/models/eventual/model/event.rb +48 -0
- data/app/models/eventual/model/event_crowd.rb +54 -0
- data/app/models/eventual/model/event_grant.rb +14 -0
- data/app/models/eventual/model/event_item.rb +30 -0
- data/app/models/eventual/model/event_participant.rb +63 -0
- data/app/models/eventual/model/event_taxon.rb +13 -0
- data/app/models/eventual/model/member.rb +18 -0
- data/app/models/eventual/model/occurrence.rb +62 -0
- data/app/models/eventual/model/place.rb +25 -0
- data/app/models/eventual/model/place_taxon.rb +18 -0
- data/app/models/eventual/model/plan.rb +147 -0
- data/app/models/eventual/model/plan_attender.rb +31 -0
- data/app/models/eventual/model/plan_item.rb +84 -0
- data/app/models/eventual/model/plan_participant/crowd_participant.rb +17 -0
- data/app/models/eventual/model/plan_participant/normal_participant.rb +9 -0
- data/app/models/eventual/model/plan_participant.rb +30 -0
- data/app/models/eventual/model/planned.rb +11 -0
- data/app/models/eventual/model/planning.rb +44 -0
- data/app/models/eventual/model/recurrence.rb +64 -0
- data/app/models/eventual/model/seat.rb +17 -0
- data/app/models/eventual/model/time_item.rb +46 -0
- data/app/models/eventual/model/time_list.rb +57 -0
- data/app/models/eventual/place.rb +5 -0
- data/app/models/eventual/place_taxon.rb +6 -0
- data/app/models/eventual/plan.rb +7 -0
- data/app/models/eventual/plan_attender.rb +5 -0
- data/app/models/eventual/plan_item.rb +6 -0
- data/app/models/eventual/plan_participant.rb +5 -0
- data/app/models/eventual/seat.rb +5 -0
- data/app/models/eventual/time_item.rb +5 -0
- data/app/models/eventual/time_list.rb +5 -0
- data/app/models/eventual.rb +11 -0
- data/app/models/plan_participant/eventual/crowd_participant.rb +5 -0
- data/app/models/plan_participant/eventual/normal_participant.rb +5 -0
- data/app/views/admin/_event_nav.html.erb +14 -0
- data/app/views/admin/_nav_event.html.erb +9 -0
- data/app/views/eventual/admin/base/_nav.html.erb +3 -0
- data/app/views/eventual/admin/bookings/_booking.json.jbuilder +12 -0
- data/app/views/eventual/admin/bookings/_filter.html.erb +6 -0
- data/app/views/eventual/admin/bookings/_form.html.erb +8 -0
- data/app/views/eventual/admin/bookings/_show.json.jbuilder +1 -0
- data/app/views/eventual/admin/bookings/_show_table.html.erb +28 -0
- data/app/views/eventual/admin/bookings/index.html.erb +43 -0
- data/app/views/eventual/admin/bookings/index.json.jbuilder +1 -0
- data/app/views/eventual/admin/crowd_members/_filter_form.html.erb +7 -0
- data/app/views/eventual/admin/crowd_members/_form.html.erb +4 -0
- data/app/views/eventual/admin/crowd_members/index.html.erb +34 -0
- data/app/views/eventual/admin/crowds/_crowd.json.jbuilder +8 -0
- data/app/views/eventual/admin/crowds/_edit_form.html.erb +4 -0
- data/app/views/eventual/admin/crowds/_filter_form.html.erb +10 -0
- data/app/views/eventual/admin/crowds/_form.html.erb +4 -0
- data/app/views/eventual/admin/crowds/_index_tbody.html.erb +5 -0
- data/app/views/eventual/admin/crowds/_index_thead.html.erb +3 -0
- data/app/views/eventual/admin/crowds/_new_form.html.erb +4 -0
- data/app/views/eventual/admin/crowds/_show.json.jbuilder +1 -0
- data/app/views/eventual/admin/crowds/_show_table.html.erb +20 -0
- data/app/views/eventual/admin/crowds/index.html.erb +5 -0
- data/app/views/eventual/admin/crowds/index.json.jbuilder +1 -0
- data/app/views/eventual/admin/event_crowds/_breadcrumb.html.erb +7 -0
- data/app/views/eventual/admin/event_crowds/_crowd_student.html.erb +18 -0
- data/app/views/eventual/admin/event_crowds/_edit_form.html.erb +15 -0
- data/app/views/eventual/admin/event_crowds/_index_tbody.html.erb +19 -0
- data/app/views/eventual/admin/event_crowds/_index_thead.html.erb +10 -0
- data/app/views/eventual/admin/event_crowds/_new_form.html.erb +6 -0
- data/app/views/eventual/admin/event_crowds/_show_table.html.erb +12 -0
- data/app/views/eventual/admin/event_crowds/index.html.erb +2 -0
- data/app/views/eventual/admin/event_items/_breadcrumb.html.erb +7 -0
- data/app/views/eventual/admin/event_items/_edit_form.html.erb +4 -0
- data/app/views/eventual/admin/event_items/_event_item.json.jbuilder +12 -0
- data/app/views/eventual/admin/event_items/_filter_form.html.erb +9 -0
- data/app/views/eventual/admin/event_items/_form.html.erb +12 -0
- data/app/views/eventual/admin/event_items/_index_tbody.html.erb +8 -0
- data/app/views/eventual/admin/event_items/_index_thead.html.erb +5 -0
- data/app/views/eventual/admin/event_items/_new_form.html.erb +4 -0
- data/app/views/eventual/admin/event_items/_show.json.jbuilder +1 -0
- data/app/views/eventual/admin/event_items/_show_table.html.erb +12 -0
- data/app/views/eventual/admin/event_items/index.html.erb +1 -0
- data/app/views/eventual/admin/event_items/index.json.jbuilder +1 -0
- data/app/views/eventual/admin/event_participants/_breadcrumb.html.erb +7 -0
- data/app/views/eventual/admin/event_participants/_button.html.erb +3 -0
- data/app/views/eventual/admin/event_participants/_filter_form.html.erb +9 -0
- data/app/views/eventual/admin/event_participants/_filter_table.html.erb +11 -0
- data/app/views/eventual/admin/event_participants/_form.html.erb +4 -0
- data/app/views/eventual/admin/event_participants/_index_tbody.html.erb +15 -0
- data/app/views/eventual/admin/event_participants/_index_thead.html.erb +5 -0
- data/app/views/eventual/admin/event_participants/index.html.erb +1 -0
- data/app/views/eventual/admin/event_taxons/_breadcrumb.html.erb +6 -0
- data/app/views/eventual/admin/event_taxons/_edit_form.html.erb +4 -0
- data/app/views/eventual/admin/event_taxons/_event_taxon.json.jbuilder +5 -0
- data/app/views/eventual/admin/event_taxons/_filter_form.html.erb +10 -0
- data/app/views/eventual/admin/event_taxons/_form.html.erb +2 -0
- data/app/views/eventual/admin/event_taxons/_index_tbody.html.erb +1 -0
- data/app/views/eventual/admin/event_taxons/_index_thead.html.erb +2 -0
- data/app/views/eventual/admin/event_taxons/_new_form.html.erb +4 -0
- data/app/views/eventual/admin/event_taxons/_show.json.jbuilder +1 -0
- data/app/views/eventual/admin/event_taxons/index.html.erb +5 -0
- data/app/views/eventual/admin/event_taxons/index.json.jbuilder +1 -0
- data/app/views/eventual/admin/events/_edit_form.html.erb +4 -0
- data/app/views/eventual/admin/events/_event.json.jbuilder +17 -0
- data/app/views/eventual/admin/events/_filter_form.html.erb +9 -0
- data/app/views/eventual/admin/events/_filter_table.html.erb +15 -0
- data/app/views/eventual/admin/events/_form.html.erb +11 -0
- data/app/views/eventual/admin/events/_index_tbody.html.erb +11 -0
- data/app/views/eventual/admin/events/_index_thead.html.erb +10 -0
- data/app/views/eventual/admin/events/_new_form.html.erb +4 -0
- data/app/views/eventual/admin/events/_show/_breadcrumb.html.erb +7 -0
- data/app/views/eventual/admin/events/_show.json.jbuilder +1 -0
- data/app/views/eventual/admin/events/create.json.jbuilder +1 -0
- data/app/views/eventual/admin/events/index.html.erb +5 -0
- data/app/views/eventual/admin/events/index.json.jbuilder +1 -0
- data/app/views/eventual/admin/events/repeat_form.js.erb +14 -0
- data/app/views/eventual/admin/events/show.html.erb +16 -0
- data/app/views/eventual/admin/place_taxons/_breadcrumb.html.erb +6 -0
- data/app/views/eventual/admin/place_taxons/_edit_form.html.erb +4 -0
- data/app/views/eventual/admin/place_taxons/_filter_form.html.erb +9 -0
- data/app/views/eventual/admin/place_taxons/_form.html.erb +6 -0
- data/app/views/eventual/admin/place_taxons/_index_tbody.html.erb +17 -0
- data/app/views/eventual/admin/place_taxons/_index_thead.html.erb +4 -0
- data/app/views/eventual/admin/place_taxons/_new_form.html.erb +4 -0
- data/app/views/eventual/admin/place_taxons/_show_table.html.erb +12 -0
- data/app/views/eventual/admin/place_taxons/index.html.erb +5 -0
- data/app/views/eventual/admin/places/_breadcrumb.html.erb +5 -0
- data/app/views/eventual/admin/places/_edit_form.html.erb +4 -0
- data/app/views/eventual/admin/places/_filter_form.html.erb +10 -0
- data/app/views/eventual/admin/places/_form.html.erb +4 -0
- data/app/views/eventual/admin/places/_index_tbody.html.erb +6 -0
- data/app/views/eventual/admin/places/_index_thead.html.erb +10 -0
- data/app/views/eventual/admin/places/_index_tr.html.erb +19 -0
- data/app/views/eventual/admin/places/_new_form.html.erb +4 -0
- data/app/views/eventual/admin/places/_place.json.jbuilder +6 -0
- data/app/views/eventual/admin/places/_show.json.jbuilder +1 -0
- data/app/views/eventual/admin/places/_show_table.html.erb +8 -0
- data/app/views/eventual/admin/places/index.html.erb +5 -0
- data/app/views/eventual/admin/places/index.json.jbuilder +1 -0
- data/app/views/eventual/admin/plan_attenders/_breadcrumb.html.erb +9 -0
- data/app/views/eventual/admin/plan_attenders/_course_student.json.jbuilder +11 -0
- data/app/views/eventual/admin/plan_attenders/_edit_form.html.erb +4 -0
- data/app/views/eventual/admin/plan_attenders/_filter.html.erb +6 -0
- data/app/views/eventual/admin/plan_attenders/_form.html.erb +5 -0
- data/app/views/eventual/admin/plan_attenders/_new_form.html.erb +4 -0
- data/app/views/eventual/admin/plan_attenders/_plan_attender.json.jbuilder +9 -0
- data/app/views/eventual/admin/plan_attenders/_show.json.jbuilder +1 -0
- data/app/views/eventual/admin/plan_attenders/_show_table.html.erb +16 -0
- data/app/views/eventual/admin/plan_attenders/absent.json.jbuilder +0 -0
- data/app/views/eventual/admin/plan_attenders/attend.json.jbuilder +0 -0
- data/app/views/eventual/admin/plan_attenders/index.html.erb +51 -0
- data/app/views/eventual/admin/plan_attenders/index.json.jbuilder +2 -0
- data/app/views/eventual/admin/plan_attenders/indexs.json.jbuilder +6 -0
- data/app/views/eventual/admin/plan_items/_breadcrumb.html.erb +8 -0
- data/app/views/eventual/admin/plan_items/_edit.html.erb +23 -0
- data/app/views/eventual/admin/plan_items/_filter.html.erb +11 -0
- data/app/views/eventual/admin/plan_items/_menu.html.erb +4 -0
- data/app/views/eventual/admin/plan_items/_plan.html.erb +6 -0
- data/app/views/eventual/admin/plan_items/_plan_item.json.jbuilder +12 -0
- data/app/views/eventual/admin/plan_items/_plan_items.json.jbuilder +13 -0
- data/app/views/eventual/admin/plan_items/_show.json.jbuilder +1 -0
- data/app/views/eventual/admin/plan_items/_show_table.html.erb +20 -0
- data/app/views/eventual/admin/plan_items/index.html.erb +72 -0
- data/app/views/eventual/admin/plan_items/index.json.jbuilder +3 -0
- data/app/views/eventual/admin/plan_items/qrcode.js.erb +1 -0
- data/app/views/eventual/admin/plans/_edit_item.html.erb +24 -0
- data/app/views/eventual/admin/plans/_filter.html.erb +8 -0
- data/app/views/eventual/admin/plans/_index.html.erb +31 -0
- data/app/views/eventual/admin/plans/_plan.json.jbuilder +12 -0
- data/app/views/eventual/admin/plans/_select_table.html.erb +30 -0
- data/app/views/eventual/admin/plans/_show.json.jbuilder +1 -0
- data/app/views/eventual/admin/plans/_show_item.html.erb +22 -0
- data/app/views/eventual/admin/plans/_show_table.html.erb +20 -0
- data/app/views/eventual/admin/plans/_table.html.erb +34 -0
- data/app/views/eventual/admin/plans/calendar.js.erb +12 -0
- data/app/views/eventual/admin/plans/index.html.erb +3 -0
- data/app/views/eventual/admin/plans/index.js.erb +42 -0
- data/app/views/eventual/admin/plans/index.json.jbuilder +1 -0
- data/app/views/eventual/admin/plans/show.html.erb +3 -0
- data/app/views/eventual/admin/seats/_breadcrumb.html.erb +0 -0
- data/app/views/eventual/admin/seats/_edit_form.html.erb +4 -0
- data/app/views/eventual/admin/seats/_filter_form.html.erb +9 -0
- data/app/views/eventual/admin/seats/_form.html.erb +4 -0
- data/app/views/eventual/admin/seats/_index_tbody.html.erb +3 -0
- data/app/views/eventual/admin/seats/_index_thead.html.erb +4 -0
- data/app/views/eventual/admin/seats/_new_form.html.erb +4 -0
- data/app/views/eventual/admin/seats/_show_table.html.erb +12 -0
- data/app/views/eventual/admin/seats/index.html.erb +5 -0
- data/app/views/eventual/admin/time_items/_edit_form.html.erb +4 -0
- data/app/views/eventual/admin/time_items/_form.html.erb +3 -0
- data/app/views/eventual/admin/time_items/_new_form.html.erb +4 -0
- data/app/views/eventual/admin/time_items/_show.json.jbuilder +1 -0
- data/app/views/eventual/admin/time_items/_show_table.html.erb +12 -0
- data/app/views/eventual/admin/time_items/_time_item.json.jbuilder +3 -0
- data/app/views/eventual/admin/time_items/_time_items_options.html.erb +1 -0
- data/app/views/eventual/admin/time_items/default.json.jbuilder +1 -0
- data/app/views/eventual/admin/time_items/index.json.jbuilder +1 -0
- data/app/views/eventual/admin/time_items/select.js.erb +3 -0
- data/app/views/eventual/admin/time_lists/_edit_form.html.erb +4 -0
- data/app/views/eventual/admin/time_lists/_filter.html.erb +8 -0
- data/app/views/eventual/admin/time_lists/_form.html.erb +4 -0
- data/app/views/eventual/admin/time_lists/_index_tbody.html.erb +14 -0
- data/app/views/eventual/admin/time_lists/_index_thead.html.erb +8 -0
- data/app/views/eventual/admin/time_lists/_index_tr.html.erb +13 -0
- data/app/views/eventual/admin/time_lists/_new_form.html.erb +4 -0
- data/app/views/eventual/admin/time_lists/_show.json.jbuilder +1 -0
- data/app/views/eventual/admin/time_lists/_show_table.html.erb +8 -0
- data/app/views/eventual/admin/time_lists/_time_items.html.erb +27 -0
- data/app/views/eventual/admin/time_lists/_time_list.json.jbuilder +10 -0
- data/app/views/eventual/admin/time_lists/index.html.erb +5 -0
- data/app/views/eventual/admin/time_lists/index.json.jbuilder +1 -0
- data/app/views/eventual/me/plan_items/_plan_item.json.jbuilder +14 -0
- data/app/views/eventual/me/plan_items/index.json.jbuilder +3 -0
- data/app/views/eventual/my/plans/_show_table.html.erb +32 -0
- data/app/views/eventual/my/plans/_table.html.erb +34 -0
- data/app/views/eventual/my/plans/_time_plan.json.jbuilder +8 -0
- data/app/views/eventual/my/plans/calendar.js.erb +12 -0
- data/app/views/eventual/my/plans/edit.html.erb +9 -0
- data/app/views/eventual/my/plans/edit.js.erb +3 -0
- data/app/views/eventual/my/plans/index-ready.js +11 -0
- data/app/views/eventual/my/plans/index.html.erb +26 -0
- data/app/views/eventual/my/plans/index.js +35 -0
- data/app/views/eventual/my/plans/index.json.jbuilder +1 -0
- data/app/views/eventual/my/plans/new.html.erb +9 -0
- data/app/views/eventual/my/plans/show.html.erb +7 -0
- data/app/views/eventual/my/plans/show.js.erb +12 -0
- data/app/views/eventual/my/plans/show.json.jbuilder +1 -0
- data/app/views/eventual/places/_filter_table.html.erb +11 -0
- data/app/views/eventual/places/index.html.erb +35 -0
- data/app/views/eventual/places/show.html.erb +0 -0
- data/app/views/eventual/time/_finish_at.html.erb +1 -0
- data/app/views/eventual/time/_finish_at_once.html.erb +1 -0
- data/app/views/eventual/time/_form.html.erb +15 -0
- data/app/views/eventual/time/_monthly_checkboxes.html.erb +1 -0
- data/app/views/eventual/time/_once_date.html.erb +1 -0
- data/app/views/eventual/time/_start_at.html.erb +1 -0
- data/app/views/eventual/time/_start_at_once.html.erb +1 -0
- data/app/views/eventual/time/_weekly_checkboxes.html.erb +1 -0
- data/app/views/eventual/time/index.css +5 -0
- data/app/views/eventual/time/repeat_form.js.erb +14 -0
- data/app/views/eventual/time/show.css +3 -0
- data/config/locales/en.enum.yml +8 -0
- data/config/locales/zh.attributes.yml +50 -0
- data/config/locales/zh.controller.yml +59 -0
- data/config/locales/zh.enum.yml +12 -0
- data/config/routes.rb +98 -0
- data/lib/rails_event/config.rb +13 -0
- data/lib/rails_event/engine.rb +29 -0
- data/lib/rails_event/version.rb +5 -0
- data/lib/rails_event.rb +4 -0
- metadata +346 -0
@@ -0,0 +1,86 @@
|
|
1
|
+
module Eventual
|
2
|
+
module Ext::Recurrence
|
3
|
+
extend ActiveSupport::Concern
|
4
|
+
|
5
|
+
included do
|
6
|
+
attribute :repeat_type, :string, default: ''
|
7
|
+
attribute :repeat_days, :integer, array: true, default: []
|
8
|
+
|
9
|
+
enum repeat_type: {
|
10
|
+
once: 'once',
|
11
|
+
weekly: 'weekly',
|
12
|
+
monthly: 'monthly'
|
13
|
+
}
|
14
|
+
|
15
|
+
before_save :deal_repeat_days, if: -> { repeat_days_changed? }
|
16
|
+
end
|
17
|
+
|
18
|
+
def deal_repeat_days
|
19
|
+
self.repeat_days = self.repeat_days.map(&:to_i)
|
20
|
+
end
|
21
|
+
|
22
|
+
|
23
|
+
def next_start_at
|
24
|
+
return if start_at.nil?
|
25
|
+
_next_day = self.next_day
|
26
|
+
_next_day.change(hour: start_at.hour, min: start_at.min, sec: start_at.sec)
|
27
|
+
end
|
28
|
+
|
29
|
+
def next_finish_at
|
30
|
+
return if finish_at.nil?
|
31
|
+
_next_day = self.next_day
|
32
|
+
_next_day.change(hour: finish_at.hour, min: finish_at.min, sec: finish_at.sec)
|
33
|
+
end
|
34
|
+
|
35
|
+
def next_day(datetime = Time.now)
|
36
|
+
if self.repeat_type == 'weekly'
|
37
|
+
next_weekly_day(datetime)
|
38
|
+
elsif self.repeat_type == 'monthly'
|
39
|
+
next_monthly_day(datetime)
|
40
|
+
else
|
41
|
+
datetime
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
def next_weekly_day(datetime = Time.now)
|
46
|
+
start_at_date = self.start_at.change(year: datetime.year, month: datetime.month, day: datetime.day)
|
47
|
+
|
48
|
+
if start_at_date > datetime
|
49
|
+
next_days = self.repeat_days.select { |day| day >= datetime.days_to_week_start(:sunday) }
|
50
|
+
else
|
51
|
+
next_days = self.repeat_days.select { |day| day > datetime.days_to_week_start(:sunday) }
|
52
|
+
end
|
53
|
+
|
54
|
+
if next_days.size > 0
|
55
|
+
next_day = next_days.min
|
56
|
+
else
|
57
|
+
next_day = self.repeat_days.min
|
58
|
+
end
|
59
|
+
|
60
|
+
str = Date::DAYS_INTO_WEEK.key(next_day)
|
61
|
+
day = datetime.next_occurring(str)
|
62
|
+
datetime.change(month: day.month, day: day.day)
|
63
|
+
end
|
64
|
+
|
65
|
+
def next_monthly_day(datetime = Time.now)
|
66
|
+
start_at_date = self.start_at.change(year: datetime.year, month: datetime.month, day: datetime.day)
|
67
|
+
|
68
|
+
if start_at_date > datetime
|
69
|
+
next_days = self.repeat_days.select { |day| day >= datetime.day }
|
70
|
+
else
|
71
|
+
next_days = self.repeat_days.select { |day| day > datetime.day }
|
72
|
+
end
|
73
|
+
|
74
|
+
if next_days.size > 0
|
75
|
+
next_day = next_days.min
|
76
|
+
month = datetime.month
|
77
|
+
else
|
78
|
+
next_day = self.repeat_days.min
|
79
|
+
month = datetime.next_month.month
|
80
|
+
end
|
81
|
+
|
82
|
+
datetime.change(month: month, day: next_day)
|
83
|
+
end
|
84
|
+
|
85
|
+
end
|
86
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module Eventual
|
2
|
+
module Model::Agency
|
3
|
+
extend ActiveSupport::Concern
|
4
|
+
|
5
|
+
included do
|
6
|
+
has_many :crowd_members
|
7
|
+
has_many :crowds, through: :crowd_members
|
8
|
+
end
|
9
|
+
|
10
|
+
def join_crowd(crowd_id)
|
11
|
+
cs = self.crowd_members.build
|
12
|
+
cs.member = client
|
13
|
+
cs.crowd_id = crowd_id
|
14
|
+
cs.save
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module Eventual
|
2
|
+
module Model::Booker
|
3
|
+
extend ActiveSupport::Concern
|
4
|
+
|
5
|
+
included do
|
6
|
+
has_many :booker_bookings, class_name: 'Booking', as: :booker
|
7
|
+
end
|
8
|
+
|
9
|
+
|
10
|
+
def confirm_booker_time!(booked)
|
11
|
+
p 'implement in application'
|
12
|
+
end
|
13
|
+
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
module Eventual
|
2
|
+
module Model::Booking
|
3
|
+
extend ActiveSupport::Concern
|
4
|
+
|
5
|
+
included do
|
6
|
+
attribute :booking_on, :date
|
7
|
+
|
8
|
+
belongs_to :booker, polymorphic: true
|
9
|
+
belongs_to :booked, polymorphic: true, optional: true
|
10
|
+
belongs_to :plan_item, optional: true
|
11
|
+
belongs_to :time_item
|
12
|
+
belongs_to :place, optional: true
|
13
|
+
belongs_to :seat, optional: true
|
14
|
+
|
15
|
+
delegate :start_at, :finish_at, to: :plan_item, allow_nil: true
|
16
|
+
|
17
|
+
validates :booking_on, presence: true
|
18
|
+
validates :booker_id, uniqueness: { scope: [:booker_type, :plan_item_id] }
|
19
|
+
|
20
|
+
before_validation :sync_from_plan_item
|
21
|
+
after_create :sync_to_booker
|
22
|
+
end
|
23
|
+
|
24
|
+
def sync_from_plan_item
|
25
|
+
if plan_item
|
26
|
+
self.booked = plan_item.planned
|
27
|
+
self.booking_on = plan_item.plan_on
|
28
|
+
self.time_item_id = plan_item.time_item_id
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def sync_to_booker
|
33
|
+
booker.confirm_booker_time!(self)
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module Eventual
|
2
|
+
module Model::Crowd
|
3
|
+
extend ActiveSupport::Concern
|
4
|
+
|
5
|
+
included do
|
6
|
+
attribute :name, :string
|
7
|
+
attribute :member_type, :string, default: 'Profile'
|
8
|
+
attribute :crowd_members_count, :integer, default: 0
|
9
|
+
|
10
|
+
belongs_to :organ, optional: true
|
11
|
+
has_many :crowd_members
|
12
|
+
has_many :members, through: :crowd_members, source_type: 'Profile'
|
13
|
+
has_many :event_participants
|
14
|
+
|
15
|
+
validates :name, presence: true
|
16
|
+
|
17
|
+
has_one_attached :logo
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module Eventual
|
2
|
+
module Model::CrowdMember
|
3
|
+
extend ActiveSupport::Concern
|
4
|
+
|
5
|
+
included do
|
6
|
+
attribute :state, :string
|
7
|
+
|
8
|
+
belongs_to :crowd, counter_cache: true
|
9
|
+
belongs_to :member, polymorphic: true
|
10
|
+
belongs_to :agency, optional: true
|
11
|
+
|
12
|
+
after_destroy_commit :quit_event
|
13
|
+
end
|
14
|
+
|
15
|
+
def quit_event
|
16
|
+
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
module Eventual
|
2
|
+
module Model::Event
|
3
|
+
extend ActiveSupport::Concern
|
4
|
+
|
5
|
+
included do
|
6
|
+
attribute :name, :string
|
7
|
+
attribute :description, :string, limit: 4096
|
8
|
+
attribute :position, :integer
|
9
|
+
attribute :price, :decimal
|
10
|
+
attribute :event_participants_count, :integer, default: 0
|
11
|
+
attribute :event_items_count, :integer, default: 0
|
12
|
+
attribute :members_count, :integer, default: 0
|
13
|
+
|
14
|
+
belongs_to :organ, optional: true
|
15
|
+
belongs_to :event_taxon, optional: true
|
16
|
+
|
17
|
+
has_many :event_items, dependent: :nullify
|
18
|
+
accepts_nested_attributes_for :event_items, allow_destroy: true
|
19
|
+
|
20
|
+
has_many :event_participants, dependent: :destroy
|
21
|
+
has_many :crowds, through: :event_participants
|
22
|
+
has_many :event_grants, dependent: :destroy
|
23
|
+
end
|
24
|
+
|
25
|
+
def member_type_ids
|
26
|
+
event_participants.pluck(:member_type, :member_id)
|
27
|
+
end
|
28
|
+
|
29
|
+
def save_with_remind
|
30
|
+
self.class.transaction do
|
31
|
+
self.save!
|
32
|
+
end
|
33
|
+
|
34
|
+
return unless self.persisted?
|
35
|
+
|
36
|
+
self.class.transaction do
|
37
|
+
EventParticipantMailer.assign(self.id).deliver_later
|
38
|
+
job = EventParticipantMailer.remind(self.id).deliver_later(wait_until: self.event.next_start_at - 1.day)
|
39
|
+
self.update(job_id: job.job_id)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
def timestamp
|
44
|
+
self.event_participants.order(created_at: :desc).first&.created_at.to_i
|
45
|
+
end
|
46
|
+
|
47
|
+
end
|
48
|
+
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
module Eventual
|
2
|
+
module Model::EventCrowd
|
3
|
+
extend ActiveSupport::Concern
|
4
|
+
|
5
|
+
included do
|
6
|
+
attribute :present_number, :integer, default: 0
|
7
|
+
|
8
|
+
belongs_to :event
|
9
|
+
belongs_to :crowd
|
10
|
+
|
11
|
+
has_many :crowd_members, foreign_key: :crowd_id, primary_key: :crowd_id
|
12
|
+
has_many :plan_items, as: :plan, dependent: :destroy
|
13
|
+
has_many :event_participants
|
14
|
+
has_many :events, foreign_key: :event_id, primary_key: :event_id
|
15
|
+
|
16
|
+
after_create_commit :sync_to_event_participants
|
17
|
+
after_destroy_commit :destroy_from_event_participants
|
18
|
+
after_update_commit :sync_to_event_plans
|
19
|
+
|
20
|
+
delegate :title, to: :event
|
21
|
+
delegate :max_members, to: :place, allow_nil: true
|
22
|
+
end
|
23
|
+
|
24
|
+
def sync_to_event_participants
|
25
|
+
self.crowd_members.each do |i|
|
26
|
+
cs = self.event_participants.build(crowd_member_id: i.id)
|
27
|
+
cs.save
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def sync_to_event_plans
|
32
|
+
if saved_change_to_teacher_id?
|
33
|
+
self.plan_items.where(teacher_id: nil).update_all(teacher_id: self.teacher_id)
|
34
|
+
end
|
35
|
+
if saved_change_to_room_id?
|
36
|
+
self.plan_items.where(room_id: nil).update_all(room_id: self.room_id)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
def sync_to_plan_items
|
41
|
+
self.event_id ||= event_crowd.event_id
|
42
|
+
self.teacher_id ||= event_crowd.teacher_id
|
43
|
+
self.room_id ||= event_crowd.room_id
|
44
|
+
end
|
45
|
+
|
46
|
+
def destroy_from_event_participants
|
47
|
+
self.crowd.members.each do |i|
|
48
|
+
cs = i.event_participants.find_by(member_id: i.id)
|
49
|
+
cs&.destroy
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
end
|
54
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
module Eventual
|
2
|
+
module Model::EventItem
|
3
|
+
extend ActiveSupport::Concern
|
4
|
+
|
5
|
+
included do
|
6
|
+
attribute :name, :string
|
7
|
+
|
8
|
+
belongs_to :event
|
9
|
+
belongs_to :author, class_name: 'Member', optional: true
|
10
|
+
has_many :event_item_members
|
11
|
+
has_many :members, through: :event_item_members, source_type: 'Profile'
|
12
|
+
|
13
|
+
has_many_attached :videos
|
14
|
+
has_many_attached :documents
|
15
|
+
|
16
|
+
accepts_nested_attributes_for :videos_attachments, allow_destroy: true
|
17
|
+
accepts_nested_attributes_for :documents_attachments, allow_destroy: true
|
18
|
+
end
|
19
|
+
|
20
|
+
|
21
|
+
def video_urls
|
22
|
+
videos.map(&:service_url)
|
23
|
+
end
|
24
|
+
|
25
|
+
def document_urls
|
26
|
+
documents.map(&:service_url)
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,63 @@
|
|
1
|
+
module Eventual
|
2
|
+
module Model::EventParticipant
|
3
|
+
extend ActiveSupport::Concern
|
4
|
+
|
5
|
+
included do
|
6
|
+
attribute :score, :integer
|
7
|
+
attribute :comment, :string
|
8
|
+
attribute :quit_note, :string
|
9
|
+
attribute :assigned_status, :string
|
10
|
+
attribute :job_id, :string
|
11
|
+
|
12
|
+
belongs_to :event_crowd, optional: true
|
13
|
+
belongs_to :event, counter_cache: true
|
14
|
+
belongs_to :crowd_member, optional: true
|
15
|
+
belongs_to :participant, polymorphic: true
|
16
|
+
|
17
|
+
validates :member_id, uniqueness: { scope: [:member_type, :event_id] }
|
18
|
+
|
19
|
+
enum state: {
|
20
|
+
in_studying: 'in_studying',
|
21
|
+
request_quit: 'request_quit',
|
22
|
+
quit: 'quit',
|
23
|
+
in_evaluating: 'in_evaluating',
|
24
|
+
passed: 'passed',
|
25
|
+
failed: 'failed'
|
26
|
+
}, _default: 'in_studying'
|
27
|
+
|
28
|
+
before_validation :sync_from_crowd_member
|
29
|
+
after_destroy :delete_reminder_job
|
30
|
+
end
|
31
|
+
|
32
|
+
def sync_from_crowd_member
|
33
|
+
if self.crowd_member
|
34
|
+
self.member_type = crowd_member.member_type
|
35
|
+
self.member_id = crowd_member.member_id
|
36
|
+
end
|
37
|
+
if self.event_crowd
|
38
|
+
self.event_id = event_crowd.event_id
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
def save_with_remind
|
43
|
+
self.class.transaction do
|
44
|
+
self.save!
|
45
|
+
end
|
46
|
+
|
47
|
+
return unless self.persisted?
|
48
|
+
|
49
|
+
self.class.transaction do
|
50
|
+
EventParticipantMailer.assign(self.id).deliver_later
|
51
|
+
if self.event.next_start_time
|
52
|
+
job = EventParticipantMailer.remind(self.id).deliver_later(wait_until: self.event.next_start_time - 1.day)
|
53
|
+
self.update(job_id: job.job_id)
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
def delete_reminder_job
|
59
|
+
ActionMailer::DeliveryJob.cancel(self.job_id) if ActionMailer::DeliveryJob.respond_to?(:cancel)
|
60
|
+
end
|
61
|
+
|
62
|
+
end
|
63
|
+
end
|