Skip to content

Commit

Permalink
Backport 'Sort valuator selectors by valuator name' to v0.28 (decidim…
Browse files Browse the repository at this point in the history
…#13652)

* Sort valuator selectors by valuator name

* Fix specs

* Fix pipeline

---------

Co-authored-by: Màxim Colls <[email protected]>
  • Loading branch information
alecslupu and mllocs authored Nov 14, 2024
1 parent b38422b commit c12ffd2
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion decidim-assemblies/app/models/decidim/assembly.rb
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ def closed?
end

def user_roles(role_name = nil)
roles = Decidim::AssemblyUserRole.where(assembly: self_and_ancestors)
roles = Decidim::AssemblyUserRole.order_by_name.where(assembly: self_and_ancestors)
return roles if role_name.blank?

roles.where(role: role_name)
Expand Down
2 changes: 1 addition & 1 deletion decidim-conferences/app/models/decidim/conference.rb
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ def closed?
end

def user_roles(role_name = nil)
roles = Decidim::ConferenceUserRole.where(conference: self)
roles = Decidim::ConferenceUserRole.order_by_name.where(conference: self)
return roles if role_name.blank?

roles.where(role: role_name)
Expand Down
4 changes: 4 additions & 0 deletions decidim-core/lib/decidim/participatory_space_user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ def target_space_association
raise "Not implemented"
end

def self.order_by_name
includes(:user).order("decidim_users.name ASC")
end

private

# Private: check if the process and the user have the same organization
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ def self.moderators(organization)
end

def user_roles(role_name = nil)
roles = Decidim::ParticipatoryProcessUserRole.where(participatory_process: self)
roles = Decidim::ParticipatoryProcessUserRole.order_by_name.where(participatory_process: self)
return roles if role_name.blank?

roles.where(role: role_name)
Expand Down

0 comments on commit c12ffd2

Please sign in to comment.