Commit f4efbd44bff626ce7eda4a3d3b0e40814f0a98af

Authored by Gabriela Navarro
Committed by Arthur Esposte
1 parent a43d588b

First step to remove institution from the plugin. Still needs to find others references

Signed-off-by: Arthur Del Esposte <>
Signed-off-by: Gabriela Navarro <navarro1703@gmail.com>
Signed-off-by: Thiago Ribeiro <thiagitosouza@hotmail.com>
Showing 39 changed files with 5 additions and 1399 deletions   Show diff stats
controllers/software_communities_plugin_controller.rb
  1 +# apenas software
1 2 require 'csv'
2 3 class SoftwareCommunitiesPluginController < ApplicationController
3 4  
4   - def hide_registration_incomplete_percentage
5   - response = false
6   -
7   - if request.xhr? && params[:hide]
8   - session[:hide_incomplete_percentage] = true
9   - response = session[:hide_incomplete_percentage]
10   - end
11   -
12   - render :json=>response.to_json
13   - end
14   -
15   - def create_institution
16   - @show_sisp_field = environment.admins.include?(current_user.person)
17   - @state_list = get_state_list()
18   -
19   - if request.xhr?
20   - render :layout=>false
21   - else
22   - redirect_to "/"
23   - end
24   - end
25   -
26   - def split_http_referer http_referer
27   - split_list = []
28   - split_list = http_referer.split("/")
29   - @url_token = split_list.last
30   - return @url_token
31   - end
32   -
33   - def create_institution_admin
34   - @show_sisp_field = environment.admins.include?(current_user.person)
35   - @state_list = get_state_list()
36   -
37   - @url_token = split_http_referer request.original_url()
38   - end
39   -
40   - def new_institution
41   - redirect_to "/" if params[:community].blank? || params[:institutions].blank?
42   -
43   - response_message = {}
44   -
45   - institution_template = Community["institution"]
46   - add_template_in_params institution_template
47   -
48   - institution = private_create_institution
49   - add_environment_admins_to_institution institution
50   -
51   - response_message = save_institution institution
52   -
53   - if request.xhr? #User create institution
54   - render :json => response_message.to_json
55   - else #Admin create institution
56   - session[:notice] = response_message[:message] # consume the notice
57   -
58   - redirect_depending_on_institution_creation response_message
59   - end
60   - end
61   -
62   - def institution_already_exists
63   - redirect_to "/" if !request.xhr? || params[:name].blank?
64   -
65   - already_exists = !Community.where(:name=>params[:name]).empty?
66   -
67   - render :json=>already_exists.to_json
68   - end
69   -
70   - def get_institutions
71   - redirect_to "/" if !request.xhr? || params[:query].blank?
72   -
73   - list = Institution.search_institution(params[:query]).map{ |institution|
74   - {:value=>institution.name, :id=>institution.id}
75   - }
76   -
77   - render :json => list.to_json
78   - end
79   -
80   - def get_brazil_states
81   - redirect_to "/" unless request.xhr?
82   -
83   - state_list = get_state_list()
84   - render :json=>state_list.collect {|state| state.name }.to_json
85   - end
86   -
87   - def get_field_data
88   - condition = !request.xhr? || params[:query].nil? || params[:field].nil?
89   - return render :json=>{} if condition
90   -
91   - model = get_model_by_params_field
92   -
93   - data = model.where("name ILIKE ?", "%#{params[:query]}%").select("id, name")
94   - .collect { |db|
95   - {:id=>db.id, :label=>db.name}
96   - }
97   -
98   - other = [model.select("id, name").last].collect { |db|
99   - {:id=>db.id, :label=>db.name}
100   - }
101   -
102   - # Always has other in the list
103   - data |= other
104   -
105   - render :json=> data
106   - end
107   -
108 5 def get_license_data
109 6 return render :json=>{} if !request.xhr? || params[:query].nil?
110 7  
... ... @@ -125,106 +22,6 @@ class SoftwareCommunitiesPluginController &lt; ApplicationController
125 22  
126 23 protected
127 24  
128   - def get_state_list
129   - NationalRegion.find(
130   - :all,
131   - :conditions=>["national_region_type_id = ?", 2],
132   - :order=>"name"
133   - )
134   - end
135   -
136   - def set_institution_type
137   - institution_params = params[:institutions].except(
138   - :governmental_power,
139   - :governmental_sphere,
140   - :juridical_nature
141   - )
142   - if params[:institutions][:type] == "PublicInstitution"
143   - PublicInstitution::new institution_params
144   - else
145   - PrivateInstitution::new institution_params
146   - end
147   - end
148   -
149   - def set_public_institution_fields institution
150   - inst_fields = params[:institutions]
151   -
152   - begin
153   - gov_power = GovernmentalPower.find inst_fields[:governmental_power]
154   - gov_sphere = GovernmentalSphere.find inst_fields[:governmental_sphere]
155   - jur_nature = JuridicalNature.find inst_fields[:juridical_nature]
156   -
157   - institution.juridical_nature = jur_nature
158   - institution.governmental_power = gov_power
159   - institution.governmental_sphere = gov_sphere
160   - rescue
161   - institution.errors.add(
162   - :governmental_fields,
163   - _("Could not find Governmental Power or Governmental Sphere")
164   - )
165   - end
166   - end
167   -
168   - def private_create_institution
169   - community = Community.new(params[:community])
170   - community.environment = environment
171   - institution = set_institution_type
172   -
173   - institution.name = community[:name]
174   - institution.community = community
175   -
176   - if institution.type == "PublicInstitution"
177   - set_public_institution_fields institution
178   - end
179   -
180   - institution.date_modification = DateTime.now
181   - institution.save
182   -
183   - institution
184   - end
185   -
186   - def add_template_in_params institution_template
187   - com_fields = params[:community]
188   - if !institution_template.blank? && institution_template.is_template
189   - com_fields[:template_id]= institution_template.id unless com_fields.blank?
190   - end
191   - end
192   -
193   - def add_environment_admins_to_institution institution
194   - edit_page = params[:edit_institution_page] == false
195   - if environment.admins.include?(current_user.person) && edit_page
196   - environment.admins.each do |adm|
197   - institution.community.add_admin(adm)
198   - end
199   - end
200   - end
201   -
202   - def save_institution institution
203   - inst_errors = institution.errors.full_messages
204   - com_errors = institution.community.errors.full_messages
205   -
206   - if inst_errors.empty? && com_errors.empty? && institution.valid? && institution.save
207   - { :success => true,
208   - :message => _("Institution successful created!"),
209   - :institution_data => {:name=>institution.name, :id=>institution.id}
210   - }
211   - else
212   - { :success => false,
213   - :message => _("Institution could not be created!"),
214   - :errors => inst_errors << com_errors
215   - }
216   - end
217   - end
218   -
219   - def redirect_depending_on_institution_creation response_message
220   - if response_message[:success]
221   - redirect_to :controller => "/admin_panel", :action => "index"
222   - else
223   - flash[:errors] = response_message[:errors]
224   - redirect_to :controller => "software_communities_plugin", :action => "create_institution_admin"
225   - end
226   - end
227   -
228 25 def get_model_by_params_field
229 26 case params[:field]
230 27 when "software_language"
... ...
controllers/software_communities_plugin_myprofile_controller.rb
... ... @@ -4,15 +4,6 @@ class SoftwareCommunitiesPluginMyprofileController &lt; MyProfileController
4 4 def index
5 5 end
6 6  
7   - def edit_institution
8   - @show_sisp_field = environment.admins.include?(current_user.person)
9   - @state_list = NationalRegion.find(:all, :conditions =>
10   - { :national_region_type_id => 2 },
11   - :order => 'name')
12   - @institution = @profile.institution
13   - update_institution if request.post?
14   - end
15   -
16 7 def new_software
17 8 set_software_as_template
18 9  
... ... @@ -81,31 +72,6 @@ class SoftwareCommunitiesPluginMyprofileController &lt; MyProfileController
81 72 end
82 73 end
83 74  
84   - def update_institution
85   - @institution.community.update_attributes(params[:community])
86   - @institution.update_attributes(params[:institutions].except(:governmental_power, :governmental_sphere, :juridical_nature))
87   - if @institution.type == "PublicInstitution"
88   - begin
89   - governmental_updates
90   - rescue
91   - @institution.errors.add(:governmental_fields,
92   - _("Could not find Governmental Power or Governmental Sphere"))
93   - end
94   - end
95   - flash[:errors] = @institution.errors.full_messages unless @institution.valid?
96   - end
97   -
98   - def governmental_updates
99   - gov_power = GovernmentalPower.find params[:institutions][:governmental_power]
100   - gov_sphere = GovernmentalSphere.find params[:institutions][:governmental_sphere]
101   - jur_nature = JuridicalNature.find params[:institutions][:juridical_nature]
102   -
103   - @institution.juridical_nature = jur_nature
104   - @institution.governmental_power = gov_power
105   - @institution.governmental_sphere = gov_sphere
106   - @institution.save
107   - end
108   -
109 75 def software_info_insert_models
110 76 proc { |list,model_attr|
111 77 @software_info.send(model_attr).destroy_all
... ...
db/migrate/20140528193816_add_extra_fields_to_user.rb
... ... @@ -1,17 +0,0 @@
1   -class AddExtraFieldsToUser < ActiveRecord::Migration
2   - def self.up
3   - change_table :users do |t|
4   - t.string :secondary_email
5   - t.references :institution
6   - t.string :role
7   - end
8   - end
9   -
10   - def self.down
11   - change_table :users do |t|
12   - t.remove :secondary_email
13   - t.remove_references :institution
14   - t.remove :role
15   - end
16   - end
17   -end
db/migrate/20140528193835_create_institutions_table.rb
... ... @@ -1,13 +0,0 @@
1   -class CreateInstitutionsTable < ActiveRecord::Migration
2   - def self.up
3   - create_table :institutions do |t|
4   - t.string :name
5   -
6   - t.timestamps
7   - end
8   - end
9   -
10   - def self.down
11   - drop_table :institutions
12   - end
13   -end
db/migrate/20140617125143_add_new_fields_institution.rb
... ... @@ -1,27 +0,0 @@
1   -class AddNewFieldsInstitution < ActiveRecord::Migration
2   - def up
3   - add_column :institutions, :acronym, :string
4   - add_column :institutions, :unit_code, :integer
5   - add_column :institutions, :parent_code, :integer
6   - add_column :institutions, :unit_type, :string
7   - add_column :institutions, :juridical_nature, :string
8   - add_column :institutions, :sub_juridical_nature, :string
9   - add_column :institutions, :normalization_level, :string
10   - add_column :institutions, :version, :string
11   - add_column :institutions, :cnpj, :string
12   - add_column :institutions, :type, :string
13   - end
14   -
15   - def down
16   - remove_column :institutions, :acronym
17   - remove_column :institutions, :unit_code
18   - remove_column :institutions, :parent_code
19   - remove_column :institutions, :unit_type
20   - remove_column :institutions, :juridical_nature
21   - remove_column :institutions, :sub_juridical_nature
22   - remove_column :institutions, :normalization_level
23   - remove_column :institutions, :version
24   - remove_column :institutions, :cnpj
25   - remove_column :institutions, :type
26   - end
27   -end
db/migrate/20140617132133_create_governmental_spheres.rb
... ... @@ -1,12 +0,0 @@
1   -class CreateGovernmentalSpheres < ActiveRecord::Migration
2   - def change
3   - create_table :governmental_spheres do |t|
4   - t.string :name
5   -
6   - t.timestamps
7   - end
8   -
9   - path_to_file = "plugins/software_communities/public/static/governmental_sphere.txt"
10   - SoftwareHelper.create_list_with_file(path_to_file, GovernmentalSphere)
11   - end
12   -end
db/migrate/20140617132451_create_governmental_powers.rb
... ... @@ -1,12 +0,0 @@
1   -class CreateGovernmentalPowers < ActiveRecord::Migration
2   - def change
3   - create_table :governmental_powers do |t|
4   - t.string :name
5   -
6   - t.timestamps
7   - end
8   -
9   - path_to_file = "plugins/software_communities/public/static/governmental_powers.txt"
10   - SoftwareHelper.create_list_with_file(path_to_file, GovernmentalPower)
11   - end
12   -end
db/migrate/20140617134556_add_references_to_institution.rb
... ... @@ -1,15 +0,0 @@
1   -class AddReferencesToInstitution < ActiveRecord::Migration
2   - def up
3   - change_table :institutions do |t|
4   - t.references :governmental_power
5   - t.references :governmental_sphere
6   - end
7   - end
8   -
9   - def down
10   - change_table :institutions do |t|
11   - t.remove_references :governmental_power
12   - t.remove_references :governmental_sphere
13   - end
14   - end
15   -end
db/migrate/20140630183326_add_relation_between_community_and_institution.rb
... ... @@ -1,13 +0,0 @@
1   -class AddRelationBetweenCommunityAndInstitution < ActiveRecord::Migration
2   - def up
3   - change_table :institutions do |t|
4   - t.references :community
5   - end
6   - end
7   -
8   - def down
9   - change_table :institutions do |t|
10   - t.remove_references :community
11   - end
12   - end
13   -end
db/migrate/20140812143218_remove_field_role_from_user.rb
... ... @@ -1,13 +0,0 @@
1   -class RemoveFieldRoleFromUser < ActiveRecord::Migration
2   - def up
3   - change_table :users do |t|
4   - t.remove :role
5   - end
6   - end
7   -
8   - def down
9   - change_table :users do |t|
10   - t.string :role
11   - end
12   - end
13   -end
db/migrate/20140814125947_add_new_fields_to_public_institution.rb
... ... @@ -1,11 +0,0 @@
1   -class AddNewFieldsToPublicInstitution < ActiveRecord::Migration
2   - def up
3   - add_column :institutions, :sisp, :boolean, :default => false
4   - remove_column :institutions, :juridical_nature
5   - end
6   -
7   - def down
8   - remove_column :institutions, :sisp
9   - add_column :institutions, :juridical_nature, :string
10   - end
11   -end
db/migrate/20140814131606_create_juridical_natures_table.rb
... ... @@ -1,14 +0,0 @@
1   -class CreateJuridicalNaturesTable < ActiveRecord::Migration
2   - def up
3   - create_table :juridical_natures do |t|
4   - t.string :name
5   - end
6   -
7   - path_to_file = "plugins/software_communities/public/static/juridical_nature.txt"
8   - SoftwareHelper.create_list_with_file(path_to_file, JuridicalNature)
9   - end
10   -
11   - def down
12   - drop_table :juridical_natures
13   - end
14   -end
db/migrate/20140814134827_add_juridical_nature_reference_to_institutions_table.rb
... ... @@ -1,13 +0,0 @@
1   -class AddJuridicalNatureReferenceToInstitutionsTable < ActiveRecord::Migration
2   - def up
3   - change_table :institutions do |t|
4   - t.references :juridical_nature
5   - end
6   - end
7   -
8   - def down
9   - change_table :institutions do |t|
10   - t.remove_references :juridical_nature
11   - end
12   - end
13   -end
db/migrate/20140815194530_register_institution_modification.rb
... ... @@ -1,13 +0,0 @@
1   -class RegisterInstitutionModification < ActiveRecord::Migration
2   - def up
3   - change_table :institutions do |t|
4   - t.string :date_modification
5   - end
6   - end
7   -
8   - def down
9   - change_table :institutions do |t|
10   - t.remove :date_modification
11   - end
12   - end
13   -end
db/migrate/20140818195821_remove_institution_from_user.rb
... ... @@ -1,9 +0,0 @@
1   -class RemoveInstitutionFromUser < ActiveRecord::Migration
2   - def up
3   - remove_column :users, :institution_id
4   - end
5   -
6   - def down
7   - add_column :users, :institution_id
8   - end
9   -end
db/migrate/20140818200738_create_institution_user_relation_table.rb
... ... @@ -1,12 +0,0 @@
1   -class CreateInstitutionUserRelationTable < ActiveRecord::Migration
2   - def up
3   - create_table :institutions_users do |t|
4   - t.belongs_to :user
5   - t.belongs_to :institution
6   - end
7   - end
8   -
9   - def down
10   - drop_table :institutions_users
11   - end
12   -end
db/migrate/20141103183013_add_corporate_name_to_institution.rb
... ... @@ -1,9 +0,0 @@
1   -class AddCorporateNameToInstitution < ActiveRecord::Migration
2   - def up
3   - add_column :institutions, :corporate_name, :string
4   - end
5   -
6   - def down
7   - remove_column :institutions, :corporate_name
8   - end
9   -end
db/migrate/20150408130613_remove_secondary_email_from_user.rb
... ... @@ -1,10 +0,0 @@
1   -class RemoveSecondaryEmailFromUser < ActiveRecord::Migration
2   - def up
3   - remove_column :users, :secondary_email
4   - end
5   -
6   - def down
7   - add_column :users, :secondary_email
8   - end
9   -
10   -end
lib/ext/community.rb
... ... @@ -11,7 +11,6 @@ class Community
11 11 attr_accessible :visible
12 12  
13 13 has_one :software_info, :dependent=>:destroy
14   - has_one :institution, :dependent=>:destroy
15 14  
16 15 def self.create_after_moderation(requestor, attributes = {})
17 16 community = Community.new(attributes)
... ... @@ -31,10 +30,6 @@ class Community
31 30 return !software_info.nil?
32 31 end
33 32  
34   - def institution?
35   - return !institution.nil?
36   - end
37   -
38 33 def deactivate
39 34 self.visible = false
40 35 self.save!
... ...
lib/ext/person.rb
... ... @@ -6,16 +6,6 @@ class Person
6 6  
7 7 delegate :login, :to => :user, :prefix => true
8 8  
9   - def institutions
10   - institutions = []
11   - unless self.user.institutions.nil?
12   - self.user.institutions.each do |institution|
13   - institutions << institution.name
14   - end
15   - end
16   - institutions
17   - end
18   -
19 9 def software?
20 10 false
21 11 end
... ...
lib/ext/search_controller.rb
... ... @@ -4,22 +4,13 @@ class SearchController
4 4  
5 5 def communities
6 6 results = filter_communities_list do |community|
7   - !community.software? and !community.institution?
  7 + !community.software?
8 8 end
9 9 results = results.paginate(:per_page => 24, :page => params[:page])
10 10 @searches[@asset] = {:results => results}
11 11 @search = results
12 12 end
13 13  
14   - def institutions
15   - @titles[:institutions] = _("Institution Catalog")
16   - results = filter_communities_list{|community| community.institution?}
17   - results = results.paginate(:per_page => 24, :page => params[:page])
18   - @searches[@asset] = {:results => results}
19   - @search = results
20   - end
21   -
22   -
23 14 def software_infos
24 15 prepare_software_search_page
25 16 results = filter_software_infos_list
... ...
lib/ext/search_helper.rb
... ... @@ -4,7 +4,6 @@ module SearchHelper
4 4  
5 5 COMMON_PROFILE_LIST_BLOCK ||= []
6 6 COMMON_PROFILE_LIST_BLOCK << :software_infos
7   - COMMON_PROFILE_LIST_BLOCK << :institutions
8 7  
9 8 def sort_by_relevance list, text
10 9 text_splited = text.split
... ...
lib/ext/user.rb
... ... @@ -1,7 +0,0 @@
1   -require_dependency 'user'
2   -
3   -class User
4   -
5   - has_and_belongs_to_many :institutions
6   -
7   -end
lib/governmental_power.rb
... ... @@ -1,13 +0,0 @@
1   -class GovernmentalPower < ActiveRecord::Base
2   - attr_accessible :name
3   -
4   - validates :name, :presence=>true, :uniqueness=>true
5   - has_many :institutions
6   -
7   - def public_institutions
8   - Institution.where(
9   - :type=>"PublicInstitution",
10   - :governmental_power_id=>self.id
11   - )
12   - end
13   -end
lib/governmental_sphere.rb
... ... @@ -1,7 +0,0 @@
1   -class GovernmentalSphere < ActiveRecord::Base
2   - attr_accessible :name
3   -
4   - validates :name, :presence=>true, :uniqueness=>true
5   -
6   - has_many :institutions
7   -end
lib/institution.rb
... ... @@ -1,122 +0,0 @@
1   -class Institution < ActiveRecord::Base
2   -
3   - SEARCH_FILTERS = {
4   - :order => %w[],
5   - :display => %w[compact]
6   - }
7   -
8   - def self.default_search_display
9   - 'compact'
10   - end
11   -
12   - belongs_to :governmental_power
13   - belongs_to :governmental_sphere
14   - belongs_to :juridical_nature
15   -
16   - has_and_belongs_to_many :users
17   -
18   - attr_accessible :name, :acronym, :unit_code, :parent_code, :unit_type,
19   - :sub_juridical_nature, :normalization_level,
20   - :version, :cnpj, :type, :governmental_power,
21   - :governmental_sphere, :sisp, :juridical_nature,
22   - :corporate_name
23   -
24   - validates :name, :presence=>true, :uniqueness=>true
25   -
26   - validates :corporate_name, :presence => true
27   -
28   - before_save :verify_institution_type
29   -
30   - belongs_to :community
31   -
32   - scope :search_institution, lambda{ |value|
33   - where("name ilike ? OR acronym ilike ?", "%#{value}%", "%#{value}%" )
34   - }
35   -
36   - validate :validate_country, :validate_state, :validate_city,
37   - :verify_institution_type, :validate_cnpj, :validate_format_cnpj
38   -
39   -
40   - protected
41   -
42   - def verify_institution_type
43   - valid_institutions_type = ["PublicInstitution", "PrivateInstitution"]
44   -
45   - unless valid_institutions_type.include? self.type
46   - self.errors.add(
47   - :type,
48   - _("invalid, only public and private institutions are allowed.")
49   - )
50   -
51   - return false
52   - end
53   - return true
54   - end
55   -
56   - def validate_country
57   - if(self.community.blank? ||
58   - self.community.country.blank? &&
59   - self.errors[:country].blank?)
60   -
61   - self.errors.add(:country, _("can't be blank"))
62   - return false
63   - end
64   - return true
65   - end
66   -
67   - def validate_state
68   - if(self.community.blank? ||
69   - self.errors[:state].blank? &&
70   - self.community.state.blank?)
71   -
72   - if self.community.country == "BR"
73   - self.errors.add(:state, _("can't be blank"))
74   - return false
75   - else
76   - return true
77   - end
78   - end
79   - return true
80   - end
81   -
82   - def validate_city
83   - if(self.community.blank? ||
84   - self.errors[:city].blank? &&
85   - self.community.city.blank?)
86   -
87   - if self.community.country == "BR"
88   - self.errors.add(:city, _("can't be blank"))
89   - return false
90   - else
91   - return true
92   - end
93   - end
94   - return true
95   - end
96   -
97   - def validate_format_cnpj
98   - return true if !self.community.blank? && self.community.country != "BR"
99   -
100   - format = /^\d{2}\.\d{3}\.\d{3}\/\d{4}\-\d{2}$/
101   -
102   - if !self.cnpj.blank? && format.match(self.cnpj)
103   - return true
104   - else
105   - self.errors.add(:cnpj, _("invalid format"))
106   - return false
107   - end
108   - end
109   -
110   - def validate_cnpj
111   - if !self.community.blank? && self.community.country == "BR"
112   - if self.errors[:cnpj].blank? && self.cnpj.blank?
113   - self.errors.add(:cnpj, _("can't be blank"))
114   - return false
115   - else
116   - return true
117   - end
118   - else
119   - return true
120   - end
121   - end
122   -end
lib/institutions_block.rb
... ... @@ -1,71 +0,0 @@
1   -class InstitutionsBlock < CommunitiesBlock
2   -
3   - def self.description
4   - _('Institutions')
5   - end
6   -
7   - def profile_count
8   - profile_list.count
9   - end
10   -
11   - def default_title
12   - n_('{#} institution', '{#} institutions', profile_count)
13   - end
14   -
15   - def help
16   - _('This block displays the institutions in which the user is a member.')
17   - end
18   -
19   - def footer
20   - owner = self.owner
21   - case owner
22   - when Profile
23   - lambda do |context|
24   - link_to s_('institutions|View all'), :profile => owner.identifier,
25   - :controller => 'profile', :action => 'communities',
26   - :type => 'Institution'
27   - end
28   - when Environment
29   - lambda do |context|
30   - link_to s_('institutions|View all'), :controller => 'search',
31   - :action => 'communities', :type => 'Institution'
32   - end
33   - else
34   - ''
35   - end
36   - end
37   -
38   - def profile_list
39   - result = get_visible_profiles
40   -
41   - result = result.select { |p| p.class == Community && p.institution? }
42   -
43   - result.slice(0..get_limit-1)
44   - end
45   -
46   - def profiles
47   - owner.communities
48   - end
49   -
50   - private
51   -
52   - def get_visible_profiles
53   - include_list = [:image,:domains,:preferred_domain,:environment]
54   - visible_profiles = profiles.visible.includes(include_list)
55   -
56   - if !prioritize_profiles_with_image
57   - visible_profiles.all(:limit => get_limit,
58   - :order => 'profiles.updated_at DESC'
59   - ).sort_by{ rand }
60   - elsif profiles.visible.with_image.count >= get_limit
61   - visible_profiles.with_image.all(:limit => get_limit * 5,
62   - :order => 'profiles.updated_at DESC'
63   - ).sort_by{ rand }
64   - else
65   - visible_profiles.with_image.sort_by{ rand } +
66   - visible_profiles.without_image.all(:limit => get_limit * 5,
67   - :order => 'profiles.updated_at DESC'
68   - ).sort_by{ rand }
69   - end
70   - end
71   -end
lib/institutions_users.rb
... ... @@ -1,4 +0,0 @@
1   -class InstitutionUser < ActiveRecord::Base
2   - belongs_to :user
3   - belongs_to :institution
4   -end
lib/juridical_nature.rb
... ... @@ -1,15 +0,0 @@
1   -class JuridicalNature < ActiveRecord::Base
2   - attr_accessible :name
3   -
4   - has_many :institutions
5   -
6   - validates_presence_of :name
7   - validates_uniqueness_of :name
8   -
9   - def public_institutions
10   - Institution.where(
11   - :type=>"PublicInstitution",
12   - :juridical_nature_id=>self.id
13   - )
14   - end
15   -end
lib/private_institution.rb
... ... @@ -1,3 +0,0 @@
1   -class PrivateInstitution < Institution
2   - validates :cnpj, :uniqueness=>true, :allow_nil=>true, :allow_blank=>true
3   -end
lib/public_institution.rb
... ... @@ -1,15 +0,0 @@
1   -class PublicInstitution < Institution
2   - validates :governmental_power, :governmental_sphere, :juridical_nature,
3   - :presence=>true
4   -
5   - validates :acronym, :allow_blank => true, :allow_nil => true,
6   - :uniqueness=>true
7   -
8   - validates :cnpj, :uniqueness=>true
9   -
10   - validates_format_of(
11   - :cnpj,
12   - :with => /^\d{2}\.\d{3}\.\d{3}\/\d{4}\-\d{2}$/,
13   - :allow_nil => true, :allow_blank => true
14   - )
15   -end
lib/software_communities_plugin.rb
... ... @@ -35,35 +35,9 @@ class SoftwareCommunitiesPlugin &lt; Noosfero::Plugin
35 35 end
36 36 end
37 37  
38   - def profile_editor_controller_filters
39   - block = proc do
40   - if request.post? && params[:institution]
41   - is_admin = environment.admins.include?(current_user.person)
42   -
43   - unless is_admin
44   - institution = profile.user.institutions
45   -
46   - if !params[:institution].blank? && !params[:institution][:sisp].nil?
47   - if params[:institution][:sisp] != institution.sisp
48   - params[:institution][:sisp] = institution.sisp
49   - end
50   - end
51   - end
52   - end
53   - end
54   -
55   - [{
56   - :type => 'before_filter',
57   - :method_name => 'validate_institution_sisp_field_access',
58   - :options => { :only => :edit },
59   - :block => block
60   - }]
61   - end
62   -
63 38 def profile_tabs
64 39 if context.profile.community?
65 40 return profile_tabs_software if context.profile.software?
66   - return profile_tabs_institution if context.profile.institution?
67 41 end
68 42 end
69 43  
... ... @@ -72,8 +46,6 @@ class SoftwareCommunitiesPlugin &lt; Noosfero::Plugin
72 46 return software_info_button
73 47 elsif context.profile.person?
74 48 return create_new_software_button
75   - elsif context.profile.institution?
76   - return institution_info_button
77 49 end
78 50 end
79 51  
... ... @@ -123,18 +95,6 @@ class SoftwareCommunitiesPlugin &lt; Noosfero::Plugin
123 95 person.has_permission_without_plugins?(permission, target)
124 96 end
125 97  
126   - def custom_user_registration_attributes(user)
127   - return if context.params[:user][:institution_ids].nil?
128   - context.params[:user][:institution_ids].delete('')
129   -
130   - update_user_institutions(user)
131   -
132   - user.institutions.each do |institution|
133   - community = institution.community
134   - community.add_member user.person
135   - end
136   - end
137   -
138 98 def admin_panel_links
139 99 [
140 100 {
... ... @@ -149,33 +109,6 @@ class SoftwareCommunitiesPlugin &lt; Noosfero::Plugin
149 109  
150 110 protected
151 111  
152   - def user_transaction
153   - user_editor_institution_actions
154   -
155   - User.transaction do
156   - context.profile.user.update_attributes!(context.params[:user])
157   - end
158   - end
159   -
160   - def institution_transaction
161   - institution.date_modification = DateTime.now
162   - institution.save
163   - institution_models = %w(governmental_power governmental_sphere
164   - juridical_nature)
165   -
166   - institution_models.each do |model|
167   - call_institution_transaction(model)
168   - end
169   -
170   - if context.params.has_key?(:institution)
171   - Institution.transaction do
172   - context.profile.
173   - institution.
174   - update_attributes!(context.params[:institution])
175   - end
176   - end
177   - end
178   -
179 112 def software_info_transaction
180 113 SoftwareInfo.transaction do
181 114 context.profile.
... ... @@ -192,27 +125,6 @@ class SoftwareCommunitiesPlugin &lt; Noosfero::Plugin
192 125  
193 126 private
194 127  
195   - # Add and remove the user from it's institutions communities
196   - def user_editor_institution_actions
197   - user = context.profile.user
198   -
199   - old_communities = []
200   - context.profile.user.institutions.each do |institution|
201   - old_communities << institution.community
202   - end
203   -
204   - new_communities = []
205   - unless context.params[:user][:institution_ids].nil?
206   - context.params[:user][:institution_ids].delete('')
207   -
208   - context.params[:user][:institution_ids].each do |id|
209   - new_communities << Institution.find(id).community
210   - end
211   - end
212   -
213   - manage_user_institutions(user, old_communities, new_communities)
214   - end
215   -
216 128 def call_model_transaction(model,name)
217 129 send(name + '_transaction') if context.params.key?(model.to_sym)
218 130 end
... ... @@ -245,56 +157,10 @@ class SoftwareCommunitiesPlugin &lt; Noosfero::Plugin
245 157 }
246 158 end
247 159  
248   - def institution_info_button
249   - {
250   - :title => _('Institution Info'),
251   - :icon => 'edit-profile-group control-panel-instituton-link',
252   - :url => {
253   - :controller => 'software_communities_plugin_myprofile',
254   - :action => 'edit_institution'
255   - }
256   - }
257   - end
258   -
259   - def manage_user_institutions(user, old_communities, new_communities)
260   - leave_communities = (old_communities - new_communities)
261   - enter_communities = (new_communities - old_communities)
262   -
263   - leave_communities.each do |community|
264   - community.remove_member(user.person)
265   - user.institutions.delete(community.institution)
266   - end
267   -
268   - enter_communities.each do |community|
269   - community.add_member(user.person)
270   - user.institutions << community.institution
271   - end
272   - end
273   -
274 160 def profile_tabs_software
275 161 { :title => _('Software'),
276 162 :id => 'software-fields',
277 163 :content => Proc::new do render :partial => 'profile/software_tab' end,
278 164 :start => true }
279 165 end
280   -
281   - def profile_tabs_institution
282   - { :title => _('Institution'),
283   - :id => 'intitution-fields',
284   - :content => Proc::new do render :partial => 'profile/institution_tab' end,
285   - :start => true
286   - }
287   - end
288   -
289   - def update_user_institutions(user)
290   - context.params[:user][:institution_ids].each do |institution_id|
291   - institution = Institution.find institution_id
292   - user.institutions << institution
293   -
294   - if institution.community.admins.blank?
295   - institution.community.add_admin(user.person)
296   - end
297   - end
298   - user.save unless user.institution_ids.empty?
299   - end
300 166 end
... ...
test/functional/profile_editor_controller_test.rb
... ... @@ -28,68 +28,6 @@ class ProfileEditorControllerTest &lt; ActionController::TestCase
28 28 login_as('adminuser')
29 29 @environment.add_admin(admin)
30 30 @environment.save
31   -
32   - @govPower = GovernmentalPower.create(:name=>"Some Gov Power")
33   - @govSphere = GovernmentalSphere.create(:name=>"Some Gov Sphere")
34   - @juridical_nature = JuridicalNature.create(:name => "Autarquia")
35   -
36   - @institution_list = []
37   - @institution_list << InstitutionTestHelper.create_public_institution(
38   - "Ministerio Publico da Uniao",
39   - "MPU",
40   - "BR",
41   - "DF",
42   - "Gama",
43   - @juridical_nature,
44   - @govPower,
45   - @govSphere,
46   - "12.345.678/9012-45"
47   - )
48   -
49   - @institution_list << InstitutionTestHelper.create_public_institution(
50   - "Tribunal Regional da Uniao",
51   - "TRU",
52   - "BR",
53   - "DF",
54   - "Brasilia",
55   - @juridical_nature,
56   - @govPower,
57   - @govSphere,
58   - "12.345.678/9012-90"
59   - )
60   - end
61   -
62   - should "add new institution for user into edit profile" do
63   - user = create_basic_user
64   -
65   - params_user = Hash.new
66   - params_user[:institution_ids] = []
67   -
68   - @institution_list.each do |institution|
69   - params_user[:institution_ids] << institution.id
70   - end
71   -
72   - post :edit, :profile => User.last.person.identifier, :user => params_user
73   -
74   - assert_equal @institution_list.count, User.last.institutions.count
75   - end
76   -
77   - should "remove institutions for user into edit profile" do
78   - user = create_basic_user
79   -
80   - @institution_list.each do |institution|
81   - user.institutions << institution
82   - end
83   - user.save!
84   -
85   - params_user = Hash.new
86   - params_user[:institution_ids] = []
87   -
88   - assert_equal @institution_list.count, User.last.institutions.count
89   -
90   - post :edit, :profile => User.last.person.identifier, :user => params_user
91   -
92   - assert_equal 0, User.last.institutions.count
93 31 end
94 32  
95 33 should "redirect to edit_software_community on edit community of software" do
... ...
test/functional/search_controller_test.rb
... ... @@ -23,29 +23,19 @@ class SearchControllerTest &lt; ActionController::TestCase
23 23 create_software_categories
24 24 end
25 25  
26   - should "communities searches don't have software or institution" do
  26 + should "communities searches don't have software" do
27 27 community = create_community("New Community")
28 28 software = create_software_info("New Software")
29   - institution = create_private_institution(
30   - "New Private Institution",
31   - "NPI" ,
32   - "Brazil",
33   - "DF",
34   - "Gama",
35   - "66.544.314/0001-63"
36   - )
37 29  
38 30 get :communities, :query => "New"
39 31  
40 32 assert_includes assigns(:searches)[:communities][:results], community
41 33 assert_not_includes assigns(:searches)[:communities][:results], software
42   - assert_not_includes assigns(:searches)[:communities][:results], institution
43 34 end
44 35  
45   - should "software_infos search don't have community or institution" do
  36 + should "software_infos search don't have community" do
46 37 community = create_community("New Community")
47 38 software = create_software_info("New Software")
48   - institution = create_private_institution("New Private Institution", "NPI" , "Brazil", "DF", "Gama", "66.544.314/0001-63")
49 39  
50 40 software.license_info = LicenseInfo.create :version => "GPL - 1.0"
51 41 software.save!
... ... @@ -54,7 +44,6 @@ class SearchControllerTest &lt; ActionController::TestCase
54 44  
55 45 assert_includes assigns(:searches)[:software_infos][:results], software.community
56 46 assert_not_includes assigns(:searches)[:software_infos][:results], community
57   - assert_not_includes assigns(:searches)[:software_infos][:results], institution.community
58 47 end
59 48  
60 49  
... ... @@ -64,15 +53,6 @@ class SearchControllerTest &lt; ActionController::TestCase
64 53 software.license_info = LicenseInfo.create(:version => "GPL")
65 54 software.save!
66 55  
67   - institution = create_private_institution(
68   - "New Private Institution",
69   - "NPI" ,
70   - "Brazil",
71   - "DF",
72   - "Gama",
73   - "66.544.314/0001-63"
74   - )
75   -
76 56 community_template = create_community("New Community Template")
77 57 community_template.is_template = true
78 58 community_template.save!
... ... @@ -85,31 +65,6 @@ class SearchControllerTest &lt; ActionController::TestCase
85 65 )
86 66 end
87 67  
88   - should "institutions_search don't have community or software" do
89   - community = create_community("New Community")
90   - software = create_software_info("New Software")
91   - institution = create_private_institution(
92   - "New Private Institution",
93   - "NPI" ,
94   - "Brazil",
95   - "DF",
96   - "Gama",
97   - "66.544.314/0001-63"
98   - )
99   -
100   - get :institutions, :query => "New"
101   -
102   - assert_includes(
103   - assigns(:searches)[:institutions][:results],
104   - institution.community
105   - )
106   - assert_not_includes assigns(:searches)[:institutions][:results], community
107   - assert_not_includes(
108   - assigns(:searches)[:institutions][:results],
109   - software.community
110   - )
111   - end
112   -
113 68 should "software_infos search by category" do
114 69 software_one = create_software_info("Software One")
115 70 software_two = create_software_info("Software Two")
... ...
test/functional/software_communities_plugin_controller_test.rb
... ... @@ -45,213 +45,4 @@ class SoftwareCommunitiesPluginControllerTest &lt; ActionController::TestCase
45 45 "12.345.678/9012-90"
46 46 )
47 47 end
48   -
49   - should "Search for institution with acronym" do
50   - xhr :get, :get_institutions, :query=>"TRU"
51   -
52   - json_response = ActiveSupport::JSON.decode(@response.body)
53   -
54   - assert_equal "Tribunal Regional da Uniao", json_response[0]["value"]
55   - end
56   -
57   - should "Search for institution with name" do
58   - xhr :get, :get_institutions, :query=>"Minis"
59   -
60   - json_response = ActiveSupport::JSON.decode(@response.body)
61   -
62   - assert_equal "Ministerio Publico da Uniao", json_response[0]["value"]
63   - end
64   -
65   - should "search with name or acronym and return a list with institutions" do
66   - xhr :get, :get_institutions, :query=>"uni"
67   -
68   - json_response = ActiveSupport::JSON.decode(@response.body)
69   -
70   - assert_equal "Ministerio Publico da Uniao", json_response[0]["value"]
71   - assert_equal "Tribunal Regional da Uniao", json_response[1]["value"]
72   - end
73   -
74   - should "method create_institution return the html for modal" do
75   - @controller.stubs(:current_user).returns(@admin.user)
76   - xhr :get, :create_institution
77   - assert_template 'create_institution'
78   - end
79   -
80   - should "create new institution with ajax without acronym" do
81   - @controller.stubs(:verify_recaptcha).returns(true)
82   -
83   - fields = InstitutionTestHelper.generate_form_fields(
84   - "foo bar",
85   - "BR",
86   - "DF",
87   - "Brasilia",
88   - "12.234.567/8900-10",
89   - "PublicInstitution"
90   - )
91   - fields[:institutions][:governmental_power] = @gov_power.id
92   - fields[:institutions][:governmental_sphere] = @gov_sphere.id
93   - fields[:institutions][:juridical_nature] = @juridical_nature.id
94   -
95   - xhr :get, :new_institution, fields
96   -
97   - json_response = ActiveSupport::JSON.decode(@response.body)
98   -
99   - assert json_response["success"]
100   - end
101   -
102   - should "not create a institution that already exists" do
103   - @controller.stubs(:verify_recaptcha).returns(true)
104   -
105   - fields = InstitutionTestHelper.generate_form_fields(
106   - "Ministerio Publico da Uniao",
107   - "BR",
108   - "DF",
109   - "Brasilia",
110   - "12.234.567/8900-10",
111   - "PublicInstitution"
112   - )
113   - fields[:institutions][:governmental_power] = @gov_power.id
114   - fields[:institutions][:governmental_sphere] = @gov_sphere.id
115   - fields[:institutions][:juridical_nature] = @juridical_nature.id
116   -
117   - xhr :get, :new_institution, fields
118   -
119   - json_response = ActiveSupport::JSON.decode(@response.body)
120   -
121   - assert !json_response["success"]
122   - end
123   -
124   - should "not create a institution without cnpj" do
125   - @controller.stubs(:verify_recaptcha).returns(true)
126   -
127   - fields = InstitutionTestHelper.generate_form_fields(
128   - "Some Private Institution",
129   - "BR",
130   - "DF",
131   - "Brasilia",
132   - "",
133   - "PrivateInstitution"
134   - )
135   - fields[:institutions][:acronym] = "SPI"
136   -
137   - xhr :get, :new_institution, fields
138   -
139   - json_response = ActiveSupport::JSON.decode(@response.body)
140   -
141   - assert !json_response["success"]
142   - end
143   -
144   - should "verify if institution name already exists" do
145   - xhr :get, :institution_already_exists, :name=>"Ministerio Publico da Uniao"
146   - assert_equal "true", @response.body
147   -
148   - xhr :get, :institution_already_exists, :name=>"Another name here"
149   - assert_equal "false", @response.body
150   - end
151   -
152   - should "hide registration incomplete message" do
153   - xhr :get, :hide_registration_incomplete_percentage, :hide=>true
154   - assert_equal "true", @response.body
155   - end
156   -
157   - should "not hide registration incomplete message" do
158   - xhr :get, :hide_registration_incomplete_percentage, :hide=>false
159   - assert_equal "false", @response.body
160   - end
161   -
162   - should "Create new institution with method post" do
163   - @controller.stubs(:verify_recaptcha).returns(true)
164   -
165   - fields = InstitutionTestHelper.generate_form_fields(
166   - "Some Private Institution",
167   - "BR",
168   - "DF",
169   - "Brasilia",
170   - "12.345.567/8900-10",
171   - "PrivateInstitution"
172   - )
173   - fields[:institutions][:acronym] = "SPI"
174   -
175   - post :new_institution, fields
176   -
177   - assert_redirected_to(controller: "admin_panel", action: "index")
178   - end
179   -
180   - should "not create new institution with method post without cnpj" do
181   - @controller.stubs(:verify_recaptcha).returns(true)
182   -
183   - fields = InstitutionTestHelper.generate_form_fields(
184   - "Some Private Institution",
185   - "BR",
186   - "DF",
187   - "Brasilia",
188   - "",
189   - "PrivateInstitution"
190   - )
191   - fields[:institutions][:acronym] = "SPI"
192   -
193   - post :new_institution, fields
194   -
195   - assert_redirected_to(controller: "software_communities_plugin", action: "create_institution_admin")
196   - end
197   -
198   - should "Create foreign institution without city, state and cnpj by post" do
199   - @controller.stubs(:verify_recaptcha).returns(true)
200   -
201   - fields = InstitutionTestHelper.generate_form_fields(
202   - "Foreign institution",
203   - "AZ",
204   - "",
205   - "",
206   - "",
207   - "PrivateInstitution"
208   - )
209   - fields[:institutions][:acronym] = "FI"
210   -
211   - post :new_institution, fields
212   -
213   - assert_redirected_to(controller: "admin_panel", action: "index")
214   - end
215   -
216   - should "Create foreign institution without city, state and cnpj by ajax" do
217   - @controller.stubs(:verify_recaptcha).returns(true)
218   -
219   - fields = InstitutionTestHelper.generate_form_fields(
220   - "Foreign institution",
221   - "AZ",
222   - "",
223   - "",
224   - "",
225   - "PrivateInstitution"
226   - )
227   - fields[:institutions][:acronym] = "FI"
228   -
229   - xhr :post, :new_institution, fields
230   -
231   - json_response = ActiveSupport::JSON.decode(@response.body)
232   - assert json_response["success"]
233   - end
234   -
235   - should "add environment admins to institution when created via admin panel" do
236   - @controller.stubs(:verify_recaptcha).returns(true)
237   - admin2 = create_user("another_admin").person
238   - admin2.stubs(:has_permission?).returns("true")
239   - @environment.add_admin(admin2)
240   - @environment.save
241   -
242   - fields = InstitutionTestHelper.generate_form_fields(
243   - "Private Institution",
244   - "BR",
245   - "DF",
246   - "Brasilia",
247   - "12.323.557/8900-10",
248   - "PrivateInstitution"
249   - )
250   - fields[:institutions][:acronym] = "PI"
251   - fields[:edit_institution_page] = false
252   - post :new_institution, fields
253   -
254   - assert(Institution.last.community.admins.include?(admin2) )
255   - end
256   -
257   -end
258 48 \ No newline at end of file
  49 +end
