diff options
-rw-r--r-- | app/controllers/public_body_controller.rb | 4 | ||||
-rw-r--r-- | app/controllers/request_controller.rb | 6 | ||||
-rw-r--r-- | app/models/public_body.rb | 8 | ||||
-rw-r--r-- | app/models/public_body_tag.rb | 11 | ||||
-rw-r--r-- | app/views/admin_public_body/_tags.rhtml | 13 | ||||
-rw-r--r-- | spec/controllers/public_body_controller_spec.rb | 21 | ||||
-rw-r--r-- | todo.txt | 3 |
7 files changed, 55 insertions, 11 deletions
diff --git a/app/controllers/public_body_controller.rb b/app/controllers/public_body_controller.rb index f46e55014..4ca8d1404 100644 --- a/app/controllers/public_body_controller.rb +++ b/app/controllers/public_body_controller.rb @@ -76,6 +76,10 @@ class PublicBodyController < ApplicationController elsif @tag.size == 1 @tag.upcase! conditions = ['first_letter = ?', @tag] + elsif @tag.include?(":") + name, value = PublicBodyTag.split_tag_into_name_value(@tag) + conditions = ['(select count(*) from public_body_tags where public_body_tags.public_body_id = public_bodies.id + and public_body_tags.name = ? and public_body_tags.value = ?) > 0', name, value] else conditions = ['(select count(*) from public_body_tags where public_body_tags.public_body_id = public_bodies.id and public_body_tags.name = ?) > 0', @tag] diff --git a/app/controllers/request_controller.rb b/app/controllers/request_controller.rb index b2f6e8631..767bb8488 100644 --- a/app/controllers/request_controller.rb +++ b/app/controllers/request_controller.rb @@ -131,6 +131,12 @@ class RequestController < ApplicationController # Page new form posts to def new + # Allow url_name + if !params[:public_body_url_name].nil? && params + end + if params[:submitted_new_request].nil? + end + # All new requests are of normal_sort if !params[:outgoing_message].nil? params[:outgoing_message][:what_doing] = 'normal_sort' diff --git a/app/models/public_body.rb b/app/models/public_body.rb index 253ba1888..e0d02a5b6 100644 --- a/app/models/public_body.rb +++ b/app/models/public_body.rb @@ -197,13 +197,7 @@ class PublicBody < ActiveRecord::Base self.public_body_tags = [] for tag in tags # see if is a machine tags (i.e. a tag which has a value) - sections = tag.split(/:/) - name = sections[0] - if sections[1] - value = sections[1,sections.size].join(":") - else - value = nil - end + name, value = PublicBodyTag.split_tag_into_name_value(tag) public_body_tag = PublicBodyTag.new(:name => name, :value => value) self.public_body_tags << public_body_tag diff --git a/app/models/public_body_tag.rb b/app/models/public_body_tag.rb index 74449abc4..42b3899a1 100644 --- a/app/models/public_body_tag.rb +++ b/app/models/public_body_tag.rb @@ -33,5 +33,16 @@ class PublicBodyTag < ActiveRecord::Base end return ret end + + def PublicBodyTag.split_tag_into_name_value(tag) + sections = tag.split(/:/) + name = sections[0] + if sections[1] + value = sections[1,sections.size].join(":") + else + value = nil + end + return name, value + end end diff --git a/app/views/admin_public_body/_tags.rhtml b/app/views/admin_public_body/_tags.rhtml index a80c69fb8..362424013 100644 --- a/app/views/admin_public_body/_tags.rhtml +++ b/app/views/admin_public_body/_tags.rhtml @@ -1,6 +1,11 @@ -<%= body.public_body_tags.map { |t| - link_to(h(t.name_and_value), main_url(list_public_bodies_url(:tag => t.name, :only_path => true))) + - ' (<a href="' + admin_url('body/list') + "?query=" + h(t.name) + '">admin</a>)' - }.join(' ') %> +<% for t in body.public_body_tags %> + <% if t.value %> + <%= link_to(h(t.name), main_url(list_public_bodies_url(:tag => t.name, :only_path => true))) %>:<%= link_to(h(t.value), main_url(list_public_bodies_url(:tag => t.name_and_value, :only_path => true))) %> + <% else %> + <%= link_to(h(t.name), main_url(list_public_bodies_url(:tag => t.name, :only_path => true))) %> + <% end %> + (<a href="<%= admin_url('body/list') %>?query=<%= h(t.name)%>">admin</a>) +<% end %> + diff --git a/spec/controllers/public_body_controller_spec.rb b/spec/controllers/public_body_controller_spec.rb index aae72dad9..ec7417400 100644 --- a/spec/controllers/public_body_controller_spec.rb +++ b/spec/controllers/public_body_controller_spec.rb @@ -68,6 +68,27 @@ describe PublicBodyController, "when listing bodies" do end + it "should list a machine tagged thing, should get it in both ways" do + public_bodies(:humpadink_public_body).tag_string = "eats_cheese:stilton" + + get :list, :tag => "eats_cheese" + response.should render_template('list') + assigns[:public_bodies].should == [ public_bodies(:humpadink_public_body) ] + assigns[:tag].should == "eats_cheese" + + get :list, :tag => "eats_cheese:jarlsberg" + response.should render_template('list') + assigns[:public_bodies].should == [ ] + assigns[:tag].should == "eats_cheese:jarlsberg" + + get :list, :tag => "eats_cheese:stilton" + response.should render_template('list') + assigns[:public_bodies].should == [ public_bodies(:humpadink_public_body) ] + assigns[:tag].should == "eats_cheese:stilton" + + + end + end @@ -5,6 +5,9 @@ Richard says he wants the internationalisation to be so it could be one site with combined search. Why obey the notion of a country? I'm not sure, but it might be prudent to write it so it can run multiple jurisdictions in one deploy, if only for administrative reasoins. + - path maybe: lib/juris/uk, lib/juris/eu etc. + - consider Single Table Inheritance (harder to back out of though) + - use mixins with explicit include otherwise Add links to these tags where possible: ch:* - Bodies that appear on the Register of Companies. '*' is replaced by the company number, which is eight characters long and consists of optional upper-case letters followed by digits. |