decidim-challenges 0.7.0 → 0.7.3

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: 46bea652eb21f13814310b3f2010678bf606a89eb0b6f643d52b7618ada9b22f
4
- data.tar.gz: 0b54f8699e24dbdb5960300a36fad5d42e0c5a52dfa67d4302a4fc2395a58623
3
+ metadata.gz: 95e745fe3d49e802946f403938a6b11603b9110cb08f81407c8fa5810c51dfbf
4
+ data.tar.gz: a24fcfa528d1023b365122e17ea937da6f0e5fb807b5b30fcfad2feed0acdb43
5
5
  SHA512:
6
- metadata.gz: d5aeda521250172c335e590e38a3375ce529c2553db76348dd291829fd42ef8cd6dd5d5d19a67a7b15c20906c6e50315e652a9ab12e4b5e86ab45df30abb21a7
7
- data.tar.gz: 62661ef946f28d42006ebb6d1a29f296955bbed4672aaf07295bf0b92e9b0dd6ebd1200e9dc26721eb27cae04819f0a5a1055b2dcace77ff0be28877f4dd7b56
6
+ metadata.gz: 24385b67ade44975efb0eb9cea8d2f976e6dbc14f66a23dc6cbb309fb932bacfdd5ca8496309032482c142c9f3e6e0a71f31b5339e3adab78d3b93879dc68771
7
+ data.tar.gz: 0e748da2b962e8e22c88526c6f608d6f72452c10800a6d88e4a791f91332e0896c2d6b3c719c4fbf2eb549119d11e8f41313fba6648984c51f625a0bc653229e
@@ -7,7 +7,7 @@
7
7
  <% end %>
8
8
  <div class="card__list-text">
9
9
  <%= description %>
10
- <% if resource_sdg %>
10
+ <% if has_sdgs? %>
11
11
  <div class="card__sdg">
12
12
  <div class="card_text--sdg--image">
13
13
  <div class="ods challenges">
@@ -6,7 +6,9 @@ module Decidim
6
6
  # for an given instance of a Solution
7
7
  class SolutionGCell < Decidim::CardGCell
8
8
  include ActiveSupport::NumberHelper
9
+ include Decidim::Solutions::SolutionsHelper
9
10
  include Decidim::Sdgs::SdgsHelper
11
+ include Decidim::Solutions::SolutionCellsHelper
10
12
 
11
13
  private
12
14
 
@@ -51,7 +51,7 @@ module Decidim
51
51
  def create_survey
52
52
  @survey = Decidim::Challenges::Survey.create!(
53
53
  challenge:,
54
- user:
54
+ author: user
55
55
  )
56
56
  end
57
57
 
@@ -60,7 +60,10 @@ module Decidim
60
60
  end
61
61
 
62
62
  def can_answer_survey?
63
- Decidim::Challenges::Survey.where(decidim_user_id: user, decidim_challenge_id: challenge).none?
63
+ Decidim::Challenges::Survey.where(
64
+ decidim_author_id: user.id,
65
+ decidim_challenge_id: challenge.id
66
+ ).none?
64
67
  end
65
68
  end
66
69
  end
@@ -13,6 +13,7 @@ module Decidim
13
13
  include Decidim::ResourceReferenceHelper
14
14
  include Decidim::TranslatableAttributes
15
15
  include Decidim::CardHelper
16
+ include WithSdgs
16
17
 
17
18
  delegate :title, :state, :published_state?, :withdrawn?, :amendable?, :emendation?, to: :model
18
19
 
@@ -7,9 +7,9 @@ module Decidim
7
7
  include Decidim::DownloadYourData
8
8
 
9
9
  belongs_to :challenge, foreign_key: "decidim_challenge_id", class_name: "Decidim::Challenges::Challenge"
10
- belongs_to :user, foreign_key: "decidim_user_id", class_name: "Decidim::User"
10
+ belongs_to :author, foreign_key: "decidim_author_id", class_name: "Decidim::User"
11
11
 
12
- validates :user, uniqueness: { scope: :challenge }
12
+ validates :decidim_author_id, uniqueness: { scope: :decidim_challenge_id }
13
13
 
14
14
  def self.export_serializer
15
15
  Decidim::Challenges::DownloadYourDataSurveySerializer
@@ -8,9 +8,9 @@ module Decidim
8
8
  def serialize
9
9
  {
10
10
  id: resource.id,
11
- user: {
12
- name: resource.user.name,
13
- email: resource.user.email,
11
+ author: {
12
+ name: resource.author.name,
13
+ email: resource.author.email,
14
14
  },
15
15
  survey_form_answers: serialize_answers,
16
16
  }
@@ -20,7 +20,7 @@ module Decidim
20
20
 
21
21
  def serialize_answers
22
22
  questions = resource.challenge.questionnaire.questions
23
- answers = resource.challenge.questionnaire.answers.where(user: resource.user)
23
+ answers = resource.challenge.questionnaire.answers.where(user: resource.author)
24
24
  questions.each_with_index.inject({}) do |serialized, (question, idx)|
25
25
  answer = answers.find_by(question:)
26
26
  serialized.update("#{idx + 1}. #{translated_attribute(question.body)}" => normalize_body(answer))
@@ -16,6 +16,8 @@ module Decidim
16
16
  status_label => resource&.project_status,
17
17
  challenge_label => translated_challenge_title,
18
18
  url_label => resource&.project_url,
19
+ author_name_label => resource.author.name,
20
+ author_email_label => resource.author.email,
19
21
  created_at_label => resource.created_at,
20
22
  published_at_label => resource&.published_at,
21
23
  }
@@ -63,6 +65,14 @@ module Decidim
63
65
  I18n.t("export.published_at", scope: "decidim.solutions.admin.exports").to_s
64
66
  end
65
67
 
68
+ def author_name_label
69
+ I18n.t("export.author_name", scope: "decidim.solutions.admin.exports").to_s
70
+ end
71
+
72
+ def author_email_label
73
+ I18n.t("export.author_email", scope: "decidim.solutions.admin.exports").to_s
74
+ end
75
+
66
76
  def translated_challenge_title
67
77
  resource&.challenge&.title.present? ? resource&.challenge&.title&.[](I18n.locale.to_s) : ""
68
78
  end
@@ -1136,7 +1136,8 @@ ca:
1136
1136
  exports:
1137
1137
  solutions: "Solucions"
1138
1138
  export:
1139
- author: "Autor"
1139
+ author_name: "Nom autor"
1140
+ author_email: "Email autor"
1140
1141
  title: "Títol"
1141
1142
  description: "Descripció"
1142
1143
  status: "Estat"
@@ -1138,7 +1138,8 @@ en:
1138
1138
  exports:
1139
1139
  solutions: "Solutions"
1140
1140
  export:
1141
- author: "Author"
1141
+ author_name: "Author name"
1142
+ author_email: "Author email"
1142
1143
  title: "Title"
1143
1144
  description: "Description"
1144
1145
  status: "Status"
@@ -1143,7 +1143,8 @@ es:
1143
1143
  exports:
1144
1144
  solutions: "Soluciones"
1145
1145
  export:
1146
- author: "Autor"
1146
+ author_name: "Nombre autor"
1147
+ author_email: "Email autor"
1147
1148
  title: "Título"
1148
1149
  description: "Descripción"
1149
1150
  status: "Estado"
@@ -0,0 +1,35 @@
1
+ # frozen_string_literal: true
2
+
3
+ class ChangeUserToAuthorInChallengesSurveys < ActiveRecord::Migration[6.1]
4
+ class ChallengeSurvey < ApplicationRecord
5
+ self.table_name = "decidim_challenges_surveys"
6
+ end
7
+
8
+ def up
9
+ rename_column :decidim_challenges_surveys, :decidim_user_id, :decidim_author_id
10
+
11
+ remove_index :decidim_challenges_surveys, name: "decidim_challenges_surveys_user_challenge_unique", if_exists: true
12
+ remove_index :decidim_challenges_surveys, name: "index_decidim_challenges_surveys_on_decidim_user_id", if_exists: true
13
+
14
+ add_index :decidim_challenges_surveys,
15
+ [:decidim_author_id, :decidim_challenge_id],
16
+ unique: true,
17
+ name: "decidim_challenges_surveys_author_challenge_unique"
18
+ end
19
+
20
+ def down
21
+ remove_index :decidim_challenges_surveys, name: "decidim_challenges_surveys_author", if_exists: true
22
+ remove_index :decidim_challenges_surveys, name: "decidim_challenges_surveys_author_challenge_unique", if_exists: true
23
+
24
+ rename_column :decidim_challenges_surveys, :decidim_author_id, :decidim_user_id
25
+
26
+ add_index :decidim_challenges_surveys,
27
+ [:decidim_user_id, :decidim_challenge_id],
28
+ unique: true,
29
+ name: "decidim_challenges_surveys_user_challenge_unique"
30
+
31
+ add_index :decidim_challenges_surveys,
32
+ :decidim_user_id,
33
+ name: "index_decidim_challenges_surveys_on_decidim_user_id"
34
+ end
35
+ end
@@ -54,6 +54,6 @@ FactoryBot.define do
54
54
 
55
55
  factory :survey, class: "Decidim::Challenges::Survey" do
56
56
  challenge
57
- user
57
+ author factory: [:user]
58
58
  end
59
59
  end
@@ -4,7 +4,7 @@ module Decidim
4
4
  # This holds the decidim-meetings version.
5
5
  module Challenges
6
6
  def self.version
7
- "0.7.0"
7
+ "0.7.3"
8
8
  end
9
9
 
10
10
  def self.decidim_version
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: decidim-challenges
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.0
4
+ version: 0.7.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Oliver Valls
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-09-29 00:00:00.000000000 Z
11
+ date: 2025-11-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: decidim-core
@@ -240,6 +240,7 @@ files:
240
240
  - db/migrate/20210427091033_remove_require_null_in_problems_for_solutions.rb
241
241
  - db/migrate/20220407110503_add_card_image_to_challenges.rb
242
242
  - db/migrate/20240919094714_add_public_fields_to_solutions.rb
243
+ - db/migrate/20250902145427_change_user_to_author_in_challenges_surveys.rb
243
244
  - lib/decidim/challenges.rb
244
245
  - lib/decidim/challenges/admin.rb
245
246
  - lib/decidim/challenges/admin_engine.rb