ecm_staff 0.0.1.pre
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.
- data/MIT-LICENSE +20 -0
- data/README.rdoc +3 -0
- data/Rakefile +27 -0
- data/app/admin/ecm_staff_business_units.rb +88 -0
- data/app/admin/ecm_staff_organisations.rb +59 -0
- data/app/admin/ecm_staff_people.rb +105 -0
- data/app/admin/ecm_staff_person_positions.rb +53 -0
- data/app/admin/ecm_staff_positions.rb +68 -0
- data/app/assets/stylesheets/ecm/staff/person.css.erb +7 -0
- data/app/assets/stylesheets/ecm/staff/person_position.css.erb +32 -0
- data/app/assets/stylesheets/ecm_staff.css +3 -0
- data/app/assets/stylesheets/ecm_staff_active_admin.css.scss.erb +14 -0
- data/app/controllers/ecm/staff/business_units_controller.rb +11 -0
- data/app/controllers/ecm/staff/organisations_controller.rb +7 -0
- data/app/controllers/ecm/staff/people_controller.rb +11 -0
- data/app/models/ecm/staff/base.rb +9 -0
- data/app/models/ecm/staff/business_unit.rb +57 -0
- data/app/models/ecm/staff/organisation.rb +42 -0
- data/app/models/ecm/staff/person.rb +94 -0
- data/app/models/ecm/staff/person_position.rb +23 -0
- data/app/models/ecm/staff/position.rb +50 -0
- data/app/views/bootstrap/_media_list_item.html.erb +17 -0
- data/app/views/ecm/staff/business_units/_business_unit_list_item.html.erb +17 -0
- data/app/views/ecm/staff/business_units/index.html.erb +5 -0
- data/app/views/ecm/staff/organisations/_organisation.html.erb +9 -0
- data/app/views/ecm/staff/organisations/index.html.erb +5 -0
- data/app/views/ecm/staff/people/_person.html.erb +17 -0
- data/app/views/ecm/staff/people/_person_in_index.html.erb +20 -0
- data/app/views/ecm/staff/people/_person_positions_table.html.erb +14 -0
- data/app/views/ecm/staff/people/index.html.erb +3 -0
- data/app/views/ecm/staff/people/show.html.erb +7 -0
- data/app/views/ecm/staff/person_positions/_person_position.html.erb +5 -0
- data/app/views/ecm/staff/person_positions/_person_position_as_table_row.html.erb +5 -0
- data/db/migrate/001_create_ecm_staff_organisations.rb +16 -0
- data/db/migrate/002_create_ecm_staff_business_units.rb +26 -0
- data/db/migrate/003_create_ecm_staff_positions.rb +23 -0
- data/db/migrate/004_create_ecm_staff_person_positions.rb +17 -0
- data/db/migrate/005_create_ecm_staff_people.rb +22 -0
- data/db/migrate/006_create_ecm_staff_organisation_translations.rb +15 -0
- data/db/migrate/007_create_ecm_staff_business_unit_translations.rb +15 -0
- data/db/migrate/008_create_ecm_staff_position_translations.rb +15 -0
- data/db/migrate/009_create_ecm_staff_person_translations.rb +15 -0
- data/lib/ecm/staff/configuration.rb +25 -0
- data/lib/ecm/staff/engine.rb +14 -0
- data/lib/ecm/staff/exceptions.rb +7 -0
- data/lib/ecm/staff/routing.rb +19 -0
- data/lib/ecm/staff/version.rb +6 -0
- data/lib/ecm_staff.rb +21 -0
- data/lib/generators/ecm/staff/install/install_generator.rb +15 -0
- data/lib/generators/ecm/staff/install/templates/ecm_staff.rb +16 -0
- data/lib/generators/ecm/staff/locales/locales_generator.rb +16 -0
- data/lib/generators/ecm/staff/locales/templates/de.yml +77 -0
- data/lib/generators/ecm/staff/locales/templates/en.yml +77 -0
- data/lib/tasks/ecm_staff_tasks.rake +4 -0
- metadata +680 -0
@@ -0,0 +1,94 @@
|
|
1
|
+
class Ecm::Staff::Person < Ecm::Staff::Base
|
2
|
+
# associations
|
3
|
+
has_many :person_positions, :class_name => Ecm::Staff::PersonPosition,
|
4
|
+
:order => 'begin_at DESC',
|
5
|
+
:inverse_of => :person
|
6
|
+
accepts_nested_attributes_for :person_positions, :allow_destroy => true
|
7
|
+
|
8
|
+
has_many :positions, :through => :person_positions,
|
9
|
+
:class_name => Ecm::Staff::Position
|
10
|
+
|
11
|
+
has_many :attached_pictures, :as => :pictureable,
|
12
|
+
:class_name => Ecm::Pictures::AttachedPicture,
|
13
|
+
:inverse_of => :pictureable
|
14
|
+
has_many :pictures, :through => :attached_pictures,
|
15
|
+
:class_name => Ecm::Pictures::Picture
|
16
|
+
|
17
|
+
accepts_nested_attributes_for :attached_pictures, :allow_destroy => true
|
18
|
+
accepts_nested_attributes_for :pictures, :allow_destroy => true
|
19
|
+
|
20
|
+
# attributes
|
21
|
+
attr_accessible :attached_pictures_attributes,
|
22
|
+
:birthdate,
|
23
|
+
:description,
|
24
|
+
:firstname,
|
25
|
+
:lastname,
|
26
|
+
:markup_language,
|
27
|
+
:person_positions_attributes,
|
28
|
+
:pictures_attributes,
|
29
|
+
:position,
|
30
|
+
:prefix
|
31
|
+
|
32
|
+
# acts as list
|
33
|
+
acts_as_list
|
34
|
+
default_scope :order => 'position ASC'
|
35
|
+
|
36
|
+
# callbacks
|
37
|
+
after_initialize :set_defaults
|
38
|
+
|
39
|
+
# globalization support
|
40
|
+
translates :description, :prefix, :slug
|
41
|
+
attr_accessible :translations, :translations_attributes
|
42
|
+
accepts_nested_attributes_for :translations
|
43
|
+
|
44
|
+
# friendly id support
|
45
|
+
extend FriendlyId
|
46
|
+
friendly_id :fullname, :use => :slugged
|
47
|
+
|
48
|
+
# markup support
|
49
|
+
acts_as_markup :language => :variable,
|
50
|
+
:columns => [ :description ]
|
51
|
+
|
52
|
+
# validations
|
53
|
+
validates :markup_language, :presence => true,
|
54
|
+
:inclusion => Ecm::Staff::Configuration.markup_languages.map(&:to_s)
|
55
|
+
validates :firstname, :presence => true
|
56
|
+
validates :lastname, :presence => true
|
57
|
+
|
58
|
+
def age
|
59
|
+
return if birthdate.nil?
|
60
|
+
if (Time.zone.now.month < self.birthdate.month) || (Time.zone.now.month == self.birthdate.month && self.birthdate.day >= Time.zone.now.day)
|
61
|
+
Time.zone.now.year - self.birthdate.year - 1
|
62
|
+
else
|
63
|
+
Time.zone.now.year - self.birthdate.year
|
64
|
+
end
|
65
|
+
end # def
|
66
|
+
|
67
|
+
def fullname
|
68
|
+
"#{firstname} #{lastname}"
|
69
|
+
end # def
|
70
|
+
|
71
|
+
def fullname_with_prefix
|
72
|
+
prefix.present? ? "#{prefix} #{fullname}" : fullname
|
73
|
+
end # def
|
74
|
+
|
75
|
+
def preview_picture
|
76
|
+
pictures.first
|
77
|
+
end # def
|
78
|
+
|
79
|
+
def preview_picture_image_url(style = nil)
|
80
|
+
preview_picture.image.url(style) if preview_picture.respond_to?(:image) && preview_picture.image.respond_to?(:url)
|
81
|
+
end # def
|
82
|
+
|
83
|
+
def to_s
|
84
|
+
fullname
|
85
|
+
end # def
|
86
|
+
|
87
|
+
private
|
88
|
+
|
89
|
+
def set_defaults
|
90
|
+
if self.new_record?
|
91
|
+
self.markup_language ||= Ecm::Staff::Configuration.default_markup_language
|
92
|
+
end # if
|
93
|
+
end # def
|
94
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
class Ecm::Staff::PersonPosition < Ecm::Staff::Base
|
2
|
+
# associations
|
3
|
+
has_one :organisation, :through => :business_unit
|
4
|
+
belongs_to :business_unit
|
5
|
+
belongs_to :person, :class_name => Ecm::Staff::Configuration.person_class_name
|
6
|
+
belongs_to :position
|
7
|
+
|
8
|
+
|
9
|
+
# attributes
|
10
|
+
attr_accessible :begin_at,
|
11
|
+
:business_unit_id,
|
12
|
+
:end_at,
|
13
|
+
:organisation_id,
|
14
|
+
:person_id,
|
15
|
+
:position_id
|
16
|
+
|
17
|
+
# validations
|
18
|
+
# @TODO: Validate end_at > begin_at if present
|
19
|
+
validates :begin_at, :presence => true
|
20
|
+
validates :business_unit, :presence => true
|
21
|
+
validates :person, :presence => true
|
22
|
+
validates :position, :presence => true
|
23
|
+
end # class Ecm::Staff::PersonPosition < Ecm::Staff::Base
|
@@ -0,0 +1,50 @@
|
|
1
|
+
class Ecm::Staff::Position < Ecm::Staff::Base
|
2
|
+
# associations
|
3
|
+
has_many :person_positions, :dependent => :restrict
|
4
|
+
has_many :people, :through => :person_positions,
|
5
|
+
:class_name => Ecm::Staff::Configuration.person_class_name
|
6
|
+
|
7
|
+
# attributes
|
8
|
+
attr_accessible :description,
|
9
|
+
:name,
|
10
|
+
:parent_id
|
11
|
+
|
12
|
+
# callbacks
|
13
|
+
after_initialize :set_defaults
|
14
|
+
|
15
|
+
# globalization support
|
16
|
+
translates :description, :name, :slug
|
17
|
+
attr_accessible :translations, :translations_attributes
|
18
|
+
accepts_nested_attributes_for :translations
|
19
|
+
|
20
|
+
# friendly id support
|
21
|
+
extend FriendlyId
|
22
|
+
friendly_id :name, :use => :slugged
|
23
|
+
|
24
|
+
# markup support
|
25
|
+
acts_as_markup :language => :variable,
|
26
|
+
:columns => [ :description ]
|
27
|
+
|
28
|
+
# nested set support
|
29
|
+
acts_as_nested_set
|
30
|
+
|
31
|
+
# validations
|
32
|
+
validates :name, :presence => true,
|
33
|
+
:uniqueness => true
|
34
|
+
|
35
|
+
def people_count
|
36
|
+
people.count
|
37
|
+
end # def
|
38
|
+
|
39
|
+
def to_s
|
40
|
+
name
|
41
|
+
end # def
|
42
|
+
|
43
|
+
private
|
44
|
+
|
45
|
+
def set_defaults
|
46
|
+
if self.new_record?
|
47
|
+
self.markup_language ||= Ecm::Staff::Configuration.default_markup_language
|
48
|
+
end # if
|
49
|
+
end # def
|
50
|
+
end # class Ecm::Staff::Position < Ecm::Staff::Base
|
@@ -0,0 +1,17 @@
|
|
1
|
+
<div class="media", id="<%= dom_id(media_object) %>">
|
2
|
+
<%= link_to "#", "#", :class => "pull-left" %>
|
3
|
+
<div class="media-body">
|
4
|
+
<h4 class="media-heading"><%= media_object.to_s %></h4>
|
5
|
+
<p><%= media_object.description %></p>
|
6
|
+
<div class="person-positions">
|
7
|
+
<ul>
|
8
|
+
<% media_object.person_positions.each do |person_position| %>
|
9
|
+
<li><%= render person_position %></li>
|
10
|
+
<% end %>
|
11
|
+
</ul>
|
12
|
+
</div>
|
13
|
+
<% media_object.children.each do |child| %>
|
14
|
+
<%= render :partial => "bootstrap/media_list_item", :locals => { :media_object => child } %>
|
15
|
+
<% end unless media_object.leaf? %>
|
16
|
+
</div>
|
17
|
+
</div>
|
@@ -0,0 +1,17 @@
|
|
1
|
+
<div class="media", id="<%= dom_id(business_unit) %>">
|
2
|
+
<%= link_to "#", business_unit, :class => "pull-left" %>
|
3
|
+
<div class="media-body">
|
4
|
+
<h4 class="media-heading"><%= business_unit.to_s %></h4>
|
5
|
+
<%= business_unit.description.to_html.html_safe %>
|
6
|
+
<div class="person-positions">
|
7
|
+
<ul>
|
8
|
+
<% business_unit.person_positions.each do |person_position| %>
|
9
|
+
<li><%= render person_position %></li>
|
10
|
+
<% end %>
|
11
|
+
</ul>
|
12
|
+
</div>
|
13
|
+
<% business_unit.children.each do |child| %>
|
14
|
+
<%= render :partial => "ecm/staff/business_units/business_unit_list_item", :locals => { :business_unit => child } %>
|
15
|
+
<% end unless business_unit.leaf? %>
|
16
|
+
</div>
|
17
|
+
</div>
|
@@ -0,0 +1,9 @@
|
|
1
|
+
<h2><%= organisation %></h2>
|
2
|
+
|
3
|
+
<%= organisation.description.to_html.html_safe %>
|
4
|
+
|
5
|
+
<% organisation.business_units.roots.all.each do |root_business_unit| %>
|
6
|
+
<%= render :partial => "ecm/staff/business_units/business_unit_list_item", :locals => { :business_unit => root_business_unit } %>
|
7
|
+
<% end %>
|
8
|
+
|
9
|
+
<hr />
|
@@ -0,0 +1,17 @@
|
|
1
|
+
<div class="media person-preview well" id="<%= dom_id(person) %>">
|
2
|
+
<div class="preview-picture pull-left">
|
3
|
+
<% if person.preview_picture.present? %>
|
4
|
+
<%= image_tag(person.preview_picture_image_url(:medium_thumb)) %>
|
5
|
+
<% else %>
|
6
|
+
<div class="preview-picture-placeholder well">☺</div>
|
7
|
+
<% end %>
|
8
|
+
</div>
|
9
|
+
<div class="media-heading">
|
10
|
+
</div>
|
11
|
+
<div class="person-description">
|
12
|
+
<%= person.description.to_html.html_safe if person.description.present? %>
|
13
|
+
</div>
|
14
|
+
<div class="person-positions">
|
15
|
+
<%= render 'person_positions_table', :person => person if person.person_positions.present? %>
|
16
|
+
</div>
|
17
|
+
</div>
|
@@ -0,0 +1,20 @@
|
|
1
|
+
<div class="media person-preview well" id="<%= dom_id(person) %>">
|
2
|
+
<div class="preview-picture pull-left">
|
3
|
+
<% if person.preview_picture.present? %>
|
4
|
+
<%= link_to person do %>
|
5
|
+
<%= image_tag(person.preview_picture_image_url(:medium_thumb)) %>
|
6
|
+
<% end %>
|
7
|
+
<% else %>
|
8
|
+
<div class="preview-picture-placeholder well"><%= link_to "☺".html_safe, person %></div>
|
9
|
+
<% end %>
|
10
|
+
</div>
|
11
|
+
<div class="media-heading">
|
12
|
+
<h4><%= link_to person.fullname_with_prefix, person %></h4>
|
13
|
+
</div>
|
14
|
+
<div class="person-description">
|
15
|
+
<%= person.description.to_html.html_safe if person.description.present? %>
|
16
|
+
</div>
|
17
|
+
<div class="person-positions">
|
18
|
+
<%= render 'person_positions_table', :person => person if person.person_positions.present? %>
|
19
|
+
</div>
|
20
|
+
</div>
|
@@ -0,0 +1,14 @@
|
|
1
|
+
<table class="table">
|
2
|
+
<thead>
|
3
|
+
<tr>
|
4
|
+
<th><%= Ecm::Staff::PersonPosition.human_attribute_name(:position) %></th>
|
5
|
+
<th><%= Ecm::Staff::PersonPosition.human_attribute_name(:begin_at) %></th>
|
6
|
+
<th><%= Ecm::Staff::PersonPosition.human_attribute_name(:end_at) %></th>
|
7
|
+
</tr>
|
8
|
+
</thead>
|
9
|
+
<tbody>
|
10
|
+
<% person.person_positions.each do |person_position| %>
|
11
|
+
<%= render 'ecm/staff/person_positions/person_position_as_table_row', :person_position => person_position %>
|
12
|
+
<% end %>
|
13
|
+
</tbody>
|
14
|
+
</table>
|
@@ -0,0 +1,5 @@
|
|
1
|
+
<%= person_position.position %>: <%= link_to person_position.person, person_position.person %>
|
2
|
+
<ul>
|
3
|
+
<li><%= Ecm::Staff::PersonPosition.human_attribute_name(:begin_at) %>: <%= person_position.begin_at %></li>
|
4
|
+
<li><%= Ecm::Staff::PersonPosition.human_attribute_name(:end_at) %>: <%= person_position.end_at %></li>
|
5
|
+
</ul>
|
@@ -0,0 +1,16 @@
|
|
1
|
+
class CreateEcmStaffOrganisations < ActiveRecord::Migration
|
2
|
+
def change
|
3
|
+
create_table :ecm_staff_organisations do |t|
|
4
|
+
t.string :name
|
5
|
+
t.text :description
|
6
|
+
|
7
|
+
# acts as markup
|
8
|
+
t.string :markup_language
|
9
|
+
|
10
|
+
# friendly id
|
11
|
+
t.string :slug
|
12
|
+
|
13
|
+
t.timestamps
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
class CreateEcmStaffBusinessUnits < ActiveRecord::Migration
|
2
|
+
def change
|
3
|
+
create_table :ecm_staff_business_units do |t|
|
4
|
+
t.references :organisation
|
5
|
+
|
6
|
+
t.string :name
|
7
|
+
t.text :description
|
8
|
+
|
9
|
+
# acts as markup
|
10
|
+
t.string :markup_language
|
11
|
+
|
12
|
+
# friendly id
|
13
|
+
t.string :slug
|
14
|
+
|
15
|
+
# awesome nested set
|
16
|
+
t.references :parent
|
17
|
+
t.integer :lft
|
18
|
+
t.integer :rgt
|
19
|
+
t.integer :depth
|
20
|
+
|
21
|
+
t.timestamps
|
22
|
+
end
|
23
|
+
add_index :ecm_staff_business_units, :organisation_id
|
24
|
+
add_index :ecm_staff_business_units, :parent_id
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
class CreateEcmStaffPositions < ActiveRecord::Migration
|
2
|
+
def change
|
3
|
+
create_table :ecm_staff_positions do |t|
|
4
|
+
t.string :name
|
5
|
+
t.text :description
|
6
|
+
|
7
|
+
# acts as markup
|
8
|
+
t.string :markup_language
|
9
|
+
|
10
|
+
# awesome nested set
|
11
|
+
t.references :parent
|
12
|
+
t.integer :lft
|
13
|
+
t.integer :rgt
|
14
|
+
t.integer :depth
|
15
|
+
|
16
|
+
# friendly id
|
17
|
+
t.string :slug
|
18
|
+
|
19
|
+
t.timestamps
|
20
|
+
end
|
21
|
+
add_index :ecm_staff_positions, :parent_id
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
class CreateEcmStaffPersonPositions < ActiveRecord::Migration
|
2
|
+
def change
|
3
|
+
create_table :ecm_staff_person_positions do |t|
|
4
|
+
t.references :person
|
5
|
+
t.references :business_unit
|
6
|
+
t.references :position
|
7
|
+
|
8
|
+
t.date :begin_at
|
9
|
+
t.date :end_at
|
10
|
+
|
11
|
+
t.timestamps
|
12
|
+
end
|
13
|
+
add_index :ecm_staff_person_positions, :person_id
|
14
|
+
add_index :ecm_staff_person_positions, :business_unit_id
|
15
|
+
add_index :ecm_staff_person_positions, :position_id
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
class CreateEcmStaffPeople < ActiveRecord::Migration
|
2
|
+
def change
|
3
|
+
create_table :ecm_staff_people do |t|
|
4
|
+
t.string :prefix
|
5
|
+
t.string :firstname
|
6
|
+
t.string :lastname
|
7
|
+
t.date :birthdate
|
8
|
+
t.text :description
|
9
|
+
|
10
|
+
# acts as list
|
11
|
+
t.integer :position
|
12
|
+
|
13
|
+
# acts as markup
|
14
|
+
t.string :markup_language
|
15
|
+
|
16
|
+
# friendly id
|
17
|
+
t.string :slug
|
18
|
+
|
19
|
+
t.timestamps
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
class CreateEcmStaffOrganisationTranslations < ActiveRecord::Migration
|
2
|
+
def up
|
3
|
+
Ecm::Staff::Organisation.create_translation_table!({
|
4
|
+
:name => :string,
|
5
|
+
:description => :text,
|
6
|
+
:slug => :string
|
7
|
+
}, {
|
8
|
+
:migrate_data => true
|
9
|
+
})
|
10
|
+
end
|
11
|
+
|
12
|
+
def down
|
13
|
+
Ecm::Staff::Organisation.drop_translation_table!( :migrate_data => true )
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
class CreateEcmStaffBusinessUnitTranslations < ActiveRecord::Migration
|
2
|
+
def up
|
3
|
+
Ecm::Staff::BusinessUnit.create_translation_table!({
|
4
|
+
:name => :string,
|
5
|
+
:description => :text,
|
6
|
+
:slug => :string
|
7
|
+
}, {
|
8
|
+
:migrate_data => true
|
9
|
+
})
|
10
|
+
end
|
11
|
+
|
12
|
+
def down
|
13
|
+
Ecm::Staff::BusinessUnit.drop_translation_table!( :migrate_data => true )
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
class CreateEcmStaffPositionTranslations < ActiveRecord::Migration
|
2
|
+
def up
|
3
|
+
Ecm::Staff::Position.create_translation_table!({
|
4
|
+
:name => :string,
|
5
|
+
:description => :text,
|
6
|
+
:slug => :string
|
7
|
+
}, {
|
8
|
+
:migrate_data => true
|
9
|
+
})
|
10
|
+
end
|
11
|
+
|
12
|
+
def down
|
13
|
+
Ecm::Staff::Position.drop_translation_table!( :migrate_data => true )
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
class CreateEcmStaffPersonTranslations < ActiveRecord::Migration
|
2
|
+
def up
|
3
|
+
Ecm::Staff::Person.create_translation_table!({
|
4
|
+
:prefix => :string,
|
5
|
+
:description => :text,
|
6
|
+
:slug => :string
|
7
|
+
}, {
|
8
|
+
:migrate_data => true
|
9
|
+
})
|
10
|
+
end
|
11
|
+
|
12
|
+
def down
|
13
|
+
Ecm::Staff::Person.drop_translation_table!( :migrate_data => true )
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'active_support/core_ext/module/delegation'
|
2
|
+
require 'active_support/core_ext/module/attribute_accessors'
|
3
|
+
require 'active_support/hash_with_indifferent_access'
|
4
|
+
|
5
|
+
module Ecm::Staff
|
6
|
+
module Configuration
|
7
|
+
def configure
|
8
|
+
yield self
|
9
|
+
end # def
|
10
|
+
|
11
|
+
mattr_accessor :default_markup_language
|
12
|
+
@@default_markup_language = nil
|
13
|
+
|
14
|
+
mattr_accessor :markup_languages
|
15
|
+
@@markup_languages = []
|
16
|
+
|
17
|
+
mattr_accessor :person_class_name
|
18
|
+
@@person_class_name = 'Person'
|
19
|
+
|
20
|
+
def self.person_class_name=(class_name)
|
21
|
+
raise PersonClassNotDefinedError unless Object.const_defined?(class_name)
|
22
|
+
@@person_class_name = class_name.constantize
|
23
|
+
end # def
|
24
|
+
end # module Configuration
|
25
|
+
end # module Ecm::Staff
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module Ecm
|
2
|
+
module Staff
|
3
|
+
class Engine < ::Rails::Engine
|
4
|
+
initializer :ecm_staff_engine do
|
5
|
+
ActiveAdmin.setup do |config|
|
6
|
+
config.load_paths << File.join(self.root, 'app/admin')
|
7
|
+
# config.load_paths.unshift File.join(self.root, 'app/admin')
|
8
|
+
|
9
|
+
config.register_stylesheet 'ecm_staff_active_admin.css'
|
10
|
+
end if defined?(::ActiveAdmin) # ::ActiveAdmin.setup
|
11
|
+
end # initializer :ecm_staff_engine do
|
12
|
+
end # class Engine < ::Rails::Engine
|
13
|
+
end # module Staff
|
14
|
+
end # module Ecm
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module Ecm::Staff
|
2
|
+
class Routing
|
3
|
+
def self.routes(router, options = {})
|
4
|
+
options.reverse_merge!(
|
5
|
+
{ :organisations_actions => [:index, :show],
|
6
|
+
:business_units_actions => [:index, :show],
|
7
|
+
:people_actions => [:index, :show],
|
8
|
+
}
|
9
|
+
)
|
10
|
+
|
11
|
+
router.resources :ecm_staff_organisations, :only => options[:organisations_actions],
|
12
|
+
:controller => 'ecm/staff/organisations'
|
13
|
+
router.resources :ecm_staff_business_units, :only => options[:business_units_actions],
|
14
|
+
:controller => 'ecm/staff/business_units'
|
15
|
+
router.resources :ecm_staff_people, :only => options[:people_actions],
|
16
|
+
:controller => 'ecm/staff/people'
|
17
|
+
end # def
|
18
|
+
end # Routing
|
19
|
+
end # module Ecm::Staff
|
data/lib/ecm_staff.rb
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'active_admin-acts_as_list'
|
2
|
+
require 'active_admin-awesome_nested_set'
|
3
|
+
require 'activeadmin-translate'
|
4
|
+
require 'acts_as_list'
|
5
|
+
require 'acts_as_markup'
|
6
|
+
require 'acts_as_published'
|
7
|
+
require 'awesome_nested_set'
|
8
|
+
require 'ecm_pictures'
|
9
|
+
require 'friendly_id'
|
10
|
+
require 'globalize'
|
11
|
+
|
12
|
+
require 'ecm/staff/engine'
|
13
|
+
require 'ecm/staff/exceptions'
|
14
|
+
require 'ecm/staff/configuration'
|
15
|
+
require 'ecm/staff/routing'
|
16
|
+
|
17
|
+
module Ecm
|
18
|
+
module Staff
|
19
|
+
extend Configuration
|
20
|
+
end # module Staff
|
21
|
+
end # module Ecm
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module Ecm
|
2
|
+
module Staff
|
3
|
+
module Generators
|
4
|
+
class InstallGenerator < Rails::Generators::Base
|
5
|
+
desc "Generates the intializer"
|
6
|
+
|
7
|
+
source_root File.expand_path('../templates', __FILE__)
|
8
|
+
|
9
|
+
def generate_intializer
|
10
|
+
copy_file "ecm_staff.rb", "config/initializers/ecm_staff.rb"
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
Ecm::Staff.configure do |config|
|
2
|
+
# Accepted markup languages
|
3
|
+
#
|
4
|
+
# default: config.markup_languages = %w[ markdown rdoc textile ]
|
5
|
+
config.markup_languages = %w[ markdown rdoc textile ]
|
6
|
+
|
7
|
+
# Default markup language
|
8
|
+
#
|
9
|
+
# default: config.default_markup_language = 'textile'
|
10
|
+
config.default_markup_language = 'textile'
|
11
|
+
|
12
|
+
# Person model
|
13
|
+
#
|
14
|
+
# default: config.person_class_name = 'Person'
|
15
|
+
config.person_class_name = 'Ecm::Staff::Person'
|
16
|
+
end # Ecm::Staff.configure
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module Ecm
|
2
|
+
module Staff
|
3
|
+
module Generators
|
4
|
+
class LocalesGenerator < Rails::Generators::Base
|
5
|
+
desc "Copies the locale files to your application"
|
6
|
+
|
7
|
+
source_root File.expand_path('../templates', __FILE__)
|
8
|
+
|
9
|
+
def generate_locales
|
10
|
+
copy_file "en.yml", "config/locales/ecm.staff.en.yml"
|
11
|
+
copy_file "de.yml", "config/locales/ecm.staff.de.yml"
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|