Commit 08b7ed8446bafb37cb21d4e29e66e5cc92aeb010
1 parent
22a9c51a
Exists in
master
and in
29 other branches
ActionItem6: some fixes in the enterprise controller
git-svn-id: https://svn.colivre.coop.br/svn/noosfero/trunk@187 3f533792-8f58-4932-b0fe-aaf55b0a4547
Showing
7 changed files
with
16 additions
and
31 deletions
Show diff stats
app/controllers/enterprise_controller.rb
| ... | ... | @@ -6,29 +6,22 @@ class EnterpriseController < ApplicationController |
| 6 | 6 | @enterprises = Enterprise.find(:all) - @my_enterprises |
| 7 | 7 | end |
| 8 | 8 | |
| 9 | - def register | |
| 10 | - unless logged_in? | |
| 11 | - redirect_to :controller => 'account' | |
| 12 | - end | |
| 13 | - end | |
| 14 | - | |
| 15 | 9 | def register_form |
| 10 | + redirect_to :controller => 'account' unless logged_in? | |
| 11 | + @enterprise = Enterprise.new() | |
| 16 | 12 | @vitual_communities = VirtualCommunity.find(:all) |
| 17 | 13 | end |
| 18 | 14 | |
| 19 | - def choose_validation_entity_or_net | |
| 20 | - @enterprise = Enterprise.new(params[:enterprise]) | |
| 21 | - end | |
| 22 | - | |
| 23 | - def create | |
| 15 | + def register | |
| 24 | 16 | @enterprise = Enterprise.new(params[:enterprise]) |
| 25 | - @enterprise.manager = current_user | |
| 17 | + @enterprise.manager_id = current_user.id | |
| 26 | 18 | if @enterprise.save |
| 19 | + @enterprise.users << current_user | |
| 27 | 20 | flash[:notice] = _('Enterprise was succesfully created') |
| 28 | - redirect_to :action => 'register' | |
| 21 | + redirect_to :action => 'index' | |
| 29 | 22 | else |
| 30 | 23 | flash[:notice] = _('Enterprise was not created') |
| 31 | - render :action => 'choose_validation_entity_or_net' | |
| 24 | + render :action => 'register' | |
| 32 | 25 | end |
| 33 | 26 | end |
| 34 | 27 | end | ... | ... |
app/models/enterprise.rb
| ... | ... | @@ -7,7 +7,7 @@ class Enterprise < ActiveRecord::Base |
| 7 | 7 | |
| 8 | 8 | has_one :enterprise_profile, :class_name => 'Profile', :as => :profile_owner |
| 9 | 9 | has_many :affiliations |
| 10 | - has_many :users, :through => :affiliation | |
| 10 | + has_many :users, :through => :affiliations | |
| 11 | 11 | belongs_to :manager, :class_name => 'User' |
| 12 | 12 | |
| 13 | 13 | validates_presence_of :name, :manager_id | ... | ... |
| ... | ... | @@ -0,0 +1 @@ |
| 1 | +<li> <%= enterprise.name %> </li> | ... | ... |
app/views/enterprise/choose_validation_entity_or_net.rhtml
app/views/enterprise/index.rhtml
| 1 | -<p> <%= link_to _('Register new enterprise'), :action => 'register' %> </p> | |
| 1 | +<p> <%= link_to _('Register new enterprise'), :action => 'register_form' %> </p> | |
| 2 | 2 | <h2> <%= _('Listing my enterprises') %> </h2> |
| 3 | -<%= render :partial => 'enterprise', :collection => @my_enterprises %> | |
| 3 | +<ul> | |
| 4 | + <%= render :partial => 'enterprise', :collection => @my_enterprises %> | |
| 5 | +</ul> | ... | ... |
app/views/enterprise/register.rhtml
app/views/enterprise/register_form.rhtml
| ... | ... | @@ -2,7 +2,7 @@ |
| 2 | 2 | |
| 3 | 3 | <h2><%= _('Register enterprise') %></h2> |
| 4 | 4 | |
| 5 | -<% form_tag :action => 'choose_validation_entity_or_net' do %> | |
| 5 | +<% form_tag :action => 'register' do %> | |
| 6 | 6 | <p><label for="name"><%= _('Name') %></label><br/> |
| 7 | 7 | <%= text_field 'enterprise', 'name', 'size' => 20 %></p> |
| 8 | 8 | |
| ... | ... | @@ -30,6 +30,6 @@ |
| 30 | 30 | <p><label for="management_information"><%= _('Management Information') %></label><br/> |
| 31 | 31 | <%= text_area 'enterprise', 'management_information', 'cols' => 40, 'rows' => 20 %></p> |
| 32 | 32 | |
| 33 | -<p><%= submit_tag 'Send' %> | |
| 34 | -<%= link_to 'Cancel', :action => 'register' %></p> | |
| 33 | +<p><%= submit_tag _('Register') %> | |
| 34 | +<%= link_to _('Cancel'), :action => 'register' %></p> | |
| 35 | 35 | <% end %> | ... | ... |