... ...
test/functional/software_communities_plugin_myprofile_controller_test.rb
1 1 require File.dirname(__FILE__) + '/../../../../test/test_helper'
2 2 require File.dirname(__FILE__) + '/../helpers/software_test_helper'
3   -require File.dirname(__FILE__) + '/../helpers/institution_test_helper'
4 3 require(
5 4 File.dirname(__FILE__) +
6 5 '/../../controllers/software_communities_plugin_myprofile_controller'
... ... @@ -115,85 +114,6 @@ class SoftwareCommunitiesPluginMyprofileControllerTest &lt; ActionController::TestC
115 114 assert_equal true, SoftwareInfo.last.public_software?
116 115 end
117 116  
118   - should "user edit its community institution" do
119   - govPower = GovernmentalPower.create(:name=>"Some Gov Power")
120   - govSphere = GovernmentalSphere.create(:name=>"Some Gov Sphere")
121   - juridical_nature = JuridicalNature.create(:name => "Autarquia")
122   -
123   - institution = InstitutionTestHelper.create_public_institution(
124   - "Ministerio Publico da Uniao",
125   - "MPU",
126   - "BR",
127   - "DF",
128   - "Gama",
129   - juridical_nature,
130   - govPower,
131   - govSphere,
132   - "12.345.678/9012-45"
133   - )
134   -
135   - identifier = institution.community.identifier
136   -
137   - fields = InstitutionTestHelper.generate_form_fields(
138   - "institution new name",
139   - "BR",
140   - "DF",
141   - "Gama",
142   - "12.345.678/9012-45",
143   - "PrivateInstitution"
144   - )
145   -
146   - post(
147   - :edit_institution,
148   - :profile=>institution.community.identifier,
149   - :community=>fields[:community],
150   - :institutions=>fields[:institutions]
151   - )
152   -
153   - institution = Community[identifier].institution
154   - assert_not_equal "Ministerio Publico da Uniao", institution.community.name
155   - end
156   -
157   - should "not user edit its community institution with wrong values" do
158   - govPower = GovernmentalPower.create(:name=>"Some Gov Power")
159   - govSphere = GovernmentalSphere.create(:name=>"Some Gov Sphere")
160   - juridical_nature = JuridicalNature.create(:name => "Autarquia")
161   -
162   - institution = InstitutionTestHelper.create_public_institution(
163   - "Ministerio Publico da Uniao",
164   - "MPU",
165   - "BR",
166   - "DF",
167   - "Gama",
168   - juridical_nature,
169   - govPower,
170   - govSphere,
171   - "12.345.678/9012-45"
172   - )
173   -
174   - identifier = institution.community.identifier
175   -
176   - fields = InstitutionTestHelper.generate_form_fields(
177   - "",
178   - "BR",
179   - "DF",
180   - "Gama",
181   - "6465465465",
182   - "PrivateInstitution"
183   - )
184   -
185   - post(
186   - :edit_institution,
187   - :profile=>institution.community.identifier,
188   - :community=>fields[:community],
189   - :institutions=>fields[:institutions]
190   - )
191   -
192   - institution = Community[identifier].institution
193   - assert_equal "Ministerio Publico da Uniao", institution.community.name
194   - assert_equal "12.345.678/9012-45", institution.cnpj
195   - end
196   -
197 117 should "create software_info with existing license_info" do
198 118 @environment.add_admin(@person)
199 119  
... ... @@ -231,5 +151,4 @@ class SoftwareCommunitiesPluginMyprofileControllerTest &lt; ActionController::TestC
231 151 assert_equal SoftwareInfo.last.license_info.version, another_license_version
232 152 assert_equal SoftwareInfo.last.license_info.link, another_license_link
233 153 end
234   -
235 154 end
... ...
views/software_communities_plugin/_institution.html.erb
... ... @@ -1,129 +0,0 @@
1   -<h1><%= _('New Institution') %></h1>
2   -
3   -<% if environment.enabled?('admin_must_approve_new_communities') %>
4   - <div class='explanation'>
5   - <%= _("Note that the creation of communities in this environment is restricted. Your request to create this new community will be sent to %{environment} administrators and will be approved or rejected according to their methods and criteria.") % { :environment => environment.name }%>
6   - </div>
7   -<%end %>
8   -
9   -<% unless flash[:errors].nil? %>
10   -<div class="errorExplanation" id="errorExplanation">
11   - <h2> <%= _("Can`t create new Institution: #{flash[:errors].length} errors") %> </h2>
12   - <ul>
13   - <% flash[:errors].each do |error| %>
14   - <li> <%= error %> </li>
15   - <% end %>
16   - </ul>
17   -</div>
18   -<% end %>
19   -
20   -<div id = 'create_institution_errors' class='errorExplanation hide-field'></div>
21   -
22   -<div>
23   - <div class="fields-required">
24   - <span class="errorExplanation"><%= _("All fields with (*) are mandatory") %></span>
25   - </div>
26   - <br/>
27   - <%= labelled_form_for :community, :url => {:action=>"new_institution"}, :html => { :multipart => true, :id=>"institution_form" } do |f| %>
28   - <%= hidden_field_tag "edit_institution_page", false %>
29   - <%= fields_for :institutions do |inst| %>
30   - <span class=''>
31   - <div class='formfield type-radio'>
32   - <label> <%= _("Public Institution") %>
33   - <%= radio_button_tag("institutions[type]", "PublicInstitution") %>
34   - </label>
35   -
36   - <label>
37   - <%= _("Private Institution") %>
38   - <%= radio_button_tag("institutions[type]" ,"PrivateInstitution", true)%>
39   - </label>
40   - </div>
41   - </span>
42   -
43   - <%= required f.text_field(:name) %>
44   - <%= content_tag :span, _("Institution name already exists"), :id=>"already_exists_text", :class=>"errorExplanation hide-field" %>
45   -
46   - <span class='required-field'>
47   - <div class="formfield type-text">
48   - <%= inst.label "corporate_name", _("Corporate Name"), :class=>"formlabel" %>
49   - <%= required inst.text_field(:corporate_name) %>
50   - </div>
51   - </span>
52   -
53   - <%= required select_country(_('Country'), 'community', 'country', {:class => 'type-select', :id => "community_country"}) %>
54   -
55   - <span class='required-field'>
56   - <div class="formfield">
57   - <label for="community_state" class="formlabel"><%= _("State") %></label>
58   - <%= f.select(:state, @state_list.collect {|state| [state.name, state.name]}) %>
59   - </div>
60   - </span>
61   -
62   - <%= required f.text_field(:city) %>
63   -
64   -
65   - <span class='required-field'>
66   - <div class="formfield type-text">
67   - <%= inst.label("cnpj" ,_("CNPJ"), :class=>"formlabel") %>
68   - <%= required inst.text_field(:cnpj, :placeholder=>"99.999.999/9999-99", :class=>"intitution_cnpj_field") %>
69   - </div>
70   - </span>
71   -
72   - <span class='optional-field'>
73   - <div class="formfield type-text">
74   - <%= hidden_field_tag "acronym_translate", _("Acronym") %>
75   - <%= hidden_field_tag "fantasy_name_translate", _("Fantasy name") %>
76   - <%= inst.label("acronym" ,_("Acronym"), :class=>"formlabel") %>
77   - <%= inst.text_field(:acronym) %>
78   - </div>
79   - </span>
80   -
81   - <span class='required-field public-institutions-fields'>
82   - <div class="formfield type-text">
83   - <%= inst.label("governmental_sphere_id" ,_("Governmental Sphere:"), :class=>"formlabel") %>
84   - <%= inst.select(:governmental_sphere, [[_("Select a Governmental Sphere"), 0]]|GovernmentalSphere.all.map {|s| [s.name, s.id]}, {:selected=>0})%>
85   - </div>
86   - </span>
87   -
88   - <span class='required-field public-institutions-fields'>
89   - <div class="formfield type-text">
90   - <%= inst.label("governmental_power_id" ,_("Governmental Power:"), :class=>"formlabel") %>
91   - <%= inst.select(:governmental_power, [[_("Select a Governmental Power"), 0]]|GovernmentalPower.all.map {|g| [g.name, g.id]}, {:selected=>0})%>
92   - </div>
93   - </span>
94   - <span class='required-field public-institutions-fields'>
95   - <div class="formfield type-text">
96   - <%= inst.label("juridical_nature_id" ,_("Juridical Nature:"), :class=>"formlabel") %>
97   - <%= inst.select(:juridical_nature, [[_("Select a Juridical Nature"), 0]]|JuridicalNature.all.map {|j| [j.name, j.id]}, {:selected=>0})%>
98   - </div>
99   - </span>
100   -
101   - <span class='required-field public-institutions-fields'>
102   - <div class="formfield type-text">
103   - <%= _("SISP?") %>
104   - <% if @show_sisp_field %>
105   - <%= inst.label("sisp" ,_("Yes")) %>
106   - <%= inst.radio_button(:sisp, true) %>
107   - <%= inst.label("sisp" ,_("No")) %>
108   - <%= inst.radio_button(:sisp, false, :checked=>"checked") %>
109   - <% else %>
110   - <%= inst.label("sisp", _("No")) %>
111   - <% end %>
112   - </div>
113   - </span>
114   - <br />
115   -
116   - <% if @url_token == "create_institution_admin" %>
117   - <%= submit_button :save, _('Save') %>
118   - <%else%>
119   - <div>
120   - <%= link_to(_('Save'), '#', :id=>'save_institution_button', :class=>'button with-text icon-add') %>
121   - </div>
122   - <%= hidden_field_tag :institution_error_message, _("Could not send the form data to the server") %>
123   - <%end%>
124   -
125   - <% end %>
126   -
127   - <% end %>
128   -</div>
129   -<%= hidden_field_tag :loading_message, _("Creating institution") %>
views/software_communities_plugin/create_institution.html.erb
... ... @@ -1 +0,0 @@
1   -<%= render :partial => "institution" %>
views/software_communities_plugin/create_institution_admin.html.erb
... ... @@ -1 +0,0 @@
1   -<%= render :partial => "institution" %>