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 +4 -4
- data/app/cells/decidim/solutions/solution_g/show.erb +1 -1
- data/app/cells/decidim/solutions/solution_g_cell.rb +2 -0
- data/app/commands/decidim/challenges/survey_challenge.rb +5 -2
- data/app/helpers/decidim/solutions/solution_cells_helper.rb +1 -0
- data/app/models/decidim/challenges/survey.rb +2 -2
- data/app/serializers/decidim/challenges/survey_serializer.rb +4 -4
- data/app/serializers/decidim/solutions/solution_serializer.rb +10 -0
- data/config/locales/ca.yml +2 -1
- data/config/locales/en.yml +2 -1
- data/config/locales/es.yml +2 -1
- data/db/migrate/20250902145427_change_user_to_author_in_challenges_surveys.rb +35 -0
- data/lib/decidim/challenges/test/factories.rb +1 -1
- data/lib/decidim/challenges/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 95e745fe3d49e802946f403938a6b11603b9110cb08f81407c8fa5810c51dfbf
|
|
4
|
+
data.tar.gz: a24fcfa528d1023b365122e17ea937da6f0e5fb807b5b30fcfad2feed0acdb43
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 24385b67ade44975efb0eb9cea8d2f976e6dbc14f66a23dc6cbb309fb932bacfdd5ca8496309032482c142c9f3e6e0a71f31b5339e3adab78d3b93879dc68771
|
|
7
|
+
data.tar.gz: 0e748da2b962e8e22c88526c6f608d6f72452c10800a6d88e4a791f91332e0896c2d6b3c719c4fbf2eb549119d11e8f41313fba6648984c51f625a0bc653229e
|
|
@@ -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(
|
|
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
|
|
@@ -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 :
|
|
10
|
+
belongs_to :author, foreign_key: "decidim_author_id", class_name: "Decidim::User"
|
|
11
11
|
|
|
12
|
-
validates :
|
|
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
|
-
|
|
12
|
-
name: resource.
|
|
13
|
-
email: resource.
|
|
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.
|
|
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
|
data/config/locales/ca.yml
CHANGED
data/config/locales/en.yml
CHANGED
data/config/locales/es.yml
CHANGED
|
@@ -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
|
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.
|
|
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-
|
|
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
|