ecm_courses2 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/ecm/courses/course_categories_controller.rb +5 -0
- data/app/models/ecm/courses/course.rb +16 -0
- data/app/models/ecm/courses/course_category.rb +10 -0
- data/app/views/ecm/courses/course_categories/_course_category.haml +5 -1
- data/config/routes.rb +3 -1
- data/lib/ecm/courses/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5310f66fa592f26c326a8b5ac5d0b8bebb1fc050
|
4
|
+
data.tar.gz: fbb46dbdd4ee0ae780d48324dc56eb16c9ac92d7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: efef4bb2e440a79b5c77348f563c507b9ee1ebc80cafaf3ab3330439a5b56d0155aae8a72a67822a4fe67bdddc801165aab3c32239b9be6c89599c9373756f4a
|
7
|
+
data.tar.gz: 81093bd93b70339fdd7818fc6738d0b01b8e150815a387442f0bb5a63b87b116048c5710e5a83e9368dc090e8615ea025ed22bae083d24d2e242b0e8f18c68fc
|
@@ -19,6 +19,11 @@ module Ecm::Courses
|
|
19
19
|
@course_dates = @courses.reduce([]) { |cd, c| cd << c.course_dates.for_month(@date).all }.flatten
|
20
20
|
end
|
21
21
|
|
22
|
+
def ical
|
23
|
+
@resource = load_resource
|
24
|
+
send_data @resource.to_icalendar.to_ical, type: 'text/calendar' # , disposition: 'inline'
|
25
|
+
end
|
26
|
+
|
22
27
|
private
|
23
28
|
|
24
29
|
def resource_class
|
@@ -1,5 +1,21 @@
|
|
1
1
|
module Ecm::Courses
|
2
2
|
class Course < ApplicationRecord
|
3
|
+
module Icalendar
|
4
|
+
def to_icalendar_events(calendar)
|
5
|
+
course_dates.map do |cd|
|
6
|
+
calendar.event do |e|
|
7
|
+
e.dtstart = cd.start_at
|
8
|
+
e.dtend = cd.end_at
|
9
|
+
e.summary = name
|
10
|
+
e.description = description
|
11
|
+
# e.ip_class = "PRIVATE"
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
include Icalendar
|
18
|
+
|
3
19
|
# acts as list
|
4
20
|
acts_as_list scope: :course_category
|
5
21
|
|
@@ -1,5 +1,15 @@
|
|
1
1
|
module Ecm::Courses
|
2
2
|
class CourseCategory < ApplicationRecord
|
3
|
+
module Icalendar
|
4
|
+
def to_icalendar
|
5
|
+
calendar = ::Icalendar::Calendar.new
|
6
|
+
courses.map { |c| c.to_icalendar_events(calendar) }
|
7
|
+
calendar
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
include Icalendar
|
12
|
+
|
3
13
|
# associations
|
4
14
|
has_many :courses, ->() { order(:position) },
|
5
15
|
dependent: :destroy
|
@@ -5,9 +5,13 @@
|
|
5
5
|
%h2.courses_category-name= course_category.name
|
6
6
|
|
7
7
|
- if action_name == 'show'
|
8
|
-
.course-calendar.bottom-margin-
|
8
|
+
.course-calendar.bottom-margin-2
|
9
9
|
= month_calendar_pagination(date)
|
10
10
|
= month_calendar date, course_dates, display_method: :course, start_day: :monday
|
11
|
+
.bottom-margin-4
|
12
|
+
= link_to(ical_course_category_path(course_category), class: 'btn btn-default') do
|
13
|
+
%span.glyphicon.glyphicon-calendar
|
14
|
+
= ical_course_category_url(course_category)
|
11
15
|
|
12
16
|
.course_categories-tree
|
13
17
|
= nested_li(course_category.descendants, {}) do |course_category, level|
|
data/config/routes.rb
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
Ecm::Courses::Engine.routes.draw do
|
2
2
|
localized do
|
3
|
-
resources :course_categories, only: [:index, :show]
|
3
|
+
resources :course_categories, only: [:index, :show] do
|
4
|
+
get :ical, on: :member
|
5
|
+
end
|
4
6
|
resources :courses, only: [:show] do
|
5
7
|
member do
|
6
8
|
get "calendar", action: :calendar
|
data/lib/ecm/courses/version.rb
CHANGED