diff --git a/app/helpers/enterprise_validation_helper.rb b/app/helpers/enterprise_validation_helper.rb new file mode 100644 index 0000000..0c38c4a --- /dev/null +++ b/app/helpers/enterprise_validation_helper.rb @@ -0,0 +1,15 @@ +module EnterpriseValidationHelper + + def status(create_enterprise) + if create_enterprise.approved? + # FIXME: aurelio + return content_tag('span', _('Approved'), :style => 'color: green; font-weight: bold;') + end + + if create_enterprise.rejected? + # FIXME: aurelio + return content_tag('span', _('Rejected'), :style => 'color: red; font-weight: bold;') + end + end + +end diff --git a/app/models/create_enterprise.rb b/app/models/create_enterprise.rb index 4725251..bf92a6f 100644 --- a/app/models/create_enterprise.rb +++ b/app/models/create_enterprise.rb @@ -46,6 +46,10 @@ class CreateEnterprise < Task self.errors.add(:target, '%{fn} is not a validator for the chosen region') end end + + if self.identifier && Profile.exists?(:identifier => self.identifier) + self.errors.add(:identifier, '%{fn} is already being as identifier by another enterprise, organization or person.') + end end def valid_before_selecting_target? diff --git a/app/views/enterprise_validation/_details.rhtml b/app/views/enterprise_validation/_details.rhtml index 7fa49fe..ff1a910 100644 --- a/app/views/enterprise_validation/_details.rhtml +++ b/app/views/enterprise_validation/_details.rhtml @@ -28,7 +28,7 @@ <%= request.foundation_year %> - <%= _('Legal Year') %> + <%= _('Legal Form') %> <%= request.legal_form %> diff --git a/app/views/enterprise_validation/details.rhtml b/app/views/enterprise_validation/details.rhtml index d136384..1fc9018 100644 --- a/app/views/enterprise_validation/details.rhtml +++ b/app/views/enterprise_validation/details.rhtml @@ -1,11 +1,30 @@

<%= _("%s's validation") % @pending.name %>

+<%= link_to _('Back'), :action => 'index' %> + <%= error_messages_for 'pending' %>

<%= _('Provided information') %>

<%= render :partial => 'details', :locals => { :request => @pending } %> -

<%= _('Final decision') %>

+

<%= _('Final decision:') %>

+ +

<%= _('Approve') %>

+ +

<%= _('If this enterprise passes the criteria to be considered an solidarity enconomy enterprise, you can approve it by click the button below.') %>

+ +<% form_tag :action => 'approve', :id => @pending.code do %> +<%= submit_tag _('Approve') %> +<% end %> + +

<%= _('Reject') %>

+ +

<%= _('If this enterprise does not pass the criteria do be considered, use this form.') %>

-<%# TODO %> +<% form_tag :action => 'reject', :id => @pending.code do %> + <%= labelled_form_field(_('Please provide an explanation for the rejection. This explanation will be sent to the requestor (required).'), text_area_tag('reject_explanation'))%> +
+ <%= submit_tag _('Reject') %> +
+<% end %> diff --git a/app/views/enterprise_validation/index.rhtml b/app/views/enterprise_validation/index.rhtml index a4247d1..fe90137 100644 --- a/app/views/enterprise_validation/index.rhtml +++ b/app/views/enterprise_validation/index.rhtml @@ -19,3 +19,7 @@ <%= link_to _("See details/approve/reject"), :action => 'details', :id => pending.code %> <% end %> + +

<%= _('Processed enterprise validations') %>

+ +

<%= link_to _("See the list of processed enterprise validations"), :action => 'list_processed' %>

diff --git a/app/views/enterprise_validation/list_processed.rhtml b/app/views/enterprise_validation/list_processed.rhtml index 9aefc8d..14a300c 100644 --- a/app/views/enterprise_validation/list_processed.rhtml +++ b/app/views/enterprise_validation/list_processed.rhtml @@ -1,7 +1,9 @@ -

<%= _("Pending enterprise validations") %>

+

<%= _("Processed enterprise validations") %>

+ +<%= link_to _("Back"), :action => 'index' %> <% for processed in @processed_validations %> -

<%= processed.name %>

+

<%= processed.name %> (<%=status(processed)%>)

<%= link_to _("See details"), :action => 'view_processed', :id => processed.code %> diff --git a/app/views/enterprise_validation/view_processed.rhtml b/app/views/enterprise_validation/view_processed.rhtml index 9e33adb..fe2ae3a 100644 --- a/app/views/enterprise_validation/view_processed.rhtml +++ b/app/views/enterprise_validation/view_processed.rhtml @@ -1,3 +1,6 @@ -

<%= _('Processed validation request for %s ') % @processed.name %>

+

<%= _('Processed validation request for %s ') % @processed.name %> (<%= status(@processed) %>)

+ +<%= link_to _('Back'), :action => 'index' %> <%= render :partial => 'details', :locals => { :request => @processed } %> + diff --git a/test/unit/create_enterprise_test.rb b/test/unit/create_enterprise_test.rb index 6d3a1bf..db074d3 100644 --- a/test/unit/create_enterprise_test.rb +++ b/test/unit/create_enterprise_test.rb @@ -174,6 +174,16 @@ class CreateEnterpriseTest < Test::Unit::TestCase request.stubs(:status).returns(Task::Status::CANCELLED) assert request.rejected? end - + + should 'refuse to create an enterprise creation request with an identifier already used by another profile' do + request = CreateEnterprise.new + request.identifier = 'testid' + request.valid? + assert !request.errors.invalid?(:test_id) + + Organization.create!(:name => 'test', :identifier => 'testid') + request.valid? + assert !request.errors.invalid?(:test_id) + end end -- libgit2 0.21.2