Commit c760938da2323dfa1fab8f1ef091f3a00c9ca0a8
1 parent
71b98ac5
Exists in
master
and in
28 other branches
ActionItem6: documented the enterprise controller and the related models
git-svn-id: https://svn.colivre.coop.br/svn/noosfero/trunk@355 3f533792-8f58-4932-b0fe-aaf55b0a4547
Showing
5 changed files
with
17 additions
and
0 deletions
Show diff stats
app/controllers/enterprise_controller.rb
... | ... | @@ -3,6 +3,7 @@ class EnterpriseController < ApplicationController |
3 | 3 | |
4 | 4 | before_filter :logon, :my_enterprises |
5 | 5 | |
6 | + # Redirects to show if there is only one action and to list otherwise | |
6 | 7 | def index |
7 | 8 | if @my_enterprises.size == 1 |
8 | 9 | redirect_to :action => 'show', :id => @my_enterprises[0] |
... | ... | @@ -11,20 +12,24 @@ class EnterpriseController < ApplicationController |
11 | 12 | end |
12 | 13 | end |
13 | 14 | |
15 | + # Lists all enterprises | |
14 | 16 | def list |
15 | 17 | @enterprises = Enterprise.find(:all) - @my_enterprises |
16 | 18 | end |
17 | 19 | |
20 | + # Show details about an enterprise | |
18 | 21 | def show |
19 | 22 | @enterprise = @my_enterprises.find(params[:id]) |
20 | 23 | end |
21 | 24 | |
25 | + # Make a form to the creation of an eterprise | |
22 | 26 | def register_form |
23 | 27 | @enterprise = Enterprise.new() |
24 | 28 | @vitual_communities = VirtualCommunity.find(:all) |
25 | 29 | @validation_entities = Organization.find(:all) |
26 | 30 | end |
27 | 31 | |
32 | + # Saves the new created enterprise | |
28 | 33 | def register |
29 | 34 | @enterprise = Enterprise.new(params[:enterprise]) |
30 | 35 | @enterprise.organization_info = OrganizationInfo.new(params[:organization]) |
... | ... | @@ -40,11 +45,13 @@ class EnterpriseController < ApplicationController |
40 | 45 | end |
41 | 46 | end |
42 | 47 | |
48 | + # Provides an interface to editing the enterprise details | |
43 | 49 | def edit |
44 | 50 | @enterprise = @my_enterprises.find(params[:id]) |
45 | 51 | @validation_entities = Organization.find(:all) - [@enterprise] |
46 | 52 | end |
47 | 53 | |
54 | + # Saves the changes made in an enterprise | |
48 | 55 | def update |
49 | 56 | @enterprise = @my_enterprises.find(params[:id]) |
50 | 57 | if @enterprise.update_attributes(params[:enterprise]) && @enterprise.organization_info.update_attributes(params[:organization_info]) |
... | ... | @@ -56,22 +63,26 @@ class EnterpriseController < ApplicationController |
56 | 63 | end |
57 | 64 | end |
58 | 65 | |
66 | + # Make the current user a new member of the enterprise | |
59 | 67 | def affiliate |
60 | 68 | @enterprise = Enterprise.find(params[:id]) |
61 | 69 | @enterprise.people << @person |
62 | 70 | redirect_to :action => 'index' |
63 | 71 | end |
64 | 72 | |
73 | + # Elimitates the enterprise of the system | |
65 | 74 | def destroy |
66 | 75 | @enterprise = @my_enterprises.find(params[:id]) |
67 | 76 | @enterprise.destroy |
68 | 77 | redirect_to :action => 'index' |
69 | 78 | end |
70 | 79 | |
80 | + # Search enterprises by name or tags | |
71 | 81 | def search |
72 | 82 | @tagged_enterprises = Enterprise.search(params[:query]) |
73 | 83 | end |
74 | 84 | |
85 | + # Activate a validated enterprise | |
75 | 86 | def activate |
76 | 87 | @enterprise = Enterprise.find(params[:id]) |
77 | 88 | if @enterprise.update_attribute('active', true) |
... | ... | @@ -84,6 +95,7 @@ class EnterpriseController < ApplicationController |
84 | 95 | |
85 | 96 | protected |
86 | 97 | |
98 | + # Make sure that the user is logged before access this controller | |
87 | 99 | def logon |
88 | 100 | if logged_in? |
89 | 101 | @user = current_user |
... | ... | @@ -93,6 +105,7 @@ class EnterpriseController < ApplicationController |
93 | 105 | end |
94 | 106 | end |
95 | 107 | |
108 | + # Initializes some variables to contain the enterprises of the current user | |
96 | 109 | def my_enterprises |
97 | 110 | if logged_in? |
98 | 111 | @my_active_enterprises = @person.active_enterprises | ... | ... |
app/models/affiliation.rb
app/models/organization.rb
app/models/person.rb
app/models/profile.rb