Commit adbea53935329e7c6a7aaa9fddded61b7181ecd1

Authored by MoisesMachado
1 parent b4853226

ActionItem6: moved registration of enterprises to the membership controller


git-svn-id: https://svn.colivre.coop.br/svn/noosfero/trunk@560 3f533792-8f58-4932-b0fe-aaf55b0a4547
app/controllers/profile_admin/membership_editor_controller.rb
@@ -4,17 +4,17 @@ class MembershipEditorController < ProfileAdminController @@ -4,17 +4,17 @@ class MembershipEditorController < ProfileAdminController
4 @memberships = current_user.person.memberships 4 @memberships = current_user.person.memberships
5 end 5 end
6 6
7 - def new_enteprise 7 + def new_enterprise
8 @enterprise = Enterprise.new() 8 @enterprise = Enterprise.new()
9 @vitual_communities = Environment.find(:all) 9 @vitual_communities = Environment.find(:all)
10 @validation_entities = Organization.find(:all) 10 @validation_entities = Organization.find(:all)
11 end 11 end
12 12
13 - def create_enteprise 13 + def create_enterprise
14 @enterprise = Enterprise.new(params[:enterprise]) 14 @enterprise = Enterprise.new(params[:enterprise])
15 @enterprise.organization_info = OrganizationInfo.new(params[:organization]) 15 @enterprise.organization_info = OrganizationInfo.new(params[:organization])
16 if @enterprise.save 16 if @enterprise.save
17 - @enterprise.people << @person 17 + @enterprise.affiliate(@person, Role.find_by_name('owner'))
18 flash[:notice] = _('The enterprise was succesfully created, the validation entity will cotact you as soon as your enterprise is approved') 18 flash[:notice] = _('The enterprise was succesfully created, the validation entity will cotact you as soon as your enterprise is approved')
19 redirect_to :action => 'index' 19 redirect_to :action => 'index'
20 else 20 else
@@ -29,5 +29,4 @@ class MembershipEditorController &lt; ProfileAdminController @@ -29,5 +29,4 @@ class MembershipEditorController &lt; ProfileAdminController
29 def search 29 def search
30 @tagged_enterprises = Enterprise.search(params[:query]) 30 @tagged_enterprises = Enterprise.search(params[:query])
31 end 31 end
32 -  
33 end 32 end
app/views/membership_editor/_form.rhtml 0 → 100644
@@ -0,0 +1,32 @@ @@ -0,0 +1,32 @@
  1 +<p><label for="name"><%= _('Name') %></label><br/>
  2 +<%= text_field 'enterprise', 'name', 'size' => 20 %></p>
  3 +
  4 +<p><label for="address"><%= _('Address') %></label><br/>
  5 +<%= text_field 'enterprise', 'address', 'size' => 50 %></p>
  6 +
  7 +<p><label for="contact_phone"><%= _('Contact Phone') %></label><br/>
  8 +<%= text_field 'enterprise', 'contact_phone', 'size' => 20 %></p>
  9 +
  10 +<p><label for="contact_person"><%= _('Contact Person') %></label><br/>
  11 +<%= text_field 'organization_info', 'contact_person', 'size' => 20 %></p>
  12 +
  13 +<p><label for="acronym"><%= _('Acronym') %></label><br/>
  14 +<%= text_field 'organization_info', 'acronym', 'size' => 20 %></p>
  15 +
  16 +<p><label for="foundation_year"><%= _('Foundation Year') %></label><br/>
  17 +<%= text_field 'organization_info', 'foundation_year', 'size' => 20 %></p>
  18 +
  19 +<p><label for="legal_form"><%= _('Legal Form') %></label><br/>
  20 +<%= text_field 'organization_info', 'legal_form', 'size' => 20 %></p>
  21 +
  22 +<p><label for="economic_activity"><%= _('Economic Activity') %></label><br/>
  23 +<%= text_field 'organization_info', 'economic_activity', 'size' => 20 %></p>
  24 +
  25 +<p><label for="management_information"><%= _('Management Information') %></label><br/>
  26 +<%= text_area 'organization_info', 'management_information', 'cols' => 40, 'rows' => 20 %></p>
  27 +
  28 +<p><label for="validation_entity"><%= _('Validation Entity') %></label><br/>
  29 +<%= select 'validation_entity', 'id', @validation_entities.map{|v| [v.name, v.id]}, :include_blank => true %></p>
  30 +
  31 +<p><label for="tag_list"><%= _('Tags') %></label><br/>
  32 +<%= text_field 'enterprise', 'tag_list', 'size' => 20 %></p>
app/views/membership_editor/index.rhtml
@@ -5,3 +5,5 @@ @@ -5,3 +5,5 @@
5 <li> <%= link_to m.name, '/' + m.identifier %> </li> 5 <li> <%= link_to m.name, '/' + m.identifier %> </li>
6 <% end %> 6 <% end %>
7 </ul> 7 </ul>
  8 +
  9 +<%= link_to _('New enterprise'), :action => 'new_enterprise' %>
app/views/membership_editor/new_enterprise.rhtml 0 → 100644
@@ -0,0 +1,14 @@ @@ -0,0 +1,14 @@
  1 +<%= error_messages_for 'enterprise' %>
  2 +
  3 +<h2><%= _('Register enterprise') %></h2>
  4 +
  5 +<h3> <%= _('How to proceed') %> </h3>
  6 +<p> <%= _('Fill the form and hit the Register button then the enterprise will be submitted for evaluation at the validation entitiy of your choice (within your state), when the enterprise is aproved you will be able to activate its profile') %> </p>
  7 +
  8 +<% form_tag :action => 'create_enterprise' do %>
  9 + <p><label for="identifier"><%= _('Identifier') %></label><br/>
  10 + <%= text_field 'enterprise', 'identifier', 'size' => 20 %></p>
  11 + <%= render :partial => 'form' %>
  12 +<p><%= submit_tag _('Register') %>
  13 +<%= link_to _('Cancel'), :action => 'index' %></p>
  14 +<% end %>
app/views/membership_editor/search.rhtml 0 → 100644
@@ -0,0 +1,3 @@ @@ -0,0 +1,3 @@
  1 +<h2> <%= @tagged_enterprises.size.to_s + _(' enterprises found') %> </h2>
  2 +
  3 +<%= render :partial => 'enterprise', :collection => @tagged_enterprises %>