decidim-admin 0.27.6 → 0.27.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ac7830a2645388ae03864d86fb38168f35a78d55f54bd0604e036cc2c6ae0fc3
4
- data.tar.gz: c79d6f340b53876b9f3d52ef0396d819020b605e74ff9c6f3d4e5928f724a448
3
+ metadata.gz: 89af8ec67ceb6341a006d36411a053aeb1ddfe47cf8b87dfa01fa06d61c34305
4
+ data.tar.gz: 3c780a0d891e04f13f982a08ef8681506337333c863f9f4fdbac5a88097cff49
5
5
  SHA512:
6
- metadata.gz: 0aeb935a256dcd62884e98e6cd195cbebec24b307998a58a12178455f7a8cbd8c8661ee938b38c85b99974d69b15b42c0862ed6c75426ae22712528b815bba9f
7
- data.tar.gz: c79145b76878d87273d2bfaee29273a0af4e5d541d901258c746caa04cd5dc51faf5ef68f54c5e28a5c18db0a284668b48792c9c306964b2bc1142cead6be567
6
+ metadata.gz: 36629e02f1ddaa454e8e5c0ee531a3067782c4f90c21d00b981ff4a81a27c633a09c88b98a6ac89d4e69837b3f59a7d76a44c1c5295f74ce11870be5162d57f3
7
+ data.tar.gz: dd3651f270e9db52fb99a06d2a288cab0fb330ed1a860e722f5f3070e264f7f48a077d5a2d37fb15e8b7daefa5199e62e5e424e54ebf5299d41f23746f6abd9c
@@ -8,7 +8,9 @@ module Decidim
8
8
  def index
9
9
  enforce_permission_to :index, :authorization_workflow
10
10
 
11
- @workflows = Decidim::Verifications.admin_workflows
11
+ @workflows = Decidim::Verifications.admin_workflows.select do |manifest|
12
+ current_organization.available_authorizations.include?(manifest.name.to_s)
13
+ end
12
14
 
13
15
  # Decidim::Verifications::Authorizations Query
14
16
  @authorizations = Decidim::Verifications::Authorizations.new(
@@ -82,6 +82,7 @@ module Decidim
82
82
  return nil unless handler.unique_id
83
83
 
84
84
  existing_authorization = Authorization.find_by(
85
+ user: User.where(organization: current_organization),
85
86
  name: handler_name,
86
87
  unique_id: handler.unique_id
87
88
  )
@@ -44,13 +44,16 @@ module Decidim
44
44
  respond_to do |format|
45
45
  format.json do
46
46
  if (term = params[:term].to_s).present?
47
- query = relation.order(name: :asc)
48
47
  query = if term.start_with?("@")
49
- query.where("nickname ILIKE ?", "#{term.delete("@")}%")
48
+ nickname = term.delete("@")
49
+ relation.where("nickname ILIKE ?", "#{nickname}%")
50
+ .order(Arel.sql(ActiveRecord::Base.sanitize_sql_array("similarity(nickname, '#{nickname}') DESC")))
50
51
  else
51
- query.where("name ILIKE ?", "%#{term}%").or(
52
- query.where("email ILIKE ?", "%#{term}%")
52
+ relation.where("name ILIKE ?", "%#{term}%").or(
53
+ relation.where("email ILIKE ?", "%#{term}%")
53
54
  )
55
+ .order(Arel.sql(ActiveRecord::Base.sanitize_sql_array("GREATEST(similarity(name, '#{term}'), similarity(email, '#{term}')) DESC")))
56
+ .order(Arel.sql(ActiveRecord::Base.sanitize_sql_array("(similarity(name, '#{term}') + similarity(email, '#{term}')) / 2 DESC")))
54
57
  end
55
58
  render json: query.all.collect { |u| { value: u.id, label: "#{u.name} (@#{u.nickname})" } }
56
59
  else