-
-
Notifications
You must be signed in to change notification settings - Fork 197
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Missing letters and incorrect ordering of authoraties #2482
Comments
The template that renders the alphabetical list currently just lists an unaccented roman alphabet - you can override that template in your theme by copying the file to The ordering of the authorities is done on the basis of a sort by name in the database, so I think the solution here may be to provide a 'collate' clause to the query as described here. |
Debian Squeeze has Postgres 8.4. The article referenced says that |
Squeeze does have |
Since Squeeze's EOL is so soon, I don't see any benefit in us dropping support of Postgres 8.4 before we stop supporting Squeeze. We should be able to use ActiveRecord::Base.connection.send(:postgresql_version)
# => 90112 |
|
I've taken a first stab at this. I think its going to be a tricky one. I've got a passing spec: diff --git a/app/controllers/public_body_controller.rb b/app/controllers/public_body_controller.rb
index 376b202..18bcf01 100644
--- a/app/controllers/public_body_controller.rb
+++ b/app/controllers/public_body_controller.rb
@@ -204,7 +204,7 @@ class PublicBodyController < ApplicationController
where_sql += [underscore_locale] + where_parameters
@public_bodies = PublicBody.where(where_sql).
joins(:translations).
- order("public_body_translations.name").
+ order(%Q(public_body_translations.name COLLATE "#{ underscore_locale }")).
paginate(:page => params[:page], :per_page => 100)
end
diff --git a/spec/controllers/public_body_controller_spec.rb b/spec/controllers/public_body_controller_spec.rb
index c5c94a4..f748f7f 100644
--- a/spec/controllers/public_body_controller_spec.rb
+++ b/spec/controllers/public_body_controller_spec.rb
@@ -198,6 +198,22 @@ describe PublicBodyController, "when listing bodies" do
assigns[:description].should == ""
end
+ it 'list bodies in alphabetical order according to the locale' do
+ AlaveteliLocalization.set_locales('nn_NO', 'en')
+ ActiveRecord::Base.connection.execute(%Q(CREATE COLLATION "nn_NO" (LOCALE = 'nn_NO.utf8');))
+ InfoRequestEvent.delete_all
+ Comment.delete_all
+ InfoRequest.all.each(&:fully_destroy)
+ PublicBody.destroy_all
+ first = FactoryGirl.create(:public_body, :name => 'Ytre Helgeland District Psychiatric Centre')
+ last = FactoryGirl.create(:public_body, :name => 'Åfjord Municipality')
+ middle = FactoryGirl.create(:public_body, :name => 'Åbjord Municipality')
+
+ get :list
+
+ expect(assigns[:public_bodies]).to eq([first, middle, last])
+ end
+
it "should support simple searching of bodies by title" do
get :list, :public_body_query => 'quango'
assigns[:public_bodies].should == [ public_bodies(:geraldine_public_body) ] Here are a few issues off the top of my head:
|
We could try @locale
# => 'en'
ActiveRecord::Base.
connection.
execute(%(SELECT * FROM pg_collation;)).
map{ |row| row['collname'] }.
include?(@locale)
# => false |
[Gareth Rees]
I suspect this comment indicate a misunderstanding of what a locale Because collation rules depend on the country, not on the language, it Perhaps you already knew this, but I thought it best to state it JFYI.Happy hacking |
I loosely used the term 'locale' as I was just brain-dumping The main problem I wanted to illustrate is that most of the time, I'm thinking at the moment the cleanest solution is to only use |
I've created a PR which results in the desired behaviour #2619. It needs a bit of cleanup and we need to consider how we suggest people add collation support to their install. |
https://alaveteli-dev.nuug.no/en/body now seems to be doing the correct thing. Did you make any changes to get this to work? |
[Gareth Rees]
Yes. We followed the instructions from Louise Crow and overrided the Gorm have the details. I'll try to get him to have a look and comment if Happy hacking |
When visisting https://alaveteli-dev.nuug.no/en/body , the Norwegian letters Æ Ø Å are missing from the list of letters:
Show only...
Beginning with
* A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
The Norwegian letters should have been listed after Z in that list.
Even worse, the ordering of authorities are wrong. For example "Åfjord Municipality" should be found after "Ytre Helgeland District Psychiatric Centre", and not sorted as an A.
Is there something wrong with our setup?
The text was updated successfully, but these errors were encountered: