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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2a2bd2bb0dd158d4fcd35a5ae96bbaab3a2d56fd
4
- data.tar.gz: b0c89bfb6e2188e28f5b1b22d3885e625b9c1c24
3
+ metadata.gz: 5310f66fa592f26c326a8b5ac5d0b8bebb1fc050
4
+ data.tar.gz: fbb46dbdd4ee0ae780d48324dc56eb16c9ac92d7
5
5
  SHA512:
6
- metadata.gz: f90a3ecc341fa54341a6bc41ade7986bb4b76415b76220d83e83885c2c2b3b6cd4744599ea832280e327ebc6c8234bbd31140c21124b9691f94f1a57f81e3ac5
7
- data.tar.gz: 662027d927f382565cc6f88ea117650bfe6de8fd4d3828f9bac83cd30d340f40670f8133fb2689e045e4d1e3b3087799d215c0806b884c127a3ceb457e2fa821
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-4
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
@@ -1,5 +1,5 @@
1
1
  module Ecm
2
2
  module Courses
3
- VERSION = '0.1.0'.freeze
3
+ VERSION = '0.2.0'.freeze
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ecm_courses2
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Roberto Vasquez Angel