Commit 5b0fa0adc9440f0dda7e4cfca1f565b412230747
1 parent
26ac33e6
Exists in
master
and in
29 other branches
ActionItem16: enhancing enterprise validation
git-svn-id: https://svn.colivre.coop.br/svn/noosfero/trunk@882 3f533792-8f58-4932-b0fe-aaf55b0a4547
Showing
8 changed files
with
65 additions
and
7 deletions
Show diff stats
| ... | ... | @@ -0,0 +1,15 @@ |
| 1 | +module EnterpriseValidationHelper | |
| 2 | + | |
| 3 | + def status(create_enterprise) | |
| 4 | + if create_enterprise.approved? | |
| 5 | + # FIXME: aurelio | |
| 6 | + return content_tag('span', _('Approved'), :style => 'color: green; font-weight: bold;') | |
| 7 | + end | |
| 8 | + | |
| 9 | + if create_enterprise.rejected? | |
| 10 | + # FIXME: aurelio | |
| 11 | + return content_tag('span', _('Rejected'), :style => 'color: red; font-weight: bold;') | |
| 12 | + end | |
| 13 | + end | |
| 14 | + | |
| 15 | +end | ... | ... |
app/models/create_enterprise.rb
| ... | ... | @@ -46,6 +46,10 @@ class CreateEnterprise < Task |
| 46 | 46 | self.errors.add(:target, '%{fn} is not a validator for the chosen region') |
| 47 | 47 | end |
| 48 | 48 | end |
| 49 | + | |
| 50 | + if self.identifier && Profile.exists?(:identifier => self.identifier) | |
| 51 | + self.errors.add(:identifier, '%{fn} is already being as identifier by another enterprise, organization or person.') | |
| 52 | + end | |
| 49 | 53 | end |
| 50 | 54 | |
| 51 | 55 | def valid_before_selecting_target? | ... | ... |
app/views/enterprise_validation/_details.rhtml
app/views/enterprise_validation/details.rhtml
| 1 | 1 | <h2><%= _("%s's validation") % @pending.name %></h2> |
| 2 | 2 | |
| 3 | +<%= link_to _('Back'), :action => 'index' %> | |
| 4 | + | |
| 3 | 5 | <%= error_messages_for 'pending' %> |
| 4 | 6 | |
| 5 | 7 | <h3><%= _('Provided information') %></h3> |
| 6 | 8 | |
| 7 | 9 | <%= render :partial => 'details', :locals => { :request => @pending } %> |
| 8 | 10 | |
| 9 | -<h3><%= _('Final decision') %></h3> | |
| 11 | +<h3><%= _('Final decision:') %></h3> | |
| 12 | + | |
| 13 | +<h4><%= _('Approve') %></h4> | |
| 14 | + | |
| 15 | +<p><%= _('If this enterprise passes the criteria to be considered an solidarity enconomy enterprise, you can approve it by click the button below.') %></p> | |
| 16 | + | |
| 17 | +<% form_tag :action => 'approve', :id => @pending.code do %> | |
| 18 | +<%= submit_tag _('Approve') %> | |
| 19 | +<% end %> | |
| 20 | + | |
| 21 | +<h4><%= _('Reject') %></h4> | |
| 22 | + | |
| 23 | +<p><%= _('If this enterprise does not pass the criteria do be considered, use this form.') %></p> | |
| 10 | 24 | |
| 11 | -<%# TODO %> | |
| 25 | +<% form_tag :action => 'reject', :id => @pending.code do %> | |
| 26 | + <%= labelled_form_field(_('Please provide an explanation for the rejection. This explanation will be sent to the requestor (required).'), text_area_tag('reject_explanation'))%> | |
| 27 | + <div> | |
| 28 | + <%= submit_tag _('Reject') %> | |
| 29 | + </div> | |
| 30 | +<% end %> | ... | ... |
app/views/enterprise_validation/index.rhtml
| ... | ... | @@ -19,3 +19,7 @@ |
| 19 | 19 | |
| 20 | 20 | <%= link_to _("See details/approve/reject"), :action => 'details', :id => pending.code %> |
| 21 | 21 | <% end %> |
| 22 | + | |
| 23 | +<h2><%= _('Processed enterprise validations') %></h2> | |
| 24 | + | |
| 25 | +<p><%= link_to _("See the list of processed enterprise validations"), :action => 'list_processed' %></p> | ... | ... |
app/views/enterprise_validation/list_processed.rhtml
| 1 | -<h2><%= _("Pending enterprise validations") %></h2> | |
| 1 | +<h2><%= _("Processed enterprise validations") %></h2> | |
| 2 | + | |
| 3 | +<%= link_to _("Back"), :action => 'index' %> | |
| 2 | 4 | |
| 3 | 5 | <% for processed in @processed_validations %> |
| 4 | - <h3><%= processed.name %></h3> | |
| 6 | + <h3><%= processed.name %> (<%=status(processed)%>)</h3> | |
| 5 | 7 | <ul> |
| 6 | 8 | <li> |
| 7 | 9 | <strong><%= _('Address') %>:</strong> |
| ... | ... | @@ -15,6 +17,7 @@ |
| 15 | 17 | <strong><%= _('Contact Person') %>:</strong> |
| 16 | 18 | <%= processed.contact_person %> |
| 17 | 19 | </li> |
| 20 | + | |
| 18 | 21 | </ul> |
| 19 | 22 | |
| 20 | 23 | <%= link_to _("See details"), :action => 'view_processed', :id => processed.code %> | ... | ... |
app/views/enterprise_validation/view_processed.rhtml
| 1 | -<h2><%= _('Processed validation request for %s ') % @processed.name %></h2> | |
| 1 | +<h2><%= _('Processed validation request for %s ') % @processed.name %> (<%= status(@processed) %>)</h2> | |
| 2 | + | |
| 3 | +<%= link_to _('Back'), :action => 'index' %> | |
| 2 | 4 | |
| 3 | 5 | <%= render :partial => 'details', :locals => { :request => @processed } %> |
| 6 | + | ... | ... |
test/unit/create_enterprise_test.rb
| ... | ... | @@ -174,6 +174,16 @@ class CreateEnterpriseTest < Test::Unit::TestCase |
| 174 | 174 | request.stubs(:status).returns(Task::Status::CANCELLED) |
| 175 | 175 | assert request.rejected? |
| 176 | 176 | end |
| 177 | - | |
| 177 | + | |
| 178 | + should 'refuse to create an enterprise creation request with an identifier already used by another profile' do | |
| 179 | + request = CreateEnterprise.new | |
| 180 | + request.identifier = 'testid' | |
| 181 | + request.valid? | |
| 182 | + assert !request.errors.invalid?(:test_id) | |
| 183 | + | |
| 184 | + Organization.create!(:name => 'test', :identifier => 'testid') | |
| 185 | + request.valid? | |
| 186 | + assert !request.errors.invalid?(:test_id) | |
| 187 | + end | |
| 178 | 188 | |
| 179 | 189 | end | ... | ... |