Commit 32ab46c627f98daff10740059fee09daa73774a8
1 parent
10cd34ce
Exists in
master
and in
28 other branches
ActionItem65: moving controllers inside directories
git-svn-id: https://svn.colivre.coop.br/svn/noosfero/trunk@488 3f533792-8f58-4932-b0fe-aaf55b0a4547
Showing
23 changed files
with
440 additions
and
425 deletions
Show diff stats
app/controllers/account_controller.rb
@@ -1,82 +0,0 @@ | @@ -1,82 +0,0 @@ | ||
1 | -class AccountController < ApplicationController | ||
2 | - | ||
3 | - # say something nice, you goof! something sweet. | ||
4 | - def index | ||
5 | - unless logged_in? | ||
6 | - render :action => 'index_anonymous' | ||
7 | - end | ||
8 | - end | ||
9 | - | ||
10 | - # action to perform login to the application | ||
11 | - def login | ||
12 | - return unless request.post? | ||
13 | - self.current_user = User.authenticate(params[:login], params[:password]) | ||
14 | - if logged_in? | ||
15 | - if params[:remember_me] == "1" | ||
16 | - self.current_user.remember_me | ||
17 | - cookies[:auth_token] = { :value => self.current_user.remember_token , :expires => self.current_user.remember_token_expires_at } | ||
18 | - end | ||
19 | - redirect_back_or_default(:controller => '/account', :action => 'index') | ||
20 | - flash[:notice] = _("Logged in successfully") | ||
21 | - else | ||
22 | - flash[:notice] = _('Incorrect username or password') | ||
23 | - end | ||
24 | - end | ||
25 | - | ||
26 | - # action to register an user to the application | ||
27 | - def signup | ||
28 | - begin | ||
29 | - @user = User.new(params[:user]) | ||
30 | - @user.terms_of_use = virtual_community.terms_of_use | ||
31 | - @terms_of_use = virtual_community.terms_of_use | ||
32 | - | ||
33 | - if request.post? | ||
34 | - @user.save! | ||
35 | - @user.person.virtual_community = virtual_community | ||
36 | - @user.person.save! | ||
37 | - self.current_user = @user | ||
38 | - redirect_back_or_default(:controller => 'account', :action => 'index') | ||
39 | - flash[:notice] = _("Thanks for signing up!") | ||
40 | - end | ||
41 | - rescue ActiveRecord::RecordInvalid | ||
42 | - render :action => 'signup' | ||
43 | - end | ||
44 | - end | ||
45 | - | ||
46 | - # action to perform logout from the application | ||
47 | - def logout | ||
48 | - self.current_user.forget_me if logged_in? | ||
49 | - cookies.delete :auth_token | ||
50 | - reset_session | ||
51 | - flash[:notice] = _("You have been logged out.") | ||
52 | - redirect_back_or_default(:controller => '/account', :action => 'index') | ||
53 | - end | ||
54 | - | ||
55 | - def change_password | ||
56 | - if request.post? | ||
57 | - @user = current_user | ||
58 | - begin | ||
59 | - @user.change_password!(params[:current_password], | ||
60 | - params[:new_password], | ||
61 | - params[:new_password_confirmation]) | ||
62 | - flash[:notice] = _('Your password has been changed successfully!') | ||
63 | - redirect_to :action => 'index' | ||
64 | - rescue User::IncorrectPassword => e | ||
65 | - flash[:notice] = _('The supplied current password is incorrect.') | ||
66 | - render :action => 'change_password' | ||
67 | - end | ||
68 | - else | ||
69 | - render :action => 'change_password' | ||
70 | - end | ||
71 | - end | ||
72 | - | ||
73 | - protected | ||
74 | - | ||
75 | - before_filter :load_profile_for_user | ||
76 | - def load_profile_for_user | ||
77 | - return unless logged_in? | ||
78 | - @profile = current_user.person | ||
79 | - end | ||
80 | - | ||
81 | - | ||
82 | -end |
app/controllers/admin_panel_controller.rb
app/controllers/cms_controller.rb
app/controllers/content_viewer_controller.rb
@@ -1,13 +0,0 @@ | @@ -1,13 +0,0 @@ | ||
1 | -class ContentViewerController < ApplicationController | ||
2 | - | ||
3 | - def view_page | ||
4 | - path = params[:page].clone | ||
5 | - path.unshift(params[:profile]) | ||
6 | - @path = path.join('/') | ||
7 | - @page = Article.find_by_path(@path) | ||
8 | - if @page.nil? | ||
9 | - render :action => 'not_found', :status => 404 | ||
10 | - end | ||
11 | - end | ||
12 | - | ||
13 | -end |
app/controllers/edit_template_controller.rb
@@ -1,18 +0,0 @@ | @@ -1,18 +0,0 @@ | ||
1 | -class EditTemplateController < ApplicationController | ||
2 | - | ||
3 | - design_editor :holder => 'virtual_community', :autosave => true, :block_types => :block_types | ||
4 | - | ||
5 | - def block_types | ||
6 | - { | ||
7 | - #'ListBlock' => _("List Block"), | ||
8 | - #'LinkBlock' => _("Link Block"), | ||
9 | - #'RecentDocumentsBlock' => _('Recent documents'), | ||
10 | - 'Design::MainBlock' => _('Main content block'), | ||
11 | - } | ||
12 | - end | ||
13 | - | ||
14 | - def index | ||
15 | - redirect_to :action => 'design_editor' | ||
16 | - end | ||
17 | - | ||
18 | -end |
app/controllers/enterprise_controller.rb
@@ -1,143 +0,0 @@ | @@ -1,143 +0,0 @@ | ||
1 | -# Manage enterprises by providing an interface to register, activate and manage them | ||
2 | -class EnterpriseController < ApplicationController | ||
3 | - | ||
4 | - before_filter :logon, :my_enterprises | ||
5 | - | ||
6 | - # Redirects to show if there is only one action and to list otherwise | ||
7 | - def index | ||
8 | - if @my_enterprises.size == 1 | ||
9 | - redirect_to :action => 'show', :id => @my_enterprises[0] | ||
10 | - else | ||
11 | - redirect_to :action => 'list' | ||
12 | - end | ||
13 | - end | ||
14 | - | ||
15 | - # Lists all enterprises | ||
16 | - def list | ||
17 | - @enterprises = Enterprise.find(:all) - @my_enterprises | ||
18 | - end | ||
19 | - | ||
20 | - # Show details about an enterprise | ||
21 | - def show | ||
22 | - @enterprise = @my_enterprises.find(params[:id]) | ||
23 | - end | ||
24 | - | ||
25 | - # Make a form to the creation of an eterprise | ||
26 | - def register_form | ||
27 | - @enterprise = Enterprise.new() | ||
28 | - @vitual_communities = VirtualCommunity.find(:all) | ||
29 | - @validation_entities = Organization.find(:all) | ||
30 | - end | ||
31 | - | ||
32 | - # Saves the new created enterprise | ||
33 | - def register | ||
34 | - @enterprise = Enterprise.new(params[:enterprise]) | ||
35 | - @enterprise.organization_info = OrganizationInfo.new(params[:organization]) | ||
36 | - if @enterprise.save | ||
37 | - @enterprise.people << @person | ||
38 | - flash[:notice] = _('The enterprise was succesfully created, the validation entity will cotact you as soon as your enterprise is approved') | ||
39 | - redirect_to :action => 'index' | ||
40 | - else | ||
41 | - flash[:notice] = _('Enterprise was not created') | ||
42 | - @vitual_communities = VirtualCommunity.find(:all) | ||
43 | - @validation_entities = Organization.find(:all) | ||
44 | - render :action => 'register_form' | ||
45 | - end | ||
46 | - end | ||
47 | - | ||
48 | - # Provides an interface to editing the enterprise details | ||
49 | - def edit | ||
50 | - @enterprise = @my_enterprises.find(params[:id]) | ||
51 | - @validation_entities = Organization.find(:all) - [@enterprise] | ||
52 | - end | ||
53 | - | ||
54 | - # Saves the changes made in an enterprise | ||
55 | - def update | ||
56 | - @enterprise = @my_enterprises.find(params[:id]) | ||
57 | - if @enterprise.update_attributes(params[:enterprise]) && @enterprise.organization_info.update_attributes(params[:organization_info]) | ||
58 | - redirect_to :action => 'index' | ||
59 | - else | ||
60 | - flash[:notice] = _('Could not update the enterprise') | ||
61 | - @validation_entities = Organization.find(:all) - [@enterprise] | ||
62 | - render :action => 'edit' | ||
63 | - end | ||
64 | - end | ||
65 | - | ||
66 | - # Make the current user a new member of the enterprise | ||
67 | - def affiliate | ||
68 | - @enterprise = Enterprise.find(params[:id]) | ||
69 | - @enterprise.people << @person | ||
70 | - redirect_to :action => 'index' | ||
71 | - end | ||
72 | - | ||
73 | - # Elimitates the enterprise of the system | ||
74 | - def destroy | ||
75 | - @enterprise = @my_enterprises.find(params[:id]) | ||
76 | - if @enterprise | ||
77 | - @enterprise.destroy | ||
78 | - else | ||
79 | - flash[:notice] = 'Can destroy only your enterprises' | ||
80 | - end | ||
81 | - redirect_to :action => 'index' | ||
82 | - end | ||
83 | - | ||
84 | - # Search enterprises by name or tags | ||
85 | - def search | ||
86 | - @tagged_enterprises = Enterprise.search(params[:query]) | ||
87 | - end | ||
88 | - | ||
89 | - # Activate a validated enterprise | ||
90 | - def activate | ||
91 | - @enterprise = Enterprise.find(params[:id]) | ||
92 | - if @enterprise.activate | ||
93 | - flash[:notice] = _('Enterprise successfuly activacted') | ||
94 | - else | ||
95 | - flash[:notice] = _('Failed to activate the enterprise') | ||
96 | - end | ||
97 | - redirect_to :action => 'index' | ||
98 | - end | ||
99 | - | ||
100 | - # Validates an eterprise | ||
101 | - def approve | ||
102 | - @enterprise = Enterprise.find(params[:id]) | ||
103 | - if @enterprise.approve | ||
104 | - flash[:notice] = _('Enterprise successfuly approved') | ||
105 | - else | ||
106 | - flash[:notice] = _('Failed to approve the enterprise') | ||
107 | - end | ||
108 | - redirect_to :action => 'index' | ||
109 | - end | ||
110 | - | ||
111 | - # Rejects an enterprise | ||
112 | - def reject | ||
113 | - @enterprise = Enterprise.find(params[:id]) | ||
114 | - if @enterprise.reject | ||
115 | - flash[:notice] = _('Enterprise successfuly rejected') | ||
116 | - else | ||
117 | - flash[:notice] = _('Failed to reject the enterprise') | ||
118 | - end | ||
119 | - redirect_to :action => 'index' | ||
120 | - end | ||
121 | - | ||
122 | - | ||
123 | - protected | ||
124 | - | ||
125 | - # Make sure that the user is logged before access this controller | ||
126 | - def logon | ||
127 | - if logged_in? | ||
128 | - @user = current_user | ||
129 | - @person = @user.person | ||
130 | - else | ||
131 | - redirect_to :controller => 'account' unless logged_in? | ||
132 | - end | ||
133 | - end | ||
134 | - | ||
135 | - # Initializes some variables to contain the enterprises of the current user | ||
136 | - def my_enterprises | ||
137 | - if logged_in? | ||
138 | - @my_active_enterprises = @person.active_enterprises | ||
139 | - @my_pending_enterprises = @person.pending_enterprises | ||
140 | - @my_enterprises = @person.enterprises | ||
141 | - end | ||
142 | - end | ||
143 | -end |
app/controllers/environment_admin/admin_panel_controller.rb
0 → 100644
app/controllers/environment_admin/edit_template_controller.rb
0 → 100644
@@ -0,0 +1,18 @@ | @@ -0,0 +1,18 @@ | ||
1 | +class EditTemplateController < ApplicationController | ||
2 | + | ||
3 | + design_editor :holder => 'virtual_community', :autosave => true, :block_types => :block_types | ||
4 | + | ||
5 | + def block_types | ||
6 | + { | ||
7 | + #'ListBlock' => _("List Block"), | ||
8 | + #'LinkBlock' => _("Link Block"), | ||
9 | + #'RecentDocumentsBlock' => _('Recent documents'), | ||
10 | + 'Design::MainBlock' => _('Main content block'), | ||
11 | + } | ||
12 | + end | ||
13 | + | ||
14 | + def index | ||
15 | + redirect_to :action => 'design_editor' | ||
16 | + end | ||
17 | + | ||
18 | +end |
app/controllers/environment_admin/features_controller.rb
0 → 100644
@@ -0,0 +1,22 @@ | @@ -0,0 +1,22 @@ | ||
1 | +class FeaturesController < ApplicationController | ||
2 | + | ||
3 | + acts_as_virtual_community_admin_controller | ||
4 | + | ||
5 | + def index | ||
6 | + @features = VirtualCommunity.available_features | ||
7 | + end | ||
8 | + | ||
9 | + post_only :update | ||
10 | + def update | ||
11 | + features = if params[:features].nil? | ||
12 | + [] | ||
13 | + else | ||
14 | + params[:features].keys | ||
15 | + end | ||
16 | + @virtual_community.enabled_features = features | ||
17 | + @virtual_community.save! | ||
18 | + flash[:notice] = _('Features updated successfully.') | ||
19 | + redirect_to :action => 'index' | ||
20 | + end | ||
21 | + | ||
22 | +end |
app/controllers/environment_admin/manage_tags_controller.rb
0 → 100644
@@ -0,0 +1,74 @@ | @@ -0,0 +1,74 @@ | ||
1 | +# Manage tags stored by the acts-as_taggable_on_steroids plugin by providing an interface to create, destroy, update and list them | ||
2 | +class ManageTagsController < ApplicationController | ||
3 | + | ||
4 | + # Index redirects to list action without modifing the url | ||
5 | + def index | ||
6 | + redirect_to :action => 'list' | ||
7 | + end | ||
8 | + | ||
9 | + # Lists the tags starting with the top tags or with the chidren of @parent if its provided | ||
10 | + def list | ||
11 | + @parent = Tag.find(params[:parent]) if params[:parent] | ||
12 | + @tags = @parent ? @parent.children : Tag.roots | ||
13 | + @pending_tags = Tag.find_all_by_pending(true) | ||
14 | + end | ||
15 | + | ||
16 | + # Prompt for data to a new tag | ||
17 | + def new | ||
18 | + @parent_tags = Tag.find_all_by_pending(false) | ||
19 | + @tag = Tag.new | ||
20 | + end | ||
21 | + | ||
22 | + # Collects the data and creates a new tag with it | ||
23 | + def create | ||
24 | + @tag = Tag.new(params[:tag]) | ||
25 | + if @tag.save | ||
26 | + flash[:notice] = _('Tag was successfully created.') | ||
27 | + redirect_to :action => 'list' | ||
28 | + else | ||
29 | + @parent_tags = Tag.find_all_by_pending(false) | ||
30 | + render :action => 'new' | ||
31 | + end | ||
32 | + end | ||
33 | + | ||
34 | + # Prompt for modifications on the attributes of a tag | ||
35 | + def edit | ||
36 | + @tag = Tag.find(params[:id]) | ||
37 | + @parent_tags = @tag.parent_candidates | ||
38 | + end | ||
39 | + | ||
40 | + # Do the modifications collected by edit | ||
41 | + def update | ||
42 | + @tag = Tag.find(params[:id]) | ||
43 | + if @tag.update_attributes(params[:tag]) | ||
44 | + flash[:notice] = _('Tag was successfully updated.') | ||
45 | + redirect_to :action => 'list' | ||
46 | + else | ||
47 | + @parent_tags = @tag.parent_candidates | ||
48 | + render :action => 'edit' | ||
49 | + end | ||
50 | + end | ||
51 | + | ||
52 | + # Destroy a tag and all its children | ||
53 | + def destroy | ||
54 | + @tag = Tag.find(params[:id]) | ||
55 | + if @tag.destroy | ||
56 | + flash[:notice] = _('Tag was successfuly destroyed') | ||
57 | + end | ||
58 | + redirect_to :action => 'list' | ||
59 | + end | ||
60 | + | ||
61 | + # Approve a pending tag so now ita can be used to tag things | ||
62 | + def approve | ||
63 | + @tag = Tag.find(params[:id]) | ||
64 | + if @tag.update_attribute(:pending, false) | ||
65 | + flash[:notice] = _('Tag was successfuly approved') | ||
66 | + redirect_to :action => 'list' | ||
67 | + end | ||
68 | + end | ||
69 | + | ||
70 | + # Full-text search for tags that have the query terms | ||
71 | + def search | ||
72 | + @tags_found = Tag.find_all_by_name_and_pending(params[:query], false) | ||
73 | + end | ||
74 | +end |
@@ -0,0 +1,47 @@ | @@ -0,0 +1,47 @@ | ||
1 | +class RoleController < ApplicationController | ||
2 | + def index | ||
3 | + @roles = Role.find(:all) | ||
4 | + end | ||
5 | + | ||
6 | + def show | ||
7 | + @role = Role.find(params[:id]) | ||
8 | + end | ||
9 | + | ||
10 | + def new | ||
11 | + @role = Role.new(:name => '', :permissions => []) | ||
12 | + end | ||
13 | + | ||
14 | + def create | ||
15 | + role = Role.new(params[:role]) | ||
16 | + if role.save | ||
17 | + redirect_to :action => 'show', :id => role | ||
18 | + else | ||
19 | + flash[:notice] = _('Failed to create role') | ||
20 | + redirect_to :action => 'index' | ||
21 | + end | ||
22 | + end | ||
23 | + | ||
24 | + def edit | ||
25 | + @role = Role.find(params[:id]) | ||
26 | + end | ||
27 | + | ||
28 | + def update | ||
29 | + role = Role.find(params[:id]) | ||
30 | + if role.update_attributes(params[:role]) | ||
31 | + redirect_to :action => 'show', :id => role | ||
32 | + else | ||
33 | + flash[:notice] = _('Failed to edit role') | ||
34 | + render :action => 'edit' | ||
35 | + end | ||
36 | + end | ||
37 | + | ||
38 | + def destroy | ||
39 | + role = Role.find(params[:id]) | ||
40 | + if role.destroy | ||
41 | + redirect_to :action => 'index' | ||
42 | + else | ||
43 | + flash[:notice] = _('Failed to edit role') | ||
44 | + redirect_to :action => 'index' | ||
45 | + end | ||
46 | + end | ||
47 | +end |
app/controllers/features_controller.rb
@@ -1,22 +0,0 @@ | @@ -1,22 +0,0 @@ | ||
1 | -class FeaturesController < ApplicationController | ||
2 | - | ||
3 | - acts_as_virtual_community_admin_controller | ||
4 | - | ||
5 | - def index | ||
6 | - @features = VirtualCommunity.available_features | ||
7 | - end | ||
8 | - | ||
9 | - post_only :update | ||
10 | - def update | ||
11 | - features = if params[:features].nil? | ||
12 | - [] | ||
13 | - else | ||
14 | - params[:features].keys | ||
15 | - end | ||
16 | - @virtual_community.enabled_features = features | ||
17 | - @virtual_community.save! | ||
18 | - flash[:notice] = _('Features updated successfully.') | ||
19 | - redirect_to :action => 'index' | ||
20 | - end | ||
21 | - | ||
22 | -end |
app/controllers/home_controller.rb
app/controllers/manage_tags_controller.rb
@@ -1,74 +0,0 @@ | @@ -1,74 +0,0 @@ | ||
1 | -# Manage tags stored by the acts-as_taggable_on_steroids plugin by providing an interface to create, destroy, update and list them | ||
2 | -class ManageTagsController < ApplicationController | ||
3 | - | ||
4 | - # Index redirects to list action without modifing the url | ||
5 | - def index | ||
6 | - redirect_to :action => 'list' | ||
7 | - end | ||
8 | - | ||
9 | - # Lists the tags starting with the top tags or with the chidren of @parent if its provided | ||
10 | - def list | ||
11 | - @parent = Tag.find(params[:parent]) if params[:parent] | ||
12 | - @tags = @parent ? @parent.children : Tag.roots | ||
13 | - @pending_tags = Tag.find_all_by_pending(true) | ||
14 | - end | ||
15 | - | ||
16 | - # Prompt for data to a new tag | ||
17 | - def new | ||
18 | - @parent_tags = Tag.find_all_by_pending(false) | ||
19 | - @tag = Tag.new | ||
20 | - end | ||
21 | - | ||
22 | - # Collects the data and creates a new tag with it | ||
23 | - def create | ||
24 | - @tag = Tag.new(params[:tag]) | ||
25 | - if @tag.save | ||
26 | - flash[:notice] = _('Tag was successfully created.') | ||
27 | - redirect_to :action => 'list' | ||
28 | - else | ||
29 | - @parent_tags = Tag.find_all_by_pending(false) | ||
30 | - render :action => 'new' | ||
31 | - end | ||
32 | - end | ||
33 | - | ||
34 | - # Prompt for modifications on the attributes of a tag | ||
35 | - def edit | ||
36 | - @tag = Tag.find(params[:id]) | ||
37 | - @parent_tags = @tag.parent_candidates | ||
38 | - end | ||
39 | - | ||
40 | - # Do the modifications collected by edit | ||
41 | - def update | ||
42 | - @tag = Tag.find(params[:id]) | ||
43 | - if @tag.update_attributes(params[:tag]) | ||
44 | - flash[:notice] = _('Tag was successfully updated.') | ||
45 | - redirect_to :action => 'list' | ||
46 | - else | ||
47 | - @parent_tags = @tag.parent_candidates | ||
48 | - render :action => 'edit' | ||
49 | - end | ||
50 | - end | ||
51 | - | ||
52 | - # Destroy a tag and all its children | ||
53 | - def destroy | ||
54 | - @tag = Tag.find(params[:id]) | ||
55 | - if @tag.destroy | ||
56 | - flash[:notice] = _('Tag was successfuly destroyed') | ||
57 | - end | ||
58 | - redirect_to :action => 'list' | ||
59 | - end | ||
60 | - | ||
61 | - # Approve a pending tag so now ita can be used to tag things | ||
62 | - def approve | ||
63 | - @tag = Tag.find(params[:id]) | ||
64 | - if @tag.update_attribute(:pending, false) | ||
65 | - flash[:notice] = _('Tag was successfuly approved') | ||
66 | - redirect_to :action => 'list' | ||
67 | - end | ||
68 | - end | ||
69 | - | ||
70 | - # Full-text search for tags that have the query terms | ||
71 | - def search | ||
72 | - @tags_found = Tag.find_all_by_name_and_pending(params[:query], false) | ||
73 | - end | ||
74 | -end |
@@ -0,0 +1,143 @@ | @@ -0,0 +1,143 @@ | ||
1 | +# Manage enterprises by providing an interface to register, activate and manage them | ||
2 | +class EnterpriseController < ApplicationController | ||
3 | + | ||
4 | + before_filter :logon, :my_enterprises | ||
5 | + | ||
6 | + # Redirects to show if there is only one action and to list otherwise | ||
7 | + def index | ||
8 | + if @my_enterprises.size == 1 | ||
9 | + redirect_to :action => 'show', :id => @my_enterprises[0] | ||
10 | + else | ||
11 | + redirect_to :action => 'list' | ||
12 | + end | ||
13 | + end | ||
14 | + | ||
15 | + # Lists all enterprises | ||
16 | + def list | ||
17 | + @enterprises = Enterprise.find(:all) - @my_enterprises | ||
18 | + end | ||
19 | + | ||
20 | + # Show details about an enterprise | ||
21 | + def show | ||
22 | + @enterprise = @my_enterprises.find(params[:id]) | ||
23 | + end | ||
24 | + | ||
25 | + # Make a form to the creation of an eterprise | ||
26 | + def register_form | ||
27 | + @enterprise = Enterprise.new() | ||
28 | + @vitual_communities = VirtualCommunity.find(:all) | ||
29 | + @validation_entities = Organization.find(:all) | ||
30 | + end | ||
31 | + | ||
32 | + # Saves the new created enterprise | ||
33 | + def register | ||
34 | + @enterprise = Enterprise.new(params[:enterprise]) | ||
35 | + @enterprise.organization_info = OrganizationInfo.new(params[:organization]) | ||
36 | + if @enterprise.save | ||
37 | + @enterprise.people << @person | ||
38 | + flash[:notice] = _('The enterprise was succesfully created, the validation entity will cotact you as soon as your enterprise is approved') | ||
39 | + redirect_to :action => 'index' | ||
40 | + else | ||
41 | + flash[:notice] = _('Enterprise was not created') | ||
42 | + @vitual_communities = VirtualCommunity.find(:all) | ||
43 | + @validation_entities = Organization.find(:all) | ||
44 | + render :action => 'register_form' | ||
45 | + end | ||
46 | + end | ||
47 | + | ||
48 | + # Provides an interface to editing the enterprise details | ||
49 | + def edit | ||
50 | + @enterprise = @my_enterprises.find(params[:id]) | ||
51 | + @validation_entities = Organization.find(:all) - [@enterprise] | ||
52 | + end | ||
53 | + | ||
54 | + # Saves the changes made in an enterprise | ||
55 | + def update | ||
56 | + @enterprise = @my_enterprises.find(params[:id]) | ||
57 | + if @enterprise.update_attributes(params[:enterprise]) && @enterprise.organization_info.update_attributes(params[:organization_info]) | ||
58 | + redirect_to :action => 'index' | ||
59 | + else | ||
60 | + flash[:notice] = _('Could not update the enterprise') | ||
61 | + @validation_entities = Organization.find(:all) - [@enterprise] | ||
62 | + render :action => 'edit' | ||
63 | + end | ||
64 | + end | ||
65 | + | ||
66 | + # Make the current user a new member of the enterprise | ||
67 | + def affiliate | ||
68 | + @enterprise = Enterprise.find(params[:id]) | ||
69 | + @enterprise.people << @person | ||
70 | + redirect_to :action => 'index' | ||
71 | + end | ||
72 | + | ||
73 | + # Elimitates the enterprise of the system | ||
74 | + def destroy | ||
75 | + @enterprise = @my_enterprises.find(params[:id]) | ||
76 | + if @enterprise | ||
77 | + @enterprise.destroy | ||
78 | + else | ||
79 | + flash[:notice] = 'Can destroy only your enterprises' | ||
80 | + end | ||
81 | + redirect_to :action => 'index' | ||
82 | + end | ||
83 | + | ||
84 | + # Search enterprises by name or tags | ||
85 | + def search | ||
86 | + @tagged_enterprises = Enterprise.search(params[:query]) | ||
87 | + end | ||
88 | + | ||
89 | + # Activate a validated enterprise | ||
90 | + def activate | ||
91 | + @enterprise = Enterprise.find(params[:id]) | ||
92 | + if @enterprise.activate | ||
93 | + flash[:notice] = _('Enterprise successfuly activacted') | ||
94 | + else | ||
95 | + flash[:notice] = _('Failed to activate the enterprise') | ||
96 | + end | ||
97 | + redirect_to :action => 'index' | ||
98 | + end | ||
99 | + | ||
100 | + # Validates an eterprise | ||
101 | + def approve | ||
102 | + @enterprise = Enterprise.find(params[:id]) | ||
103 | + if @enterprise.approve | ||
104 | + flash[:notice] = _('Enterprise successfuly approved') | ||
105 | + else | ||
106 | + flash[:notice] = _('Failed to approve the enterprise') | ||
107 | + end | ||
108 | + redirect_to :action => 'index' | ||
109 | + end | ||
110 | + | ||
111 | + # Rejects an enterprise | ||
112 | + def reject | ||
113 | + @enterprise = Enterprise.find(params[:id]) | ||
114 | + if @enterprise.reject | ||
115 | + flash[:notice] = _('Enterprise successfuly rejected') | ||
116 | + else | ||
117 | + flash[:notice] = _('Failed to reject the enterprise') | ||
118 | + end | ||
119 | + redirect_to :action => 'index' | ||
120 | + end | ||
121 | + | ||
122 | + | ||
123 | + protected | ||
124 | + | ||
125 | + # Make sure that the user is logged before access this controller | ||
126 | + def logon | ||
127 | + if logged_in? | ||
128 | + @user = current_user | ||
129 | + @person = @user.person | ||
130 | + else | ||
131 | + redirect_to :controller => 'account' unless logged_in? | ||
132 | + end | ||
133 | + end | ||
134 | + | ||
135 | + # Initializes some variables to contain the enterprises of the current user | ||
136 | + def my_enterprises | ||
137 | + if logged_in? | ||
138 | + @my_active_enterprises = @person.active_enterprises | ||
139 | + @my_pending_enterprises = @person.pending_enterprises | ||
140 | + @my_enterprises = @person.enterprises | ||
141 | + end | ||
142 | + end | ||
143 | +end |
app/controllers/profile_admin/profile_editor_controller.rb
0 → 100644
@@ -0,0 +1,15 @@ | @@ -0,0 +1,15 @@ | ||
1 | +class ProfileEditorController < ApplicationController | ||
2 | + helper :profile | ||
3 | + | ||
4 | + # edits the profile info (posts back) | ||
5 | + def edit | ||
6 | + if request.post? | ||
7 | + profile.info.update_attributes(params[:info]) | ||
8 | + redirect_to :action => 'index' | ||
9 | + else | ||
10 | + @info = profile.info | ||
11 | + render :action => @info.class.name.underscore | ||
12 | + end | ||
13 | + end | ||
14 | +end | ||
15 | + |
app/controllers/profile_editor_controller.rb
@@ -1,15 +0,0 @@ | @@ -1,15 +0,0 @@ | ||
1 | -class ProfileEditorController < ApplicationController | ||
2 | - helper :profile | ||
3 | - | ||
4 | - # edits the profile info (posts back) | ||
5 | - def edit | ||
6 | - if request.post? | ||
7 | - profile.info.update_attributes(params[:info]) | ||
8 | - redirect_to :action => 'index' | ||
9 | - else | ||
10 | - @info = profile.info | ||
11 | - render :action => @info.class.name.underscore | ||
12 | - end | ||
13 | - end | ||
14 | -end | ||
15 | - |
@@ -0,0 +1,82 @@ | @@ -0,0 +1,82 @@ | ||
1 | +class AccountController < ApplicationController | ||
2 | + | ||
3 | + # say something nice, you goof! something sweet. | ||
4 | + def index | ||
5 | + unless logged_in? | ||
6 | + render :action => 'index_anonymous' | ||
7 | + end | ||
8 | + end | ||
9 | + | ||
10 | + # action to perform login to the application | ||
11 | + def login | ||
12 | + return unless request.post? | ||
13 | + self.current_user = User.authenticate(params[:login], params[:password]) | ||
14 | + if logged_in? | ||
15 | + if params[:remember_me] == "1" | ||
16 | + self.current_user.remember_me | ||
17 | + cookies[:auth_token] = { :value => self.current_user.remember_token , :expires => self.current_user.remember_token_expires_at } | ||
18 | + end | ||
19 | + redirect_back_or_default(:controller => '/account', :action => 'index') | ||
20 | + flash[:notice] = _("Logged in successfully") | ||
21 | + else | ||
22 | + flash[:notice] = _('Incorrect username or password') | ||
23 | + end | ||
24 | + end | ||
25 | + | ||
26 | + # action to register an user to the application | ||
27 | + def signup | ||
28 | + begin | ||
29 | + @user = User.new(params[:user]) | ||
30 | + @user.terms_of_use = virtual_community.terms_of_use | ||
31 | + @terms_of_use = virtual_community.terms_of_use | ||
32 | + | ||
33 | + if request.post? | ||
34 | + @user.save! | ||
35 | + @user.person.virtual_community = virtual_community | ||
36 | + @user.person.save! | ||
37 | + self.current_user = @user | ||
38 | + redirect_back_or_default(:controller => 'account', :action => 'index') | ||
39 | + flash[:notice] = _("Thanks for signing up!") | ||
40 | + end | ||
41 | + rescue ActiveRecord::RecordInvalid | ||
42 | + render :action => 'signup' | ||
43 | + end | ||
44 | + end | ||
45 | + | ||
46 | + # action to perform logout from the application | ||
47 | + def logout | ||
48 | + self.current_user.forget_me if logged_in? | ||
49 | + cookies.delete :auth_token | ||
50 | + reset_session | ||
51 | + flash[:notice] = _("You have been logged out.") | ||
52 | + redirect_back_or_default(:controller => '/account', :action => 'index') | ||
53 | + end | ||
54 | + | ||
55 | + def change_password | ||
56 | + if request.post? | ||
57 | + @user = current_user | ||
58 | + begin | ||
59 | + @user.change_password!(params[:current_password], | ||
60 | + params[:new_password], | ||
61 | + params[:new_password_confirmation]) | ||
62 | + flash[:notice] = _('Your password has been changed successfully!') | ||
63 | + redirect_to :action => 'index' | ||
64 | + rescue User::IncorrectPassword => e | ||
65 | + flash[:notice] = _('The supplied current password is incorrect.') | ||
66 | + render :action => 'change_password' | ||
67 | + end | ||
68 | + else | ||
69 | + render :action => 'change_password' | ||
70 | + end | ||
71 | + end | ||
72 | + | ||
73 | + protected | ||
74 | + | ||
75 | + before_filter :load_profile_for_user | ||
76 | + def load_profile_for_user | ||
77 | + return unless logged_in? | ||
78 | + @profile = current_user.person | ||
79 | + end | ||
80 | + | ||
81 | + | ||
82 | +end |
@@ -0,0 +1,13 @@ | @@ -0,0 +1,13 @@ | ||
1 | +class ContentViewerController < ApplicationController | ||
2 | + | ||
3 | + def view_page | ||
4 | + path = params[:page].clone | ||
5 | + path.unshift(params[:profile]) | ||
6 | + @path = path.join('/') | ||
7 | + @page = Article.find_by_path(@path) | ||
8 | + if @page.nil? | ||
9 | + render :action => 'not_found', :status => 404 | ||
10 | + end | ||
11 | + end | ||
12 | + | ||
13 | +end |
app/controllers/role_controller.rb
@@ -1,47 +0,0 @@ | @@ -1,47 +0,0 @@ | ||
1 | -class RoleController < ApplicationController | ||
2 | - def index | ||
3 | - @roles = Role.find(:all) | ||
4 | - end | ||
5 | - | ||
6 | - def show | ||
7 | - @role = Role.find(params[:id]) | ||
8 | - end | ||
9 | - | ||
10 | - def new | ||
11 | - @role = Role.new(:name => '', :permissions => []) | ||
12 | - end | ||
13 | - | ||
14 | - def create | ||
15 | - role = Role.new(params[:role]) | ||
16 | - if role.save | ||
17 | - redirect_to :action => 'show', :id => role | ||
18 | - else | ||
19 | - flash[:notice] = _('Failed to create role') | ||
20 | - redirect_to :action => 'index' | ||
21 | - end | ||
22 | - end | ||
23 | - | ||
24 | - def edit | ||
25 | - @role = Role.find(params[:id]) | ||
26 | - end | ||
27 | - | ||
28 | - def update | ||
29 | - role = Role.find(params[:id]) | ||
30 | - if role.update_attributes(params[:role]) | ||
31 | - redirect_to :action => 'show', :id => role | ||
32 | - else | ||
33 | - flash[:notice] = _('Failed to edit role') | ||
34 | - render :action => 'edit' | ||
35 | - end | ||
36 | - end | ||
37 | - | ||
38 | - def destroy | ||
39 | - role = Role.find(params[:id]) | ||
40 | - if role.destroy | ||
41 | - redirect_to :action => 'index' | ||
42 | - else | ||
43 | - flash[:notice] = _('Failed to edit role') | ||
44 | - redirect_to :action => 'index' | ||
45 | - end | ||
46 | - end | ||
47 | -end |
config/environment.rb
@@ -10,6 +10,14 @@ RAILS_GEM_VERSION = '1.1.6' | @@ -10,6 +10,14 @@ RAILS_GEM_VERSION = '1.1.6' | ||
10 | # Bootstrap the Rails environment, frameworks, and default configuration | 10 | # Bootstrap the Rails environment, frameworks, and default configuration |
11 | require File.join(File.dirname(__FILE__), 'boot') | 11 | require File.join(File.dirname(__FILE__), 'boot') |
12 | 12 | ||
13 | +# extra directories for controllers organization | ||
14 | +extra_controller_dirs = %w[ | ||
15 | + app/controllers/profile_admin | ||
16 | + app/controllers/environment_admin | ||
17 | + app/controllers/system_admin | ||
18 | + app/controllers/public | ||
19 | +].map {|item| File.join(RAILS_ROOT, item) } | ||
20 | + | ||
13 | Rails::Initializer.run do |config| | 21 | Rails::Initializer.run do |config| |
14 | # Settings in config/environments/* take precedence those specified here | 22 | # Settings in config/environments/* take precedence those specified here |
15 | 23 | ||
@@ -34,11 +42,18 @@ Rails::Initializer.run do |config| | @@ -34,11 +42,18 @@ Rails::Initializer.run do |config| | ||
34 | 42 | ||
35 | # Activate observers that should always be running | 43 | # Activate observers that should always be running |
36 | # config.active_record.observers = :cacher, :garbage_collector | 44 | # config.active_record.observers = :cacher, :garbage_collector |
37 | - | ||
38 | # Make Active Record use UTC-base instead of local time | 45 | # Make Active Record use UTC-base instead of local time |
39 | # config.active_record.default_timezone = :utc | 46 | # config.active_record.default_timezone = :utc |
40 | 47 | ||
41 | # See Rails::Configuration for more options | 48 | # See Rails::Configuration for more options |
49 | + | ||
50 | + extra_controller_dirs.each do |item| | ||
51 | + $LOAD_PATH << item | ||
52 | + config.controller_paths << item | ||
53 | + end | ||
54 | +end | ||
55 | +extra_controller_dirs.each do |item| | ||
56 | + Dependencies.load_paths << item | ||
42 | end | 57 | end |
43 | 58 | ||
44 | # Add new inflection rules using the following format | 59 | # Add new inflection rules using the following format |