ecm_courses 0.0.1.pre
Sign up to get free protection for your applications and to get access to all the features.
- data/MIT-LICENSE +20 -0
- data/README.rdoc +45 -0
- data/Rakefile +33 -0
- data/app/admin/ecm_courses_course_categories.rb +82 -0
- data/app/admin/ecm_courses_course_dates.rb +47 -0
- data/app/admin/ecm_courses_courses.rb +58 -0
- data/app/assets/images/ecm_courses/course_categories/last_node.png +0 -0
- data/app/assets/images/ecm_courses/course_categories/node.png +0 -0
- data/app/assets/images/ecm_courses/course_categories/vertical_line.png +0 -0
- data/app/assets/stylesheets/ecm_courses/courses_categories.css.erb +30 -0
- data/app/assets/stylesheets/ecm_courses.css +1 -0
- data/app/controllers/ecm/courses/course_categories_controller.rb +16 -0
- data/app/controllers/ecm/courses/course_dates_controller.rb +9 -0
- data/app/controllers/ecm/courses/courses_controller.rb +19 -0
- data/app/models/ecm/courses/course.rb +47 -0
- data/app/models/ecm/courses/course_category.rb +57 -0
- data/app/models/ecm/courses/course_date.rb +52 -0
- data/app/views/ecm/courses/course_categories/_course_category.html.erb +29 -0
- data/app/views/ecm/courses/course_categories/index.de.html.erb +7 -0
- data/app/views/ecm/courses/course_categories/show.de.html.erb +19 -0
- data/app/views/ecm/courses/course_dates/_course_date.html.erb +7 -0
- data/app/views/ecm/courses/course_dates/index.de.html.erb +5 -0
- data/app/views/ecm/courses/course_dates/show.de.html.erb +11 -0
- data/app/views/ecm/courses/courses/_course.html.erb +15 -0
- data/app/views/ecm/courses/courses/calendar.de.html.erb +6 -0
- data/app/views/ecm/courses/courses/index.de.html.erb +3 -0
- data/app/views/ecm/courses/courses/show.de.html.erb +13 -0
- data/config/locales/absence_validator.de.yml +5 -0
- data/config/locales/absence_validator.en.yml +5 -0
- data/config/locales/ecm.courses.course.de.yml +24 -0
- data/config/locales/ecm.courses.course.en.yml +24 -0
- data/config/locales/ecm.courses.course_category.de.yml +24 -0
- data/config/locales/ecm.courses.course_category.en.yml +24 -0
- data/config/locales/ecm.courses.course_date.de.yml +19 -0
- data/config/locales/ecm.courses.course_date.en.yml +19 -0
- data/config/locales/ecm.courses.de.yml +14 -0
- data/config/locales/ecm.courses.en.yml +14 -0
- data/config/locales/ecm.courses.routes.de.yml +5 -0
- data/config/locales/ecm.courses.routes.en.yml +5 -0
- data/db/migrate/001_create_ecm_courses_course_categories.rb +22 -0
- data/db/migrate/002_create_ecm_courses_courses.rb +22 -0
- data/db/migrate/003_create_ecm_courses_course_dates.rb +17 -0
- data/lib/absence_validator.rb +5 -0
- data/lib/ecm/courses/engine.rb +15 -0
- data/lib/ecm/courses/routing.rb +33 -0
- data/lib/ecm/courses/version.rb +5 -0
- data/lib/ecm_courses.rb +19 -0
- data/lib/tasks/ecm_courses_tasks.rake +4 -0
- metadata +289 -0
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright 2012 YOURNAME
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
= EcmCourses
|
2
|
+
|
3
|
+
{<img src="https://secure.travis-ci.org/robotex82/ecm_courses.png?branch=master" alt="Build Status" />}[http://travis-ci.org/robotex82/ecm_courses]
|
4
|
+
|
5
|
+
= Purpose
|
6
|
+
|
7
|
+
Create and administrate courses in active admin and display them on
|
8
|
+
in your ruby on rails applictation.
|
9
|
+
|
10
|
+
= Features
|
11
|
+
|
12
|
+
* Drop in module for active admin.
|
13
|
+
|
14
|
+
= Installation
|
15
|
+
|
16
|
+
Add it to your gemfile:
|
17
|
+
|
18
|
+
gem 'ecm_courses'
|
19
|
+
|
20
|
+
Install your bundle:
|
21
|
+
|
22
|
+
> bundle install
|
23
|
+
|
24
|
+
Update your layout to include the needed css and javascript:
|
25
|
+
|
26
|
+
<!-- ecm pictures -->
|
27
|
+
<%= javascript_include_tag "ecm_courses" %>
|
28
|
+
<%= stylesheet_link_tag "ecm_courses" %>
|
29
|
+
|
30
|
+
= Usage
|
31
|
+
|
32
|
+
You can administrate your courses in active admin.
|
33
|
+
|
34
|
+
Once you have a course, you can display it like this:
|
35
|
+
|
36
|
+
<%= render_course 'Advanced Lightsaber Training' %>
|
37
|
+
|
38
|
+
= Todo
|
39
|
+
|
40
|
+
* Tests, tests, tests.
|
41
|
+
* Better docs.
|
42
|
+
|
43
|
+
= License
|
44
|
+
|
45
|
+
This project rocks and uses MIT-LICENSE.
|
data/Rakefile
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
#!/usr/bin/env rake
|
2
|
+
begin
|
3
|
+
require 'bundler/setup'
|
4
|
+
rescue LoadError
|
5
|
+
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
6
|
+
end
|
7
|
+
begin
|
8
|
+
require 'rdoc/task'
|
9
|
+
rescue LoadError
|
10
|
+
require 'rdoc/rdoc'
|
11
|
+
require 'rake/rdoctask'
|
12
|
+
RDoc::Task = Rake::RDocTask
|
13
|
+
end
|
14
|
+
|
15
|
+
RDoc::Task.new(:rdoc) do |rdoc|
|
16
|
+
rdoc.rdoc_dir = 'rdoc'
|
17
|
+
rdoc.title = 'EcmCourses'
|
18
|
+
rdoc.options << '--line-numbers'
|
19
|
+
rdoc.rdoc_files.include('README.rdoc')
|
20
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
21
|
+
end
|
22
|
+
|
23
|
+
|
24
|
+
|
25
|
+
|
26
|
+
Bundler::GemHelper.install_tasks
|
27
|
+
|
28
|
+
# travis ci
|
29
|
+
task :default => [:spec]
|
30
|
+
desc 'run Rspec specs'
|
31
|
+
task :spec do
|
32
|
+
sh 'cd ./spec/dummy && rspec && cd ../../'
|
33
|
+
end
|
@@ -0,0 +1,82 @@
|
|
1
|
+
if defined?(ActiveAdmin)
|
2
|
+
include ActiveAdmin::ActsAsList::Helper
|
3
|
+
include ActiveAdmin::AwesomeNestedSet::Helper
|
4
|
+
|
5
|
+
ActiveAdmin.register Ecm::Courses::CourseCategory do
|
6
|
+
# menu entry settings
|
7
|
+
menu :parent => I18n.t('ecm.courses.active_admin.menu')
|
8
|
+
|
9
|
+
# sorting
|
10
|
+
config.sort_order = 'lft_asc'
|
11
|
+
|
12
|
+
# awesome nested set
|
13
|
+
sortable_tree_member_actions
|
14
|
+
|
15
|
+
form do |f|
|
16
|
+
f.inputs do
|
17
|
+
f.input :parent, :as => :select,
|
18
|
+
:collection => nested_set_options(Ecm::Courses::CourseCategory, f.object) { |cc| "#{'-' * cc.level} #{cc.name}" }
|
19
|
+
f.input :locale, :as => :select,
|
20
|
+
:collection => I18n.available_locales.map(&:to_s)
|
21
|
+
f.input :name
|
22
|
+
f.input :description
|
23
|
+
end
|
24
|
+
|
25
|
+
f.actions
|
26
|
+
end
|
27
|
+
|
28
|
+
index do
|
29
|
+
selectable_column
|
30
|
+
sortable_tree_columns
|
31
|
+
column :index_name
|
32
|
+
# column :locale
|
33
|
+
# column :parent
|
34
|
+
# column :name
|
35
|
+
column :description
|
36
|
+
column :ecm_courses_courses_count
|
37
|
+
default_actions
|
38
|
+
end
|
39
|
+
|
40
|
+
|
41
|
+
|
42
|
+
show :title => :to_s do
|
43
|
+
attributes_table do
|
44
|
+
row :parent
|
45
|
+
row :locale
|
46
|
+
row :name
|
47
|
+
row :ecm_courses_courses_count
|
48
|
+
row :created_at
|
49
|
+
row :updated_at
|
50
|
+
end
|
51
|
+
|
52
|
+
panel Ecm::Courses::CourseCategory.human_attribute_name(:description) do
|
53
|
+
div do
|
54
|
+
ecm_courses_course_category.description
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
panel Ecm::Courses::CourseCategory.human_attribute_name(:children) do
|
59
|
+
table_for ecm_courses_course_category.children, :i18n => Ecm::Courses::CourseCategory do
|
60
|
+
# column(:name) { |ecm_courses_course| link_to ecm_courses_course, [:admin, ecm_courses_course] }
|
61
|
+
sortable_tree_columns
|
62
|
+
column(:index_name) { |ecm_courses_course_category| link_to ecm_courses_course_category, [:admin, ecm_courses_course_category] }
|
63
|
+
# column :locale
|
64
|
+
# column :parent
|
65
|
+
# column :name
|
66
|
+
column :description
|
67
|
+
column :ecm_courses_courses_count
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
panel Ecm::Courses::CourseCategory.human_attribute_name(:ecm_courses_courses) do
|
72
|
+
table_for ecm_courses_course_category.ecm_courses_courses, :i18n => Ecm::Courses::Course do
|
73
|
+
sortable_columns
|
74
|
+
column :locale
|
75
|
+
column(:name) { |ecm_courses_course| link_to ecm_courses_course, [:admin, ecm_courses_course] }
|
76
|
+
column :ecm_courses_course_dates_count
|
77
|
+
column :description
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
if defined?(ActiveAdmin)
|
2
|
+
ActiveAdmin.register Ecm::Courses::CourseDate do
|
3
|
+
# menu config
|
4
|
+
menu :parent => I18n.t('ecm.courses.active_admin.menu')
|
5
|
+
|
6
|
+
form do |f|
|
7
|
+
f.inputs do
|
8
|
+
f.input :ecm_courses_course, :as => :select,
|
9
|
+
:collection => Ecm::Courses::Course.all.collect { |ecc| [ecc, ecc.id] }
|
10
|
+
f.input :start_at
|
11
|
+
f.input :end_at
|
12
|
+
f.input :description
|
13
|
+
end
|
14
|
+
|
15
|
+
f.actions
|
16
|
+
end
|
17
|
+
|
18
|
+
index do
|
19
|
+
selectable_column
|
20
|
+
column :ecm_courses_course_category
|
21
|
+
column :ecm_courses_course
|
22
|
+
column :start_at
|
23
|
+
column :end_at
|
24
|
+
column :duration_in_minutes
|
25
|
+
column :description
|
26
|
+
default_actions
|
27
|
+
end
|
28
|
+
|
29
|
+
show :title => :to_s do
|
30
|
+
attributes_table do
|
31
|
+
row :ecm_courses_course_category
|
32
|
+
row :ecm_courses_course
|
33
|
+
row :duration_in_minutes
|
34
|
+
row :start_at
|
35
|
+
row :end_at
|
36
|
+
row :created_at
|
37
|
+
row :updated_at
|
38
|
+
end
|
39
|
+
|
40
|
+
panel Ecm::Courses::CourseDate.human_attribute_name(:description) do
|
41
|
+
div do
|
42
|
+
ecm_courses_course_date.description
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
if defined?(ActiveAdmin)
|
2
|
+
include ActiveAdmin::ActsAsList::Helper
|
3
|
+
|
4
|
+
ActiveAdmin.register Ecm::Courses::Course do
|
5
|
+
# acts as list
|
6
|
+
sortable_member_actions
|
7
|
+
|
8
|
+
# menu config
|
9
|
+
menu :parent => I18n.t('ecm.courses.active_admin.menu')
|
10
|
+
|
11
|
+
form do |f|
|
12
|
+
f.inputs do
|
13
|
+
f.input :ecm_courses_course_category, :as => :select,
|
14
|
+
:collection => nested_set_options(Ecm::Courses::CourseCategory) { |cc| "#{'-' * cc.level} #{cc.name}" }
|
15
|
+
f.input :locale, :as => :select,
|
16
|
+
:collection => I18n.available_locales.map(&:to_s)
|
17
|
+
f.input :name
|
18
|
+
f.input :description
|
19
|
+
end
|
20
|
+
|
21
|
+
f.actions
|
22
|
+
end
|
23
|
+
|
24
|
+
index do
|
25
|
+
selectable_column
|
26
|
+
column :locale
|
27
|
+
column :ecm_courses_course_category
|
28
|
+
column :name
|
29
|
+
column :ecm_courses_course_dates_count
|
30
|
+
column :description
|
31
|
+
default_actions
|
32
|
+
end
|
33
|
+
|
34
|
+
show :title => :to_s do
|
35
|
+
attributes_table do
|
36
|
+
row :ecm_courses_course_category
|
37
|
+
row :locale
|
38
|
+
row :ecm_courses_course_dates_count
|
39
|
+
row :created_at
|
40
|
+
row :updated_at
|
41
|
+
end
|
42
|
+
|
43
|
+
panel Ecm::Courses::Course.human_attribute_name(:description) do
|
44
|
+
div do
|
45
|
+
ecm_courses_course.description
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
panel Ecm::Courses::Course.human_attribute_name(:ecm_courses_course_dates) do
|
50
|
+
table_for ecm_courses_course.ecm_courses_course_dates, :i18n => Ecm::Courses::CourseDate do
|
51
|
+
column(:name) { |ecm_courses_course_date| link_to ecm_courses_course_date, [:admin, ecm_courses_course_date] }
|
52
|
+
column :duration_in_minutes
|
53
|
+
column :description
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
Binary file
|
Binary file
|
Binary file
|
@@ -0,0 +1,30 @@
|
|
1
|
+
.download_categories-tree {
|
2
|
+
background-color: white;
|
3
|
+
}
|
4
|
+
|
5
|
+
ul.tree, ul.tree ul {
|
6
|
+
background-color: inherit;
|
7
|
+
list-style-type: none;
|
8
|
+
background-image: url("<%= asset_path 'ecm_downloads/download_categories/vertical_line.png' %>");
|
9
|
+
background-repeat: repeat-y;
|
10
|
+
margin: 0;
|
11
|
+
padding: 0;
|
12
|
+
}
|
13
|
+
|
14
|
+
.tree ul {
|
15
|
+
margin-left: 10px;
|
16
|
+
}
|
17
|
+
|
18
|
+
ul.tree li {
|
19
|
+
margin: 0;
|
20
|
+
padding: 0 12px;
|
21
|
+
line-height: 20px;
|
22
|
+
background: url("<%= asset_path 'ecm_downloads/download_categories/node.png' %>");
|
23
|
+
background-repeat: no-repeat;
|
24
|
+
}
|
25
|
+
|
26
|
+
ul.tree li:last-child {
|
27
|
+
background-color: white;
|
28
|
+
background-image: url("<%= asset_path 'ecm_downloads/download_categories/last_node.png' %>") !important;
|
29
|
+
background-repeat: no-repeat;
|
30
|
+
}
|
@@ -0,0 +1 @@
|
|
1
|
+
//= require_tree ./ecm_downloads
|
@@ -0,0 +1,16 @@
|
|
1
|
+
class Ecm::Courses::CourseCategoriesController < ::FrontendController
|
2
|
+
def index
|
3
|
+
@course_categories = Ecm::Courses::CourseCategory.all
|
4
|
+
end
|
5
|
+
|
6
|
+
def show
|
7
|
+
@year = params[:year] ||= Time.zone.now.year
|
8
|
+
@month = params[:month] ||= Time.zone.now.month
|
9
|
+
|
10
|
+
@date = Date.strptime("#{@month}-#{@year}", "%m-%Y")
|
11
|
+
|
12
|
+
@course_category = Ecm::Courses::CourseCategory.includes(:ecm_courses_courses => [ :ecm_courses_course_dates ]).find(params[:id])
|
13
|
+
@courses = @course_category.ecm_courses_courses.all
|
14
|
+
@course_dates = @courses.reduce([]) { |cd, c| cd << c.ecm_courses_course_dates.for_month(@date).all }.flatten
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,9 @@
|
|
1
|
+
class Ecm::Courses::CourseDatesController < ::FrontendController
|
2
|
+
def index
|
3
|
+
@course_dates = Ecm::Courses::CourseDate.includes(:ecm_courses_course => [ :ecm_courses_course_category ]).all
|
4
|
+
end
|
5
|
+
|
6
|
+
def show
|
7
|
+
@course_date = Ecm::Courses::CourseDate.includes(:ecm_courses_course => [ :ecm_courses_course_category ]).find(params[:id])
|
8
|
+
end
|
9
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
class Ecm::Courses::CoursesController < ::FrontendController
|
2
|
+
def calendar
|
3
|
+
@year = params[:year] ||= Time.zone.now.year
|
4
|
+
@month = params[:month] ||= Time.zone.now.month
|
5
|
+
|
6
|
+
@date = Date.strptime("#{@month}-#{@year}", "%m-%Y")
|
7
|
+
|
8
|
+
@course = Ecm::Courses::Course.includes(:ecm_courses_course_category, :ecm_courses_course_dates).find(params[:id])
|
9
|
+
@course_dates = @course.ecm_courses_course_dates.for_month(@date).all
|
10
|
+
end
|
11
|
+
|
12
|
+
def index
|
13
|
+
@courses = Ecm::Courses::Course.includes(:ecm_courses_course_category, :ecm_courses_course_dates).all
|
14
|
+
end
|
15
|
+
|
16
|
+
def show
|
17
|
+
@course = Ecm::Courses::Course.includes(:ecm_courses_course_category, :ecm_courses_course_dates).find(params[:id])
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
class Ecm::Courses::Course < ActiveRecord::Base
|
2
|
+
# db settings
|
3
|
+
self.table_name = 'ecm_courses_courses'
|
4
|
+
|
5
|
+
# acts as list
|
6
|
+
acts_as_list :scope => :ecm_courses_course_category
|
7
|
+
|
8
|
+
# associations
|
9
|
+
belongs_to :ecm_courses_course_category,
|
10
|
+
:class_name => Ecm::Courses::CourseCategory,
|
11
|
+
:counter_cache => :ecm_courses_courses_count
|
12
|
+
|
13
|
+
has_many :ecm_courses_course_dates,
|
14
|
+
:class_name => Ecm::Courses::CourseDate,
|
15
|
+
:dependent => :destroy,
|
16
|
+
:foreign_key => :ecm_courses_course_id,
|
17
|
+
:order => 'start_at'
|
18
|
+
|
19
|
+
# attibutes
|
20
|
+
attr_accessible :description,
|
21
|
+
:ecm_courses_course_category_id,
|
22
|
+
:locale,
|
23
|
+
:name
|
24
|
+
# :name,
|
25
|
+
# :position,
|
26
|
+
# :slug
|
27
|
+
|
28
|
+
# friendly id
|
29
|
+
extend FriendlyId
|
30
|
+
friendly_id :name, :use => :slugged
|
31
|
+
|
32
|
+
# validations
|
33
|
+
validates :ecm_courses_course_category, :presence => true
|
34
|
+
validates :locale, :inclusion => { :in => I18n.available_locales.map(&:to_s) }, :unless => Proc.new { |c| c.locale.blank? }
|
35
|
+
validates :name, :presence => true
|
36
|
+
|
37
|
+
# public methods
|
38
|
+
|
39
|
+
def heading_name
|
40
|
+
locale_prefix = (locale.blank?) ? "" : "[#{locale}] "
|
41
|
+
"#{locale_prefix}#{name}"
|
42
|
+
end
|
43
|
+
|
44
|
+
def to_s
|
45
|
+
"#{ecm_courses_course_category.name} - #{name}"
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
class Ecm::Courses::CourseCategory < ActiveRecord::Base
|
2
|
+
# db settings
|
3
|
+
self.table_name = 'ecm_courses_course_categories'
|
4
|
+
|
5
|
+
# associations
|
6
|
+
has_many :ecm_courses_courses,
|
7
|
+
:class_name => Ecm::Courses::Course,
|
8
|
+
:dependent => :destroy,
|
9
|
+
:foreign_key => :ecm_courses_course_category_id,
|
10
|
+
:order => 'position'
|
11
|
+
|
12
|
+
# attributes
|
13
|
+
attr_accessible :description,
|
14
|
+
:ecm_courses_courses_count,
|
15
|
+
:locale,
|
16
|
+
:name,
|
17
|
+
:parent_id,
|
18
|
+
:position,
|
19
|
+
:slug
|
20
|
+
|
21
|
+
# awesome nested set
|
22
|
+
acts_as_nested_set
|
23
|
+
default_scope :order => 'lft ASC'
|
24
|
+
|
25
|
+
# friendly id
|
26
|
+
extend FriendlyId
|
27
|
+
friendly_id :name, :use => :slugged
|
28
|
+
|
29
|
+
# validations
|
30
|
+
validates :name, :presence => true, :uniqueness => { :scope => [ :parent_id ] }
|
31
|
+
validates :locale, :presence => true, :if => :root?
|
32
|
+
validates :locale, :inclusion => { :in => I18n.available_locales.map(&:to_s) }, :unless => Proc.new { |cc| cc.locale.blank? }
|
33
|
+
validates :locale, :absence => true, :unless => :root?
|
34
|
+
|
35
|
+
# public methods
|
36
|
+
def index_name
|
37
|
+
if self.root?
|
38
|
+
"[#{self.locale}] #{self.name}"
|
39
|
+
else
|
40
|
+
"#{'    ' * self.level} |-- #{self.name}".html_safe
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
def to_s
|
45
|
+
name
|
46
|
+
end
|
47
|
+
|
48
|
+
def tree_name
|
49
|
+
root_prefix = (self.root?) ? "[#{self.locale}] " : ""
|
50
|
+
|
51
|
+
if ecm_courses_courses_count < 1
|
52
|
+
"#{root_prefix}#{to_s}"
|
53
|
+
else
|
54
|
+
"#{root_prefix}#{to_s} (#{ecm_courses_courses_count})"
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
class Ecm::Courses::CourseDate < ActiveRecord::Base
|
2
|
+
# db settings
|
3
|
+
self.table_name = 'ecm_courses_course_dates'
|
4
|
+
|
5
|
+
# associations
|
6
|
+
belongs_to :ecm_courses_course,
|
7
|
+
:class_name => Ecm::Courses::Course,
|
8
|
+
:counter_cache => :ecm_courses_course_dates_count
|
9
|
+
|
10
|
+
has_one :ecm_courses_course_category,
|
11
|
+
:class_name => Ecm::Courses::CourseCategory,
|
12
|
+
:through => :ecm_courses_course
|
13
|
+
|
14
|
+
# attributes
|
15
|
+
attr_accessible :description,
|
16
|
+
:ecm_courses_course_id,
|
17
|
+
:end_at,
|
18
|
+
# :slug,
|
19
|
+
:start_at
|
20
|
+
|
21
|
+
# callbacks
|
22
|
+
after_initialize :set_defaults
|
23
|
+
|
24
|
+
# validations
|
25
|
+
validates :ecm_courses_course, :presence => true
|
26
|
+
validates :end_at, :presence => true
|
27
|
+
validates :start_at, :presence => true
|
28
|
+
|
29
|
+
# public methods
|
30
|
+
def duration_in_minutes
|
31
|
+
((self.end_at) - (self.start_at)).to_i / 60
|
32
|
+
end
|
33
|
+
|
34
|
+
def to_s
|
35
|
+
"#{I18n.l(start_at)} - #{I18n.l(end_at)}"
|
36
|
+
end
|
37
|
+
|
38
|
+
# class methods
|
39
|
+
def self.for_month(date)
|
40
|
+
date ||= Time.zone.now.to_date
|
41
|
+
where(:start_at => (date.beginning_of_month..date.end_of_month))
|
42
|
+
end
|
43
|
+
|
44
|
+
# protected methods
|
45
|
+
protected
|
46
|
+
def set_defaults
|
47
|
+
if self.new_record?
|
48
|
+
self.start_at ||= 6.hours.from_now.change( :min => 0 )
|
49
|
+
self.end_at ||= self.start_at + 1.hours
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
<div class="course_category" id="course_category-<%= course_category.id %>">
|
2
|
+
<% if action_name == 'show' %>
|
3
|
+
<h1 class="courses_category-name"><%= course_category.name %></h1>
|
4
|
+
<% else %>
|
5
|
+
<h2 class="courses_category-name"><%= course_category.name %></h2>
|
6
|
+
<% end %>
|
7
|
+
|
8
|
+
<div class="course_categories-tree">
|
9
|
+
<%= nested_li(course_category.descendants, {}) do |course_category| %>
|
10
|
+
<%= link_to course_category.tree_name, course_category %>
|
11
|
+
<% end %>
|
12
|
+
</div>
|
13
|
+
|
14
|
+
<% unless course_category.description.blank? %>
|
15
|
+
<div class="course_categories-description">
|
16
|
+
<p><%= course_category.description %></p>
|
17
|
+
</div>
|
18
|
+
<% end %>
|
19
|
+
|
20
|
+
<div class="course_category-courses">
|
21
|
+
<h2><%= Ecm::Courses::CourseCategory.human_attribute_name(:ecm_courses_courses) %></h2>
|
22
|
+
<% if course_category.ecm_courses_courses_count == 0 %>
|
23
|
+
<%= t('ecm.courses.course_category.messages.no_courses_available') %>
|
24
|
+
<hr />
|
25
|
+
<% else %>
|
26
|
+
<%= render course_category.ecm_courses_courses %>
|
27
|
+
<% end %>
|
28
|
+
</div>
|
29
|
+
</div>
|
@@ -0,0 +1,19 @@
|
|
1
|
+
<%= render @course_category %>
|
2
|
+
|
3
|
+
<p>
|
4
|
+
<% if @course_category.root? %>
|
5
|
+
<%= link_to(t('ecm.courses.course_category.actions.back_to_index'), ecm_courses_course_categories_path) if respond_to?(:ecm_courses_course_categories_path) %>
|
6
|
+
<% else %>
|
7
|
+
<%= link_to(Ecm::Courses::CourseCategory.human_attribute_name(:parent), @course_category.parent) %>
|
8
|
+
<% end %>
|
9
|
+
</p>
|
10
|
+
|
11
|
+
|
12
|
+
<div class="course_category-calendar" id="course_category-<%= @course_category.to_param %>">
|
13
|
+
<% unless @course_category.ecm_courses_courses.empty? %>
|
14
|
+
<h2>Kurskalender für <%= I18n.l(@date, :format => :month_with_year) %></h2>
|
15
|
+
|
16
|
+
<%= month_calendar_pagination(@date) %>
|
17
|
+
<%= month_calendar(@date, @course_dates, { :display_method => :ecm_courses_course.to_s, :start_day => :monday}) %>
|
18
|
+
<% end %>
|
19
|
+
</div>
|
@@ -0,0 +1,11 @@
|
|
1
|
+
<div class="course-date" id="course-date_<%= @course_date.to_param %>">
|
2
|
+
<h1><%= link_to @course_date.ecm_courses_course_category.to_s, @course_date.ecm_courses_course_category %></h1>
|
3
|
+
|
4
|
+
<h2><%= link_to @course_date.ecm_courses_course.to_s, @course_date.ecm_courses_course %></h2>
|
5
|
+
|
6
|
+
<h3><%= @course_date %></h3>
|
7
|
+
|
8
|
+
<div class="course_date-description">
|
9
|
+
<%= @course_date.description %>
|
10
|
+
</div>
|
11
|
+
</div>
|
@@ -0,0 +1,15 @@
|
|
1
|
+
<div class="course" id="course-<%= course.to_param %>">
|
2
|
+
<h2><%= course.heading_name %></h2>
|
3
|
+
|
4
|
+
<% unless course.description.blank? %>
|
5
|
+
<div class="course-description">
|
6
|
+
<p><%= course.description %></p>
|
7
|
+
</div>
|
8
|
+
<% end %>
|
9
|
+
|
10
|
+
<div class="course-dates">
|
11
|
+
<%= render course.ecm_courses_course_dates %>
|
12
|
+
</div>
|
13
|
+
</div>
|
14
|
+
|
15
|
+
<hr />
|
@@ -0,0 +1,6 @@
|
|
1
|
+
<h1>Kurskalender für <%= I18n.l(@date, :format => :month_with_year) %></h1>
|
2
|
+
|
3
|
+
<%= link_to "Zurück zu #{@course.ecm_courses_course_category}", @course.ecm_courses_course_category %>
|
4
|
+
|
5
|
+
<%= month_calendar_pagination(@date) %>
|
6
|
+
<%= month_calendar(@date, @course_dates, { :display_method => :ecm_courses_course.to_s}) %>
|
@@ -0,0 +1,13 @@
|
|
1
|
+
<div class="course" id="course_<%= @course.to_param %>">
|
2
|
+
<h1><%= link_to @course.ecm_courses_course_category.to_s, @course.ecm_courses_course_category %></h1>
|
3
|
+
|
4
|
+
<h2><%= @course %></h2>
|
5
|
+
|
6
|
+
<div class="course-description">
|
7
|
+
<%= @course.description %>
|
8
|
+
</div>
|
9
|
+
|
10
|
+
<div class="course-dates">
|
11
|
+
<%= render @course.ecm_courses_course_dates %>
|
12
|
+
</div>
|
13
|
+
</div>
|