decidim-admin 0.27.6 → 0.27.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ac7830a2645388ae03864d86fb38168f35a78d55f54bd0604e036cc2c6ae0fc3
4
- data.tar.gz: c79d6f340b53876b9f3d52ef0396d819020b605e74ff9c6f3d4e5928f724a448
3
+ metadata.gz: 05b4e853053e19c294d34bac72798acf0348feebae52ec2955d373bc939ed911
4
+ data.tar.gz: b89597557e962de240a917069ac429743d7a4554e3585379d58be7458e700c66
5
5
  SHA512:
6
- metadata.gz: 0aeb935a256dcd62884e98e6cd195cbebec24b307998a58a12178455f7a8cbd8c8661ee938b38c85b99974d69b15b42c0862ed6c75426ae22712528b815bba9f
7
- data.tar.gz: c79145b76878d87273d2bfaee29273a0af4e5d541d901258c746caa04cd5dc51faf5ef68f54c5e28a5c18db0a284668b48792c9c306964b2bc1142cead6be567
6
+ metadata.gz: 5a01b4503098fdcdf58c01614b1820bbd481078d8de1b1dc75f3e29bce3096434c06f78a790e26e2bdad821e4fdd0bc35f33d81c6ca93ea2fb5fb1ce2527b4cb
7
+ data.tar.gz: 96838c254ea3d1d73b5b8d7d89d60cd684783b4a839d4a090e0ed52e6cfa57ccf3e57ecc6d6bbf6e1ae9a14b4efc2dae0d5249da6a3527bc551a38efa82367c7
@@ -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